From: Michael Qiu Date: Wed, 24 Jun 2015 07:56:25 +0000 (+0800) Subject: app/testpmd: fix error message when closing port twice X-Git-Tag: spdx-start~8595 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d4e8ad64fadde895146f944a71d6ba45c3fcbca6;p=dpdk.git app/testpmd: fix error message when closing port twice When close one port twice, testpmd will give out wrong messagse. testpmd> port stop 0 Stopping ports... Checking link statuses... Port 0 Link Up - speed 0 Mbps - full-duplex Port 1 Link Up - speed 0 Mbps - full-duplex Done testpmd> port close 0 Closing ports... Done testpmd> port close 0 Closing ports... Port 0 is now not stopped Done testpmd> Signed-off-by: Michael Qiu --- diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 4bcece6727..386bf84d30 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1473,6 +1473,12 @@ close_port(portid_t pid) continue; port = &ports[pi]; + if (rte_atomic16_cmpset(&(port->port_status), + RTE_PORT_CLOSED, RTE_PORT_CLOSED) == 1) { + printf("Port %d is already closed\n", pi); + continue; + } + if (rte_atomic16_cmpset(&(port->port_status), RTE_PORT_STOPPED, RTE_PORT_HANDLING) == 0) { printf("Port %d is now not stopped\n", pi);