From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A9B655A89 for ; Fri, 25 Dec 2015 10:17:10 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 25 Dec 2015 01:17:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,478,1444719600"; d="scan'208";a="19039498" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 25 Dec 2015 01:17:09 -0800 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 25 Dec 2015 01:17:09 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 25 Dec 2015 01:17:08 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.28]) by shsmsx102.ccr.corp.intel.com ([169.254.2.158]) with mapi id 14.03.0248.002; Fri, 25 Dec 2015 17:17:07 +0800 From: "Wang, Zhihong" To: "Ananyev, Konstantin" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd Thread-Index: AQHRPjwoMGCmwyHv/Eua6EfJEtZmH57bbJ0g Date: Fri, 25 Dec 2015 09:17:06 +0000 Message-ID: <8F6C2BD409508844A0EFC19955BE0941858034@SHSMSX103.ccr.corp.intel.com> References: <1450900995-84185-1-git-send-email-zhihong.wang@intel.com> <1450900995-84185-4-git-send-email-zhihong.wang@intel.com> <2601191342CEEE43887BDE71AB97725836AD83CE@irsmsx105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB97725836AD83CE@irsmsx105.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzIyZTNjOWYtNGZkYS00OWY5LWJkODgtMTEzMTk4YmViNTI3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiYXhMa2FyY1A0RllmSWU5RzhoblRJUjQ0T01YNEthUzR2R3pKczhrWmhjWT0ifQ== x-originating-ip: [10.239.127.40] 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: Fri, 25 Dec 2015 09:17:11 -0000 > > +/* 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); >=20 > Hmm, so your interrupt thread invokes dev_stop, while IO lcores keep call= ing > rx_burst/tx_burst? > 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). Thanks for the advice! This works once the program enters the forwarding ph= ase. Have to go the other way if it's still in initialization phase which can ta= ke quite some time. /Zhihong > Konstantin >=20 > > + 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; > > > > + signal(SIGINT, sigint_handler); > > + signal(SIGTERM, sigint_handler); > > + > > /* init EAL */ > > ret =3D rte_eal_init(argc, argv); > > if (ret < 0) > > -- > > 2.5.0