Skip to content

Commit aa32796

Browse files
committed
examples/zcrx: RQ flush
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
1 parent dd047ec commit aa32796

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

examples/zcrx.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,26 @@ static inline void fill_rqe(const struct io_uring_cqe *cqe,
401401
rqe->len = cqe->res;
402402
}
403403

404-
static void return_buffer(struct io_uring_zcrx_rq *rq_ring,
404+
static void return_buffer(struct io_uring *ring,
405+
struct io_uring_zcrx_rq *rq_ring,
405406
const struct io_uring_cqe *cqe)
406407
{
407408
struct io_uring_zcrx_rqe *rqe;
408409
unsigned rq_mask;
409410

410411
if (rq_nr_queued(rq_ring) == rq_ring->ring_entries) {
411-
printf("refill queue is full, drop the buffer\n");
412-
return;
412+
struct zcrx_ctrl ctrl = {
413+
.zcrx_id = zcrx_id,
414+
.op = ZCRX_CTRL_FLUSH_RQ,
415+
};
416+
int ret;
417+
418+
ret = io_uring_register(ring->ring_fd, IORING_REGISTER_ZCRX_CTRL,
419+
&ctrl, 0);
420+
if (rq_nr_queued(rq_ring) == rq_ring->ring_entries) {
421+
printf("RQ is full, drop the buffer (%i)\n", ret);
422+
return;
423+
}
413424
}
414425

415426
rq_mask = rq_ring->ring_entries - 1;
@@ -473,7 +484,7 @@ static void process_recvzc(struct io_uring *ring,
473484

474485
verify_data(data, cqe->res, conn->received);
475486
conn->received += cqe->res;
476-
return_buffer(&rq_ring, cqe);
487+
return_buffer(ring, &rq_ring, cqe);
477488
}
478489

479490
static void server_loop(struct io_uring *ring)

0 commit comments

Comments
 (0)