Skip to content

Commit

Permalink
examples/proxy: re-arm receive if no new send is prepared
Browse files Browse the repository at this point in the history
We should re-arm the receive if we get -ENOBUFS for a receive even
if there's no send pending, as we may not actually prepare a send.
Check the return value of prep_next_send() to help make that call.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Apr 20, 2024
1 parent bd527a5 commit c18c8fb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,12 @@ static void recv_enobufs(struct io_uring *ring, struct conn *c,
* kick the recv rearm.
*/
if (!is_sink) {
int do_recv_arm = 1;

if (!cd->pending_send)
prep_next_send(ring, c, cd, fd);
do_recv_arm = !prep_next_send(ring, c, cd, fd);
if (do_recv_arm)
__submit_receive(ring, c, &c->cd[0], c->in_fd);
} else {
__submit_receive(ring, c, &c->cd[0], c->in_fd);
}
Expand Down

0 comments on commit c18c8fb

Please sign in to comment.