Changes to avoid possible hang in connection reply mode due to race condition.

This commit is contained in:
Richard Frith-Macdonald 2017-12-21 13:51:01 +00:00
parent 38fc2bde82
commit 4ce7a25541
5 changed files with 209 additions and 224 deletions

View file

@ -909,10 +909,6 @@ again:
{
NSDebugMLLog(@"NSMessagePort",
@"got event on invalidated port 0x%x in mode %@", self, mode);
[[NSRunLoop currentRunLoop] removeEvent: data
type: type
forMode: mode
all: YES];
}
RELEASE(self);
}
@ -1109,7 +1105,21 @@ again:
&& [when timeIntervalSinceNow] > 0)
{
M_UNLOCK(this->lock);
[loop runMode: NSConnectionReplyMode beforeDate: when];
NS_DURING
[loop runMode: NSConnectionReplyMode beforeDate: when];
NS_HANDLER
M_LOCK(this->lock);
[loop removeEvent: (void*)(uintptr_t)this->wEvent
type: ET_HANDLE
forMode: NSConnectionReplyMode
all: NO];
[loop removeEvent: (void*)(uintptr_t)this->wEvent
type: ET_HANDLE
forMode: NSDefaultRunLoopMode
all: NO];
M_UNLOCK(this->lock);
[localException raise];
NS_ENDHANDLER
M_LOCK(this->lock);
}