Commit 931e3d51 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Daniel Verkamp
Browse files

util: call for_each_channel completion in original thread



As specified in the doc of spdk_for_each_channel:
```
Once 'fn' has been called on each channel, 'cpl' will be called
on the thread that spdk_for_each_channel was initially called from.
```

Fixes: ff87d29c ("io_channel: Add mechanism to call a function on
each channel")

Change-Id: Ic60b061ec402672f510d99697943e96ff9a73417
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/369719


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 740e5dc5
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -322,6 +322,15 @@ struct call_channel {
	spdk_channel_for_each_cpl cpl;
};

static void
_call_completion(void *ctx)
{
	struct call_channel *ch_ctx = ctx;

	ch_ctx->cpl(ch_ctx->io_device, ch_ctx->ctx);
	free(ch_ctx);
}

static void
_call_channel(void *ctx)
{
@@ -351,8 +360,7 @@ _call_channel(void *ctx)

	pthread_mutex_unlock(&g_devlist_mutex);

	ch_ctx->cpl(ch_ctx->io_device, ch_ctx->ctx);
	free(ch_ctx);
	spdk_thread_send_msg(ch_ctx->orig_thread, _call_completion, ch_ctx);
}

void