Avoid possibility of stream deallocation while sending events.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25004 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2007-04-12 19:39:23 +00:00
parent b7fe1c5ad3
commit 9036e0aae8
2 changed files with 6 additions and 0 deletions

View file

@ -564,6 +564,7 @@ static void setNonblocking(int fd)
socklen_t len = sizeof(error); socklen_t len = sizeof(error);
unsigned i = [_modes count]; unsigned i = [_modes count];
AUTORELEASE(RETAIN(self));
while (i-- > 0) while (i-- > 0)
{ {
[_runloop removeStream: self mode: [_modes objectAtIndex: i]]; [_runloop removeStream: self mode: [_modes objectAtIndex: i]];
@ -977,6 +978,7 @@ static void setNonblocking(int fd)
int result; int result;
unsigned i = [_modes count]; unsigned i = [_modes count];
AUTORELEASE(RETAIN(self));
while (i-- > 0) while (i-- > 0)
{ {
[_runloop removeStream: self mode: [_modes objectAtIndex: i]]; [_runloop removeStream: self mode: [_modes objectAtIndex: i]];

View file

@ -876,6 +876,7 @@ static void setNonblocking(SOCKET fd)
- (void) _dispatch - (void) _dispatch
{ {
AUTORELEASE(RETAIN(self));
/* /*
* Windows only permits a single event to be associated with a socket * Windows only permits a single event to be associated with a socket
* at any time, but the runloop system only allows an event handle to * at any time, but the runloop system only allows an event handle to
@ -1089,6 +1090,8 @@ static void setNonblocking(SOCKET fd)
{ {
[self _recordError]; [self _recordError];
[self _sendEvent: NSStreamEventErrorOccurred]; [self _sendEvent: NSStreamEventErrorOccurred];
CloseHandle(h);
return;
} }
} }
[self _setLoopID: (void*)h]; [self _setLoopID: (void*)h];
@ -1609,6 +1612,7 @@ static void setNonblocking(SOCKET fd)
- (void) _dispatch - (void) _dispatch
{ {
AUTORELEASE(RETAIN(self));
/* /*
* Windows only permits a single event to be associated with a socket * Windows only permits a single event to be associated with a socket
* at any time, but the runloop system only allows an event handle to * at any time, but the runloop system only allows an event handle to