bug-gnustep
[Top][All Lists]
Advanced

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

Threading problem in NSNetServices


From: Chris Vetter
Subject: Threading problem in NSNetServices
Date: Sun, 07 Jan 2007 12:19:28 +0100
User-agent: GNUMail (Version 1.2.0)

Hullo,

NSNetServices in SVN's -base have a bug with respect to threading, that is, it tries to lock the same lock several times. I originally avoided that problem by using pthread's spin-locks.

For a more portable implementation (I guess), the current version in -base uses GSLazyLocks, which cannot acquire a lock recursively -- as its name implies, NSRecursiveLock can.

The following patch is tested and proven to work.

--- NSNetServices.m.ORG Sun Jan  7 12:06:44 2007
+++ NSNetServices.m     Sun Jan  7 12:15:55 2007
@@ -30,7 +30,9 @@
 #import "Foundation/NSStream.h"
 #import "Foundation/NSTimer.h"
 #import "Foundation/NSValue.h"
-#import "GNUstepBase/GSLock.h"
+#if defined(_REENTRANT)
+#  import "Foundation/NSLock.h"
+#endif

 #import <dns_sd.h>             // Apple's DNS Service Discovery

@@ -78,8 +80,8 @@
         } while(0);

 #if defined(_REENTRANT)
-#  define THE_LOCK             GSLazyLock      *lock
-#  define CREATELOCK(x)                x->lock = [GSLazyLock new]
+#  define THE_LOCK             NSRecursiveLock *lock
+#  define CREATELOCK(x)                x->lock = [NSRecursiveLock new]
 #  define LOCK(x)              [x->lock lock]
 #  define UNLOCK(x)            [x->lock unlock]
 #  define DESTROYLOCK(x)       DESTROY(x->lock)

BTW, NSNetServices are missing in Source/DocMakefile.

--
Chris






reply via email to

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