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 2C11EA04FD; Thu, 10 Nov 2022 08:14:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1238B400EF; Thu, 10 Nov 2022 08:14:36 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id A8601400D4 for ; Thu, 10 Nov 2022 08:14:34 +0100 (CET) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 025CC66; Thu, 10 Nov 2022 10:14:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 025CC66 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1668064473; bh=yXcd/VMuHzgQElpTGSh6ju/KLDU0mZyQDwlFA4AVEss=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=JrAQGsqK3ZMsH35WmuB46z3hjFGcwvTLoRuxCdk0s1DtksAh4DTq/ojOLW52oy3wy d/zya5M6zjcfJNHQ4g8MK2oU9z3WYVdiUbk72lB4CZlz5yIaunp6LJiC3GLL5LPn6Z YhOGPrIrRNJ5+Vp/xfVI4xHneAXKbuvDwtYw+MXQ= Message-ID: Date: Thu, 10 Nov 2022 10:14:32 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v5] testpmd: cleanup cleanly from signal Content-Language: en-US To: Stephen Hemminger , dev@dpdk.org Cc: phil.yang@arm.com References: <20221014172328.185219-2-stephen@networkplumber.org> <20221109172927.71411-1-stephen@networkplumber.org> From: Andrew Rybchenko Organization: OKTET Labs In-Reply-To: <20221109172927.71411-1-stephen@networkplumber.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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/9/22 20:29, Stephen Hemminger wrote: > Do a clean shutdown of testpmd when a signal is received; > instead of having testpmd kill itself. > This fixes problem where a signal could be received > in the middle of a PMD and then the signal handler would call > PMD's close routine which could cause a deadlock. > > Added benefit is it gets rid of Windows specific code. > > Fixes: d9a191a00e81 ("app/testpmd: fix quitting in container") Cc to stable? > Signed-off-by: Stephen Hemminger with one nit below: Reviewed-by: Andrew Rybchenko [snip] > @@ -4476,15 +4459,37 @@ 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"); > - rc = read(0, &c, 1); > - pmd_test_exit(); > - if (rc < 0) > - return 1; > + printf("Press enter to exit\n"); > + > + FD_ZERO(&fds); > + FD_SET(0, &fds); > + > + if (select(1, &fds, NULL, NULL, NULL) <= 0) { > + fprintf(stderr, "Select failed: %s\n", > + strerror(errno)); > + } else if (read(0, &c, 1) <= 0) { > + fprintf(stderr, > + "Read stdin failed: %s\n", > + strerror(errno)); > + } > + } > + stop_packet_forwarding(); force_quit() calls stop_packet_forwarding() if test_done is 0. So, there is no difference in test_done == 0 case. If test_done is not zero, stop_packet_forwarding() just logs "Packet forwarding not started" and does nothing. So, the difference is only in error message. Is it intentional? > + force_quit(); > } > > +#ifdef RTE_LIB_PDUMP > + /* uninitialize packet capture framework */ > + rte_pdump_uninit(); > +#endif > +#ifdef RTE_LIB_LATENCYSTATS > + if (latencystats_enabled != 0) > + rte_latencystats_uninit(); > +#endif > + > ret = rte_eal_cleanup(); > if (ret != 0) > rte_exit(EXIT_FAILURE,