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

Function main

test/socket-rw-eagain.c:23–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21#include "helpers.h"
22
23int main(int argc, char *argv[])
24{
25 int p_fd[2], ret;
26 int32_t recv_s0;
27 int32_t val = 1;
28 struct sockaddr_in addr;
29 struct iovec iov_r[1], iov_w[1];
30
31 if (argc > 1)
32 return 0;
33
34 srand(getpid());
35
36 recv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
37
38 ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
39 assert(ret != -1);
40 ret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
41 assert(ret != -1);
42
43 addr.sin_family = AF_INET;
44 addr.sin_addr.s_addr = inet_addr("127.0.0.1");
45 ret = t_bind_ephemeral_port(recv_s0, &addr);
46 assert(!ret);
47 ret = listen(recv_s0, 128);
48 assert(ret != -1);
49
50 p_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
51
52 val = 1;
53 ret = setsockopt(p_fd[1], IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
54 assert(ret != -1);
55
56 t_set_nonblock(p_fd[1]);
57
58 ret = connect(p_fd[1], (struct sockaddr*)&addr, sizeof(addr));
59 assert(ret == -1);
60
61 p_fd[0] = accept(recv_s0, NULL, NULL);
62 assert(p_fd[0] != -1);
63
64 t_set_nonblock(p_fd[0]);
65
66 while (1) {
67 int32_t code;
68 socklen_t code_len = sizeof(code);
69
70 ret = getsockopt(p_fd[1], SOL_SOCKET, SO_ERROR, &code, &code_len);
71 assert(ret != -1);
72
73 if (!code)
74 break;
75 }
76
77 struct io_uring m_io_uring;
78 struct io_uring_params p = { };
79
80 ret = io_uring_queue_init_params(32, &m_io_uring, &p);

Callers

nothing calls this directly

Calls 6

t_bind_ephemeral_portFunction · 0.85
t_set_nonblockFunction · 0.85
io_uring_submit_and_waitFunction · 0.85
io_uring_queue_exitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected