From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 2111DC3C4 for ; Mon, 6 Jul 2015 04:27:07 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 05 Jul 2015 19:27:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,412,1432623600"; d="scan'208";a="723402152" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 05 Jul 2015 19:27:08 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t662R5F9009559; Mon, 6 Jul 2015 10:27:05 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t662R2a0030436; Mon, 6 Jul 2015 10:27:04 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t662R2pg030432; Mon, 6 Jul 2015 10:27:02 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Mon, 6 Jul 2015 10:26:53 +0800 Message-Id: <1436149613-30239-4-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1436149613-30239-1-git-send-email-changchun.ouyang@intel.com> References: <1435807983-20383-1-git-send-email-changchun.ouyang@intel.com> <1436149613-30239-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH v2 3/3] vhost: call api to unregister vhost driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2015 02:27:08 -0000 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. Signed-off-by: Changchun Ouyang --- examples/vhost/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) change in v2: - refine the signal handler name 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) -- 1.8.4.2