mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-26 06:41:03 +08:00
Problem: accept4 not available on all platforms
Solution: check for availability in CMake and autoconf before using it
This commit is contained in:
parent
0d0d72e836
commit
ac552ba448
@ -236,6 +236,10 @@ set (CMAKE_REQUIRED_INCLUDES stdlib.h)
|
||||
check_function_exists (mkdtemp HAVE_MKDTEMP)
|
||||
set (CMAKE_REQUIRED_INCLUDES)
|
||||
|
||||
set (CMAKE_REQUIRED_INCLUDES sys/socket.h)
|
||||
check_function_exists (accept4 HAVE_ACCEPT4)
|
||||
set (CMAKE_REQUIRED_INCLUDES)
|
||||
|
||||
add_definitions (-D_REENTRANT -D_THREAD_SAFE)
|
||||
add_definitions (-DZMQ_CUSTOM_PLATFORM_HPP)
|
||||
|
||||
|
3
NEWS
3
NEWS
@ -212,6 +212,9 @@
|
||||
|
||||
* Fixed #2809 - optimize select() usage on Windows
|
||||
|
||||
* Fixed #2816 - add CMake and autoconf check for accept4, as it is not
|
||||
available on old Linux releases, and fallback to accept + FD_CLOEXEC
|
||||
|
||||
* Fixed #2824 - ZMQ_REQ socket does not report ZMQ_POLLOUT when ZMQ_REQ_RELAXED
|
||||
is set
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#cmakedefine ZMQ_HAVE_PTHREAD_SETNAME_2
|
||||
#cmakedefine ZMQ_HAVE_PTHREAD_SETNAME_3
|
||||
#cmakedefine ZMQ_HAVE_PTHREAD_SET_NAME
|
||||
#cmakedefine HAVE_ACCEPT4
|
||||
|
||||
#cmakedefine ZMQ_HAVE_OPENPGM
|
||||
#cmakedefine ZMQ_MAKE_VALGRIND_HAPPY
|
||||
|
@ -71,6 +71,7 @@
|
||||
# define ZMQ_HAVE_UIO 1
|
||||
# define HAVE_CLOCK_GETTIME 1
|
||||
# define HAVE_FORK 1
|
||||
# define HAVE_ACCEPT4 1
|
||||
|
||||
#else
|
||||
# error "No platform defined, abandoning"
|
||||
|
@ -621,7 +621,7 @@ AC_LANG_POP([C++])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs fork posix_memalign mkdtemp)
|
||||
AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs fork posix_memalign mkdtemp accept4)
|
||||
AC_CHECK_HEADERS([alloca.h])
|
||||
|
||||
# pthread_setname is non-posix, and there are at least 4 different implementations
|
||||
|
@ -382,7 +382,7 @@ zmq::fd_t zmq::ipc_listener_t::accept ()
|
||||
// The situation where connection cannot be accepted due to insufficient
|
||||
// resources is considered valid and treated by ignoring the connection.
|
||||
zmq_assert (s != retired_fd);
|
||||
#if defined ZMQ_HAVE_SOCK_CLOEXEC
|
||||
#if defined ZMQ_HAVE_SOCK_CLOEXEC && defined HAVE_ACCEPT4
|
||||
fd_t sock = ::accept4 (s, NULL, NULL, SOCK_CLOEXEC);
|
||||
#else
|
||||
fd_t sock = ::accept (s, NULL, NULL);
|
||||
@ -394,7 +394,7 @@ zmq::fd_t zmq::ipc_listener_t::accept ()
|
||||
return retired_fd;
|
||||
}
|
||||
|
||||
#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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user