From: Jeffrey Altman Date: Wed, 23 Jul 2008 20:55:56 +0000 (+0000) Subject: In the gss rpc package, replace the type used for a X-Git-Tag: krb5-1.7-alpha1~559 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4b6f2fd2ea29a84fec63b328846bfb31bb85268e;p=krb5.git In the gss rpc package, replace the type used for a socket on Windows with SOCKET (instead of int) and replace all calls to close() that are used to close sockets with closesocket(). src/include/port-sockets.h includes the definitions of SOCKET and closesocket() for non-Windows systems. ticket: 6041 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20578 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/gssrpc/svc.h b/src/include/gssrpc/svc.h index a5198e777..dfe0bec65 100644 --- a/src/include/gssrpc/svc.h +++ b/src/include/gssrpc/svc.h @@ -72,7 +72,11 @@ enum xprt_stat { * Server side transport handle */ typedef struct SVCXPRT { +#ifdef _WIN32 + SOCKET xp_sock; +#else int xp_sock; +#endif u_short xp_port; /* associated port number */ struct xp_ops { /* receive incomming requests */ diff --git a/src/lib/rpc/clnt_simple.c b/src/lib/rpc/clnt_simple.c index d2434a13c..65ae5c176 100644 --- a/src/lib/rpc/clnt_simple.c +++ b/src/lib/rpc/clnt_simple.c @@ -45,11 +45,12 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; #include #include #include +#include #include "autoconf.h" static struct callrpc_private { CLIENT *client; - int socket; + SOCKET socket; int oldprognum, oldversnum, valid; char *oldhost; } *callrpc_private; @@ -89,7 +90,7 @@ callrpc( /* reuse old client */ } else { crp->valid = 0; - (void)close(crp->socket); + (void)closesocket(crp->socket); crp->socket = RPC_ANYSOCK; if (crp->client) { clnt_destroy(crp->client); diff --git a/src/lib/rpc/clnt_tcp.c b/src/lib/rpc/clnt_tcp.c index 1f8de8276..dc7e2ff50 100644 --- a/src/lib/rpc/clnt_tcp.c +++ b/src/lib/rpc/clnt_tcp.c @@ -60,6 +60,7 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; #include /* FD_ZERO may need memset declaration (e.g., Solaris 9) */ #include +#include #define MCALL_MSG_SIZE 24 @@ -118,7 +119,7 @@ clnttcp_create( struct sockaddr_in *raddr, rpcprog_t prog, rpcvers_t vers, - register int *sockp, + SOCKET *sockp, u_int sendsz, u_int recvsz) { @@ -166,7 +167,7 @@ clnttcp_create( sizeof(*raddr)) < 0)) { rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; - (void)close(*sockp); + (void)closesocket(*sockp); goto fooy; } ct->ct_closeit = TRUE; @@ -198,9 +199,8 @@ clnttcp_create( xdrmem_create(&(ct->ct_xdrs), ct->ct_u.ct_mcall, MCALL_MSG_SIZE, XDR_ENCODE); if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { - if (ct->ct_closeit) { - (void)close(*sockp); - } + if (ct->ct_closeit) + (void)closesocket(*sockp); goto fooy; } ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); @@ -404,9 +404,8 @@ clnttcp_destroy(CLIENT *h) register struct ct_data *ct = (struct ct_data *) h->cl_private; - if (ct->ct_closeit) { - (void)close(ct->ct_sock); - } + if (ct->ct_closeit) + (void)closesocket(ct->ct_sock); XDR_DESTROY(&(ct->ct_xdrs)); mem_free((caddr_t)ct, sizeof(struct ct_data)); mem_free((caddr_t)h, sizeof(CLIENT)); diff --git a/src/lib/rpc/clnt_udp.c b/src/lib/rpc/clnt_udp.c index a8b59563f..bb0727d11 100644 --- a/src/lib/rpc/clnt_udp.c +++ b/src/lib/rpc/clnt_udp.c @@ -49,6 +49,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; #include #include #include +#include #include @@ -76,7 +77,7 @@ static struct clnt_ops udp_ops = { * Private data kept per client handle */ struct cu_data { - int cu_sock; + SOCKET cu_sock; bool_t cu_closeit; struct sockaddr_in cu_raddr; int cu_rlen; @@ -475,9 +476,8 @@ clntudp_destroy(CLIENT *cl) { register struct cu_data *cu = (struct cu_data *)cl->cl_private; - if (cu->cu_closeit) { - (void)close(cu->cu_sock); - } + if (cu->cu_closeit) + (void)closesocket(cu->cu_sock); XDR_DESTROY(&(cu->cu_outxdrs)); mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz)); mem_free((caddr_t)cl, sizeof(CLIENT)); diff --git a/src/lib/rpc/pmap_rmt.c b/src/lib/rpc/pmap_rmt.c index 71804ab7e..d2e2ccdbc 100644 --- a/src/lib/rpc/pmap_rmt.c +++ b/src/lib/rpc/pmap_rmt.c @@ -59,6 +59,7 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; #include #define MAX_BROADCAST_SIZE 1400 #include +#include #include "k5-platform.h" /* set_cloexec_fd */ static struct timeval timeout = { 3, 0 }; @@ -84,7 +85,7 @@ pmap_rmtcall( struct timeval tout, rpcport_t *port_ptr) { - int sock = -1; + SOCKET sock = INVALID_SOCKET; register CLIENT *client; struct rmtcallargs a; struct rmtcallres r; @@ -107,7 +108,7 @@ pmap_rmtcall( } else { stat = RPC_FAILED; } - (void)close(sock); + (void)closesocket(sock); addr->sin_port = 0; return (stat); } @@ -245,7 +246,7 @@ clnt_broadcast( XDR xdr_stream; register XDR *xdrs = &xdr_stream; int outlen, inlen, fromlen, nets; - register int sock; + SOCKET sock; int on = 1; #ifdef FD_SETSIZE fd_set mask; @@ -412,7 +413,7 @@ clnt_broadcast( } } done_broad: - (void)close(sock); + (void)closesocket(sock); AUTH_DESTROY(unix_auth); return (stat); } diff --git a/src/lib/rpc/svc_tcp.c b/src/lib/rpc/svc_tcp.c index 8220ea2ab..595723f04 100644 --- a/src/lib/rpc/svc_tcp.c +++ b/src/lib/rpc/svc_tcp.c @@ -50,6 +50,7 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro"; #include #include "autoconf.h" #include "k5-platform.h" /* set_cloexec_fd */ +#include /*extern bool_t abort(); extern errno; */ @@ -137,7 +138,7 @@ struct tcp_conn { /* kept in xprt->xp_p1 */ */ SVCXPRT * svctcp_create( - register int sock, + SOCKET sock, u_int sendsize, u_int recvsize) { @@ -166,14 +167,14 @@ svctcp_create( } if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) { perror("svc_tcp.c - cannot getsockname"); - if (madesock) - (void) close(sock); + if (madesock) + (void)closesocket(sock); return ((SVCXPRT *)NULL); } if (listen(sock, 2) != 0) { perror("svctcp_.c - cannot listen"); - if (madesock) - (void)close(sock); + if (madesock) + (void)closesocket(sock); return ((SVCXPRT *)NULL); } r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r)); @@ -270,7 +271,7 @@ rendezvous_request( register SVCXPRT *xprt, struct rpc_msg *msg) { - int sock; + SOCKET sock; struct tcp_rendezvous *r; struct sockaddr_in addr, laddr; int len, llen; @@ -293,7 +294,7 @@ rendezvous_request( */ xprt = makefd_xprt(sock, r->sendsize, r->recvsize); if (xprt == NULL) { - close(sock); + (void)closesocket(sock); return (FALSE); } xprt->xp_raddr = addr; @@ -316,7 +317,7 @@ svctcp_destroy(register SVCXPRT *xprt) register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1; xprt_unregister(xprt); - (void)close(xprt->xp_sock); + (void)closesocket(xprt->xp_sock); if (xprt->xp_port != 0) { /* a rendezvouser socket */ xprt->xp_port = 0; diff --git a/src/lib/rpc/svc_udp.c b/src/lib/rpc/svc_udp.c index de1b30f4f..f4cbddd56 100644 --- a/src/lib/rpc/svc_udp.c +++ b/src/lib/rpc/svc_udp.c @@ -49,6 +49,7 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro"; #ifdef HAVE_SYS_UIO_H #include #endif +#include #include "k5-platform.h" @@ -305,9 +306,9 @@ svcudp_destroy(register SVCXPRT *xprt) register struct svcudp_data *su = su_data(xprt); xprt_unregister(xprt); - if (xprt->xp_sock != -1) - (void)close(xprt->xp_sock); - xprt->xp_sock = -1; + if (xprt->xp_sock != INVALID_SOCKET) + (void)closesocket(xprt->xp_sock); + xprt->xp_sock = INVALID_SOCKET; if (xprt->xp_auth != NULL) { SVCAUTH_DESTROY(xprt->xp_auth); xprt->xp_auth = NULL;