* 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>
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.
#include <stdio.h>
#include <unistd.h>
#include <rpc/rpc.h>
+#include <sys/poll.h>
#include <sys/socket.h>
#include <rpc/pmap_clnt.h>
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;
#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>
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;
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:
#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>
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;
struct rmtcallargs a;
struct rmtcallres r;
struct rpc_msg msg;
- struct timeval t, t1;
+ struct timeval t;
char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE];
/*
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;
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 */
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,