summaryrefslogtreecommitdiff
path: root/lib/ZLocateU.c
diff options
context:
space:
mode:
authorGravatar John Kohl <jtkohl@mit.edu>1988-07-08 06:17:10 +0000
committerGravatar John Kohl <jtkohl@mit.edu>1988-07-08 06:17:10 +0000
commitcd8947b75038d28d16095c6f3a5b7e6fb3c0e6fe (patch)
tree302cd138bf5d41607a7d7d9750bb199d43478e29 /lib/ZLocateU.c
parentc68b027989b2280657640b607abb2d5dd96885d2 (diff)
more intelligent select()
Diffstat (limited to 'lib/ZLocateU.c')
-rw-r--r--lib/ZLocateU.c16
1 files changed, 13 insertions, 3 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,