]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
unittest_erasure_code_plugin: fix deadlock caused by locked mutex in cancelled thread 8314/head
authorJohn Coyle <dx9err@gmail.com>
Sat, 26 Mar 2016 03:05:41 +0000 (23:05 -0400)
committerJohn Coyle <dx9err@gmail.com>
Sat, 2 Apr 2016 04:10:12 +0000 (00:10 -0400)
Added unlock when thread is cancelled.

Signed-off-by: John Coyle <dx9err@gmail.com>
src/test/erasure-code/TestErasureCodePlugin.cc

index 4691ff6e23dc7cb822186b70c17918c966abc246..5b0518e4e3096b221e3b0f391ee40d7fc876f141 100644 (file)
@@ -30,13 +30,21 @@ protected:
 
   class Thread_factory : public Thread {
   public:
+    static void cleanup(void *arg) {
+      ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
+      if (instance.lock.is_locked())
+        instance.lock.Unlock();
+    }
+
     virtual void *entry() {
       ErasureCodeProfile profile;
       ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
       ErasureCodeInterfaceRef erasure_code;
+      pthread_cleanup_push(cleanup, NULL);
       instance.factory("hangs",
                       g_conf->erasure_code_dir,
                       profile, &erasure_code, &cerr);
+      pthread_cleanup_pop(0);
       return NULL;
     }
   };