bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multithreading problem with NSMessagePort/NSMessagePortServer


From: Roland Schwingel
Subject: Multithreading problem with NSMessagePort/NSMessagePortServer
Date: Mon, 17 May 2004 12:06:13 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007

Hi...

A few days ago we encountered some very odd and strange crashes on linux when using gnustep heavily multithreaded. We found that there was no thread registration/unregistration for it in cleanup_names(). After adding them everything runs fine now.

The patches for the classes are attached in this email..

Hope they can be applied.

Roland

PS: On may,12 I submitted a patch for NSTimeZone to make it working on non english windows system. Haven't heard anything about it till now. Is there anything wrong with it?

--- NSMessagePort.m     2004-05-17 10:43:55.000000000 +0200
+++ NSMessagePort.m.new 2004-05-17 10:44:33.000000000 +0200
@@ -1152,10 +1152,15 @@
 
 static void clean_up_sockets(void)
 {
+  NSAutoreleasePool *arp = nil;
+  
   NSMessagePort *port;
   NSData *name;
   NSMapEnumerator mEnum;
 
+  if (GSRegisterCurrentThread())
+               CREATE_AUTORELEASE_POOL(arp);
+
   mEnum = NSEnumerateMapTable(messagePortMap);
   while (NSNextMapEnumeratorPair(&mEnum, (void *)&name, (void *)&port))
     {
@@ -1163,6 +1168,12 @@
        unlink([name bytes]);
     }
   NSEndMapTableEnumeration(&mEnum);
+
+  if (arp)
+  {
+         DESTROY(arp);
+     GSUnregisterCurrentThread();                
+  }      
 }
 
 
--- NSMessagePortNameServer.m   2004-05-17 10:44:03.000000000 +0200
+++ NSMessagePortNameServer.m.new       2004-05-17 10:44:46.000000000 +0200
@@ -9,6 +9,7 @@
 #include "Foundation/NSPort.h"
 #include "Foundation/NSFileManager.h"
 #include "Foundation/NSValue.h"
+#include "Foundation/NSThread.h"
 
 #include <sys/stat.h>
 #include <unistd.h>
@@ -54,7 +55,11 @@
 
 static void clean_up_names(void)
 {
-  CREATE_AUTORELEASE_POOL(arp);
+       NSAutoreleasePool *arp = nil;
+       
+       if (GSRegisterCurrentThread())
+               CREATE_AUTORELEASE_POOL(arp);
+               
   NSMapEnumerator mEnum;
   NSMessagePort *port;
   NSString *name;
@@ -65,7 +70,12 @@
       [defaultServer removePort: port];
     }
   NSEndMapTableEnumeration(&mEnum);
-  DESTROY(arp);
+
+  if (arp)
+  {
+         DESTROY(arp);
+     GSUnregisterCurrentThread();                
+  }      
 }
 
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]