diff --git a/ChangeLog b/ChangeLog index dbe1a2414..cd561e040 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2002-09-19 Richard Frith-Macdonald + * Source/GSTcpHandle.m: Check port for invalidation while looping + on write events, so we can fail if we become invalid while sending + or connecting, before the port timeout expires. + * Source/NSConnection.m: Check connection for invalidation while + looping waiting for a reply, so we can fail if we become invalid + before the timeout expires. * Source/DocMakefile: Specify template options * Tools/autogsdoc.m: Remove hack to turn templates on by default. Document the use of templates. diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m index b49c31621..0ab62fab8 100644 --- a/Source/GSTcpPort.m +++ b/Source/GSTcpPort.m @@ -556,7 +556,8 @@ static Class runLoopClass; type: ET_EDESC watcher: self forMode: NSConnectionReplyMode]; - while (state == GS_H_TRYCON && [when timeIntervalSinceNow] > 0) + while (valid == YES && state == GS_H_TRYCON + && [when timeIntervalSinceNow] > 0) { [l runMode: NSConnectionReplyMode beforeDate: when]; } @@ -1154,6 +1155,10 @@ static Class runLoopClass; type: ET_WDESC forMode: mode all: NO]; + [l removeEvent: data + type: ET_EDESC + forMode: mode + all: NO]; } } } @@ -1183,7 +1188,8 @@ static Class runLoopClass; type: ET_WDESC watcher: self forMode: NSConnectionReplyMode]; - while ([wMsgs indexOfObjectIdenticalTo: components] != NSNotFound + while (valid == YES + && [wMsgs indexOfObjectIdenticalTo: components] != NSNotFound && [when timeIntervalSinceNow] > 0) { DO_UNLOCK(myLock); diff --git a/Source/NSConnection.m b/Source/NSConnection.m index cfea0cdcb..14d883a08 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -2655,7 +2655,7 @@ static void callEncoder (DOContext *ctxt) - _getReplyRmc: (int)sn { NSPortCoder *rmc; - GSIMapNode node; + GSIMapNode node = 0; NSDate *timeout_date = nil; NSTimeInterval last_interval = 0.0001; NSTimeInterval delay_interval = last_interval; @@ -2666,7 +2666,8 @@ static void callEncoder (DOContext *ctxt) NSLog(@"Waiting for reply sequence %d on %x:%x", sn, self, [NSThread currentThread]); M_LOCK(_queueGate); - while ((node = GSIMapNodeForKey(_replyMap, (GSIMapKey)sn)) != 0 + while (_isValid == YES + && (node = GSIMapNodeForKey(_replyMap, (GSIMapKey)sn)) != 0 && node->value.obj == dummyObject) { M_UNLOCK(_queueGate); @@ -2765,8 +2766,16 @@ static void callEncoder (DOContext *ctxt) } if (rmc == dummyObject) { - [NSException raise: NSPortTimeoutException - format: @"timed out waiting for reply"]; + if (_isValid == YES) + { + [NSException raise: NSPortTimeoutException + format: @"timed out waiting for reply"]; + } + else + { + [NSException raise: NSPortTimeoutException + format: @"invalidated while awaiting reply"]; + } } NSDebugMLLog(@"NSConnection", @"Consuming reply RMC %d on %x", sn, self); return rmc;