Module Name:    src
Committed By:   yamt
Date:           Wed Jun 23 18:07:59 UTC 2010

Modified Files:
        src/usr.bin/eject: am_glue.c am_glue.h eject.c

Log Message:
don't bother to connect to amd unless necessary.  PR/42207


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/eject/am_glue.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/eject/am_glue.h
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/eject/eject.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.3 src/usr.bin/eject/am_glue.c:1.4
--- src/usr.bin/eject/am_glue.c:1.3	Fri Feb 26 22:44:17 2010
+++ src/usr.bin/eject/am_glue.c	Wed Jun 23 18:07:59 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: am_glue.c,v 1.3 2010/02/26 22:44:17 christos Exp $	*/
+/*	$NetBSD: am_glue.c,v 1.4 2010/06/23 18:07:59 yamt 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.3 2010/02/26 22:44:17 christos Exp $");
+__RCSID("$NetBSD: am_glue.c,v 1.4 2010/06/23 18:07:59 yamt Exp $");
 #endif /* not lint */
 
 #ifdef HAVE_CONFIG_H
@@ -39,6 +39,8 @@
 #include <rpc/pmap_prot.h>
 #include <rpc/pmap_clnt.h>
 
+#include <stdbool.h>
+
 #include "am_glue.h"
 
 static CLIENT *clnt;
@@ -85,10 +87,15 @@
 	return rv;
 }
 
-void
+static void
 am_init(void)
 {
 	static const char *server = "localhost";
+	static bool called;
+
+	if (called)
+		return;
+	called = true;
 
 	if (ping_pmap() == -1)
 		return;
@@ -112,6 +119,8 @@
 	static struct timeval timeout = { ALLOWED_MOUNT_TIME, 0 };
 	amq_sync_umnt result;
 
+	am_init();
+
 	if (clnt == NULL)
 		return AMQ_UMNT_FAILED;
 

Index: src/usr.bin/eject/am_glue.h
diff -u src/usr.bin/eject/am_glue.h:1.1 src/usr.bin/eject/am_glue.h:1.2
--- src/usr.bin/eject/am_glue.h:1.1	Fri Jan 16 17:31:22 2009
+++ src/usr.bin/eject/am_glue.h	Wed Jun 23 18:07:59 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: am_glue.h,v 1.1 2009/01/16 17:31:22 christos Exp $	*/
+/*	$NetBSD: am_glue.h,v 1.2 2010/06/23 18:07:59 yamt Exp $	*/
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,9 +28,6 @@
 #ifndef __AM_GLUE_H__
 #define __AM_GLUE_H__
 
-#include <rpc/rpc.h>
-
-void am_init(void);
 int am_unmount(const char *);
 
 #endif /* __AM_GLUE_H__ */

Index: src/usr.bin/eject/eject.c
diff -u src/usr.bin/eject/eject.c:1.25 src/usr.bin/eject/eject.c:1.26
--- src/usr.bin/eject/eject.c:1.25	Fri Jan 16 17:31:22 2009
+++ src/usr.bin/eject/eject.c	Wed Jun 23 18:07:59 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: eject.c,v 1.25 2009/01/16 17:31:22 christos Exp $	*/
+/*	$NetBSD: eject.c,v 1.26 2010/06/23 18:07:59 yamt Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #endif				/* not lint */
 
 #ifndef lint
-__RCSID("$NetBSD: eject.c,v 1.25 2009/01/16 17:31:22 christos Exp $");
+__RCSID("$NetBSD: eject.c,v 1.26 2010/06/23 18:07:59 yamt Exp $");
 #endif				/* not lint */
 
 #include <sys/types.h>
@@ -332,9 +332,6 @@
 	int i, nmnts;
 	const char *dn;
 
-#ifdef AMD_SUPPORT
-	am_init();
-#endif
 	nmnts = getmntinfo(&mounts, MNT_NOWAIT);
 	if (nmnts == 0)
 		err(1, "getmntinfo");

Reply via email to