rocksdb: free existing channel when allocating a new channel

ASAN will report memory leak if we didn't free the old thread context,
it's related with Rocksdb version, I didn't get this issue with Rocksdb
v5.6, but Rocksdb v5.14 and v5.18 will complain the memory leak.

Change-Id: I116cad6c1bc723a60284a5c7cf1e78d10efa9ddd
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/666
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Changpeng Liu 2020-01-23 04:24:05 -05:00 committed by Tomasz Zawadzki
parent 8e7d6e1b0c
commit 19d5c3ed8e

View File

@ -643,6 +643,9 @@ void SpdkInitializeThread(void)
struct spdk_thread *thread;
if (g_fs != NULL) {
if (g_sync_args.channel) {
spdk_fs_free_thread_ctx(g_sync_args.channel);
}
thread = spdk_thread_create("spdk_rocksdb", NULL);
spdk_set_thread(thread);
g_sync_args.channel = spdk_fs_alloc_thread_ctx(g_fs);