Module Name: src
Committed By: christos
Date: Fri Feb 26 20:18:37 UTC 2010
Modified Files:
src/usr.bin/eject: am_glue.c
Log Message:
PR/42207: YAMAMOTO Takashi: If the portmapper (rpcbind) is not running, eject
takes 2 minutes to timeout. Add a ping the portmapper function that times out
after 5 seconds.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/eject/am_glue.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/eject/am_glue.c
diff -u src/usr.bin/eject/am_glue.c:1.1 src/usr.bin/eject/am_glue.c:1.2
--- src/usr.bin/eject/am_glue.c:1.1 Fri Jan 16 12:31:22 2009
+++ src/usr.bin/eject/am_glue.c Fri Feb 26 15:18:37 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: am_glue.c,v 1.1 2009/01/16 17:31:22 christos Exp $ */
+/* $NetBSD: am_glue.c,v 1.2 2010/02/26 20:18:37 christos Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: am_glue.c,v 1.1 2009/01/16 17:31:22 christos Exp $");
+__RCSID("$NetBSD: am_glue.c,v 1.2 2010/02/26 20:18:37 christos Exp $");
#endif /* not lint */
#ifdef HAVE_CONFIG_H
@@ -36,11 +36,14 @@
#endif /* HAVE_CONFIG_H */
#include <am_defs.h>
#include <amu.h>
+#include <rpc/pmap_prot.h>
+#include <rpc/pmap_clnt.h>
#include "am_glue.h"
static CLIENT *clnt;
+static struct timeval tv = { 5, 0 };
/*
* Appease lint: Properly typecast some numbers defined in
* src/extern/bsd/am-utils/dist/include/amq_defs.h.
@@ -49,12 +52,45 @@
#define xAMQ_VERSION (rpcvers_t)AMQ_VERSION
#define xAMQPROC_SYNC_UMNT (rpcproc_t)AMQPROC_SYNC_UMNT
+static int
+ping_pmap(void)
+{
+ u_short port = 0;
+ CLIENT *cl;
+ struct pmap parms;
+ struct sockaddr_in si;
+ int s = -1, rv;
+
+ (void)memset(&si, 0, sizeof(si));
+ si.sin_family = AF_INET;
+ si.sin_len = sizeof(si);
+ si.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ si.sin_port = htons(PMAPPORT);
+
+ if ((cl = clntudp_bufcreate(&si, PMAPPROG, PMAPVERS, tv,
+ &s, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE)) == NULL)
+ return -1;
+
+ parms.pm_prog = PMAPPROG;
+ parms.pm_vers = PMAPVERS;
+ parms.pm_prot = IPPROTO_UDP;
+ parms.pm_port = 0; /* not needed or used */
+
+ rv = CLNT_CALL(cl, (rpcproc_t)PMAPPROC_GETPORT,
+ (xdrproc_t)xdr_pmap, &parms,
+ (xdrproc_t)xdr_u_short, &port, tv) == RPC_SUCCESS ? 0 : -1;
+
+ CLNT_DESTROY(cl);
+ return rv;
+}
+
void
am_init(void)
{
- static struct timeval tv = { 5, 0 };
static const char *server = "localhost";
+ if (ping_pmap() == -1)
+ return;
/*
* Create RPC endpoint
*/