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

Function rcv

test/232c93d07b74.c:61–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61static void *rcv(void *arg)
62{
63 struct params *p = arg;
64 int s0;
65 int res;
66
67 if (p->tcp) {
68 int ret, val = 1;
69
70 s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
71 res = setsockopt(s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
72 assert(res != -1);
73 res = setsockopt(s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
74 assert(res != -1);
75
76 struct sockaddr_in addr;
77
78 addr.sin_family = AF_INET;
79 addr.sin_addr.s_addr = inet_addr("127.0.0.1");
80 ret = t_bind_ephemeral_port(s0, &addr);
81 assert(!ret);
82 p->bind_port = addr.sin_port;
83 } else {
84 s0 = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
85 assert(s0 != -1);
86
87 struct sockaddr_un addr;
88 memset(&addr, 0, sizeof(addr));
89
90 addr.sun_family = AF_UNIX;
91 memcpy(addr.sun_path, "\0sock", 6);
92 res = bind(s0, (struct sockaddr *) &addr, sizeof(addr));
93 assert(res != -1);
94 }
95 res = listen(s0, 128);
96 assert(res != -1);
97
98 set_rcv_ready();
99
100 int s1 = accept(s0, NULL, NULL);
101 assert(s1 != -1);
102
103 if (p->non_blocking)
104 t_set_nonblock(s1);
105
106 struct io_uring m_io_uring;
107 void *ret = NULL;
108
109 res = io_uring_queue_init(32, &m_io_uring, 0);
110 assert(res >= 0);
111
112 int bytes_read = 0;
113 int expected_byte = 0;
114 int done = 0;
115
116 while (!done && bytes_read != 33) {
117 char buff[RECV_BUFF_SIZE];
118 struct iovec iov;

Callers

nothing calls this directly

Calls 7

t_bind_ephemeral_portFunction · 0.85
set_rcv_readyFunction · 0.85
t_set_nonblockFunction · 0.85
io_uring_queue_initFunction · 0.85
io_uring_submitFunction · 0.85
io_uring_queue_exitFunction · 0.85
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected