mirror of
https://github.com/zeromq/libzmq.git
synced 2025-11-06 21:56:25 +01:00
Problem: accept4 not available on all platforms
Solution: check for availability in CMake and autoconf before using it
This commit is contained in:
@@ -281,7 +281,7 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
|
||||
#else
|
||||
socklen_t ss_len = sizeof (ss);
|
||||
#endif
|
||||
#if defined ZMQ_HAVE_SOCK_CLOEXEC
|
||||
#if defined ZMQ_HAVE_SOCK_CLOEXEC && defined HAVE_ACCEPT4
|
||||
fd_t sock = ::accept4 (s, (struct sockaddr *) &ss, &ss_len, SOCK_CLOEXEC);
|
||||
#else
|
||||
fd_t sock = ::accept (s, (struct sockaddr *) &ss, &ss_len);
|
||||
@@ -311,7 +311,7 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined ZMQ_HAVE_SOCK_CLOEXEC && defined FD_CLOEXEC
|
||||
#if (!defined ZMQ_HAVE_SOCK_CLOEXEC || !defined HAVE_ACCEPT4) && defined FD_CLOEXEC
|
||||
// Race condition can cause socket not to be closed (if fork happens
|
||||
// between accept and this point).
|
||||
int rc = fcntl (sock, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
Reference in New Issue
Block a user