[Libreoffice-commits] .: sal/osl

Michael Meeks michael at kemper.freedesktop.org
Mon Jul 23 07:38:57 PDT 2012


 sal/osl/unx/system.c |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

New commits:
commit ba47dd6f03cfea17ae1117598bed8fe4e7d18a51
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Sun Jul 22 16:04:06 2012 +0200

    Don't use a mutex for gethostbyname_r on Mac OS X
    
    Change-Id: I5b8c7901266ae73d95626e98116b9a3b43710642

diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c
index 720d1cd..1eaeb18 100644
--- a/sal/osl/unx/system.c
+++ b/sal/osl/unx/system.c
@@ -30,11 +30,26 @@
 
 #ifdef NO_PTHREAD_RTL
 
-static pthread_mutex_t getrtl_mutex = PTHREAD_MUTEX_INITIALIZER;
-
 /* struct passwd differs on some platforms */
+
 #if defined(MACOSX) || defined(IOS) || defined(OPENBSD) || defined(NETBSD)
 
+//No mutex needed on Mac OS X, gethostbyname is thread safe
+
+#if defined(MACOSX)
+
+#define RTL_MUTEX_LOCK
+#define RTL_MUTEX_UNLOCK
+
+#else //defined(MACOSX)
+
+static pthread_mutex_t getrtl_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+#define RTL_MUTEX_LOCK pthread_mutex_lock(&getrtl_mutex);
+#define RTL_MUTEX_UNLOCK pthread_mutex_unlock(&getrtl_mutex);
+
+#endif //defined(MACOSX)
+
 extern int h_errno;
 
 struct hostent *gethostbyname_r(const char *name, struct hostent *result,
@@ -50,7 +65,7 @@ struct hostent *gethostbyname_r(const char *name, struct hostent *result,
      */
       struct hostent* res;
 
-      pthread_mutex_lock(&getrtl_mutex);
+      RTL_MUTEX_LOCK
 
       if ( (res = gethostbyname(name)) )
       {
@@ -120,9 +135,9 @@ struct hostent *gethostbyname_r(const char *name, struct hostent *result,
         *h_errnop = h_errno;
     }
 
-    pthread_mutex_unlock(&getrtl_mutex);
+    RTL_MUTEX_UNLOCK
 
-      return res;
+    return res;
 }
 #endif // OSX || IOS || OPENBSD || NETBSD
 


More information about the Libreoffice-commits mailing list