lib/vhost: Fix passing wrong data to callback to vhost_dev_foreach_session()
Not context passed to vhost_dev_for_each_session() but struct spdk_vhost_session had been passed to the callback to vhost_dev_for_each_session() by mistake. This patch fixes the bug. Besides, rename ctx by ev_ctx to avoid potential future degradation. Fixes issue #1306. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I8ceed4e1bb7c0c27fb75516527e3bad91a054b02 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1432 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Karol Latecki <karol.latecki@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
89519ebc49
commit
0a992c64c7
@ -793,8 +793,8 @@ vhost_session_send_event(struct spdk_vhost_session *vsession,
|
||||
static void
|
||||
foreach_session_finish_cb(void *arg1)
|
||||
{
|
||||
struct vhost_session_fn_ctx *ctx = arg1;
|
||||
struct spdk_vhost_dev *vdev = ctx->vdev;
|
||||
struct vhost_session_fn_ctx *ev_ctx = arg1;
|
||||
struct spdk_vhost_dev *vdev = ev_ctx->vdev;
|
||||
|
||||
if (pthread_mutex_trylock(&g_vhost_mutex) != 0) {
|
||||
spdk_thread_send_msg(spdk_get_thread(),
|
||||
@ -804,20 +804,20 @@ foreach_session_finish_cb(void *arg1)
|
||||
|
||||
assert(vdev->pending_async_op_num > 0);
|
||||
vdev->pending_async_op_num--;
|
||||
if (ctx->cpl_fn != NULL) {
|
||||
ctx->cpl_fn(vdev, ctx->user_ctx);
|
||||
if (ev_ctx->cpl_fn != NULL) {
|
||||
ev_ctx->cpl_fn(vdev, ev_ctx->user_ctx);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&g_vhost_mutex);
|
||||
free(ctx);
|
||||
free(ev_ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
foreach_session(void *arg1)
|
||||
{
|
||||
struct vhost_session_fn_ctx *ctx = arg1;
|
||||
struct vhost_session_fn_ctx *ev_ctx = arg1;
|
||||
struct spdk_vhost_session *vsession;
|
||||
struct spdk_vhost_dev *vdev = ctx->vdev;
|
||||
struct spdk_vhost_dev *vdev = ev_ctx->vdev;
|
||||
int rc;
|
||||
|
||||
if (pthread_mutex_trylock(&g_vhost_mutex) != 0) {
|
||||
@ -827,7 +827,7 @@ foreach_session(void *arg1)
|
||||
|
||||
TAILQ_FOREACH(vsession, &vdev->vsessions, tailq) {
|
||||
if (vsession->initialized) {
|
||||
rc = ctx->cb_fn(vdev, vsession, ctx);
|
||||
rc = ev_ctx->cb_fn(vdev, vsession, ev_ctx->user_ctx);
|
||||
if (rc < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user