Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/eject PR/42207: YAMAMOTO Takashi: If the portmapper ...
details: https://anonhg.NetBSD.org/src/rev/853999f3381c
branches: trunk
changeset: 752461:853999f3381c
user: christos <christos%NetBSD.org@localhost>
date: Fri Feb 26 20:18:37 2010 +0000
description:
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.
diffstat:
usr.bin/eject/am_glue.c | 42 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 39 insertions(+), 3 deletions(-)
diffs (80 lines):
diff -r 7de18100b12c -r 853999f3381c usr.bin/eject/am_glue.c
--- a/usr.bin/eject/am_glue.c Fri Feb 26 19:25:07 2010 +0000
+++ b/usr.bin/eject/am_glue.c Fri Feb 26 20:18:37 2010 +0000
@@ -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
*/
Home |
Main Index |
Thread Index |
Old Index