MCPcopy Create free account
hub / github.com/axboe/liburing / handle_send_ring

Function handle_send_ring

examples/proxy.c:1549–1588  ·  view source on GitHub ↗

* Handling a send with an outgoing send ring. Get the buffers from the * receive side, and add them to the ingoing buffer ring again. */

Source from the content-addressed store, hash-verified

1547 * receive side, and add them to the ingoing buffer ring again.
1548 */
1549static int handle_send_ring(struct conn *c, struct conn_dir *cd, int bid,
1550 int bytes)
1551{
1552 struct conn_buf_ring *in_cbr = &c->in_br;
1553 struct conn_buf_ring *out_cbr = &c->out_br;
1554 int i = 0;
1555
1556 while (bytes) {
1557 struct io_uring_buf *buf = &out_cbr->br->bufs[bid];
1558 int this_bytes;
1559 void *this_buf;
1560
1561 this_bytes = buf->len;
1562 if (this_bytes > bytes)
1563 this_bytes = bytes;
1564
1565 cd->out_bytes += this_bytes;
1566
1567 vlog("%d: send: bid=%d, len=%d\n", c->tid, bid, this_bytes);
1568
1569 this_buf = in_cbr->buf + bid * buf_size;
1570 io_uring_buf_ring_add(in_cbr->br, this_buf, buf_size, bid, br_mask, i);
1571 /*
1572 * Find the provided buffer that the receive consumed, and
1573 * which we then used for the send, and add it back to the
1574 * pool so it can get picked by another receive. Once the send
1575 * is done, we're done with it.
1576 */
1577 bid = (bid + 1) & (nr_bufs - 1);
1578 bytes -= this_bytes;
1579 i++;
1580 }
1581 cd->snd_next_bid = bid;
1582 io_uring_buf_ring_advance(in_cbr->br, i);
1583
1584 if (pending_shutdown(c))
1585 close_cd(c, cd);
1586
1587 return i;
1588}
1589
1590/*
1591 * sendmsg, or send without a ring. Just add buffers back to the ingoing

Callers 1

__handle_sendFunction · 0.85

Calls 2

pending_shutdownFunction · 0.85
close_cdFunction · 0.85

Tested by

no test coverage detected