thread: fix deadlock in spdk_for_each_thread error handling
We could return from spdk_for_each_thread() without
unlocking the global threading mutex, rendering the
entire SPDK application useless.
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452087 (master)
(cherry picked from commit 7b3f411063
)
Change-Id: I641c7b36db996f9a36310332279648014579de83
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457188
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
cf0daf7f3b
commit
a9085b08c3
@ -780,7 +780,6 @@ spdk_for_each_thread(spdk_msg_fn fn, void *ctx, spdk_msg_fn cpl)
|
||||
ct->ctx = ctx;
|
||||
ct->cpl = cpl;
|
||||
|
||||
pthread_mutex_lock(&g_devlist_mutex);
|
||||
thread = _get_thread();
|
||||
if (!thread) {
|
||||
SPDK_ERRLOG("No thread allocated\n");
|
||||
@ -789,6 +788,8 @@ spdk_for_each_thread(spdk_msg_fn fn, void *ctx, spdk_msg_fn cpl)
|
||||
return;
|
||||
}
|
||||
ct->orig_thread = thread;
|
||||
|
||||
pthread_mutex_lock(&g_devlist_mutex);
|
||||
ct->cur_thread = TAILQ_FIRST(&g_threads);
|
||||
pthread_mutex_unlock(&g_devlist_mutex);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user