io_channel: always set dev->unregister_thread under a mutex

Fixes #278

Change-Id: I5689c3c315feea221335ae4b0218b5e64410a3aa
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/408194
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2018-04-18 14:58:53 +02:00 committed by Daniel Verkamp
parent a7aa9d5737
commit 3ed915618f

View File

@ -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 */