Close socket correctly in three places. Fixes various problems such as inetd not reloading correctly. Discovered by the NetBSD project. See Revision 1.10 of rpcb_clnt.c in the NetBSD code. Fix provided by Michael van Elst in NetBSD [lib/14454] - thanks! Should also fix NetBSD [bin/12651] and NetBSD [bin/13657] Index: rpcb_clnt.c =================================================================== RCS file: /home/ncvs/src/lib/libc/rpc/rpcb_clnt.c,v retrieving revision 1.5 diff -u -r1.5 rpcb_clnt.c --- rpcb_clnt.c 5 Feb 2002 23:12:51 -0000 1.5 +++ rpcb_clnt.c 9 Feb 2002 13:26:36 -0000 @@ -459,8 +459,16 @@ client = clnt_vc_create(sock, &nbuf, (rpcprog_t)RPCBPROG, (rpcvers_t)RPCBVERS, tsize, tsize); - if (client != NULL) + if (client != NULL) { + /* mark the socket to be closed in destructor */ + (void) CLNT_CONTROL(client, CLSET_FD_CLOSE, NULL); return client; + } + + /* nobody needs this socket anymore, + * free the descriptor + */ + close(sock); try_nconf: @@ -552,6 +560,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 */ }