Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/9683/?format=api
https://patches.dpdk.org/api/patches/9683/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1451431644-98362-2-git-send-email-zhihong.wang@intel.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1451431644-98362-2-git-send-email-zhihong.wang@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1451431644-98362-2-git-send-email-zhihong.wang@intel.com", "date": "2015-12-29T23:27:22", "name": "[dpdk-dev,v4,1/3] app/test-pmd: Handle SIGINT and SIGTERM in testpmd", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "74fdb68ee64289eb73ba7e292f78ce081b503c69", "submitter": { "id": 156, "url": "https://patches.dpdk.org/api/people/156/?format=api", "name": "Zhihong Wang", "email": "zhihong.wang@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1451431644-98362-2-git-send-email-zhihong.wang@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/9683/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/9683/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 045D38E82;\n\tWed, 30 Dec 2015 07:30:51 +0100 (CET)", "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 8E4367EEF\n\tfor <dev@dpdk.org>; Wed, 30 Dec 2015 07:30:47 +0100 (CET)", "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga102.fm.intel.com with ESMTP; 29 Dec 2015 22:30:47 -0800", "from unknown (HELO dpdk5.sh.intel.com) ([10.239.129.244])\n\tby fmsmga001.fm.intel.com with ESMTP; 29 Dec 2015 22:30:45 -0800" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.20,499,1444719600\"; d=\"scan'208\";a=\"871632688\"", "From": "Zhihong Wang <zhihong.wang@intel.com>", "To": "dev@dpdk.org", "Date": "Tue, 29 Dec 2015 18:27:22 -0500", "Message-Id": "<1451431644-98362-2-git-send-email-zhihong.wang@intel.com>", "X-Mailer": "git-send-email 2.5.0", "In-Reply-To": "<1451431644-98362-1-git-send-email-zhihong.wang@intel.com>", "References": "<1451011032-83106-1-git-send-email-zhihong.wang@intel.com>\n\t<1451431644-98362-1-git-send-email-zhihong.wang@intel.com>", "Subject": "[dpdk-dev] [PATCH v4 1/3] app/test-pmd: Handle SIGINT and SIGTERM\n\tin testpmd", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Handle SIGINT and SIGTERM in testpmd.\n\nSigned-off-by: Zhihong Wang <zhihong.wang@intel.com>\nAcked-by: Michael Qiu <michael.qiu@intel.com>\n---\n app/test-pmd/cmdline.c | 20 +++++++++++++-------\n app/test-pmd/testpmd.c | 39 +++++++++++++++++++++++++++++++++------\n app/test-pmd/testpmd.h | 1 +\n 3 files changed, 47 insertions(+), 13 deletions(-)", "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex 73298c9..6d28c1b 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -90,6 +90,8 @@\n \n #include \"testpmd.h\"\n \n+static struct cmdline *testpmd_cl;\n+\n static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);\n \n #ifdef RTE_NIC_BYPASS\n@@ -9778,17 +9780,21 @@ cmdline_parse_ctx_t main_ctx[] = {\n void\n prompt(void)\n {\n-\tstruct cmdline *cl;\n-\n \t/* initialize non-constant commands */\n \tcmd_set_fwd_mode_init();\n \n-\tcl = cmdline_stdin_new(main_ctx, \"testpmd> \");\n-\tif (cl == NULL) {\n+\ttestpmd_cl = cmdline_stdin_new(main_ctx, \"testpmd> \");\n+\tif (testpmd_cl == NULL)\n \t\treturn;\n-\t}\n-\tcmdline_interact(cl);\n-\tcmdline_stdin_exit(cl);\n+\tcmdline_interact(testpmd_cl);\n+\tcmdline_stdin_exit(testpmd_cl);\n+}\n+\n+void\n+prompt_exit(void)\n+{\n+\tif (testpmd_cl != NULL)\n+\t\tcmdline_quit(testpmd_cl);\n }\n \n static void\ndiff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex 98ae46d..1319917 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -1570,13 +1570,16 @@ pmd_test_exit(void)\n \tif (test_done == 0)\n \t\tstop_packet_forwarding();\n \n-\tFOREACH_PORT(pt_id, ports) {\n-\t\tprintf(\"Stopping port %d...\", pt_id);\n-\t\tfflush(stdout);\n-\t\trte_eth_dev_close(pt_id);\n-\t\tprintf(\"done\\n\");\n+\tif (ports != NULL) {\n+\t\tno_link_check = 1;\n+\t\tFOREACH_PORT(pt_id, ports) {\n+\t\t\tprintf(\"\\nShutting down port %d...\\n\", pt_id);\n+\t\t\tfflush(stdout);\n+\t\t\tstop_port(pt_id);\n+\t\t\tclose_port(pt_id);\n+\t\t}\n \t}\n-\tprintf(\"bye...\\n\");\n+\tprintf(\"\\nBye...\\n\");\n }\n \n typedef void (*cmd_func_t)(void);\n@@ -1984,12 +1987,35 @@ init_port(void)\n \t\tports[pid].enabled = 1;\n }\n \n+static void\n+force_quit(void)\n+{\n+\tpmd_test_exit();\n+\tprompt_exit();\n+}\n+\n+static void\n+signal_handler(int signum)\n+{\n+\tif (signum == SIGINT || signum == SIGTERM) {\n+\t\tprintf(\"\\nSignal %d received, preparing to exit...\\n\",\n+\t\t\t\tsignum);\n+\t\tforce_quit();\n+\t\t/* exit with the expected status */\n+\t\tsignal(signum, SIG_DFL);\n+\t\tkill(getpid(), signum);\n+\t}\n+}\n+\n int\n main(int argc, char** argv)\n {\n \tint diag;\n \tuint8_t port_id;\n \n+\tsignal(SIGINT, signal_handler);\n+\tsignal(SIGTERM, signal_handler);\n+\n \tdiag = rte_eal_init(argc, argv);\n \tif (diag < 0)\n \t\trte_panic(\"Cannot init EAL\\n\");\n@@ -2041,6 +2067,7 @@ main(int argc, char** argv)\n \t\tstart_packet_forwarding(0);\n \t\tprintf(\"Press enter to exit\\n\");\n \t\trc = read(0, &c, 1);\n+\t\tpmd_test_exit();\n \t\tif (rc < 0)\n \t\t\treturn 1;\n \t}\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex ee7de98..7ffc17b 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -462,6 +462,7 @@ unsigned int parse_item_list(char* str, const char* item_name,\n \t\t\tunsigned int *parsed_items, int check_unique_values);\n void launch_args_parse(int argc, char** argv);\n void prompt(void);\n+void prompt_exit(void);\n void nic_stats_display(portid_t port_id);\n void nic_stats_clear(portid_t port_id);\n void nic_xstats_display(portid_t port_id);\n", "prefixes": [ "dpdk-dev", "v4", "1/3" ] }{ "id": 9683, "url": "