From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 090CD41EB2; Thu, 16 Mar 2023 18:28:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB37A40DF6; Thu, 16 Mar 2023 18:27:59 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by mails.dpdk.org (Postfix) with ESMTP id C09E440DDC for ; Thu, 16 Mar 2023 18:27:57 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gA9sYc7hqLYvR+8nSaRBjNjh3P6ZSnfgI2g/yjv8Sh+rrBSDn8V0pRCCft3EIjdtzSaebf0PAHwOw8oK4wd+iRVc+H+D/3xHJxuDU1JqFb2KDUvXYhqOlTQ2u2bE/a/1+ILt4CMhRRJtsHgbf6MEFHF1aa+uUQFEexZ7KyReOZBwvgnBtnN2hlcLXuy2d1MkS0vbIRdgF03KhMWYpLPV9LKel/JM7BfpOiSR1GXrHwukIHhEawzojhrP2hYliilfil2aZc/CScqNMvkpcpjnNyTD+Mp98xb6ujuydH7uIk/i6/sQ4ob18L862K35QxJ3e7NI1Wncg20Y2RmkoaiHFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xdG+F0T4e5RUQgj5cr+9ixc+tyIi7RhQcnP4aNedgGQ=; b=kxp8Ws1rtbja/QsHP5bbfzF5pcV3obcp0peUnvG/jYECJaw3qkdZznEuag6VrPmhlfXNey233RkUXRJcz2MCU0fhBMDPR6O93wGo9ZxquT5L4QiUU6nqw1kJGEq46dNXVTPMwELRawKNLq4QILshp/Hx+pf6wJSI00sCzjjxxotBgEVB4+iA4PZkDWY1KKvX8qpxFZH3OUV59gqG2uxqIpCLnZAuZlA30bNGUrwQJZmAjanL0wCNq4HS92Da5fcqhqrqG8U0Y3j/f07kLGnclrPOyxdGU7uBXhjudy54uGtyLxEu3QV7Xuai3hbwg9Md3Cc18URMjWmvKDKHpCyAiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xdG+F0T4e5RUQgj5cr+9ixc+tyIi7RhQcnP4aNedgGQ=; b=Eit0ZaYa+5G50pLkkHCBH717XIjOybB/453K7JpKk6JqjBcM7MO74UgNgbVPk/JkzUAqqWbZFd2lHEs1mzKC9rR4CtxKeZD8LX9nB31rYfGsALH30CbeN1fsqWQyVrEkqEO7zMiCFgSvaXpdIqeSY03RxLnsyUJT1s3lgBGVmec= Received: from MW2PR16CA0039.namprd16.prod.outlook.com (2603:10b6:907:1::16) by PH7PR12MB8825.namprd12.prod.outlook.com (2603:10b6:510:26a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.31; Thu, 16 Mar 2023 17:27:56 +0000 Received: from CO1NAM11FT092.eop-nam11.prod.protection.outlook.com (2603:10b6:907:1:cafe::e1) by MW2PR16CA0039.outlook.office365.com (2603:10b6:907:1::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.33 via Frontend Transport; Thu, 16 Mar 2023 17:27:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT092.mail.protection.outlook.com (10.13.175.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6199.18 via Frontend Transport; Thu, 16 Mar 2023 17:27:55 +0000 Received: from telcodpdk.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 16 Mar 2023 12:27:53 -0500 From: Ferruh Yigit To: Aman Singh , Yuying Zhang CC: Thomas Monjalon , Andrew Rybchenko , , Stephen Hemminger , Pier Damouny Subject: [PATCH] app/testpmd: revert cleanup cleanly from signal Date: Thu, 16 Mar 2023 17:27:39 +0000 Message-ID: <20230316172739.77933-1-ferruh.yigit@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315173132.4044-1-stephen@networkplumber.org> References: <20230315173132.4044-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT092:EE_|PH7PR12MB8825:EE_ X-MS-Office365-Filtering-Correlation-Id: 099535b3-965f-4870-655e-08db2643c78e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tg6X5K9YTJFQz+8InWTFRa8DldS8Mfd6WYhROkSh8WBv2JrlZe8cY2Org1uVovZzVEcRinhTC/ckpe/2f43TXn9rRV1Y8Qd7sinISgWHIUKwDhbMyll3Ekx8PRiZtkPo6wCirfBqSPaKSlqQjk/ULwcpeiPK7BYBlPoXV88Td9cdxbnUX0JSX4zM2bhp0jb3rcF+jK3VHvd3Y9xPGqQI14LxVS5js0WoHhi9uWTPM93TNVxL9kznI3nYzVqFkYkY9Tpp3XaqR5GvQvI+g40KX2PNCgTI6+FJBWeDbykiJ9zmsqvk/fOIcp9wF1WlfXsorUiqgsDQLcuE1LhziYSwcLx3vmw/X5GBYtuIyfBe5HWJ/WE3BbAZddd+96jeVHjtdkBOPXzisUpX5VbsRr+kJzgbheiOi6/iL/dDBPwWNqMT7ONP2UgJXkjJCKlZXWakehrGkFv8JUUmUX2ce1+o5j8j8Kww4l3ThFS6NUMNbwDrUuNVrw9kywK+HzAtXt0A2PKHntD2cR3q+ETTc8208ljrlVtyAtRaD4sL5N/S632LPYNDsMxL0Sx7/kNJTEyM5+ueycdZltZWcpYHUsJDnCdKUTUh5EsL6z5wgoMNnGoAu9y+oY6Q55oWB7A9PmO4mEZQaXRJGXoQBnh2HS6dK7UgTroBzWga5mQExiH1my12aD6dzOm+a9BOeU3a3Uebc+CyWgukunQreaoYAHkw0UQ4k1Eha54u1rLhvqYSdKo= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199018)(46966006)(36840700001)(40470700004)(83380400001)(40460700003)(36756003)(86362001)(40480700001)(82740400003)(36860700001)(81166007)(82310400005)(47076005)(186003)(16526019)(26005)(426003)(1076003)(356005)(336012)(2616005)(6666004)(478600001)(7696005)(316002)(4326008)(44832011)(70586007)(110136005)(70206006)(8676002)(8936002)(2906002)(5660300002)(54906003)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2023 17:27:55.4312 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 099535b3-965f-4870-655e-08db2643c78e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT092.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8825 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This reverts commit 0fd1386c30c3ad9365d7fdd2829bf7cb2e1b9dff. Because of reported issues on Windows [1] and it is risky to fix it at this stage, fixed feature will be considered in next version. [1] Bugzilla ID: 1180 Signed-off-by: Ferruh Yigit --- Cc: Stephen Hemminger Cc: Pier Damouny --- app/test-pmd/cmdline.c | 29 ++++++++++------ app/test-pmd/testpmd.c | 77 ++++++++++++++++++++++-------------------- app/test-pmd/testpmd.h | 1 - 3 files changed, 59 insertions(+), 48 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 6fa870dc329b..02c72d06b768 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -66,6 +66,7 @@ #include "cmdline_tm.h" #include "bpf_cmd.h" +static struct cmdline *testpmd_cl; static cmdline_parse_ctx_t *main_ctx; static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head = TAILQ_HEAD_INITIALIZER(driver_commands_head); @@ -13032,22 +13033,28 @@ cmdline_read_from_file(const char *filename) void prompt(void) { - struct cmdline *cl; + int ret; - cl = cmdline_stdin_new(main_ctx, "testpmd> "); - if (cl == NULL) + testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); + if (testpmd_cl == NULL) return; - /* loop until signal or quit command */ - while (f_quit == 0 && cl_quit == 0) { - int status = cmdline_poll(cl); + ret = atexit(prompt_exit); + if (ret != 0) + fprintf(stderr, "Cannot set exit function for cmdline\n"); - if (status < 0 || status == RDLINE_EXITED) - break; - } + cmdline_interact(testpmd_cl); + if (ret != 0) + cmdline_stdin_exit(testpmd_cl); +} - cmdline_quit(cl); - cmdline_stdin_exit(cl); +void +prompt_exit(void) +{ + if (testpmd_cl != NULL) { + cmdline_quit(testpmd_cl); + cmdline_stdin_exit(testpmd_cl); + } } void diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 2ce19ed47ab4..003269660801 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -11,7 +11,6 @@ #include #ifndef RTE_EXEC_ENV_WINDOWS #include -#include #endif #include #include @@ -232,7 +231,7 @@ unsigned int xstats_display_num; /**< Size of extended statistics to show */ * In container, it cannot terminate the process which running with 'stats-period' * option. Set flag to exit stats period loop after received SIGINT/SIGTERM. */ -volatile uint8_t f_quit; +static volatile uint8_t f_quit; uint8_t cl_quit; /* Quit testpmd from cmdline. */ /* @@ -4448,6 +4447,13 @@ init_port(void) memset(txring_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS); } +static void +force_quit(void) +{ + pmd_test_exit(); + prompt_exit(); +} + static void print_stats(void) { @@ -4466,9 +4472,28 @@ print_stats(void) } static void -signal_handler(int signum __rte_unused) +signal_handler(int signum) { - f_quit = 1; + if (signum == SIGINT || signum == SIGTERM) { + fprintf(stderr, "\nSignal %d received, preparing to exit...\n", + signum); +#ifdef RTE_LIB_PDUMP + /* uninitialize packet capture framework */ + rte_pdump_uninit(); +#endif +#ifdef RTE_LIB_LATENCYSTATS + if (latencystats_enabled != 0) + rte_latencystats_uninit(); +#endif + force_quit(); + /* Set flag to indicate the force termination. */ + f_quit = 1; + /* exit with the expected status */ +#ifndef RTE_EXEC_ENV_WINDOWS + signal(signum, SIG_DFL); + kill(getpid(), signum); +#endif + } } int @@ -4652,9 +4677,15 @@ main(int argc, char** argv) start_packet_forwarding(0); } prompt(); + pmd_test_exit(); } else #endif { + 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) { @@ -4677,40 +4708,14 @@ main(int argc, char** argv) prev_time = cur_time; rte_delay_us_sleep(US_PER_S); } - } else { - char c; - fd_set fds; - - printf("Press enter to exit\n"); - - FD_ZERO(&fds); - FD_SET(0, &fds); - - /* wait for signal or enter */ - ret = select(1, &fds, NULL, NULL, NULL); - if (ret < 0 && errno != EINTR) - rte_exit(EXIT_FAILURE, - "Select failed: %s\n", - strerror(errno)); - - /* if got enter then consume it */ - if (ret == 1 && read(0, &c, 1) < 0) - rte_exit(EXIT_FAILURE, - "Read failed: %s\n", - strerror(errno)); } - } - pmd_test_exit(); - -#ifdef RTE_LIB_PDUMP - /* uninitialize packet capture framework */ - rte_pdump_uninit(); -#endif -#ifdef RTE_LIB_LATENCYSTATS - if (latencystats_enabled != 0) - rte_latencystats_uninit(); -#endif + printf("Press enter to exit\n"); + rc = read(0, &c, 1); + pmd_test_exit(); + if (rc < 0) + return 1; + } ret = rte_eal_cleanup(); if (ret != 0) diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index bdfbfd36d3c5..b9215720b615 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -34,7 +34,6 @@ #define RTE_PORT_HANDLING (uint16_t)3 extern uint8_t cl_quit; -extern volatile uint8_t f_quit; /* * It is used to allocate the memory for hash key. -- 2.34.1