mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 01:01:03 +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
9268343c0e
commit
2347f04f15
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>
|
2004-01-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/Foundation/NSKeyedArchiver.h: Update ivars for unarchiver.
|
* Headers/Foundation/NSKeyedArchiver.h: Update ivars for unarchiver.
|
||||||
|
|
|
@ -439,11 +439,13 @@ static Class runLoopClass;
|
||||||
type: ET_EDESC
|
type: ET_EDESC
|
||||||
watcher: self
|
watcher: self
|
||||||
forMode: NSConnectionReplyMode];
|
forMode: NSConnectionReplyMode];
|
||||||
|
|
||||||
while (valid == YES && state == GS_H_TRYCON
|
while (valid == YES && state == GS_H_TRYCON
|
||||||
&& [when timeIntervalSinceNow] > 0)
|
&& [when timeIntervalSinceNow] > 0)
|
||||||
{
|
{
|
||||||
[l runMode: NSConnectionReplyMode beforeDate: when];
|
[l runMode: NSConnectionReplyMode beforeDate: when];
|
||||||
}
|
}
|
||||||
|
|
||||||
[l removeEvent: (void*)(gsaddr)desc
|
[l removeEvent: (void*)(gsaddr)desc
|
||||||
type: ET_WDESC
|
type: ET_WDESC
|
||||||
forMode: NSConnectionReplyMode
|
forMode: NSConnectionReplyMode
|
||||||
|
@ -977,6 +979,7 @@ static Class runLoopClass;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// NSLog(@"No messages to write on 0x%x.", self);
|
// NSLog(@"No messages to write on 0x%x.", self);
|
||||||
|
M_UNLOCK(myLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1022,8 +1025,6 @@ static Class runLoopClass;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRunLoop *l = [runLoopClass currentRunLoop];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* message completed - remove from list.
|
* message completed - remove from list.
|
||||||
*/
|
*/
|
||||||
|
@ -1033,15 +1034,6 @@ static Class runLoopClass;
|
||||||
wData = nil;
|
wData = nil;
|
||||||
wItem = 0;
|
wItem = 0;
|
||||||
[wMsgs removeObjectAtIndex: 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
|
type: ET_WDESC
|
||||||
watcher: self
|
watcher: self
|
||||||
forMode: NSConnectionReplyMode];
|
forMode: NSConnectionReplyMode];
|
||||||
|
[l addEvent: (void*)(gsaddr)desc
|
||||||
|
type: ET_EDESC
|
||||||
|
watcher: self
|
||||||
|
forMode: NSConnectionReplyMode];
|
||||||
|
|
||||||
while (valid == YES
|
while (valid == YES
|
||||||
&& [wMsgs indexOfObjectIdenticalTo: components] != NSNotFound
|
&& [wMsgs indexOfObjectIdenticalTo: components] != NSNotFound
|
||||||
&& [when timeIntervalSinceNow] > 0)
|
&& [when timeIntervalSinceNow] > 0)
|
||||||
|
@ -1079,10 +1076,16 @@ static Class runLoopClass;
|
||||||
[l runMode: NSConnectionReplyMode beforeDate: when];
|
[l runMode: NSConnectionReplyMode beforeDate: when];
|
||||||
M_LOCK(myLock);
|
M_LOCK(myLock);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* NB. We will remove ourself from the run loop when the message send
|
[l removeEvent: (void*)(gsaddr)desc
|
||||||
* is completed, so we don't need to do it here.
|
type: ET_WDESC
|
||||||
*/
|
forMode: NSConnectionReplyMode
|
||||||
|
all: NO];
|
||||||
|
[l removeEvent: (void*)(gsaddr)desc
|
||||||
|
type: ET_EDESC
|
||||||
|
forMode: NSConnectionReplyMode
|
||||||
|
all: NO];
|
||||||
|
|
||||||
if ([wMsgs indexOfObjectIdenticalTo: components] == NSNotFound)
|
if ([wMsgs indexOfObjectIdenticalTo: components] == NSNotFound)
|
||||||
{
|
{
|
||||||
sent = YES;
|
sent = YES;
|
||||||
|
|
|
@ -104,9 +104,9 @@ static BOOL multi_threaded = NO;
|
||||||
*/
|
*/
|
||||||
static gsu32 maxDataLength = 10 * 1024 * 1024;
|
static gsu32 maxDataLength = 10 * 1024 * 1024;
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
#define M_LOCK(X) {NSDebugMLLog(@"GSTcpHandle",@"lock %@",X); [X lock];}
|
#define M_LOCK(X) {NSDebugMLLog(@"GSTcpHandleLock",@"lock %@ in %@",X,[NSThread currentThread]); [X lock];}
|
||||||
#define M_UNLOCK(X) {NSDebugMLLog(@"GSTcpHandle",@"unlock %@",X); [X unlock];}
|
#define M_UNLOCK(X) {NSDebugMLLog(@"GSTcpHandleLock",@"unlock %@ in %@",X,[NSThread currentThread]); [X unlock];}
|
||||||
#else
|
#else
|
||||||
#define M_LOCK(X) {[X lock];}
|
#define M_LOCK(X) {[X lock];}
|
||||||
#define M_UNLOCK(X) {[X unlock];}
|
#define M_UNLOCK(X) {[X unlock];}
|
||||||
|
@ -544,11 +544,15 @@ static Class runLoopClass;
|
||||||
type: ET_EDESC
|
type: ET_EDESC
|
||||||
watcher: self
|
watcher: self
|
||||||
forMode: NSConnectionReplyMode];
|
forMode: NSConnectionReplyMode];
|
||||||
|
|
||||||
while (valid == YES && state == GS_H_TRYCON
|
while (valid == YES && state == GS_H_TRYCON
|
||||||
&& [when timeIntervalSinceNow] > 0)
|
&& [when timeIntervalSinceNow] > 0)
|
||||||
{
|
{
|
||||||
|
M_UNLOCK(myLock);
|
||||||
[l runMode: NSConnectionReplyMode beforeDate: when];
|
[l runMode: NSConnectionReplyMode beforeDate: when];
|
||||||
|
M_LOCK(myLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
[l removeEvent: (void*)(gsaddr)desc
|
[l removeEvent: (void*)(gsaddr)desc
|
||||||
type: ET_WDESC
|
type: ET_WDESC
|
||||||
forMode: NSConnectionReplyMode
|
forMode: NSConnectionReplyMode
|
||||||
|
@ -1090,6 +1094,7 @@ static Class runLoopClass;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// NSLog(@"No messages to write on 0x%x.", self);
|
// NSLog(@"No messages to write on 0x%x.", self);
|
||||||
|
M_UNLOCK(myLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1131,8 +1136,6 @@ static Class runLoopClass;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRunLoop *l = [runLoopClass currentRunLoop];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* message completed - remove from list.
|
* message completed - remove from list.
|
||||||
*/
|
*/
|
||||||
|
@ -1142,15 +1145,6 @@ static Class runLoopClass;
|
||||||
wData = nil;
|
wData = nil;
|
||||||
wItem = 0;
|
wItem = 0;
|
||||||
[wMsgs removeObjectAtIndex: 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
|
type: ET_WDESC
|
||||||
watcher: self
|
watcher: self
|
||||||
forMode: NSConnectionReplyMode];
|
forMode: NSConnectionReplyMode];
|
||||||
|
[l addEvent: (void*)(gsaddr)desc
|
||||||
|
type: ET_EDESC
|
||||||
|
watcher: self
|
||||||
|
forMode: NSConnectionReplyMode];
|
||||||
|
|
||||||
while (valid == YES
|
while (valid == YES
|
||||||
&& [wMsgs indexOfObjectIdenticalTo: components] != NSNotFound
|
&& [wMsgs indexOfObjectIdenticalTo: components] != NSNotFound
|
||||||
&& [when timeIntervalSinceNow] > 0)
|
&& [when timeIntervalSinceNow] > 0)
|
||||||
|
@ -1188,10 +1187,16 @@ static Class runLoopClass;
|
||||||
[l runMode: NSConnectionReplyMode beforeDate: when];
|
[l runMode: NSConnectionReplyMode beforeDate: when];
|
||||||
M_LOCK(myLock);
|
M_LOCK(myLock);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* NB. We will remove ourself from the run loop when the message send
|
[l removeEvent: (void*)(gsaddr)desc
|
||||||
* is completed, so we don't need to do it here.
|
type: ET_WDESC
|
||||||
*/
|
forMode: NSConnectionReplyMode
|
||||||
|
all: NO];
|
||||||
|
[l removeEvent: (void*)(gsaddr)desc
|
||||||
|
type: ET_EDESC
|
||||||
|
forMode: NSConnectionReplyMode
|
||||||
|
all: NO];
|
||||||
|
|
||||||
if ([wMsgs indexOfObjectIdenticalTo: components] == NSNotFound)
|
if ([wMsgs indexOfObjectIdenticalTo: components] == NSNotFound)
|
||||||
{
|
{
|
||||||
sent = YES;
|
sent = YES;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue