mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 08:40:44 +00:00
Thread deadlock fixup
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40033 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
eb497bf67e
commit
205f26ec86
3 changed files with 44 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2016-07-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/Additions/NSObject+GNUstepbase.m: use separate lock to
|
||||||
|
protect at exit methods ... avoid conflict/deadlock with multithreaded
|
||||||
|
notification change.
|
||||||
|
|
||||||
2016-07-18 Larry Campbell <lcampbel@akamai.com>
|
2016-07-18 Larry Campbell <lcampbel@akamai.com>
|
||||||
|
|
||||||
* Source/NSThread.m: Send notification about becoming multithreaded
|
* Source/NSThread.m: Send notification about becoming multithreaded
|
||||||
|
|
|
@ -123,6 +123,7 @@ static Class documentClass = 0;
|
||||||
static Class headerClass = 0;
|
static Class headerClass = 0;
|
||||||
|
|
||||||
static BOOL oldStyleFolding = NO;
|
static BOOL oldStyleFolding = NO;
|
||||||
|
static NSString *text7bitEncoding = @"quoted-printable";
|
||||||
|
|
||||||
typedef BOOL (*boolIMP)(id, SEL, id);
|
typedef BOOL (*boolIMP)(id, SEL, id);
|
||||||
|
|
||||||
|
@ -4500,6 +4501,14 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
|
||||||
*/
|
*/
|
||||||
@implementation GSMimeDocument
|
@implementation GSMimeDocument
|
||||||
|
|
||||||
|
+ (void) setText7bitBase64: (BOOL)aFlag
|
||||||
|
{
|
||||||
|
if (YES == aFlag)
|
||||||
|
text7bitEncoding = @"base64";
|
||||||
|
else
|
||||||
|
text7bitEncoding = @"quoted-printable";
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Examine xml data to find out the characterset needed to convert from
|
* Examine xml data to find out the characterset needed to convert from
|
||||||
* binary data to an NSString object.
|
* binary data to an NSString object.
|
||||||
|
@ -5776,7 +5785,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
|
||||||
if (e != NSASCIIStringEncoding && e != NSUTF7StringEncoding)
|
if (e != NSASCIIStringEncoding && e != NSUTF7StringEncoding)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
v = @"quoted-printable";
|
v = text7bitEncoding;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -6686,7 +6695,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
|
||||||
*/
|
*/
|
||||||
if (YES == want7Bit)
|
if (YES == want7Bit)
|
||||||
{
|
{
|
||||||
encoding = @"quoted-printable";
|
encoding = text7bitEncoding;
|
||||||
}
|
}
|
||||||
enc = [self setHeader: @"Content-Transfer-Encoding"
|
enc = [self setHeader: @"Content-Transfer-Encoding"
|
||||||
value: encoding
|
value: encoding
|
||||||
|
|
|
@ -145,6 +145,20 @@ struct exitLink {
|
||||||
static struct exitLink *exited = 0;
|
static struct exitLink *exited = 0;
|
||||||
static BOOL enabled = NO;
|
static BOOL enabled = NO;
|
||||||
static BOOL shouldCleanUp = NO;
|
static BOOL shouldCleanUp = NO;
|
||||||
|
static NSLock *exitLock = nil;
|
||||||
|
|
||||||
|
static inline void setup()
|
||||||
|
{
|
||||||
|
if (nil == exitLock)
|
||||||
|
{
|
||||||
|
[gnustep_global_lock lock];
|
||||||
|
if (nil == exitLock)
|
||||||
|
{
|
||||||
|
exitLock = [NSLock new];
|
||||||
|
}
|
||||||
|
[gnustep_global_lock unlock];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handleExit()
|
handleExit()
|
||||||
|
@ -197,10 +211,11 @@ handleExit()
|
||||||
l->at = anAddress;
|
l->at = anAddress;
|
||||||
l->obj = [*anAddress retain];
|
l->obj = [*anAddress retain];
|
||||||
l->sel = 0;
|
l->sel = 0;
|
||||||
[gnustep_global_lock lock];
|
setup();
|
||||||
|
[exitLock lock];
|
||||||
l->next = exited;
|
l->next = exited;
|
||||||
exited = l;
|
exited = l;
|
||||||
[gnustep_global_lock unlock];
|
[exitLock unlock];
|
||||||
return l->obj;
|
return l->obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,10 +227,11 @@ handleExit()
|
||||||
l->at = 0;
|
l->at = 0;
|
||||||
l->obj = [anObject retain];
|
l->obj = [anObject retain];
|
||||||
l->sel = 0;
|
l->sel = 0;
|
||||||
[gnustep_global_lock lock];
|
setup();
|
||||||
|
[exitLock lock];
|
||||||
l->next = exited;
|
l->next = exited;
|
||||||
exited = l;
|
exited = l;
|
||||||
[gnustep_global_lock unlock];
|
[exitLock unlock];
|
||||||
return l->obj;
|
return l->obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,12 +263,13 @@ handleExit()
|
||||||
return NO; // method not implemented in this class
|
return NO; // method not implemented in this class
|
||||||
}
|
}
|
||||||
|
|
||||||
[gnustep_global_lock lock];
|
setup();
|
||||||
|
[exitLock lock];
|
||||||
for (l = exited; l != 0; l = l->next)
|
for (l = exited; l != 0; l = l->next)
|
||||||
{
|
{
|
||||||
if (l->obj == self && sel_isEqual(l->sel, sel))
|
if (l->obj == self && sel_isEqual(l->sel, sel))
|
||||||
{
|
{
|
||||||
[gnustep_global_lock unlock];
|
[exitLock unlock];
|
||||||
return NO; // Already registered
|
return NO; // Already registered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,7 +284,7 @@ handleExit()
|
||||||
atexit(handleExit);
|
atexit(handleExit);
|
||||||
enabled = YES;
|
enabled = YES;
|
||||||
}
|
}
|
||||||
[gnustep_global_lock unlock];
|
[exitLock unlock];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,13 +292,14 @@ handleExit()
|
||||||
{
|
{
|
||||||
if (YES == aFlag)
|
if (YES == aFlag)
|
||||||
{
|
{
|
||||||
[gnustep_global_lock lock];
|
setup();
|
||||||
|
[exitLock lock];
|
||||||
if (NO == enabled)
|
if (NO == enabled)
|
||||||
{
|
{
|
||||||
atexit(handleExit);
|
atexit(handleExit);
|
||||||
enabled = YES;
|
enabled = YES;
|
||||||
}
|
}
|
||||||
[gnustep_global_lock unlock];
|
[exitLock unlock];
|
||||||
shouldCleanUp = YES;
|
shouldCleanUp = YES;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue