diff mbox series

[API-NEXT,v2,2/2] linux-generic: pktio: fail send/recv calls if pktio is not started

Message ID 1516032011-16269-3-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v2,1/2] api: pktio: clarify timeout and stop interaction | expand

Commit Message

Github ODP bot Jan. 15, 2018, 4 p.m. UTC
From: Bill Fischofer <bill.fischofer@linaro.org>


Fail send and recv calls if the pktio is not in the STARTED state.
This allows pending recv_tmo() calls to be terminated by
odp_pktio_stop().

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
/** Email created from pull request 387 (Bill-Fischofer-Linaro:pktio-docs)
 ** https://github.com/Linaro/odp/pull/387
 ** Patch: https://github.com/Linaro/odp/pull/387.patch
 ** Base sha: 6303c7d0e98fafe0f14c8c4dd9989b3b7633ebf4
 ** Merge commit sha: 44a458d201cb186a2ad2462da1fa9c4cd3a386b2
 **/
 platform/linux-generic/odp_packet_io.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index ffbc73b26..dcb46c7b5 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -1669,6 +1669,9 @@  int odp_pktin_recv(odp_pktin_queue_t queue, odp_packet_t packets[], int num)
 		return -1;
 	}
 
+	if (entry->s.state != PKTIO_STATE_STARTED)
+		return -1;
+
 	return entry->s.ops->recv(entry, queue.index, packets, num);
 }
 
@@ -1791,5 +1794,8 @@  int odp_pktout_send(odp_pktout_queue_t queue, const odp_packet_t packets[],
 		return -1;
 	}
 
+	if (entry->s.state != PKTIO_STATE_STARTED)
+		return -1;
+
 	return entry->s.ops->send(entry, queue.index, packets, num);
 }