Commit 2a8281fd authored by Changpeng Liu's avatar Changpeng Liu
Browse files

thread: free message event after executing the callback successfully



We should check the thread's state at the end of message callback, or
we may leak the message memory in case the thread was set to exit state.

Change-Id: Ifb67c3b5c39440c411eca1d045c11e8aa6c514cc
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/482206


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent de4bf954
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -432,10 +432,6 @@ _spdk_msg_queue_run_batch(struct spdk_thread *thread, uint32_t max_msgs)
		assert(msg != NULL);
		msg->fn(msg->arg);

		if (thread->exit) {
			break;
		}

		if (thread->msg_cache_count < SPDK_MSG_MEMPOOL_CACHE_SIZE) {
			/* Insert the messages at the head. We want to re-use the hot
			 * ones. */
@@ -444,6 +440,10 @@ _spdk_msg_queue_run_batch(struct spdk_thread *thread, uint32_t max_msgs)
		} else {
			spdk_mempool_put(g_spdk_msg_mempool, msg);
		}

		if (thread->exit) {
			break;
		}
	}

	return count;