From ec79b64f85d553a5cd14a3893eb2d5c382e98206 Mon Sep 17 00:00:00 2001 From: John Coyle Date: Fri, 25 Mar 2016 23:05:41 -0400 Subject: [PATCH] unittest_erasure_code_plugin: fix deadlock caused by locked mutex in cancelled thread Added unlock when thread is cancelled. Signed-off-by: John Coyle --- src/test/erasure-code/TestErasureCodePlugin.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/erasure-code/TestErasureCodePlugin.cc b/src/test/erasure-code/TestErasureCodePlugin.cc index 4691ff6e23d..5b0518e4e30 100644 --- a/src/test/erasure-code/TestErasureCodePlugin.cc +++ b/src/test/erasure-code/TestErasureCodePlugin.cc @@ -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; } }; -- 2.47.3