diff options
author | John Kohl <jtkohl@mit.edu> | 1988-07-08 06:17:10 +0000 |
---|---|---|
committer | John Kohl <jtkohl@mit.edu> | 1988-07-08 06:17:10 +0000 |
commit | cd8947b75038d28d16095c6f3a5b7e6fb3c0e6fe (patch) | |
tree | 302cd138bf5d41607a7d7d9750bb199d43478e29 | |
parent | c68b027989b2280657640b607abb2d5dd96885d2 (diff) |
more intelligent select()
-rw-r--r-- | lib/ZLocateU.c | 16 | ||||
-rw-r--r-- | lib/ZRetSubs.c | 14 |
2 files changed, 25 insertions, 5 deletions
diff --git a/lib/ZLocateU.c b/lib/ZLocateU.c index 3959eda..9287461 100644 --- a/lib/ZLocateU.c +++ b/lib/ZLocateU.c @@ -28,7 +28,8 @@ Code_t ZLocateUser(user, nlocs) ZNotice_t notice, retnotice; char *ptr, *end; int nrecv, ack; - fd_set read, write, except; + fd_set read, setup; + int nfds; int gotone; struct timeval tv; @@ -57,14 +58,23 @@ Code_t ZLocateUser(user, nlocs) nrecv = ack = 0; + FD_ZERO(&setup); + FD_SET(ZGetFD(), &setup); + nfds = ZGetFD() + 1; + while (!nrecv || !ack) { tv.tv_sec = 0; tv.tv_usec = 500000; for (i=0;i<HM_TIMEOUT*2;i++) { /* 30 secs in 1/2 sec intervals */ gotone = 0; - if (select(0, &read, &write, &except, &tv) < 0) - return (errno); + read = setup; + if (select(nfds, &read, (fd_set *) 0, + (fd_set *) 0, &tv) < 0) + return (errno); + if (FD_ISSET(ZGetFD(), &read)) + i--; /* make sure we time out the + full 30 secs */ retval = ZCheckIfNotice(&retnotice, (struct sockaddr_in *)0, ZCompareMultiUIDPred, diff --git a/lib/ZRetSubs.c b/lib/ZRetSubs.c index dabf9b9..9af736d 100644 --- a/lib/ZRetSubs.c +++ b/lib/ZRetSubs.c @@ -64,7 +64,8 @@ static Code_t Z_RetSubs(notice, nsubs) register int i; ZNotice_t retnotice; char *ptr,*end,*ptr2; - fd_set read, write, except; + fd_set read, setup; + int nfds; struct timeval tv; int gotone; @@ -92,14 +93,23 @@ static Code_t Z_RetSubs(notice, nsubs) gimmeack = 0; __subscriptions_list = (ZSubscription_t *) 0; + FD_ZERO(&setup); + FD_SET(ZGetFD(), &setup); + nfds = ZGetFD() + 1; + while (!nrecv || !gimmeack) { tv.tv_sec = 0; tv.tv_usec = 500000; for (i=0;i<HM_TIMEOUT*2;i++) { /* 30 secs in 1/2 sec intervals */ gotone = 0; - if (select(0, &read, &write, &except, &tv) < 0) + read = setup; + if (select(nfds, &read, (fd_set *) 0, + (fd_set *) 0, &tv) < 0) return (errno); + if (FD_ISSET(ZGetFD(), &read)) + i--; /* make sure we time out the + full 30 secs */ retval = ZCheckIfNotice(&retnotice, (struct sockaddr_in *)0, ZCompareMultiUIDPred, |