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

Function do_test_inet_send

test/send-zerocopy.c:308–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306};
307
308static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_server,
309 struct send_conf *conf)
310{
311 struct iovec iov[MAX_IOV];
312 struct msghdr msghdr[CORK_REQS];
313 const unsigned zc_flags = 0;
314 struct io_uring_sqe *sqe;
315 struct io_uring_cqe *cqe;
316 int nr_reqs = conf->cork ? CORK_REQS : 1;
317 int i, ret, nr_cqes, addr_len = 0;
318 size_t send_size = buffers_iov[conf->buf_index].iov_len;
319 size_t chunk_size = send_size / nr_reqs;
320 size_t chunk_size_last = send_size - chunk_size * (nr_reqs - 1);
321 char *buf = buffers_iov[conf->buf_index].iov_base;
322
323 assert(MAX_IOV >= CORK_REQS);
324
325 if (conf->addr) {
326 sa_family_t fam = ((struct sockaddr_in *)conf->addr)->sin_family;
327
328 addr_len = (fam == AF_INET) ? sizeof(struct sockaddr_in) :
329 sizeof(struct sockaddr_in6);
330 }
331
332 memset(rx_buffer, 0, send_size);
333
334 for (i = 0; i < nr_reqs; i++) {
335 bool real_fixed_buf = conf->fixed_buf;
336 size_t cur_size = chunk_size;
337 int msg_flags = MSG_WAITALL;
338
339 if (conf->mix_register)
340 real_fixed_buf = rand() & 1;
341
342 if (i != nr_reqs - 1)
343 msg_flags |= MSG_MORE;
344 else
345 cur_size = chunk_size_last;
346
347 sqe = io_uring_get_sqe(ring);
348
349 if (!conf->use_sendmsg) {
350 if (conf->zc) {
351 io_uring_prep_send_zc(sqe, sock_client, buf + i * chunk_size,
352 cur_size, msg_flags, zc_flags);
353 } else {
354 io_uring_prep_send(sqe, sock_client, buf + i * chunk_size,
355 cur_size, msg_flags);
356 }
357
358 if (real_fixed_buf) {
359 sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
360 sqe->buf_index = conf->buf_index;
361 }
362 if (conf->addr)
363 io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)conf->addr,
364 addr_len);
365 } else {

Callers 1

test_inet_sendFunction · 0.85

Calls 2

io_uring_submitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by 1

test_inet_sendFunction · 0.68