From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 51082594B for ; Thu, 24 Dec 2015 12:13:46 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 24 Dec 2015 03:13:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,473,1444719600"; d="scan'208";a="847690381" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by orsmga001.jf.intel.com with ESMTP; 24 Dec 2015 03:13:44 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.203]) by IRSMSX152.ger.corp.intel.com ([169.254.6.143]) with mapi id 14.03.0248.002; Thu, 24 Dec 2015 11:13:43 +0000 From: "Ananyev, Konstantin" To: "Wang, Zhihong" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd Thread-Index: AQHRPfhFFQ3Hw1sO+UyKHn/0Mfh4Dp7Z+uUw Date: Thu, 24 Dec 2015 11:13:43 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725836AD83CE@irsmsx105.ger.corp.intel.com> References: <1450900995-84185-1-git-send-email-zhihong.wang@intel.com> <1450900995-84185-4-git-send-email-zhihong.wang@intel.com> In-Reply-To: <1450900995-84185-4-git-send-email-zhihong.wang@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd 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: Thu, 24 Dec 2015 11:13:46 -0000 Hi, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Zhihong Wang > Sent: Wednesday, December 23, 2015 8:03 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM= in l3fwd >=20 > Handle SIGINT and SIGTERM in l3fwd. >=20 > Signed-off-by: Zhihong Wang > --- > examples/l3fwd/main.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) >=20 > diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c > index 5b0c2dd..aae16d2 100644 > --- a/examples/l3fwd/main.c > +++ b/examples/l3fwd/main.c > @@ -41,6 +41,7 @@ > #include > #include > #include > +#include >=20 > #include > #include > @@ -2559,6 +2560,27 @@ check_all_ports_link_status(uint8_t port_num, uint= 32_t port_mask) > } > } >=20 > +/* When we receive a INT signal, close all ports */ > +static void > +sigint_handler(__rte_unused int signum) > +{ > + unsigned portid, nb_ports; > + > + printf("Preparing to exit...\n"); > + nb_ports =3D rte_eth_dev_count(); > + for (portid =3D 0; portid < nb_ports; portid++) { > + if ((enabled_port_mask & (1 << portid)) =3D=3D 0) { > + continue; > + } > + printf("Stopping port %d...", portid); > + rte_eth_dev_stop(portid); > + rte_eth_dev_close(portid); Hmm, so your interrupt thread invokes dev_stop, while IO lcores keep calling rx_burst/tx_burst?=20 For graceful shutdown on SIGINT, I suppose you first have to stop your IO lcores first. Let say have a global var: 'stop' that every lcore has to check from time to time (or something similar). Konstantin > + printf(" Done\n"); > + } > + printf("Bye...\n"); > + exit(0); > +} > + > int > main(int argc, char **argv) > { > @@ -2572,6 +2594,9 @@ main(int argc, char **argv) > uint32_t n_tx_queue, nb_lcores; > uint8_t portid, nb_rx_queue, queue, socketid; >=20 > + signal(SIGINT, sigint_handler); > + signal(SIGTERM, sigint_handler); > + > /* init EAL */ > ret =3D rte_eal_init(argc, argv); > if (ret < 0) > -- > 2.5.0