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 61D2C606A320 for ; Mon, 30 Nov 2026 21:54:09 +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=DVPscPEb Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4351640B92; Mon, 30 Nov 2026 22:52:29 +0100 (CET) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTPS id 18C4A4068E for ; Mon, 30 Nov 2026 22:52:18 +0100 (CET) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-8b3577deeb0so4932875b3a.3 for ; Mon, 30 Nov 2026 13:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796075536; x=1796680336; 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=DVPscPEb1XZ0Emz3J5oBlaswi5DuQvnN2hYcTusiWEVGf7VlBrRuHa340UFYmW2cF/ UWE94+wtZU7caFm3fHBEjmb+B33N2qWBHghof+2Cbmg5wjYTSH7m8o6RcesWQPTUalSE LWUgZKvbTf/dd+IBHV8XIcZB8pkIxaR4pAHINyt5Bp3uSXC+/EBFAyKW6Tz9cvBG4zoP XOqDqrznVp7sFf4c3y+A9wQczhgDaLXTCCjFnwnEicsgOXtZfQErUWhmVsZSaUaFk6yq Fnrg3Syr90jelMQIHWRsvM21X/GyTvTHOGxD4eC5SpUEKf5pNwDkJzXHypr+6P1Gawlt qCsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796075536; x=1796680336; 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=sTbNjWNk6IMsO4czX48RUiani8hx3qTYfTA8g2/99f/tXzq547JMgkrHLHPm8pEVHT L4kT1kwdlVBcRCNn6nRwKUaprOSX31Pi3SxqXIiyWS0pM6C2OUBhwU2Jde4VXKVYJ+Lh Q/tzCMvfLxsYoAEV64YFdRsN3wDhjkGY7JZxX4VgQQQEL8Jot8q/Oc69v0qXmKRIiQBS DW/8zwUKVvLik0kY/mJAxie+MkfN5f8gHiFF/XLSbIy7JraokS5yHXE/iJL6ApbITcWj zYZP5t3AV8vGyCuQzEjys/i4Eg6tCcNA+0sVZPfg/yDJMkErRlZFBk7hyzI2XLXIiZye xnIA== X-Gm-Message-State: APuU4Z9nLRHlTZkV+Q4O2UFBc+5uz+l4kLGDVXohXSqQyBq1dE6wjUJk au8h648aoscGhJHroY+zEG4rizckQiudJ3RiKsRTUNJhISGDcY9ketSwcIt6B7p13ReKfqIMY+m Tggilj8A= X-Gm-Gg: AZFdTZeQ47USbZ/SsgZQqUZpK86gHpyyZs1muIL2uzihTBnh8PI7Q+8VlTkXS1NI8xe Wt8Ai+G3Fzy6zW+28In8rKJCufi4V0g2YTL7rCo8OMYnTm71+aYuqidJBXENguqvlgJU/Mj4e8a dzuWpUEfasBX9JDuFSHGq8AUNNGFufM5B14C4+mCb7/G6hV6GvaH9BJnp28dQt7CqZlWXhV92mM ++EDJPa5168Pz/HIvPlubSBHzHeeLw1MdL5RvsbkWtT6VMTLlGrTydv/znkfFjzen5Yauc9Ghrl H1CmUSuGRkoTEBG18yzQcDw5zqYhy3YvzjwvzW54Uw/duCHmPgiszAOzmYL1etVWz5Nf3g4gM7M mcqn0sPQSvzd3pgc0xoA0odROw3oxajLz8vkgiajZ797yW0+Uh6MJnaYlYC9wzMpTlh+WJK0Kbe 9qvCt+aXcCxvFvjNnRODF37deIWmhVSkTHuML4IYyNMLXa5FHrl48En5XSH0NmrMKsAf4G/WZxE XEcKYGCewoUMuVDZhGp1OeIkZJQRTg6HYYSYT3rhhWdk1Qm1KoOLI1s2ZDtps+qk2QIzxEI+PVi 8aIuKsIPkDAy+I8FdmewNA4KsCG01Vv8UI1k54WYlolFwh2IQ7DvrAw8fAcD2B2PxdTG X-Received: by 2002:a05:6a20:6a03:b0:3eb:acc3:1a4e with SMTP id adf61e73a8af0-4014e25bbf2mr37883604637.82.1796075536523; Mon, 30 Nov 2026 13:52:16 -0800 (PST) Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c872e45756sm18561940b3a.27.2026.11.30.13.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 13:52:16 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v2 16/38] examples/pipeline: handle SIGINT and SIGTERM Date: Mon, 30 Nov 2026 13:49:22 -0800 Message-ID: <20261130215203.886245-17-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261130215203.886245-1-stephen@networkplumber.org> References: <20261129205006.1440292-1-stephen@networkplumber.org> <20261130215203.886245-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