From 77a95cdce2f3d80dac2832b68310eb5b23769c0e Mon Sep 17 00:00:00 2001 From: Jan Cavojsky Date: Tue, 3 Mar 2020 16:25:58 +0100 Subject: libmemif: don't consume rx queue interrupt, if memif_rx_burst fails Type: fix Signed-off-by: Jan Cavojsky Change-Id: Ic6c15c88c80c4045c290cd78533be6f070c7470a --- extras/libmemif/docs/gettingstarted_doc.md | 2 +- extras/libmemif/src/libmemif.h | 3 +++ extras/libmemif/src/main.c | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'extras') diff --git a/extras/libmemif/docs/gettingstarted_doc.md b/extras/libmemif/docs/gettingstarted_doc.md index dbe465c4b8a..1e5ce227eb3 100644 --- a/extras/libmemif/docs/gettingstarted_doc.md +++ b/extras/libmemif/docs/gettingstarted_doc.md @@ -114,7 +114,7 @@ typedef struct ``` 5. Packet receive - - Api call memif\_rx\_burst will set all required fields in memif buffers provided by user application and dequeue received buffers. + - Api call memif\_rx\_burst will set all required fields in memif buffers provided by user application, dequeue received buffers and consume interrupt event on receive queue. The event is not consumed, if memif_rx_burst fails. ```C err = memif_rx_burst (c->conn, qid, c->bufs, MAX_MEMIF_BUFS, &rx); ``` diff --git a/extras/libmemif/src/libmemif.h b/extras/libmemif/src/libmemif.h index 244c3fe2b72..66006f37f79 100644 --- a/extras/libmemif/src/libmemif.h +++ b/extras/libmemif/src/libmemif.h @@ -669,6 +669,9 @@ int memif_tx_burst (memif_conn_handle_t conn, uint16_t qid, @param count - number of memif buffers to receive @param rx - returns number of received buffers + Consume interrupt event for receive queue. + The event is not consumed, if memif_rx_burst fails. + \return memif_err_t */ int memif_rx_burst (memif_conn_handle_t conn, uint16_t qid, diff --git a/extras/libmemif/src/main.c b/extras/libmemif/src/main.c index 0c4adc256a2..b80dd6481b8 100644 --- a/extras/libmemif/src/main.c +++ b/extras/libmemif/src/main.c @@ -2506,14 +2506,18 @@ memif_rx_burst (memif_conn_handle_t conn, uint16_t qid, *rx = 0; uint64_t b; - ssize_t r = read (mq->int_fd, &b, sizeof (b)); - if (EXPECT_FALSE ((r == -1) && (errno != EAGAIN))) - return memif_syscall_error_handler (errno); + ssize_t r; cur_slot = (c->args.is_master) ? mq->last_head : mq->last_tail; last_slot = (c->args.is_master) ? ring->head : ring->tail; if (cur_slot == last_slot) - return MEMIF_ERR_SUCCESS; + { + r = read (mq->int_fd, &b, sizeof (b)); + if (EXPECT_FALSE ((r == -1) && (errno != EAGAIN))) + return memif_syscall_error_handler (errno); + + return MEMIF_ERR_SUCCESS; + } ns = last_slot - cur_slot; @@ -2562,6 +2566,10 @@ memif_rx_burst (memif_conn_handle_t conn, uint16_t qid, return MEMIF_ERR_NOBUF; } + r = read (mq->int_fd, &b, sizeof (b)); + if (EXPECT_FALSE ((r == -1) && (errno != EAGAIN))) + return memif_syscall_error_handler (errno); + return MEMIF_ERR_SUCCESS; /* 0 */ } -- cgit 1.2.3-korg