summaryrefslogtreecommitdiff
path: root/lib/ZRetSubs.c
diff options
context:
space:
mode:
authorGravatar John Kohl <jtkohl@mit.edu>1988-06-30 14:19:07 +0000
committerGravatar John Kohl <jtkohl@mit.edu>1988-06-30 14:19:07 +0000
commit198f9bfc7491a847c549b30d119dab4a21029111 (patch)
treeece6d18afa424130ea6ca1103c990df22025c9f6 /lib/ZRetSubs.c
parent075a1dd9cc55b16f1a0eb19a8a88ede818d1155b (diff)
add code to time out and/or detect old servers
Diffstat (limited to 'lib/ZRetSubs.c')
-rw-r--r--lib/ZRetSubs.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/lib/ZRetSubs.c b/lib/ZRetSubs.c
index 3dc4cad..dabf9b9 100644
--- a/lib/ZRetSubs.c
+++ b/lib/ZRetSubs.c
@@ -60,9 +60,13 @@ static Code_t Z_RetSubs(notice, nsubs)
register ZNotice_t *notice;
int *nsubs;
{
- int i,retval,nrecv,gimmeack;
+ int retval,nrecv,gimmeack;
+ register int i;
ZNotice_t retnotice;
char *ptr,*end,*ptr2;
+ fd_set read, write, except;
+ struct timeval tv;
+ int gotone;
retval = ZFlushSubscriptions();
@@ -89,17 +93,38 @@ static Code_t Z_RetSubs(notice, nsubs)
__subscriptions_list = (ZSubscription_t *) 0;
while (!nrecv || !gimmeack) {
- if ((retval = ZIfNotice(&retnotice, (struct sockaddr_in *) 0,
- ZCompareMultiUIDPred,
- (char *)&notice->z_multiuid))
- != ZERR_NONE)
- return (retval);
+ 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);
+ retval = ZCheckIfNotice(&retnotice,
+ (struct sockaddr_in *)0,
+ ZCompareMultiUIDPred,
+ (char *)&notice->z_multiuid);
+ if (retval == ZERR_NONE) {
+ gotone = 1;
+ break;
+ }
+ if (retval != ZERR_NONOTICE)
+ return(retval);
+ }
+
+ if (!gotone)
+ return(ETIMEDOUT);
if (retnotice.z_kind == SERVNAK) {
ZFreeNotice(&retnotice);
return (ZERR_SERVNAK);
}
-
+ /* non-matching protocol version numbers means the
+ server is probably an older version--must punt */
+ if (strcmp(notice->z_version,retnotice.z_version)) {
+ ZFreeNotice(&retnotice);
+ return(ZERR_VERS);
+ }
if (retnotice.z_kind == SERVACK &&
!strcmp(retnotice.z_opcode,notice->z_opcode)) {
ZFreeNotice(&retnotice);