MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / accept

Function accept

src/remote/inet.cpp:3407–3429  ·  view source on GitHub ↗

force socket descriptor to have SOCK_CLOEXEC set

Source from the content-addressed store, hash-verified

3405
3406// force socket descriptor to have SOCK_CLOEXEC set
3407SOCKET accept(SOCKET sockfd, struct sockaddr* addr, socklen_t* addrlen)
3408{
3409#ifdef WIN_NT
3410 return ::accept(sockfd, addr, addrlen);
3411#else
3412 int fd;
3413#if defined(HAVE_ACCEPT4) && HAVE_DECL_SOCK_CLOEXEC
3414 do {
3415 fd = ::accept4(sockfd, addr, addrlen, SOCK_CLOEXEC);
3416 } while (fd < 0 && SYSCALL_INTERRUPTED(errno));
3417
3418 if (fd < 0 && errno == EINVAL) // probably SOCK_CLOEXEC not accepted
3419#endif
3420 {
3421 do {
3422 fd = ::accept(sockfd, addr, addrlen);
3423 } while (fd < 0 && SYSCALL_INTERRUPTED(errno));
3424 }
3425
3426 setCloseOnExec(fd);
3427 return fd;
3428#endif
3429}
3430
3431} // namespace os_utils

Callers 5

listener_socketFunction · 0.70
aux_connectFunction · 0.70
select_acceptFunction · 0.70
acceptMethod · 0.70
authenticateMethod · 0.50

Calls 1

setCloseOnExecFunction · 0.85

Tested by

no test coverage detected