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

Function main

test/shutdown.c:28–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

t_bind_ephemeral_portFunction · 0.85
t_set_nonblockFunction · 0.85
t_clear_nonblockFunction · 0.85
io_uring_queue_initFunction · 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