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: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/482206 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Community-CI: SPDK CI Jenkins <sys_sgci@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
de4bf95443
commit
2a8281fdfd
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user