diff --git a/Source/GSStream.h b/Source/GSStream.h index d87c4fe51..4f270dd22 100644 --- a/Source/GSStream.h +++ b/Source/GSStream.h @@ -75,7 +75,7 @@ { \ id _delegate; /* Delegate controls operation. */\ NSMutableDictionary *_properties; /* storage for properties */\ - BOOL _delegateValid;/* whether the delegate responds*/\ + BOOL _delegateValid; /* whether the delegate responds*/\ NSError *_lastError; /* last error occured */\ NSStreamStatus _currentStatus;/* current status */\ NSMapTable *_loops; /* Run loops and their modes. */\ diff --git a/Source/GSStream.m b/Source/GSStream.m index 5e2f5b394..bce1954ca 100644 --- a/Source/GSStream.m +++ b/Source/GSStream.m @@ -407,7 +407,7 @@ static RunLoopEventType typeForStream(NSStream *aStream) { NSDebugMLLog(@"NSStream", @"record error: %@ - %@", self, anError); ASSIGN(_lastError, anError); - _currentStatus = NSStreamStatusError; + [self _setStatus: NSStreamStatusError]; } - (void) _resetEvents: (NSUInteger)mask @@ -533,7 +533,22 @@ static RunLoopEventType typeForStream(NSStream *aStream) - (void) _setStatus: (NSStreamStatus)newStatus { - _currentStatus = newStatus; + if (_currentStatus != newStatus) + { + if (NSStreamStatusError == newStatus && NSCountMapTable(_loops) > 0) + { + /* After an error, we are in the run loops only to trigger + * errors, not for I/O, sop we must re-schedule in the right mode. + */ + [self _unschedule]; + _currentStatus = newStatus; + [self _schedule]; + } + else + { + _currentStatus = newStatus; + } + } } - (BOOL) _unhandledData