gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1945 - bug905


From: grothoff
Subject: [GNUnet-SVN] r1945 - bug905
Date: Fri, 26 Aug 2005 21:57:48 -0700 (PDT)

Author: grothoff
Date: 2005-08-26 21:57:47 -0700 (Fri, 26 Aug 2005)
New Revision: 1945

Added:
   bug905/workaround.c
Modified:
   bug905/plug.cc
Log:
workaround

Modified: bug905/plug.cc
===================================================================
--- bug905/plug.cc      2005-08-27 04:47:27 UTC (rev 1944)
+++ bug905/plug.cc      2005-08-27 04:57:47 UTC (rev 1945)
@@ -15,7 +15,7 @@
     void f() {
       printf("In plug.\n");
       try {    
-        throw Error(); 
+       throw Error();  
       } catch (const E::Error& e) {
       }
       printf("Leaving plug.\n");

Added: bug905/workaround.c
===================================================================
--- bug905/workaround.c 2005-08-27 04:47:27 UTC (rev 1944)
+++ bug905/workaround.c 2005-08-27 04:57:47 UTC (rev 1945)
@@ -0,0 +1,59 @@
+#include <pthread.h>
+#include <dlfcn.h>
+#include <errno.h>
+
+#define WORKAROUND 1
+#if WORKAROUND
+static void * run2(void * lib) {
+  void (*cb)();
+
+  cb = dlsym(lib, "f");
+  if (cb == NULL) {
+    printf("dlsym failed: %s\n", strerror(errno));
+    return NULL;
+  }
+  cb();
+  return NULL;
+}
+#endif
+
+static void * run(void * arg) {
+  void * lib;
+  void (*cb)();
+
+  lib = dlopen("./plug.so", RTLD_NOW);
+  if (lib == NULL) {
+    printf("dlopen failed: %s\n", strerror(errno));
+    return NULL;
+  }
+#if WORKAROUND
+  { 
+    pthread_t pt2;
+    void * anull;
+
+    pthread_create(&pt2, NULL, &run2, lib);
+    pthread_join(pt2, &anull);
+  }
+#else  
+  cb = dlsym(lib, "f");
+  if (cb == NULL) {
+    printf("dlsym failed: %s\n", strerror(errno));
+    return NULL;
+  }
+  cb();
+#endif
+  dlclose(lib);
+  return NULL;
+}
+
+int main(int argc, char * argv[]) {
+  pthread_t pt;
+  void * anull;
+
+  if (0 != pthread_create(&pt, NULL, &run, NULL)) 
+    return 1;
+  if (0 != pthread_join(pt, &anull))
+    return 1;
+  printf("Ok.\n");
+  return 0;
+}





reply via email to

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