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

Function test_basic_send

test/send-zerocopy.c:116–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116static int test_basic_send(struct io_uring *ring, int sock_tx, int sock_rx,
117 int vec)
118{
119 struct io_uring_sqe *sqe;
120 struct io_uring_cqe *cqe;
121 struct iovec vecs[2];
122 int msg_flags = 0;
123 unsigned zc_flags = 0;
124 int payload_size = 100;
125 int ret;
126
127 if (vec && no_send_vec)
128 return 0;
129
130 sqe = io_uring_get_sqe(ring);
131 if (vec) {
132 size_t split = payload_size / 2;
133
134 vecs[0].iov_base = tx_buffer;
135 vecs[0].iov_len = split;
136 vecs[1].iov_base = tx_buffer + split;
137 vecs[1].iov_len = split;
138 io_uring_prep_send_zc(sqe, sock_tx, vecs, 2, msg_flags, zc_flags);
139 sqe->ioprio |= (1U << 5);
140 } else {
141 io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size,
142 msg_flags, zc_flags);
143 }
144 sqe->user_data = 1;
145
146 ret = io_uring_submit(ring);
147 assert(ret == 1);
148
149 ret = io_uring_wait_cqe(ring, &cqe);
150 assert(!ret && cqe->user_data == 1);
151 if (cqe->res != payload_size) {
152 if (cqe->res == -EINVAL && vec) {
153 int has_more = cqe->flags & IORING_CQE_F_MORE;
154
155 no_send_vec = 1;
156 io_uring_cqe_seen(ring, cqe);
157 if (has_more) {
158 ret = io_uring_peek_cqe(ring, &cqe);
159 if (ret) {
160 fprintf(stderr, "peek failed\n");
161 return T_EXIT_FAIL;
162 }
163 io_uring_cqe_seen(ring, cqe);
164 }
165 return T_EXIT_PASS;
166 }
167 fprintf(stderr, "send failed %i\n", cqe->res);
168 return T_EXIT_FAIL;
169 }
170
171 assert(cqe->flags & IORING_CQE_F_MORE);
172 io_uring_cqe_seen(ring, cqe);
173

Callers 1

run_basic_testsFunction · 0.85

Calls 3

io_uring_submitFunction · 0.85
check_cq_emptyFunction · 0.70
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected