libmemif: icmp-responder example buffer management fix
Type: fix Change-Id: Ieeb763f282ee929a121585747119f458c00056ae Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
This commit is contained in:

committed by
Damjan Marion

parent
160c923f99
commit
389c82286d
@ -290,7 +290,6 @@ on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
|
||||
memif_connection_t *c = &memif_connection;
|
||||
int err;
|
||||
uint16_t rx;
|
||||
uint16_t fb = 0;
|
||||
/* receive data from shared memory buffers */
|
||||
err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
|
||||
c->rx_buf_num += rx;
|
||||
@ -314,10 +313,14 @@ on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
|
||||
|
||||
/* mark memif buffers and shared memory buffers as free */
|
||||
err = memif_refill_queue (c->conn, qid, rx, 0);
|
||||
c->rx_buf_num -= fb;
|
||||
/*
|
||||
* In this example we can assert that c->conn points to valid connection
|
||||
* and 'rx <= c->rx_buf_num'.
|
||||
*/
|
||||
c->rx_buf_num -= rx;
|
||||
|
||||
DBG ("freed %d buffers. %u/%u alloc/free buffers",
|
||||
fb, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
|
||||
rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
|
||||
|
||||
icmpr_tx_burst (c->tx_qid);
|
||||
|
||||
@ -327,9 +330,9 @@ error:
|
||||
err = memif_refill_queue (c->conn, qid, rx, 0);
|
||||
if (err != MEMIF_ERR_SUCCESS)
|
||||
INFO ("memif_buffer_free: %s", memif_strerror (err));
|
||||
c->rx_buf_num -= fb;
|
||||
c->rx_buf_num -= rx;
|
||||
DBG ("freed %d buffers. %u/%u alloc/free buffers",
|
||||
fb, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
|
||||
rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user