summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOuyang Changchun <changchun.ouyang@intel.com>2015-07-06 10:26:53 +0800
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-07-17 15:09:42 +0200
commitc83d2d00796ee5c12647007886c7fa483f97b82c (patch)
tree4712a33b313e5ddc351f272017cf0cb50b442522
parent29c0f3c8979e5ce6381aa1d0022418c654264ba0 (diff)
downloaddpdk-c83d2d00796ee5c12647007886c7fa483f97b82c.zip
dpdk-c83d2d00796ee5c12647007886c7fa483f97b82c.tar.gz
dpdk-c83d2d00796ee5c12647007886c7fa483f97b82c.tar.xz
examples/vhost: fix driver unregistering
The following commit broke vhost sample when it runs in second time: 292959c71961acde0cda6e77e737bb0a4df1559c It should call api to unregister vhost driver when sample exit/quit, then the socket file will be removed(by calling unlink), and thus make vhost sample work correctly in the second time startup. Test report: http://dpdk.org/ml/archives/dev/2015-July/020896.html Fixes: 292959c71961 ("vhost: cleanup unix socket") Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com> Acked-by: Huawei Xie <huawei.xie@intel.com>
-rw-r--r--examples/vhost/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 56a5c70..1b137b9 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2871,6 +2871,16 @@ setup_mempool_tbl(int socket, uint32_t index, char *pool_name,
}
}
+/* When we receive a INT signal, unregister vhost driver */
+static void
+sigint_handler(__rte_unused int signum)
+{
+ /* Unregister vhost driver. */
+ int ret = rte_vhost_driver_unregister((char *)&dev_basename);
+ if (ret != 0)
+ rte_exit(EXIT_FAILURE, "vhost driver unregister failure.\n");
+ exit(0);
+}
/*
* Main function, does initialisation and calls the per-lcore functions. The CUSE
@@ -2887,6 +2897,8 @@ main(int argc, char *argv[])
uint16_t queue_id;
static pthread_t tid;
+ signal(SIGINT, sigint_handler);
+
/* init EAL */
ret = rte_eal_init(argc, argv);
if (ret < 0)