MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / accept

Function accept

net/basic_socket.cpp:115–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115int accept(int fd, struct sockaddr *addr, socklen_t *addrlen,
116 Timeout timeout) {
117#ifdef __APPLE__
118 auto ret = DOIO_ONCE(::accept(fd, addr, addrlen),
119 wait_for_fd_readable(fd, timeout));
120 if (ret > 0) {
121 set_fd_nonblocking(ret);
122 int val = 1;
123 ::setsockopt(ret, SOL_SOCKET, SO_NOSIGPIPE, (void*)&val, sizeof(val));
124 }
125 return ret;
126#else
127 return DOIO_ONCE(::accept4(fd, addr, addrlen, SOCK_NONBLOCK),
128 wait_for_fd_readable(fd, timeout));
129#endif
130}
131
132ssize_t read(int fd, void *buf, size_t count, Timeout timeout) {
133 return DOIO_ONCE(::read(fd, buf, count), wait_for_fd_readable(fd, timeout));

Callers 6

do_acceptMethod · 0.85
accept_loopMethod · 0.85
test_socket_serverFunction · 0.85
accept_loopMethod · 0.85
serverFunction · 0.85
st_acceptFunction · 0.85

Calls 2

set_fd_nonblockingFunction · 0.85
wait_for_fd_readableFunction · 0.50

Tested by 1

test_socket_serverFunction · 0.68