mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-26 23:01:04 +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)
|
check_function_exists (mkdtemp HAVE_MKDTEMP)
|
||||||
set (CMAKE_REQUIRED_INCLUDES)
|
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 (-D_REENTRANT -D_THREAD_SAFE)
|
||||||
add_definitions (-DZMQ_CUSTOM_PLATFORM_HPP)
|
add_definitions (-DZMQ_CUSTOM_PLATFORM_HPP)
|
||||||
|
|
||||||
|
3
NEWS
3
NEWS
@ -212,6 +212,9 @@
|
|||||||
|
|
||||||
* Fixed #2809 - optimize select() usage on Windows
|
* 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
|
* Fixed #2824 - ZMQ_REQ socket does not report ZMQ_POLLOUT when ZMQ_REQ_RELAXED
|
||||||
is set
|
is set
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#cmakedefine ZMQ_HAVE_PTHREAD_SETNAME_2
|
#cmakedefine ZMQ_HAVE_PTHREAD_SETNAME_2
|
||||||
#cmakedefine ZMQ_HAVE_PTHREAD_SETNAME_3
|
#cmakedefine ZMQ_HAVE_PTHREAD_SETNAME_3
|
||||||
#cmakedefine ZMQ_HAVE_PTHREAD_SET_NAME
|
#cmakedefine ZMQ_HAVE_PTHREAD_SET_NAME
|
||||||
|
#cmakedefine HAVE_ACCEPT4
|
||||||
|
|
||||||
#cmakedefine ZMQ_HAVE_OPENPGM
|
#cmakedefine ZMQ_HAVE_OPENPGM
|
||||||
#cmakedefine ZMQ_MAKE_VALGRIND_HAPPY
|
#cmakedefine ZMQ_MAKE_VALGRIND_HAPPY
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
# define ZMQ_HAVE_UIO 1
|
# define ZMQ_HAVE_UIO 1
|
||||||
# define HAVE_CLOCK_GETTIME 1
|
# define HAVE_CLOCK_GETTIME 1
|
||||||
# define HAVE_FORK 1
|
# define HAVE_FORK 1
|
||||||
|
# define HAVE_ACCEPT4 1
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# error "No platform defined, abandoning"
|
# error "No platform defined, abandoning"
|
||||||
|
@ -621,7 +621,7 @@ AC_LANG_POP([C++])
|
|||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_TYPE_SIGNAL
|
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])
|
AC_CHECK_HEADERS([alloca.h])
|
||||||
|
|
||||||
# pthread_setname is non-posix, and there are at least 4 different implementations
|
# 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
|
// The situation where connection cannot be accepted due to insufficient
|
||||||
// resources is considered valid and treated by ignoring the connection.
|
// resources is considered valid and treated by ignoring the connection.
|
||||||
zmq_assert (s != retired_fd);
|
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);
|
fd_t sock = ::accept4 (s, NULL, NULL, SOCK_CLOEXEC);
|
||||||
#else
|
#else
|
||||||
fd_t sock = ::accept (s, NULL, NULL);
|
fd_t sock = ::accept (s, NULL, NULL);
|
||||||
@ -394,7 +394,7 @@ zmq::fd_t zmq::ipc_listener_t::accept ()
|
|||||||
return retired_fd;
|
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
|
// Race condition can cause socket not to be closed (if fork happens
|
||||||
// between accept and this point).
|
// between accept and this point).
|
||||||
int rc = fcntl (sock, F_SETFD, FD_CLOEXEC);
|
int rc = fcntl (sock, F_SETFD, FD_CLOEXEC);
|
||||||
|
@ -281,7 +281,7 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
|
|||||||
#else
|
#else
|
||||||
socklen_t ss_len = sizeof (ss);
|
socklen_t ss_len = sizeof (ss);
|
||||||
#endif
|
#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);
|
fd_t sock = ::accept4 (s, (struct sockaddr *) &ss, &ss_len, SOCK_CLOEXEC);
|
||||||
#else
|
#else
|
||||||
fd_t sock = ::accept (s, (struct sockaddr *) &ss, &ss_len);
|
fd_t sock = ::accept (s, (struct sockaddr *) &ss, &ss_len);
|
||||||
@ -311,7 +311,7 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
// Race condition can cause socket not to be closed (if fork happens
|
||||||
// between accept and this point).
|
// between accept and this point).
|
||||||
int rc = fcntl (sock, F_SETFD, FD_CLOEXEC);
|
int rc = fcntl (sock, F_SETFD, FD_CLOEXEC);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user