mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Multithreaded operation fixes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18462 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3580989e20
commit
a7e07d9a65
3 changed files with 48 additions and 33 deletions
|
@ -1,3 +1,10 @@
|
|||
2004-01-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSSocketPort.m:
|
||||
* Source/NSMessagePort.m: Fixed return form method without unlocking
|
||||
a lock ... could cause a hang. Also, tidied up add/romve watchers
|
||||
in runloops.
|
||||
|
||||
2004-01-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSKeyedArchiver.h: Update ivars for unarchiver.
|
||||
|
|
|
@ -439,11 +439,13 @@ static Class runLoopClass;
|
|||
type: ET_EDESC
|
||||
watcher: self
|
||||
forMode: NSConnectionReplyMode];
|
||||
|
||||
while (valid == YES && state == GS_H_TRYCON
|
||||
&& [when timeIntervalSinceNow] > 0)
|
||||
{
|
||||
[l runMode: NSConnectionReplyMode beforeDate: when];
|
||||
}
|
||||
|
||||
[l removeEvent: (void*)(gsaddr)desc
|
||||
type: ET_WDESC
|
||||
forMode: NSConnectionReplyMode
|
||||
|
@ -977,6 +979,7 @@ static Class runLoopClass;
|
|||
else
|
||||
{
|
||||
// NSLog(@"No messages to write on 0x%x.", self);
|
||||
M_UNLOCK(myLock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1022,8 +1025,6 @@ static Class runLoopClass;
|
|||
}
|
||||
else
|
||||
{
|
||||
NSRunLoop *l = [runLoopClass currentRunLoop];
|
||||
|
||||
/*
|
||||
* message completed - remove from list.
|
||||
*/
|
||||
|
@ -1033,15 +1034,6 @@ static Class runLoopClass;
|
|||
wData = nil;
|
||||
wItem = 0;
|
||||
[wMsgs removeObjectAtIndex: 0];
|
||||
|
||||
[l removeEvent: data
|
||||
type: ET_WDESC
|
||||
forMode: mode
|
||||
all: NO];
|
||||
[l removeEvent: data
|
||||
type: ET_EDESC
|
||||
forMode: mode
|
||||
all: NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1071,6 +1063,11 @@ static Class runLoopClass;
|
|||
type: ET_WDESC
|
||||
watcher: self
|
||||
forMode: NSConnectionReplyMode];
|
||||
[l addEvent: (void*)(gsaddr)desc
|
||||
type: ET_EDESC
|
||||
watcher: self
|
||||
forMode: NSConnectionReplyMode];
|
||||
|
||||
while (valid == YES
|
||||
&& [wMsgs indexOfObjectIdenticalTo: components] != NSNotFound
|
||||
&& [when timeIntervalSinceNow] > 0)
|
||||
|
@ -1079,10 +1076,16 @@ static Class runLoopClass;
|
|||
[l runMode: NSConnectionReplyMode beforeDate: when];
|
||||
M_LOCK(myLock);
|
||||
}
|
||||
/*
|
||||
* NB. We will remove ourself from the run loop when the message send
|
||||
* is completed, so we don't need to do it here.
|
||||
*/
|
||||
|
||||
[l removeEvent: (void*)(gsaddr)desc
|
||||
type: ET_WDESC
|
||||
forMode: NSConnectionReplyMode
|
||||
all: NO];
|
||||
[l removeEvent: (void*)(gsaddr)desc
|
||||
type: ET_EDESC
|
||||
forMode: NSConnectionReplyMode
|
||||
all: NO];
|
||||
|
||||
if ([wMsgs indexOfObjectIdenticalTo: components] == NSNotFound)
|
||||
{
|
||||
sent = YES;
|
||||
|
|
|
@ -104,9 +104,9 @@ static BOOL multi_threaded = NO;
|
|||
*/
|
||||
static gsu32 maxDataLength = 10 * 1024 * 1024;
|
||||
|
||||
#if 0
|
||||
#define M_LOCK(X) {NSDebugMLLog(@"GSTcpHandle",@"lock %@",X); [X lock];}
|
||||
#define M_UNLOCK(X) {NSDebugMLLog(@"GSTcpHandle",@"unlock %@",X); [X unlock];}
|
||||
#if 1
|
||||
#define M_LOCK(X) {NSDebugMLLog(@"GSTcpHandleLock",@"lock %@ in %@",X,[NSThread currentThread]); [X lock];}
|
||||
#define M_UNLOCK(X) {NSDebugMLLog(@"GSTcpHandleLock",@"unlock %@ in %@",X,[NSThread currentThread]); [X unlock];}
|
||||
#else
|
||||
#define M_LOCK(X) {[X lock];}
|
||||
#define M_UNLOCK(X) {[X unlock];}
|
||||
|
@ -544,11 +544,15 @@ static Class runLoopClass;
|
|||
type: ET_EDESC
|
||||
watcher: self
|
||||
forMode: NSConnectionReplyMode];
|
||||
|
||||
while (valid == YES && state == GS_H_TRYCON
|
||||
&& [when timeIntervalSinceNow] > 0)
|
||||
{
|
||||
M_UNLOCK(myLock);
|
||||
[l runMode: NSConnectionReplyMode beforeDate: when];
|
||||
M_LOCK(myLock);
|
||||
}
|
||||
|
||||
[l removeEvent: (void*)(gsaddr)desc
|
||||
type: ET_WDESC
|
||||
forMode: NSConnectionReplyMode
|
||||
|
@ -1090,6 +1094,7 @@ static Class runLoopClass;
|
|||
else
|
||||
{
|
||||
// NSLog(@"No messages to write on 0x%x.", self);
|
||||
M_UNLOCK(myLock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1131,8 +1136,6 @@ static Class runLoopClass;
|
|||
}
|
||||
else
|
||||
{
|
||||
NSRunLoop *l = [runLoopClass currentRunLoop];
|
||||
|
||||
/*
|
||||
* message completed - remove from list.
|
||||
*/
|
||||
|
@ -1142,15 +1145,6 @@ static Class runLoopClass;
|
|||
wData = nil;
|
||||
wItem = 0;
|
||||
[wMsgs removeObjectAtIndex: 0];
|
||||
|
||||
[l removeEvent: data
|
||||
type: ET_WDESC
|
||||
forMode: mode
|
||||
all: NO];
|
||||
[l removeEvent: data
|
||||
type: ET_EDESC
|
||||
forMode: mode
|
||||
all: NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1180,6 +1174,11 @@ static Class runLoopClass;
|
|||
type: ET_WDESC
|
||||
watcher: self
|
||||
forMode: NSConnectionReplyMode];
|
||||
[l addEvent: (void*)(gsaddr)desc
|
||||
type: ET_EDESC
|
||||
watcher: self
|
||||
forMode: NSConnectionReplyMode];
|
||||
|
||||
while (valid == YES
|
||||
&& [wMsgs indexOfObjectIdenticalTo: components] != NSNotFound
|
||||
&& [when timeIntervalSinceNow] > 0)
|
||||
|
@ -1188,10 +1187,16 @@ static Class runLoopClass;
|
|||
[l runMode: NSConnectionReplyMode beforeDate: when];
|
||||
M_LOCK(myLock);
|
||||
}
|
||||
/*
|
||||
* NB. We will remove ourself from the run loop when the message send
|
||||
* is completed, so we don't need to do it here.
|
||||
*/
|
||||
|
||||
[l removeEvent: (void*)(gsaddr)desc
|
||||
type: ET_WDESC
|
||||
forMode: NSConnectionReplyMode
|
||||
all: NO];
|
||||
[l removeEvent: (void*)(gsaddr)desc
|
||||
type: ET_EDESC
|
||||
forMode: NSConnectionReplyMode
|
||||
all: NO];
|
||||
|
||||
if ([wMsgs indexOfObjectIdenticalTo: components] == NSNotFound)
|
||||
{
|
||||
sent = YES;
|
||||
|
|
Loading…
Reference in a new issue