From patchwork Fri Sep 22 06:12:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Yang X-Patchwork-Id: 29082 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 975EE7CDE; Fri, 22 Sep 2017 08:13:24 +0200 (CEST) Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id 70246F94 for ; Fri, 22 Sep 2017 08:13:22 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5EFA480D; Thu, 21 Sep 2017 23:13:21 -0700 (PDT) Received: from phil-VirtualBox.shanghai.arm.com (phil-virtualbox.shanghai.arm.com [10.169.38.96]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 910ED3F578; Thu, 21 Sep 2017 23:13:20 -0700 (PDT) From: Phil Yang To: dev@dpdk.org Cc: nd@arm.com, jianbo.liu@linaro.org, Herbert.Guan@arm.com Date: Fri, 22 Sep 2017 14:12:49 +0800 Message-Id: <1506060769-2411-1-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505706058-1841-1-git-send-email-phil.yang@arm.com> References: <1505706058-1841-1-git-send-email-phil.yang@arm.com> Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix stats period can't quit normally in container X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In container, the process cannot be terminated by SIGINT/SIGTERM when execute with 'stats-period' option. Fixed by adding a flag to exit stats period loop after received SIGINT/SIGTERM. Signed-off-by: Phil Yang --- app/test-pmd/testpmd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index e097ee0..3ccc9ba 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -183,6 +183,13 @@ uint16_t mbuf_data_size = DEFAULT_MBUF_DATA_SIZE; /**< Mbuf data space size. */ uint32_t param_total_num_mbufs = 0; /**< number of mbufs in all pools - if * specified on command-line. */ uint16_t stats_period; /**< Period to show statistics (disabled by default) */ + +/* + * In container, it cannot terminate the process which running with 'stats-period' + * option. Set flag to exit stats period loop after received SIGINT/SIGTERM. + */ +uint8_t f_quit; + /* * Configuration of packet segments used by the "txonly" processing engine. */ @@ -2318,6 +2325,8 @@ signal_handler(int signum) rte_latencystats_uninit(); #endif force_quit(); + /* Set flag to indicate the force termination. */ + f_quit = 1; /* exit with the expected status */ signal(signum, SIG_DFL); kill(getpid(), signum); @@ -2435,6 +2444,8 @@ main(int argc, char** argv) char c; int rc; + f_quit = 0; + printf("No commandline core given, start packet forwarding\n"); start_packet_forwarding(tx_first); if (stats_period != 0) { @@ -2444,7 +2455,7 @@ main(int argc, char** argv) /* Convert to number of cycles */ timer_period = stats_period * rte_get_timer_hz(); - while (1) { + while (f_quit == 0) { cur_time = rte_get_timer_cycles(); diff_time += cur_time - prev_time;