test/nvme_pcie: initialize mutex for portability
For correct behaviour, pthread_mutex must be initialized before use and destroyed before the memory is zeroed. Add mutex initialization and destroy calls to test_nvme_pcie_hotplug_monitor. Tested with a pthreads library that contains debugging code to check the mutex state. Signed-off-by: Nick Connolly <nick.connolly@mayadata.io> Change-Id: Ifd770a85627a11e2b2c6643f798f796bab10b6cb Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6153 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
48b2ac7a13
commit
6ff30cefe9
@ -305,6 +305,7 @@ test_nvme_pcie_hotplug_monitor(void)
|
||||
driver.initialized = true;
|
||||
driver.hotplug_fd = 123;
|
||||
CU_ASSERT(pthread_mutexattr_init(&attr) == 0);
|
||||
CU_ASSERT(pthread_mutex_init(&pctrlr.ctrlr.ctrlr_lock, &attr) == 0);
|
||||
CU_ASSERT(pthread_mutex_init(&driver.lock, &attr) == 0);
|
||||
TAILQ_INIT(&driver.shared_attached_ctrlrs);
|
||||
g_spdk_nvme_driver = &driver;
|
||||
@ -387,6 +388,7 @@ test_nvme_pcie_hotplug_monitor(void)
|
||||
CU_ASSERT(pctrlr.ctrlr.is_failed == true);
|
||||
|
||||
pthread_mutex_destroy(&driver.lock);
|
||||
pthread_mutex_destroy(&pctrlr.ctrlr.ctrlr_lock);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
g_spdk_nvme_driver = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user