[dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd

Stephen Hemminger stephen at networkplumber.org
Thu Dec 24 18:51:34 CET 2015


On Wed, 23 Dec 2015 15:03:15 -0500
Zhihong Wang <zhihong.wang at intel.com> wrote:

> +/* 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);
> +		printf(" Done\n");
> +	}
> +	printf("Bye...\n");
> +	exit(0);
> +}

Signal handlers should only set a flag, which is then checked by thread loops.
Calling functions in DPDK from signal handlers is not safe.


More information about the dev mailing list