Skip to content

Commit 5365e40

Browse files
committed
enospace
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
1 parent f5e5910 commit 5365e40

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

examples/zcrx.c

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,20 +330,38 @@ static void return_buffer(struct io_uring_zcrx_rq *rq_ring,
330330
io_uring_smp_store_release(rq_ring->ktail, ++rq_ring->rq_tail);
331331
}
332332

333-
static void process_recvzc(struct io_uring __attribute__((unused)) *ring,
333+
static void process_recvzc_error(struct io_uring *ring, int ret)
334+
{
335+
if (ret == -ENOSPC) {
336+
size_t left = 0;
337+
338+
if (cfg_size) {
339+
left = cfg_size - received;
340+
if (left == 0)
341+
t_error(1, 0, "ENOSPC for a finished request");
342+
}
343+
344+
add_recvzc(ring, connfd, left);
345+
return;
346+
}
347+
348+
if (ret != 0)
349+
t_error(1, 0, "invalid final recvzc ret %i", ret);
350+
if (cfg_size && received != cfg_size)
351+
t_error(1, 0, "total receive size mismatch %lu / %lu",
352+
received, cfg_size);
353+
stop = true;
354+
}
355+
356+
static void process_recvzc(struct io_uring *ring,
334357
struct io_uring_cqe *cqe)
335358
{
336359
const struct io_uring_zcrx_cqe *rcqe;
337360
uint64_t mask;
338361
char *data;
339362

340363
if (!(cqe->flags & IORING_CQE_F_MORE)) {
341-
if (!cfg_size || cqe->res != 0)
342-
t_error(1, 0, "invalid final recvzc ret %i", cqe->res);
343-
if (received != cfg_size)
344-
t_error(1, 0, "total receive size mismatch %lu / %lu",
345-
received, cfg_size);
346-
stop = true;
364+
process_recvzc_error(ring, cqe->res);
347365
return;
348366
}
349367
if (cqe->res < 0)

0 commit comments

Comments
 (0)