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: ff87d29cc3 ("io_channel: Add mechanism to call a function on
each channel")

Change-Id: Ic60b061ec402672f510d99697943e96ff9a73417
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/369719
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-07-17 10:55:01 +02:00 committed by Daniel Verkamp
parent 740e5dc50b
commit 931e3d51d9

View File

@ -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