From 77c1652531da9d2e2d919a869c7e8466e5ef4b46 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 14 Apr 1999 16:04:09 +0000 Subject: [PATCH] svc.c (svc_getreq, svc_getreqset): Avoid using internal, private fd_set structure elements (Needed for Linux/glibc 2.1) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11360 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/rpc/ChangeLog | 5 +++++ src/lib/rpc/svc.c | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/lib/rpc/ChangeLog b/src/lib/rpc/ChangeLog index 337bd03c4..2db24107c 100644 --- a/src/lib/rpc/ChangeLog +++ b/src/lib/rpc/ChangeLog @@ -1,3 +1,8 @@ +1999-04-14 + + * svc.c (svc_getreq, svc_getreqset): Avoid using internal, private + fd_set structure elements (Needed for Linux/glibc 2.1) + Thu Apr 1 19:11:50 1999 Tom Yu * rpc_commondata.c: Add initializers to prevent lossage on systems diff --git a/src/lib/rpc/svc.c b/src/lib/rpc/svc.c index b5bc708a0..725570b0c 100644 --- a/src/lib/rpc/svc.c +++ b/src/lib/rpc/svc.c @@ -50,6 +50,7 @@ extern int errno; #ifdef FD_SETSIZE static SVCXPRT **xports; +static int max_xport = 0; #else #define NOFILE 32 @@ -93,6 +94,8 @@ xprt_register(xprt) if (sock < _gssrpc_rpc_dtablesize()) { xports[sock] = xprt; FD_SET(sock, &svc_fdset); + if (max_xport < sock) + max_xport = sock; } #else if (sock < NOFILE) { @@ -116,6 +119,10 @@ xprt_unregister(xprt) if ((sock < _gssrpc_rpc_dtablesize()) && (xports[sock] == xprt)) { xports[sock] = (SVCXPRT *)0; FD_CLR(sock, &svc_fdset); + if (max_xport = sock) { + while ((max_xport > 0) && xports[max_xport] == 0) + max_xport--; + } } #else if ((sock < NOFILE) && (xports[sock] == xprt)) { @@ -371,9 +378,14 @@ svc_getreq(rdfds) { #ifdef FD_SETSIZE fd_set readfds; + int i, mask; FD_ZERO(&readfds); - readfds.fds_bits[0] = rdfds; + for (i=0, mask=1; rdfds; i++, mask <<=1) { + if (rdfds & mask) + FD_SET(i, &readfds); + rdfds &= ~mask; + } svc_getreqset(&readfds); #else int readfds = rdfds & svc_fds; @@ -402,7 +414,6 @@ svc_getreqset(readfds) rpc_u_int32 mask; int bit; rpc_u_int32 *maskp; - register int setsize; register int sock; bool_t no_dispatch; @@ -412,11 +423,8 @@ svc_getreqset(readfds) r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]); #ifdef FD_SETSIZE - setsize = _gssrpc_rpc_dtablesize(); - - maskp = (rpc_u_int32 *)readfds->fds_bits; - for (sock = 0; sock < setsize; sock += NFDBITS) { - for (mask = *maskp++; bit = ffs(mask); mask ^= (1 << (bit - 1))) { + for (sock = 0; sock <= max_xport; sock++) { + if (FD_ISSET(sock, readfds)) { /* sock has input waiting */ xprt = xports[sock + bit - 1]; #else -- 2.26.2