AC_C_ENDIAN
+AX_CHECK_SOCK_CLOEXEC([AC_DEFINE([HAVE_SOCK_CLOEXEC], [1], [Check for SOCK_CLOEXEC.])],
+ [AC_DEFINE([HAVE_SOCK_CLOEXEC], [0], [Check for SOCK_CLOEXEC.])])
+
AC_CONFIG_FILES([
Makefile
docs/conf.py
#include <ctime>
#include <sys/time.h>
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 0
+#endif
+
static memcached_return_t connect_poll(memcached_server_st *server)
{
struct pollfd fds[1];
continue;
}
+ int type= server->address_info_next->ai_socktype;
+ if (HAVE_SOCK_CLOEXEC)
+ {
+ type|= SOCK_CLOEXEC;
+ }
+
if ((server->fd= socket(server->address_info_next->ai_family,
- server->address_info_next->ai_socktype,
+ type,
server->address_info_next->ai_protocol)) < 0)
{
return memcached_set_errno(*server, get_socket_errno(), NULL);
}
+ if (HAVE_SOCK_CLOEXEC == 0)
+ {
+#ifdef FD_CLOEXEC
+ int rval;
+ do
+ {
+ rval= fcntl (server->fd, F_SETFD, FD_CLOEXEC);
+ } while (rval == -1 && (errno == EINTR or errno == EAGAIN));
+#endif
+ }
+
set_socket_options(server);
/* connect to server */
--- /dev/null
+dnl CHECK_SOCK_CLOEXEC([action-if-found], [action-if-not-found])
+AC_DEFUN([AX_CHECK_SOCK_CLOEXEC], [{
+ AC_MSG_CHECKING(whether SOCK_CLOEXEC is supported)
+ AC_TRY_RUN([/* SOCK_CLOEXEC test */
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int main (int argc, char *argv [])
+{
+ int s= socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ return (s == -1);
+}
+ ],
+ [AC_MSG_RESULT(yes) ; ax_cv_sock_cloexec="yes" ; $1],
+ [AC_MSG_RESULT(no) ; ax_cv_sock_cloexec="no" ; $2],
+ [AC_MSG_RESULT(not during cross-compile) ; ax_cv_sock_cloexec="no"]
+ )
+}])