From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2F15606A31C for ; Mon, 30 Nov 2026 00:29:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=rzb6YFeM Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E267840BA2; Mon, 30 Nov 2026 01:28:16 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTPS id 6FA2F40B92 for ; Mon, 30 Nov 2026 01:28:13 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-cdebab6fdb3so1767071a12.2 for ; Sun, 29 Nov 2026 16:28:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1795998492; x=1796603292; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KfQPm4YB9Vzn+CXSM6MqbAAdfJCY3F9cJjt5sUmJvPY=; b=rzb6YFeMilkoeSZBMQFVEytiuQuvSQimyCmdRJT2RHQ3e84wAKw/0yUmFIsjuvXpYn yG0G6CJtp6JbBb9DuJtNmpTPfLMx+P0q3YKaTIQj3CqdwTBr0nF1B2U1DIZHOwY8K3jt 7+OKZ+QbHuN4vueiNP2J03ZrmrYLRM7dIbOK+ixKhncDstexx8rhWDgek9gwOesxi50H nFiKBUDHGuRs85RQg9cWmxOr7lxMYLQFgPXZC+RtEwbQLu7l39JJKOdKGS4hncZe5ZNU 6D5ni2fKRDcyq5oXp4sVNZO2hmPIaXN/iE/wYLSRwjTsElccC09/GvlClMothv+rFUh+ EYHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795998492; x=1796603292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=KfQPm4YB9Vzn+CXSM6MqbAAdfJCY3F9cJjt5sUmJvPY=; b=gbqqPv9n50M5yvejx829to73UXLeG34mI8ZHv2uCMJoy+I7v7GTUcrMQMRlwT2i7S1 vqvI4/tn2wEhU/9sQMn1BIlc4ANdfdX4I9axl8wegE2xNVrwPJMEb+sGjNxGDISGjrCY WcDio33vPyq16Hx2ZFf6hWCfgGPqH9xaBD+oP8uHURdaD2uDVTPxFZAnD3a1mWuc5TkR VrW+uqK37IMya/1vhzJh2mmqJh17TjvUrF7XAgzd36sIzty6yE7/6z9BAmxvOW8CQXdT oK9vi9l/GH1pqKns53lY21y0jeeOD314g9kbUgOKvhdeXN2BUpCGmCeBDm0JTyDCjmlF Qm5w== X-Gm-Message-State: APuU4Z/BBfqnbuV5/1zDOKmwvT4/R2Ih30Vbk4xl/nS5JceEErwmnAeS 5KHhY1YvnWMnH1i32V1R6pparMr3kWrpNx93/j0V1AH0PynY5XdxcbJVxRWFOUd5xYW9FzN92Mu O8J3i X-Gm-Gg: AZFdTZdj08fib6NnjgjPAe1LXtRndcGMUyrjpNQNeHrtaGJyGsRfPLS40RdHoNj9/X3 Iu6LLmVu50I/PvEfmyZ6+UWA/F++Pw25E+Avb19ndqWH70DNbJVXAsmV/J8dlfrQJsQs7d2Zan4 rTctp2w3nvh6POqkiUwPbx4iJ8M3ch4j2Y7Qbhtcs+EPotvBAgUjVzDXruL6NvYkNAUiW6Js8lb 6KFhl4CmxMyhraiqne5VW7uvABqef0TsNjgDfGYeDXMzE5EsqmJzQVfNI397BqaAiwA5y7M+GBU Zlp6cylaI8q8v3qQcFgs/EHKzhglfrxFgQDjhATCIoEFe/3NuAzMxq0inXblojuVxg5uOlOKYTQ ZzPFLhfZKI1fsUmLa3pSMsyVqrOrElaLTfTOfimS3cHEsK8trhZnbAnBq7Zve1l8QfSLf2oPtI8 7zC0MsTXx7/3p27IzxwsBdqj9dJOQFoVO2bf0k0SWSWglZvTfNa9TshjVJGPgYXxW9xPGj7tztW 0Gkd8K2rla/NfnR3IJ2GlMLF9el2CezjuLS+r3uyvf8spCLZLVQFG7L4/+A8H0hxUXaapWZPJyE WSDtS6mliFJBFsR3ftFOQoYT1QNxGh7c3SQuf2wsDZSrNP4FLDyN2ZH6JH6d9FOqcqGV X-Received: by 2002:a17:90b:2ecb:b0:3b0:e2a9:3466 with SMTP id 98e67ed59e1d1-3b41c98a1d1mr27886398a91.16.1795998491830; Sun, 29 Nov 2026 16:28:11 -0800 (PST) Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b44b21e19fsm19455840a91.0.2026.11.29.16.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 16:28:11 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH 15/37] examples/pipeline: handle SIGINT and SIGTERM Date: Sun, 29 Nov 2026 16:27:00 -0800 Message-ID: <20261130002752.2342213-16-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261130002752.2342213-1-stephen@networkplumber.org> References: <20261130002752.2342213-1-stephen@networkplumber.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The dispatch loop in main() never terminates, so the rte_eal_cleanup() after it is unreachable. Clang reports this with -Wunreachable-code. This example has two independent dispatch loops: the control plane loop in main() and the data plane loop in thread_main() running on every worker lcore. Stopping only the control plane would tear down the EAL while the workers are still running pipelines, so force_quit is declared in thread.h and tested by both loops. The connectivity poll functions are non blocking, so the control plane loop notices the flag immediately. Signed-off-by: Stephen Hemminger --- examples/pipeline/main.c | 21 ++++++++++++++++++++- examples/pipeline/thread.c | 2 +- examples/pipeline/thread.h | 6 ++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/examples/pipeline/main.c b/examples/pipeline/main.c index da5dd2b3f6..57f9584a64 100644 --- a/examples/pipeline/main.c +++ b/examples/pipeline/main.c @@ -2,6 +2,8 @@ * Copyright(c) 2020 Intel Corporation */ +#include +#include #include #include #include @@ -131,6 +133,15 @@ parse_args(int argc, char **argv) return 0; } +volatile bool force_quit; + +static void +signal_handler(int signum) +{ + if (signum == SIGINT || signum == SIGTERM) + force_quit = true; +} + int main(int argc, char **argv) { @@ -149,6 +160,9 @@ main(int argc, char **argv) return status; }; + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + /* Thread */ status = thread_init(); if (status) { @@ -178,12 +192,17 @@ main(int argc, char **argv) }; /* Dispatch loop */ - for ( ; ; ) { + while (!force_quit) { conn_poll_for_conn(conn); conn_poll_for_msg(conn); } + /* wait for the data plane threads to stop running the pipelines */ + rte_eal_mp_wait_lcore(); + /* clean up the EAL */ rte_eal_cleanup(); + + return 0; } diff --git a/examples/pipeline/thread.c b/examples/pipeline/thread.c index cf2af55f68..8cdbd4fade 100644 --- a/examples/pipeline/thread.c +++ b/examples/pipeline/thread.c @@ -359,7 +359,7 @@ thread_main(void *arg __rte_unused) t = &threads[thread_id]; /* Dispatch loop. */ - for ( ; ; ) { + while (!force_quit) { uint32_t i; /* Pipelines. */ diff --git a/examples/pipeline/thread.h b/examples/pipeline/thread.h index f2e643def5..ad83b27506 100644 --- a/examples/pipeline/thread.h +++ b/examples/pipeline/thread.h @@ -5,10 +5,16 @@ #ifndef _INCLUDE_THREAD_H_ #define _INCLUDE_THREAD_H_ +#include #include #include +/** + * Set by the signal handler to stop the control and data plane threads. + */ +extern volatile bool force_quit; + /** * Control plane (CP) thread. */ -- 2.53.0