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

Function recv_fn

test/socket.c:125–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123};
124
125static void *recv_fn(void *data)
126{
127 struct recv_data *rd = data;
128 char buf[MAX_MSG + 1];
129 struct iovec iov = {
130 .iov_base = buf,
131 .iov_len = sizeof(buf) - 1,
132 };
133 struct io_uring_params p = { };
134 struct io_uring ring;
135 int ret, sock;
136
137 if (rd->use_sqthread)
138 p.flags = IORING_SETUP_SQPOLL;
139 ret = t_create_ring_params(1, &ring, &p);
140 if (ret == T_SETUP_SKIP) {
141 pthread_mutex_unlock(&rd->mutex);
142 ret = 0;
143 goto err;
144 } else if (ret < 0) {
145 pthread_mutex_unlock(&rd->mutex);
146 goto err;
147 }
148
149 if (rd->use_sqthread && !rd->registerfiles) {
150 if (!(p.features & IORING_FEAT_SQPOLL_NONFIXED)) {
151 fprintf(stdout, "Non-registered SQPOLL not available, skipping\n");
152 pthread_mutex_unlock(&rd->mutex);
153 goto err;
154 }
155 }
156
157 ret = recv_prep(&ring, &iov, &sock, rd->registerfiles);
158 if (ret) {
159 fprintf(stderr, "recv_prep failed: %d\n", ret);
160 goto err;
161 }
162 pthread_mutex_unlock(&rd->mutex);
163 ret = do_recv(&ring, &iov);
164
165 close(sock);
166 io_uring_queue_exit(&ring);
167err:
168 return (void *)(intptr_t)ret;
169}
170
171static int fallback_send(struct io_uring *ring, struct sockaddr_in *saddr)
172{

Callers

nothing calls this directly

Calls 4

t_create_ring_paramsFunction · 0.85
io_uring_queue_exitFunction · 0.85
recv_prepFunction · 0.70
do_recvFunction · 0.70

Tested by

no test coverage detected