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 30C464241A; Thu, 19 Jan 2023 16:53:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA3B940223; Thu, 19 Jan 2023 16:53:13 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2078.outbound.protection.outlook.com [40.107.243.78]) by mails.dpdk.org (Postfix) with ESMTP id 4DAAA400D5 for ; Thu, 19 Jan 2023 16:53:13 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y4SrK3I15RJDnoXF1RF5hnsLhG7Cp9hv+G6WtHKBmRiLUXzZRlKY0juvS3Z/U3iuVFseQzsIYs034y9+2h3Q3mSROcm1FtqFqkNXcyccwnIuAxMtGD8f5RCynuPDBXl/rmbx9CilLZaFnOLhfXKzAG+QYJ3x7qVuX4pEuad6jXRTDa0hv9QTmYgvgmvO/CUpexLsL5TBBiKECfp0LODAZd0+VkLbLVinscheGPsj+0/cHXsOkuBF42VyO3QoVswmr2oT5zh2WG2cSyP/EqkFfzN53zOBv3U7G7lIKg1bo4QGUSzuVBoCerCCzRs7fId/mh4V+qGAo3b/cP5TcQpxxw== 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=noDE+RKtD2LJvI6J3X3TEN6wE2N4gzTCojcy3ThTeWc=; b=HsesA+A+B/K14L/k3jbf//vIZLVKajy2hPsJcmqyolT4TfOMpJMMiqr1l0A6Qb5nKNG2o+w7sLMx9G9bj2aalgYR92zJMxrR5KB31WMgqRMFkbhUE+d7Ej4+/dW3NGVvb8fRs7tBTJ276fDEeNyy1d3HpG3Yk/TwQpdmTh3CloLrLCcgZwZfTLvn5MSspLSw+XJAFOW9ECkOePob1sDXBtzdxhh0Jnz/Zebv9U39GQSmtKj/FlIDYKOj7hRMBA4PhTH7jPM8O3YPl3F9PrN4fwUpVUVbq0wdZzVy4EqGJPKR0VsO36JJbw9+Ss6B5dWiFiSKT681Ph5H9TZ1BxxD2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=noDE+RKtD2LJvI6J3X3TEN6wE2N4gzTCojcy3ThTeWc=; b=Zy0zJa5gTh/5/wqNbB0sA/nl4FV4K4aBHUlELKWoEkJomMPYPhGtac53+QBSSRRcV+kPnz10RkIZgPeh8Taz/nNm2Ti1l2RGYb5X1nQMzFxc0SoQ4Lp7YthBvlAE7w/hoBay4+t+532kvXPY7rnAc8350+9V8P4nzlA2R4fPR/M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by SJ0PR12MB6686.namprd12.prod.outlook.com (2603:10b6:a03:479::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Thu, 19 Jan 2023 15:53:11 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a%8]) with mapi id 15.20.6002.024; Thu, 19 Jan 2023 15:53:11 +0000 Message-ID: <07a31181-948a-75ee-4272-a30cc5466a33@amd.com> Date: Thu, 19 Jan 2023 15:53:05 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v8] testpmd: cleanup cleanly from signal Content-Language: en-US To: Stephen Hemminger , dev@dpdk.org Cc: Aman Singh , Yuying Zhang , Phil Yang , Jianbo Liu References: <20221014172328.185219-2-stephen@networkplumber.org> <20221112172839.70087-1-stephen@networkplumber.org> From: Ferruh Yigit In-Reply-To: <20221112172839.70087-1-stephen@networkplumber.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0593.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:295::8) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|SJ0PR12MB6686:EE_ X-MS-Office365-Filtering-Correlation-Id: d667a1b2-ab08-4b31-47d4-08dafa3543e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gshe5cgv6ELig1sDJaoqwTc7wvH713ZO3BhOL7Ro+XykNQrDv9nYdKBfwt0BAl+3455fSfPYe9xaehqbH+3YbS+Z/jE+nJFQzWF7LtZsBh9vMcJRxYt47kuudGy1qnhCJeSkaWmI/aw4Dz9LbrgdNk3OjYfk5cbIYyxp2qmE6LhMphDhXywADxI78HvzRClGzSwm3crGhFw2eELyo3OLyvNUN/WV3pzrNTpe/OKOaqELD48RpjU/cn7snDo2oUgBT2KomyZhUBU0+ZdF4Xn2iQOaRJqI6HGCQKyLe55E5RbDJj/jJG5DSd7oFJY3CnC39QerDjsIqHNvdBGUrzsrs7kpf8kBaJaJ9DOMKO9yAfGHFtDJAOCYeK10XTbiHDQd5hNRl19/dF+F1kSup45XtJqAFJl6J+gUyr6Cn+CbeR85s6bc54tmDX1z9NpJt9S2WmMJk26n2b6luhTHBRbsvbKk3iWqXn0T0qo7lWePoPZgIoaZtXH5n6oP3qoSJG0HtsFJksLfqRwOui9cKfCm6x6Tde3/kie4UZsLBbGmK5i8as/mU2VWfbn0nOGrQoklTmPCTppVI/T34ON9y4hjvUAGBq8VXKLEp2gxX/M1ueJOpbSFTKHybWUHqva7dnblBP3ZJLnpeLWgdprgvZ7b/2rQNvBhb1qtJV+rpf4in1JKLCaktTUx5mKuK1zyMrlV5zfF43U5cLDfdGF+uDTHW19NwaShwfmQrUUZUIvCZJM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(376002)(346002)(136003)(39860400002)(366004)(396003)(451199015)(31686004)(8676002)(36756003)(186003)(66476007)(66556008)(6512007)(66946007)(53546011)(4326008)(41300700001)(2616005)(26005)(86362001)(31696002)(6506007)(5660300002)(8936002)(478600001)(83380400001)(54906003)(316002)(38100700002)(6486002)(6666004)(44832011)(2906002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eWpTWlY1U2lBemdyeEt3UFpNSlRjYjcxNlZoTHViRWlRNnJZeEwyMldqWFNO?= =?utf-8?B?Y1JsTjJwRFlxb1V1dkFRdFZ0L2I3UzRoMmxFQnJ4dHJIWnd6V1JxU2RvaE5X?= =?utf-8?B?dVlEZVF2RHN6TjNpTEZ3d01Fdk1sZys1VFRESTRuMU5vOHBwNnVZOUpWUkY2?= =?utf-8?B?dEhTNnNrd1VkendsMk9LTFZFT0NZOE0zZmdXejAxbCtqNng0SzJlL1NYMXBZ?= =?utf-8?B?MHNhK1hxNmRoL0taU0Vwb3JSbG1SNUVJdGwvWDA0dW9XQ1gyRmNvTXB0NXk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B?Qjd4MUpGbXZwVzFUTmxlWHoxZmZJTkZPRGN5VWpjc3RJYXdQUTBSSUhOM0dW?= =?utf-8?Q?kIo4qd5QxvjKeWBzcXQEHhnS3?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d667a1b2-ab08-4b31-47d4-08dafa3543e2 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 15:53:10.8272 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aoIUf7MZIbsj7ltGMpivsrFrmnC5BDjZJ9zOE7EIzNWDmyg5yovmD1AL+avIyFl/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6686 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 On 11/12/2022 5:28 PM, Stephen Hemminger wrote: > Do a clean shutdown of testpmd when a signal is received; > instead of having testpmd kill itself. > This fixes the problem where a signal could be received > in the middle of a PMD and then the signal handler would call > PMD's close routine leading to locking problems. > > An added benefit is it gets rid of some Windows specific code. > > Fixes: d9a191a00e81 ("app/testpmd: fix quitting in container") > Signed-off-by: Stephen Hemminger > --- > v8 - fix build on Windows (again) > Windows doesn't have FILENO_STDIN > > app/test-pmd/testpmd.c | 67 +++++++++++++++++++----------------------- > 1 file changed, 31 insertions(+), 36 deletions(-) > > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index aa7ea29f15ba..b4fb6a2bcbcf 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -11,6 +11,7 @@ > #include > #ifndef RTE_EXEC_ENV_WINDOWS > #include > +#include > #endif > #include > #include > @@ -4224,13 +4225,6 @@ 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) > { > @@ -4249,28 +4243,9 @@ print_stats(void) > } > > static void > -signal_handler(int signum) > +signal_handler(int signum __rte_unused) > { > - 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 > - } > + f_quit = 1; > } Signal handler used for interactive mode too, that is why 'force_quit();' is still needed in signal handler. Perhaps different signal handlers can be set for interactive and non-interactive modes. > > int > @@ -4449,9 +4424,6 @@ main(int argc, char** argv) > } else > #endif > { > - char c; > - int rc; > - > f_quit = 0; > > printf("No commandline core given, start packet forwarding\n"); > @@ -4476,15 +4448,38 @@ 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); > > - printf("Press enter to exit\n"); > - rc = read(0, &c, 1); > + ret = select(1, &fds, NULL, NULL, NULL); > + if (ret < 0 && errno != EINTR) > + rte_exit(EXIT_FAILURE, > + "Select failed: %s\n", > + strerror(errno)); > + > + if (ret == 1 && read(0, &c, 1) < 0) > + rte_exit(EXIT_FAILURE, > + "Read failed: %s\n", > + strerror(errno)); > + } > pmd_test_exit(); > - if (rc < 0) > - return 1; > } > > +#ifdef RTE_LIB_PDUMP > + /* uninitialize packet capture framework */ > + rte_pdump_uninit(); > +#endif > +#ifdef RTE_LIB_LATENCYSTATS > + if (latencystats_enabled != 0) > + rte_latencystats_uninit(); > +#endif +1 to move these functions here, but signal handler for the interactive mode also needs these functions. > + > ret = rte_eal_cleanup(); > if (ret != 0) > rte_exit(EXIT_FAILURE,