mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 20:26:42 +00:00
ithreading fix
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23442 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a94904a806
commit
ff19cd1f03
2 changed files with 37 additions and 16 deletions
|
@ -203,11 +203,13 @@ static Class messagePortClass = 0;
|
|||
{
|
||||
p = [[self alloc] initWithName: name];
|
||||
}
|
||||
else
|
||||
{
|
||||
[p _setupSendPort];
|
||||
}
|
||||
M_UNLOCK(messagePortLock);
|
||||
if ([self _setupSendPort] == NO)
|
||||
{
|
||||
NSLog(@"unable to access mailslot '%@' - %s",
|
||||
p->name, GSLastErrorStr(errno));
|
||||
DESTROY(p);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -382,22 +384,12 @@ static Class messagePortClass = 0;
|
|||
this->wHandle = INVALID_HANDLE_VALUE;
|
||||
this->wEvent = INVALID_HANDLE_VALUE;
|
||||
|
||||
if ([self _setupSendPort] == NO)
|
||||
{
|
||||
NSLog(@"unable to access mailslot '%@' - %s",
|
||||
this->name, GSLastErrorStr(errno));
|
||||
DESTROY(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMapInsert(ports, (void*)this->name, (void*)self);
|
||||
NSDebugMLLog(@"NSMessagePort", @"Created speaking port: %@", self);
|
||||
}
|
||||
NSMapInsert(ports, (void*)this->name, (void*)self);
|
||||
NSDebugMLLog(@"NSMessagePort", @"Created speaking port: %@", self);
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASE(self);
|
||||
[p _setupSendPort];
|
||||
self = p;
|
||||
}
|
||||
M_UNLOCK(messagePortLock);
|
||||
|
@ -935,6 +927,28 @@ again:
|
|||
return sizeof(GSPortItemHeader) + sizeof(GSPortMsgHeader);
|
||||
}
|
||||
|
||||
- (void) release
|
||||
{
|
||||
/* We lock the port table while checking, to prevent
|
||||
* another thread from grabbing this port while we are
|
||||
* checking it.
|
||||
* If we are going to deallocate the object, we first remove
|
||||
* it from the table so that no other thread will find it
|
||||
* and try to use it while it is being deallocated.
|
||||
*/
|
||||
M_LOCK(messagePortLock);
|
||||
if (NSDecrementExtraRefCountWasZero(self))
|
||||
{
|
||||
NSMapRemove(ports, (void*)this->name);
|
||||
M_UNLOCK(messagePortLock);
|
||||
[self dealloc];
|
||||
}
|
||||
else
|
||||
{
|
||||
M_UNLOCK(messagePortLock);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) sendBeforeDate: (NSDate*)when
|
||||
msgid: (int)msgId
|
||||
components: (NSMutableArray*)components
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue