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 DD78C5A89 for ; Fri, 25 Dec 2015 10:23:16 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 25 Dec 2015 01:23:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,478,1444719600"; d="scan'208";a="19040982" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 25 Dec 2015 01:23:16 -0800 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 25 Dec 2015 01:23:15 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 25 Dec 2015 01:23:15 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.28]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.190]) with mapi id 14.03.0248.002; Fri, 25 Dec 2015 17:23:13 +0800 From: "Wang, Zhihong" To: Stephen Hemminger Thread-Topic: [dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd Thread-Index: AQHRPfggJYaPRGxaa0mvq4YptwmiZ57Z5WgAgAGIu9A= Date: Fri, 25 Dec 2015 09:23:13 +0000 Message-ID: <8F6C2BD409508844A0EFC19955BE0941858043@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> <20151224095134.6eea3d4b@xeon-e3> In-Reply-To: <20151224095134.6eea3d4b@xeon-e3> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWZmNjQzMDgtMTdjMC00NDJiLWJlMTUtMzE0OTQyNTFhODBjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiYUlaeXJlZ2ZOa3RGRkVwRm1CTmFxYW5kQlN1RHZsK1ZDRm5iNEprd25ERT0ifQ== x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" 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:23:17 -0000 > On Wed, 23 Dec 2015 15:03:15 -0500 > Zhihong Wang wrote: >=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); > > + printf(" Done\n"); > > + } > > + printf("Bye...\n"); > > + exit(0); > > +} >=20 > Signal handlers should only set a flag, which is then checked by thread l= oops. > Calling functions in DPDK from signal handlers is not safe. I'll make changes in v2 to address this issue. Thanks for pointing out :) In some cases signal handler have to do the exit though, like when the prog= ram is still doing memory initialization and will take some time.