diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | sunrpc/clnt_tcp.c | 23 | ||||
-rw-r--r-- | sunrpc/clnt_udp.c | 24 | ||||
-rw-r--r-- | sunrpc/pmap_rmt.c | 30 |
4 files changed, 31 insertions, 53 deletions
@@ -1,5 +1,12 @@ 1998-06-28 Andreas Jaeger <aj@arthur.rhein-neckar.de> + * sunrpc/clnt_tcp.c (readtcp): Use poll instead of select. + * sunrpc/pmap_rmt.c (clnt_broadcast): Likewise. + * sunrpc/clnt_udp.c (clntudp_call): Likewise. + Patches from FreeBSD current. + +1998-06-28 Andreas Jaeger <aj@arthur.rhein-neckar.de> + * nscd/connections.c (handle_new_request): Handle POLLHUP correctly. (close_sockets): Correct parameter to dbg_log. diff --git a/sunrpc/clnt_tcp.c b/sunrpc/clnt_tcp.c index d4fd7c4..be74f0d 100644 --- a/sunrpc/clnt_tcp.c +++ b/sunrpc/clnt_tcp.c @@ -55,6 +55,7 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; #include <stdio.h> #include <unistd.h> #include <rpc/rpc.h> +#include <sys/poll.h> #include <sys/socket.h> #include <rpc/pmap_clnt.h> @@ -469,28 +470,18 @@ static int readtcp (char *ctptr, char *buf, int len) { struct ct_data *ct = (struct ct_data *)ctptr; -#ifdef FD_SETSIZE - fd_set mask; - fd_set readfds; + struct pollfd fd; + int milliseconds = (ct->ct_wait.tv_sec * 1000) + + (ct->ct_wait.tv_usec / 1000); if (len == 0) return 0; - FD_ZERO (&mask); - FD_SET (ct->ct_sock, &mask); -#else - int mask = 1 << (ct->ct_sock); - int readfds; - if (len == 0) - return 0; - -#endif /* def FD_SETSIZE */ + fd.fd = ct->ct_sock; + fd.events = POLLIN; while (TRUE) { - struct timeval timeout = ct->ct_wait; - readfds = mask; - switch (select (_rpc_dtablesize (), &readfds, (fd_set*)NULL, - (fd_set*)NULL, &timeout)) + switch (__poll(&fd, 1, milliseconds)) { case 0: ct->ct_error.re_status = RPC_TIMEDOUT; diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c index c3545db..1e2fe65 100644 --- a/sunrpc/clnt_udp.c +++ b/sunrpc/clnt_udp.c @@ -42,6 +42,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; #include <rpc/rpc.h> #include <rpc/xdr.h> #include <rpc/clnt.h> +#include <sys/poll.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <netdb.h> @@ -234,13 +235,9 @@ clntudp_call (cl, proc, xargs, argsp, xresults, resultsp, utimeout) int outlen = 0; int inlen; socklen_t fromlen; -#ifdef FD_SETSIZE - fd_set readfds; - fd_set mask; -#else - int readfds; - int mask; -#endif /* def FD_SETSIZE */ + struct pollfd fd; + int milliseconds = (cu->cu_wait.tv_sec * 1000) + + (cu->cu_wait.tv_usec / 1000); struct sockaddr_in from; struct rpc_msg reply_msg; XDR reply_xdrs; @@ -301,18 +298,11 @@ send_again: reply_msg.acpted_rply.ar_verf = _null_auth; reply_msg.acpted_rply.ar_results.where = resultsp; reply_msg.acpted_rply.ar_results.proc = xresults; -#ifdef FD_SETSIZE - FD_ZERO (&mask); - FD_SET (cu->cu_sock, &mask); -#else - mask = 1 << cu->cu_sock; -#endif /* def FD_SETSIZE */ + fd.fd = cu->cu_sock; + fd.events = POLLIN; for (;;) { - struct timeval cu_wait = cu->cu_wait; - readfds = mask; - switch (select (_rpc_dtablesize (), &readfds, (fd_set*) NULL, - (fd_set*) NULL, &cu_wait)) + switch (__poll(&fd, 1, milliseconds)) { case 0: diff --git a/sunrpc/pmap_rmt.c b/sunrpc/pmap_rmt.c index ec0b84e..b3c8fcb 100644 --- a/sunrpc/pmap_rmt.c +++ b/sunrpc/pmap_rmt.c @@ -45,6 +45,7 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; #include <rpc/pmap_prot.h> #include <rpc/pmap_clnt.h> #include <rpc/pmap_rmt.h> +#include <sys/poll.h> #include <sys/socket.h> #include <stdio.h> #include <errno.h> @@ -240,13 +241,8 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) socklen_t fromlen; int sock; int on = 1; -#ifdef FD_SETSIZE - fd_set mask; - fd_set readfds; -#else - int readfds; - int mask; -#endif /* def FD_SETSIZE */ + struct pollfd fd; + int milliseconds; int i; bool_t done = FALSE; u_long xid; @@ -256,7 +252,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) struct rmtcallargs a; struct rmtcallres r; struct rpc_msg msg; - struct timeval t, t1; + struct timeval t; char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE]; /* @@ -277,12 +273,8 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) goto done_broad; } #endif /* def SO_BROADCAST */ -#ifdef FD_SETSIZE - FD_ZERO (&mask); - FD_SET (sock, &mask); -#else - mask = (1 << sock); -#endif /* def FD_SETSIZE */ + fd.fd = sock; + fd.events = POLLIN; nets = getbroadcastnets (addrs, sock, inbuf); bzero ((char *) &baddr, sizeof (baddr)); baddr.sin_family = AF_INET; @@ -342,10 +334,8 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) msg.acpted_rply.ar_verf = _null_auth; msg.acpted_rply.ar_results.where = (caddr_t) & r; msg.acpted_rply.ar_results.proc = (xdrproc_t) xdr_rmtcallres; - readfds = mask; - t1 = t; - switch (select (_rpc_dtablesize (), &readfds, (fd_set *) NULL, - (fd_set *) NULL, &t1)) + milliseconds = t.tv_sec * 1000 + t.tv_usec / 1000; + switch (__poll(&fd, 1, milliseconds)) { case 0: /* timed out */ @@ -355,11 +345,11 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) case -1: /* some kind of error */ if (errno == EINTR) goto recv_again; - perror (_("Broadcast select problem")); + perror (_("Broadcast poll problem")); stat = RPC_CANTRECV; goto done_broad; - } /* end of select results switch */ + } /* end of poll results switch */ try_again: fromlen = sizeof (struct sockaddr); inlen = recvfrom (sock, inbuf, UDPMSGSIZE, 0, |