From owner-freebsd-current@FreeBSD.ORG Fri May 20 19:50:18 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B5E1B16A4CE for ; Fri, 20 May 2005 19:50:18 +0000 (GMT) Received: from postfix4-2.free.fr (postfix4-2.free.fr [213.228.0.176]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3459143D94 for ; Fri, 20 May 2005 19:50:18 +0000 (GMT) (envelope-from tataz@tataz.chchile.org) Received: from tatooine.tataz.chchile.org (vol75-8-82-233-239-98.fbx.proxad.net [82.233.239.98]) by postfix4-2.free.fr (Postfix) with ESMTP id 54B2C31D723 for ; Fri, 20 May 2005 21:50:17 +0200 (CEST) Received: by tatooine.tataz.chchile.org (Postfix, from userid 1000) id 701AC405A; Fri, 20 May 2005 21:50:18 +0200 (CEST) Date: Fri, 20 May 2005 21:50:17 +0200 From: Jeremie Le Hen To: freebsd-current@FreeBSD.org Message-ID: <20050520195017.GZ818@obiwan.tataz.chchile.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="CE+1k2dSO48ffgeK" Content-Disposition: inline User-Agent: Mutt/1.5.9i Subject: rpc.umntall timeout X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2005 19:50:18 -0000 --CE+1k2dSO48ffgeK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I used to connect to multiple networks with my laptop. The problem is that rpc.umntall(8) automatically tries to send a RPCMNT_UMOUNT to all old entries in /var/db/mounttab. I always need to hit ^C because it takes too long to timeout. I watched at the code to see if I couldn't set a timeout on the sending socket to shorten the amount of time it tries to contact the NFS server of each deprecated mount. It looks there is already a hard-coded timeout of three seconds on the call of clnt_call(3), but I added some printf(3)s and this is obviously the preceding clnt_create(3) call which takes so much time. I looked at the code of this function, and this is not much than a simple wrapper to clnt_create_timed(3) function. So I changed rpc.umntall(3) code to use this function and the same timeout as clnt_call(3) instead of using the non-timed version. This is what this small patch does. It may be worth creating an option for this, I don't know if waiting a big amount of time is relevant in specific some cases. Regards, -- Jeremie Le Hen < jeremie at le-hen dot org >< ttz at chchile dot org > --CE+1k2dSO48ffgeK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rpc.umntall-timed.patch" Index: rpc.umntall.c =================================================================== RCS file: /nfs/donald/repo/FreeBSD/src/usr.sbin/rpc.umntall/rpc.umntall.c,v retrieving revision 1.12 diff -u -p -r1.12 rpc.umntall.c --- rpc.umntall.c 26 Oct 2003 06:14:10 -0000 1.12 +++ rpc.umntall.c 20 May 2005 17:59:45 -0000 @@ -174,14 +174,15 @@ do_umntall(char *hostname) { struct timeval try; CLIENT *clp; - clp = clnt_create(hostname, RPCPROG_MNT, RPCMNT_VER1, "udp"); + try.tv_sec = 3; + try.tv_usec = 0; + clp = clnt_create_timed(hostname, RPCPROG_MNT, RPCMNT_VER1, "udp", + &try); if (clp == NULL) { warnx("%s: %s", hostname, clnt_spcreateerror("RPCPROG_MNT")); return (0); } clp->cl_auth = authunix_create_default(); - try.tv_sec = 3; - try.tv_usec = 0; clnt_stat = clnt_call(clp, RPCMNT_UMNTALL, (xdrproc_t)xdr_void, (caddr_t)0, (xdrproc_t)xdr_void, (caddr_t)0, try); @@ -201,14 +202,15 @@ do_umount(char *hostname, char *dirp) { struct timeval try; CLIENT *clp; - clp = clnt_create(hostname, RPCPROG_MNT, RPCMNT_VER1, "udp"); + try.tv_sec = 3; + try.tv_usec = 0; + clp = clnt_create_timed(hostname, RPCPROG_MNT, RPCMNT_VER1, "udp", + &try); if (clp == NULL) { warnx("%s: %s", hostname, clnt_spcreateerror("RPCPROG_MNT")); return (0); } clp->cl_auth = authsys_create_default(); - try.tv_sec = 3; - try.tv_usec = 0; clnt_stat = clnt_call(clp, RPCMNT_UMOUNT, (xdrproc_t)xdr_dir, dirp, (xdrproc_t)xdr_void, (caddr_t)0, try); if (clnt_stat != RPC_SUCCESS) --CE+1k2dSO48ffgeK--