example/nvmf: Fix the case when thread is terminated by communicating with other threads
As we have done for SPDK reactor, SPDK thread termination needs communication among SPDK threads. So At application shutdown, create the while loop until all threads are destroyed and in the loop, check each thread is exited, and destroy the thread if exited or mark it as exiting and retry checking after traversing other threads. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I7a1008b95f3303de17449d574e917eb47cbe54b5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2660 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
90be351f87
commit
44ab133f70
@ -224,11 +224,17 @@ nvmf_reactor_run(void *arg)
|
||||
while (spdk_ring_dequeue(nvmf_reactor->threads, (void **)&lw_thread, 1)) {
|
||||
thread = spdk_thread_get_from_ctx(lw_thread);
|
||||
spdk_set_thread(thread);
|
||||
spdk_thread_exit(thread);
|
||||
while (!spdk_thread_is_exited(thread)) {
|
||||
|
||||
if (spdk_thread_is_exited(thread)) {
|
||||
spdk_thread_destroy(thread);
|
||||
} else {
|
||||
/* This thread is not exited yet, and may need to communicate with other threads
|
||||
* to be exited. So mark it as exiting, and check again after traversing other threads.
|
||||
*/
|
||||
spdk_thread_exit(thread);
|
||||
spdk_thread_poll(thread, 0, 0);
|
||||
spdk_ring_enqueue(nvmf_reactor->threads, (void **)&lw_thread, 1, NULL);
|
||||
}
|
||||
spdk_thread_destroy(thread);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user