DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: "Wang, Zhihong" <zhihong.wang@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in	l3fwd
Date: Thu, 24 Dec 2015 11:13:43 +0000	[thread overview]
Message-ID: <2601191342CEEE43887BDE71AB97725836AD83CE@irsmsx105.ger.corp.intel.com> (raw)
In-Reply-To: <1450900995-84185-4-git-send-email-zhihong.wang@intel.com>


Hi,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Zhihong Wang
> Sent: Wednesday, December 23, 2015 8:03 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd
> 
> Handle SIGINT and SIGTERM in l3fwd.
> 
> Signed-off-by: Zhihong Wang <zhihong.wang@intel.com>
> ---
>  examples/l3fwd/main.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
> index 5b0c2dd..aae16d2 100644
> --- a/examples/l3fwd/main.c
> +++ b/examples/l3fwd/main.c
> @@ -41,6 +41,7 @@
>  #include <stdarg.h>
>  #include <errno.h>
>  #include <getopt.h>
> +#include <signal.h>
> 
>  #include <rte_common.h>
>  #include <rte_vect.h>
> @@ -2559,6 +2560,27 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
>  	}
>  }
> 
> +/* When we receive a INT signal, close all ports */
> +static void
> +sigint_handler(__rte_unused int signum)
> +{
> +	unsigned portid, nb_ports;
> +
> +	printf("Preparing to exit...\n");
> +	nb_ports = rte_eth_dev_count();
> +	for (portid = 0; portid < nb_ports; portid++) {
> +		if ((enabled_port_mask & (1 << portid)) == 0) {
> +			continue;
> +		}
> +		printf("Stopping port %d...", portid);
> +		rte_eth_dev_stop(portid);
> +		rte_eth_dev_close(portid);

Hmm, so your interrupt thread invokes dev_stop,
while IO lcores keep calling rx_burst/tx_burst? 
For graceful shutdown on SIGINT, I suppose you first have to
stop your IO lcores first.
Let say have a global var: 'stop' that every lcore has to check from
time to time (or something similar).
Konstantin

> +		printf(" Done\n");
> +	}
> +	printf("Bye...\n");
> +	exit(0);
> +}
> +
>  int
>  main(int argc, char **argv)
>  {
> @@ -2572,6 +2594,9 @@ main(int argc, char **argv)
>  	uint32_t n_tx_queue, nb_lcores;
>  	uint8_t portid, nb_rx_queue, queue, socketid;
> 
> +	signal(SIGINT, sigint_handler);
> +	signal(SIGTERM, sigint_handler);
> +
>  	/* init EAL */
>  	ret = rte_eal_init(argc, argv);
>  	if (ret < 0)
> --
> 2.5.0

  reply	other threads:[~2015-12-24 11:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-23 20:03 [dpdk-dev] [PATCH 0/3] Handle SIGINT and SIGTERM in DPDK examples Zhihong Wang
2015-12-23 20:03 ` [dpdk-dev] [PATCH 1/3] app/test-pmd: Handle SIGINT and SIGTERM in testpmd Zhihong Wang
2015-12-24  8:09   ` Qiu, Michael
2015-12-24 10:18     ` Wang, Zhihong
2015-12-23 20:03 ` [dpdk-dev] [PATCH 2/3] examples/l2fwd: Handle SIGINT and SIGTERM in l2fwd Zhihong Wang
2015-12-24  8:12   ` Qiu, Michael
2015-12-23 20:03 ` [dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd Zhihong Wang
2015-12-24 11:13   ` Ananyev, Konstantin [this message]
2015-12-25  9:17     ` Wang, Zhihong
     [not found]   ` <20151224095134.6eea3d4b@xeon-e3>
2015-12-25  9:23     ` Wang, Zhihong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2601191342CEEE43887BDE71AB97725836AD83CE@irsmsx105.ger.corp.intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=dev@dpdk.org \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).