From fbd6c30b8baaf1c9752bc34d5c4811f9dd695424 Mon Sep 17 00:00:00 2001 From: Liu Xiaodong Date: Wed, 24 Feb 2021 11:38:40 -0500 Subject: [PATCH] intr: call intr_enable before thread lib init Restrict spdk_interrupt_mode_enable must be called once prior to initializing the threading library. Change-Id: I833ff63fae19882e82154195d03dd7ce56ffb1de Signed-off-by: Liu Xiaodong Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6707 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- lib/thread/thread.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 1d3fa20ec..19f3d9904 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -2019,6 +2019,14 @@ static bool g_interrupt_mode = false; int spdk_interrupt_mode_enable(void) { + /* It must be called once prior to initializing the threading library. + * g_spdk_msg_mempool will be valid if thread library is initialized. + */ + if (g_spdk_msg_mempool) { + SPDK_ERRLOG("Failed due to threading library is already initailzied.\n"); + return -1; + } + #ifdef __linux__ SPDK_NOTICELOG("Set SPDK running in interrupt mode.\n"); g_interrupt_mode = true;