From 74243e36b9a869d8f00614fab745bcaa8d565979 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Mon, 24 Jun 2019 12:54:24 +0200 Subject: [PATCH] vhost: reorder spdk_vhost_session_send_event Put it next to other functions in this call chain. Change-Id: Ieafd91c6cfefec134594aec8671eb4efdac15dfe Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459164 Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- lib/vhost/vhost.c | 62 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 3b4ad6b10..43900c463 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -937,6 +937,37 @@ spdk_vhost_event_cb(void *arg1) pthread_mutex_unlock(&g_spdk_vhost_mutex); } +int +spdk_vhost_session_send_event(struct vhost_poll_group *pg, + struct spdk_vhost_session *vsession, + spdk_vhost_session_fn cb_fn, unsigned timeout_sec, + const char *errmsg) +{ + struct spdk_vhost_session_fn_ctx ev_ctx = {0}; + struct timespec timeout; + int rc; + + ev_ctx.vdev = vsession->vdev; + ev_ctx.vsession_id = vsession->id; + ev_ctx.cb_fn = cb_fn; + + vsession->poll_group = pg; + spdk_thread_send_msg(pg->thread, spdk_vhost_event_cb, &ev_ctx); + pthread_mutex_unlock(&g_spdk_vhost_mutex); + + clock_gettime(CLOCK_REALTIME, &timeout); + timeout.tv_sec += timeout_sec; + + rc = sem_timedwait(&g_dpdk_sem, &timeout); + if (rc != 0) { + SPDK_ERRLOG("Timeout waiting for event: %s.\n", errmsg); + sem_wait(&g_dpdk_sem); + } + + pthread_mutex_lock(&g_spdk_vhost_mutex); + return g_dpdk_response; +} + static void foreach_session_continue(struct spdk_vhost_dev *vdev, struct spdk_vhost_session *vsession, spdk_vhost_session_fn fn, void *arg); @@ -988,37 +1019,6 @@ out_unlock: free(ctx); } -int -spdk_vhost_session_send_event(struct vhost_poll_group *pg, - struct spdk_vhost_session *vsession, - spdk_vhost_session_fn cb_fn, unsigned timeout_sec, - const char *errmsg) -{ - struct spdk_vhost_session_fn_ctx ev_ctx = {0}; - struct timespec timeout; - int rc; - - ev_ctx.vdev = vsession->vdev; - ev_ctx.vsession_id = vsession->id; - ev_ctx.cb_fn = cb_fn; - - vsession->poll_group = pg; - spdk_thread_send_msg(pg->thread, spdk_vhost_event_cb, &ev_ctx); - pthread_mutex_unlock(&g_spdk_vhost_mutex); - - clock_gettime(CLOCK_REALTIME, &timeout); - timeout.tv_sec += timeout_sec; - - rc = sem_timedwait(&g_dpdk_sem, &timeout); - if (rc != 0) { - SPDK_ERRLOG("Timeout waiting for event: %s.\n", errmsg); - sem_wait(&g_dpdk_sem); - } - - pthread_mutex_lock(&g_spdk_vhost_mutex); - return g_dpdk_response; -} - static void _stop_session(struct spdk_vhost_session *vsession) {