From 3ed915618fc5683889be8387aa6f4d2eb6d6b695 Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Wed, 18 Apr 2018 14:58:53 +0200 Subject: [PATCH] io_channel: always set dev->unregister_thread under a mutex Fixes #278 Change-Id: I5689c3c315feea221335ae4b0218b5e64410a3aa Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/408194 Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Daniel Verkamp Tested-by: SPDK Automated Test System --- lib/util/io_channel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/util/io_channel.c b/lib/util/io_channel.c index b1d4e1597..6898d67e3 100644 --- a/lib/util/io_channel.c +++ b/lib/util/io_channel.c @@ -356,6 +356,9 @@ spdk_io_device_unregister(void *io_device, spdk_io_device_unregister_cb unregist { struct io_device *dev; uint32_t refcnt; + struct spdk_thread *thread; + + thread = spdk_get_thread(); pthread_mutex_lock(&g_devlist_mutex); TAILQ_FOREACH(dev, &g_io_devices, tailq) { @@ -380,8 +383,8 @@ spdk_io_device_unregister(void *io_device, spdk_io_device_unregister_cb unregist dev->unregistered = true; TAILQ_REMOVE(&g_io_devices, dev, tailq); refcnt = dev->refcnt; + dev->unregister_thread = thread; pthread_mutex_unlock(&g_devlist_mutex); - dev->unregister_thread = spdk_get_thread(); if (refcnt > 0) { /* defer deletion */