* don't close the socket unless it was opened by the function
* note (in the comments) that the client is responsible for closing the socket if they opened it, or they didn't use CLNT_DESTROY() fixes a couple of unnecessary closing of already-closed sockets. noted by: Matthias Drochner <M.Drochner@fz-juelich.de>
This commit is contained in:
parent
eb6b33ee3f
commit
15896e79fe
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: clnt_simple.c,v 1.15 1999/01/20 11:37:35 lukem Exp $ */
|
||||
/* $NetBSD: clnt_simple.c,v 1.16 1999/03/25 01:16:10 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: clnt_simple.c,v 1.15 1999/01/20 11:37:35 lukem Exp $");
|
||||
__RCSID("$NetBSD: clnt_simple.c,v 1.16 1999/03/25 01:16:10 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -99,13 +99,15 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
|||
/* reuse old client */
|
||||
} else {
|
||||
crp->valid = 0;
|
||||
if (crp->socket != -1)
|
||||
if (crp->socket != -1) {
|
||||
(void)close(crp->socket);
|
||||
crp->socket = RPC_ANYSOCK;
|
||||
crp->socket = -1;
|
||||
}
|
||||
if (crp->client) {
|
||||
clnt_destroy(crp->client);
|
||||
CLNT_DESTROY(crp->client);
|
||||
crp->client = NULL;
|
||||
}
|
||||
crp->socket = RPC_ANYSOCK;
|
||||
if ((hp = gethostbyname(host)) == NULL)
|
||||
return ((int) RPC_UNKNOWNHOST);
|
||||
timeout.tv_usec = 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: clnt_tcp.c,v 1.17 1999/01/31 20:45:31 christos Exp $ */
|
||||
/* $NetBSD: clnt_tcp.c,v 1.18 1999/03/25 01:16:10 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: clnt_tcp.c,v 1.17 1999/01/31 20:45:31 christos Exp $");
|
||||
__RCSID("$NetBSD: clnt_tcp.c,v 1.18 1999/03/25 01:16:10 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -126,7 +126,11 @@ struct ct_data {
|
|||
* If raddr->sin_port is 0, then a binder on the remote machine is
|
||||
* consulted for the right port number.
|
||||
* NB: *sockp is copied into a private area.
|
||||
* NB: It is the clients responsibility to close *sockp.
|
||||
* NB: It is the client's responsibility to close *sockp, unless
|
||||
* CLNT_DESTROY() is used
|
||||
* NB: It is the client's responsibility to close *sockp, unless
|
||||
* clnttcp_create() was called with *sockp = -1 (so it created
|
||||
* the socket), and CLNT_DESTROY() is used.
|
||||
* NB: The rpch->cl_auth is set null authentication. Caller may wish to set
|
||||
* this something more useful.
|
||||
*/
|
||||
|
@ -414,7 +418,7 @@ clnttcp_destroy(h)
|
|||
{
|
||||
struct ct_data *ct = (struct ct_data *) h->cl_private;
|
||||
|
||||
if (ct->ct_closeit) {
|
||||
if (ct->ct_closeit && ct->ct_sock != -1) {
|
||||
(void)close(ct->ct_sock);
|
||||
}
|
||||
XDR_DESTROY(&(ct->ct_xdrs));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: clnt_udp.c,v 1.16 1999/01/20 11:37:36 lukem Exp $ */
|
||||
/* $NetBSD: clnt_udp.c,v 1.17 1999/03/25 01:16:11 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: clnt_udp.c,v 1.16 1999/01/20 11:37:36 lukem Exp $");
|
||||
__RCSID("$NetBSD: clnt_udp.c,v 1.17 1999/03/25 01:16:11 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -112,7 +112,9 @@ struct cu_data {
|
|||
* If *sockp<0, *sockp is set to a newly created UPD socket.
|
||||
* If raddr->sin_port is 0 a binder on the remote machine
|
||||
* is consulted for the correct port number.
|
||||
* NB: It is the clients responsibility to close *sockp.
|
||||
* NB: It is the client's responsibility to close *sockp, unless
|
||||
* clntudp_bufcreate() was called with *sockp = -1 (so it created
|
||||
* the socket), and CLNT_DESTROY() is used.
|
||||
* NB: The rpch->cl_auth is initialized to null authentication.
|
||||
* Caller may wish to set this something more useful.
|
||||
*
|
||||
|
@ -200,9 +202,9 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
|||
rpc_createerr.cf_error.re_errno = errno;
|
||||
goto fooy;
|
||||
}
|
||||
/* attempt to bind to priv port */
|
||||
/* attempt to bind to priv port */
|
||||
(void)bindresvport(*sockp, (struct sockaddr_in *)0);
|
||||
/* the sockets rpc controls are non-blocking */
|
||||
/* the sockets rpc controls are non-blocking */
|
||||
(void)ioctl(*sockp, FIONBIO, (char *)(void *)&dontblock);
|
||||
cu->cu_closeit = TRUE;
|
||||
} else {
|
||||
|
@ -467,7 +469,7 @@ clntudp_destroy(cl)
|
|||
{
|
||||
struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
||||
|
||||
if (cu->cu_closeit) {
|
||||
if (cu->cu_closeit && cu->cu_sock != -1) {
|
||||
(void)close(cu->cu_sock);
|
||||
}
|
||||
XDR_DESTROY(&(cu->cu_outxdrs));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pmap_clnt.c,v 1.11 1999/01/31 20:45:31 christos Exp $ */
|
||||
/* $NetBSD: pmap_clnt.c,v 1.12 1999/03/25 01:16:11 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: pmap_clnt.c,v 1.11 1999/01/31 20:45:31 christos Exp $");
|
||||
__RCSID("$NetBSD: pmap_clnt.c,v 1.12 1999/03/25 01:16:11 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -92,13 +92,9 @@ pmap_set(program, version, protocol, port)
|
|||
if (CLNT_CALL(client, PMAPPROC_SET, (xdrproc_t)xdr_pmap,
|
||||
&parms, (xdrproc_t)xdr_bool, &rslt, tottimeout) != RPC_SUCCESS) {
|
||||
clnt_perror(client, "Cannot register service");
|
||||
if (socket != -1)
|
||||
(void)close(socket);
|
||||
return (FALSE);
|
||||
rslt = FALSE;
|
||||
}
|
||||
CLNT_DESTROY(client);
|
||||
if (socket != -1)
|
||||
(void)close(socket);
|
||||
return (rslt);
|
||||
}
|
||||
|
||||
|
@ -129,7 +125,5 @@ pmap_unset(program, version)
|
|||
CLNT_CALL(client, PMAPPROC_UNSET, (xdrproc_t)xdr_pmap, &parms,
|
||||
(xdrproc_t)xdr_bool, &rslt, tottimeout);
|
||||
CLNT_DESTROY(client);
|
||||
if (socket != -1)
|
||||
(void)close(socket);
|
||||
return (rslt);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pmap_getmaps.c,v 1.11 1999/01/31 20:45:31 christos Exp $ */
|
||||
/* $NetBSD: pmap_getmaps.c,v 1.12 1999/03/25 01:16:11 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: pmap_getmaps.c,v 1.11 1999/01/31 20:45:31 christos Exp $");
|
||||
__RCSID("$NetBSD: pmap_getmaps.c,v 1.12 1999/03/25 01:16:11 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -97,8 +97,6 @@ pmap_getmaps(address)
|
|||
}
|
||||
CLNT_DESTROY(client);
|
||||
}
|
||||
if (sock != -1)
|
||||
(void)close(sock);
|
||||
address->sin_port = 0;
|
||||
return (head);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pmap_getport.c,v 1.11 1999/01/31 20:45:31 christos Exp $ */
|
||||
/* $NetBSD: pmap_getport.c,v 1.12 1999/03/25 01:16:11 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: pmap_getport.c,v 1.11 1999/01/31 20:45:31 christos Exp $");
|
||||
__RCSID("$NetBSD: pmap_getport.c,v 1.12 1999/03/25 01:16:11 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -101,8 +101,6 @@ pmap_getport(address, program, version, protocol)
|
|||
}
|
||||
CLNT_DESTROY(client);
|
||||
}
|
||||
if (sock != -1)
|
||||
(void)close(sock);
|
||||
address->sin_port = 0;
|
||||
return (port);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pmap_rmt.c,v 1.19 1999/01/31 20:45:31 christos Exp $ */
|
||||
/* $NetBSD: pmap_rmt.c,v 1.20 1999/03/25 01:16:11 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: pmap_rmt.c,v 1.19 1999/01/31 20:45:31 christos Exp $");
|
||||
__RCSID("$NetBSD: pmap_rmt.c,v 1.20 1999/03/25 01:16:11 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -123,8 +123,6 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout,
|
|||
} else {
|
||||
stat = RPC_FAILED;
|
||||
}
|
||||
if (sock != -1)
|
||||
(void)close(sock);
|
||||
addr->sin_port = 0;
|
||||
return (stat);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: svc_tcp.c,v 1.21 1999/01/20 11:37:39 lukem Exp $ */
|
||||
/* $NetBSD: svc_tcp.c,v 1.22 1999/03/25 01:16:11 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: svc_tcp.c,v 1.21 1999/01/20 11:37:39 lukem Exp $");
|
||||
__RCSID("$NetBSD: svc_tcp.c,v 1.22 1999/03/25 01:16:11 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -295,7 +295,8 @@ svctcp_destroy(xprt)
|
|||
struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1;
|
||||
|
||||
xprt_unregister(xprt);
|
||||
(void)close(xprt->xp_sock);
|
||||
if (xprt->xp_sock != -1)
|
||||
(void)close(xprt->xp_sock);
|
||||
if (xprt->xp_port != 0) {
|
||||
/* a rendezvouser socket */
|
||||
xprt->xp_port = 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: svc_udp.c,v 1.16 1999/01/20 11:37:40 lukem Exp $ */
|
||||
/* $NetBSD: svc_udp.c,v 1.17 1999/03/25 01:16:11 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)svc_udp.c 2.2 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: svc_udp.c,v 1.16 1999/01/20 11:37:40 lukem Exp $");
|
||||
__RCSID("$NetBSD: svc_udp.c,v 1.17 1999/03/25 01:16:11 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -287,7 +287,8 @@ svcudp_destroy(xprt)
|
|||
struct svcudp_data *su = su_data(xprt);
|
||||
|
||||
xprt_unregister(xprt);
|
||||
(void)close(xprt->xp_sock);
|
||||
if (xprt->xp_sock != -1)
|
||||
(void)close(xprt->xp_sock);
|
||||
XDR_DESTROY(&(su->su_xdrs));
|
||||
mem_free(rpc_buffer(xprt), su->su_iosz);
|
||||
mem_free(su, sizeof(struct svcudp_data));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: xdr_stdio.c,v 1.12 1998/11/15 17:32:47 christos Exp $ */
|
||||
/* $NetBSD: xdr_stdio.c,v 1.13 1999/03/25 01:16:11 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
|
@ -35,7 +35,7 @@
|
|||
static char *sccsid = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
|
||||
static char *sccsid = "@(#)xdr_stdio.c 2.1 88/07/29 4.0 RPCSRC";
|
||||
#else
|
||||
__RCSID("$NetBSD: xdr_stdio.c,v 1.12 1998/11/15 17:32:47 christos Exp $");
|
||||
__RCSID("$NetBSD: xdr_stdio.c,v 1.13 1999/03/25 01:16:11 lukem Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -111,7 +111,7 @@ xdrstdio_destroy(xdrs)
|
|||
XDR *xdrs;
|
||||
{
|
||||
(void)fflush((FILE *)xdrs->x_private);
|
||||
/* xx should we close the file ?? */
|
||||
/* XXX: should we close the file ?? */
|
||||
}
|
||||
|
||||
static bool_t
|
||||
|
|
Loading…
Reference in New Issue