[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7306 - Extractor/src/main
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7306 - Extractor/src/main |
Date: |
Sun, 22 Jun 2008 12:28:19 -0600 (MDT) |
Author: holindho
Date: 2008-06-22 12:28:19 -0600 (Sun, 22 Jun 2008)
New Revision: 7306
Modified:
Extractor/src/main/Makefile.am
Extractor/src/main/extractor.c
Log:
libltdl functions are not thread-safe: add locking
Modified: Extractor/src/main/Makefile.am
===================================================================
--- Extractor/src/main/Makefile.am 2008-06-22 18:20:35 UTC (rev 7305)
+++ Extractor/src/main/Makefile.am 2008-06-22 18:28:19 UTC (rev 7306)
@@ -38,7 +38,7 @@
libextractor_la_LDFLAGS = \
-export-dynamic -export-symbols-regex "EXTRACTOR_[a-zA-Z0-9_]*"
-version-info @LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@
$(LIBICONV)
libextractor_la_LIBADD = \
- $(LIBLTDL) $(dlflag) $(zlib) $(bz2lib) $(GSF_LIBS_X)
+ $(LIBLTDL) $(dlflag) $(zlib) $(bz2lib) $(GSF_LIBS_X) -lpthread
libextractor_la_DEPENDENCIES = \
$(LIBLTDL)
Modified: Extractor/src/main/extractor.c
===================================================================
--- Extractor/src/main/extractor.c 2008-06-22 18:20:35 UTC (rev 7305)
+++ Extractor/src/main/extractor.c 2008-06-22 18:28:19 UTC (rev 7306)
@@ -20,6 +20,7 @@
#include "platform.h"
#include "extractor.h"
+#include <pthread.h>
#if HAVE_LTDL_H
#include <ltdl.h>
@@ -725,6 +726,15 @@
return NULL;
}
+static pthread_mutex_t ltdl_lock = PTHREAD_MUTEX_INITIALIZER;
+
+#define LTDL_MUTEX_LOCK \
+ if (pthread_mutex_lock (<dl_lock) != 0) \
+ abort();
+#define LTDL_MUTEX_UNLOCK \
+ if (pthread_mutex_unlock (<dl_lock) != 0) \
+ abort();
+
static void *getSymbolWithPrefix(void *lib_handle,
const char *lib_name,
const char *sym_name)
@@ -743,6 +753,7 @@
lib_name,
sym_name);
+ LTDL_MUTEX_LOCK
symbol=lt_dlsym(lib_handle,name+1 /* skip the '_' */);
if (symbol==NULL) {
first_error=strdup(lt_dlerror());
@@ -760,6 +771,7 @@
#endif
free(first_error);
}
+ LTDL_MUTEX_UNLOCK
free(name);
return symbol;
}
@@ -773,6 +785,7 @@
void **libHandle,
ExtractMethod * method)
{
+ LTDL_MUTEX_LOCK
*libHandle = lt_dlopenext (name);
if (*libHandle == NULL)
{
@@ -782,12 +795,16 @@
name,
lt_dlerror ());
#endif
+ LTDL_MUTEX_UNLOCK
return -1;
}
+ LTDL_MUTEX_UNLOCK
*method = (ExtractMethod) getSymbolWithPrefix (*libHandle, name, "_extract");
if (*method == NULL) {
+ LTDL_MUTEX_LOCK
lt_dlclose (*libHandle);
+ LTDL_MUTEX_UNLOCK
return -1;
}
return 1;
@@ -976,8 +993,11 @@
free (pos->libname);
if( pos->options )
free (pos->options);
- if( pos->libraryHandle )
+ if( pos->libraryHandle ) {
+ LTDL_MUTEX_LOCK
lt_dlclose (pos->libraryHandle);
+ LTDL_MUTEX_UNLOCK
+ }
free (pos);
}
#if DEBUG
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7306 - Extractor/src/main,
gnunet <=