Commit 6ff30cef authored by Nick Connolly's avatar Nick Connolly Committed by Tomasz Zawadzki
Browse files

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: default avatarNick Connolly <nick.connolly@mayadata.io>
Change-Id: Ifd770a85627a11e2b2c6643f798f796bab10b6cb
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6153


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
Community-CI: Mellanox Build Bot
parent 48b2ac7a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
}