diff mbox series

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

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

Commit Message

Github ODP bot Jan. 15, 2018, 11 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: f6dab2bfa90ef5d3146cb76f86bc8782666f0f3e
 ** Merge commit sha: b1f177bfce913daf4fabbba1e18912aed180b1e8
 **/
 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);
 }