Author: rfm
Date: Tue Jul 26 10:20:09 2016
New Revision: 40033
URL: http://svn.gna.org/viewcvs/gnustep?rev=40033&view=rev
Log:
Thread deadlock fixup
Modified:
libs/base/trunk/ChangeLog
libs/base/trunk/Source/Additions/GSMime.m
libs/base/trunk/Source/Additions/NSObject+GNUstepBase.m
Modified: libs/base/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=40033&r1=40032&r2=40033&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog (original)
+++ libs/base/trunk/ChangeLog Tue Jul 26 10:20:09 2016
@@ -1,3 +1,9 @@
+2016-07-26 Richard Frith-Macdonald <[email protected]>
+
+ * 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 <[email protected]>
* Source/NSThread.m: Send notification about becoming multithreaded
Modified: libs/base/trunk/Source/Additions/GSMime.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/Additions/GSMime.m?rev=40033&r1=40032&r2=40033&view=diff
==============================================================================
--- libs/base/trunk/Source/Additions/GSMime.m (original)
+++ libs/base/trunk/Source/Additions/GSMime.m Tue Jul 26 10:20:09 2016
@@ -123,6 +123,7 @@
static Class headerClass = 0;
static BOOL oldStyleFolding = NO;
+static NSString *text7bitEncoding = @"quoted-printable";
typedef BOOL (*boolIMP)(id, SEL, id);
@@ -4500,6 +4501,14 @@
*/
@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
* binary data to an NSString object.
@@ -5776,7 +5785,7 @@
if (e != NSASCIIStringEncoding && e != NSUTF7StringEncoding)
#endif
{
- v = @"quoted-printable";
+ v = text7bitEncoding;
}
else
{
@@ -6686,7 +6695,7 @@
*/
if (YES == want7Bit)
{
- encoding = @"quoted-printable";
+ encoding = text7bitEncoding;
}
enc = [self setHeader: @"Content-Transfer-Encoding"
value: encoding
Modified: libs/base/trunk/Source/Additions/NSObject+GNUstepBase.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/Additions/NSObject%2BGNUstepBase.m?rev=40033&r1=40032&r2=40033&view=diff
==============================================================================
--- libs/base/trunk/Source/Additions/NSObject+GNUstepBase.m (original)
+++ libs/base/trunk/Source/Additions/NSObject+GNUstepBase.m Tue Jul 26
10:20:09 2016
@@ -145,6 +145,20 @@
static struct exitLink *exited = 0;
static BOOL enabled = 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
handleExit()
@@ -197,10 +211,11 @@
l->at = anAddress;
l->obj = [*anAddress retain];
l->sel = 0;
- [gnustep_global_lock lock];
+ setup();
+ [exitLock lock];
l->next = exited;
exited = l;
- [gnustep_global_lock unlock];
+ [exitLock unlock];
return l->obj;
}
@@ -212,10 +227,11 @@
l->at = 0;
l->obj = [anObject retain];
l->sel = 0;
- [gnustep_global_lock lock];
+ setup();
+ [exitLock lock];
l->next = exited;
exited = l;
- [gnustep_global_lock unlock];
+ [exitLock unlock];
return l->obj;
}
@@ -247,12 +263,13 @@
return NO; // method not implemented in this class
}
- [gnustep_global_lock lock];
+ setup();
+ [exitLock lock];
for (l = exited; l != 0; l = l->next)
{
if (l->obj == self && sel_isEqual(l->sel, sel))
{
- [gnustep_global_lock unlock];
+ [exitLock unlock];
return NO; // Already registered
}
}
@@ -267,7 +284,7 @@
atexit(handleExit);
enabled = YES;
}
- [gnustep_global_lock unlock];
+ [exitLock unlock];
return YES;
}
@@ -275,13 +292,14 @@
{
if (YES == aFlag)
{
- [gnustep_global_lock lock];
+ setup();
+ [exitLock lock];
if (NO == enabled)
{
atexit(handleExit);
enabled = YES;
}
- [gnustep_global_lock unlock];
+ [exitLock unlock];
shouldCleanUp = YES;
}
else
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs