Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/rpc Close socket correctly in three places.



details:   https://anonhg.NetBSD.org/src/rev/68d73962582a
branches:  trunk
changeset: 517011:68d73962582a
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sun Nov 04 14:43:55 2001 +0000

description:
Close socket correctly in three places.
Fixes various problems such as inetd not reloading correctly.
Fix provided by Michael van Elst in [lib/14454] - thanks!
Should also fix [bin/12651] and [bin/13657]

diffstat:

 lib/libc/rpc/rpcb_clnt.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r 250a5e72a7de -r 68d73962582a lib/libc/rpc/rpcb_clnt.c
--- a/lib/libc/rpc/rpcb_clnt.c  Sun Nov 04 14:07:13 2001 +0000
+++ b/lib/libc/rpc/rpcb_clnt.c  Sun Nov 04 14:43:55 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpcb_clnt.c,v 1.9 2001/09/27 18:59:37 jdolecek Exp $   */
+/*     $NetBSD: rpcb_clnt.c,v 1.10 2001/11/04 14:43:55 lukem Exp $     */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -463,8 +463,14 @@
        client = clnt_vc_create(sock, &nbuf, (rpcprog_t)RPCBPROG,
            (rpcvers_t)RPCBVERS, tsize, tsize);
 
-       if (client != NULL)
+       if (client != NULL) {
+               /* XXX - mark the socket to be closed in destructor */
+               (void) CLNT_CONTROL(client, CLSET_FD_CLOSE, NULL);
                return client;
+       }
+
+       /* XXX - nobody needs this socket anymore, free the descriptor */
+       close(sock);
 
 try_nconf:
 
@@ -556,6 +562,7 @@
        parms.r_addr = taddr2uaddr((struct netconfig *) nconf,
                                   (struct netbuf *)address);
        if (!parms.r_addr) {
+               CLNT_DESTROY(client);
                rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE;
                return (FALSE); /* no universal address */
        }



Home | Main Index | Thread Index | Old Index