Commit e76e2f5e authored by Marek Vavrusa's avatar Marek Vavrusa

Do not check for MSG_WAITFORONE as it is not used anymore.

Reverted to usual recvmmsg/sendmmsg availability check.
parent aac3ba49
......@@ -116,33 +116,19 @@ AC_ARG_ENABLE([debuglevel],
;;
esac], [])
AX_MSG_WAITFORONE
# recvmmsg() (valgrind doesn't support it, so disable for debugging)
AC_ARG_ENABLE([recvmmsg],
AS_HELP_STRING([--enable-recvmmsg=yes|no], [enable recvmmsg() network API under Linux (kernel support required) (set to 'no' if you have trouble running server under valgrind) [default=yes]]),
[case "${enableval}" in
yes)
if test "$ax_cv_have_msg_waitforone" = "yes"; then
AC_DEFINE([ENABLE_RECVMMSG], [1], [recvmmsg enabled])
recvmmsg=true
else
recvmmsg=false
fi
AC_CHECK_FUNCS([recvmmsg sendmmsg])
;;
no)
recvmmsg=false
;;
*)
AC_MSG_ERROR([bad value ${enableval} for --enable-recvmmsg])
;;
esac], [
if test "$ax_cv_have_msg_waitforone" = "yes"; then
AC_DEFINE([ENABLE_RECVMMSG], [1], [recvmmsg enabled])
recvmmsg=true
else
recvmmsg=false
fi
])
esac], [ AC_CHECK_FUNCS([recvmmsg sendmmsg]) ])
# Enable integrity check
AC_ARG_ENABLE([integrity-check],
......@@ -302,7 +288,7 @@ AC_TYPE_SSIZE_T
AC_DEFINE([DSFMT_MEXP], [521], [DSFMT parameters])
# Checks for library functions.
AC_CHECK_FUNCS([clock_gettime gettimeofday fgetln getline madvise poll posix_memalign pselect pthread_setaffinity_np regcomp select sendmmsg setgroups])
AC_CHECK_FUNCS([clock_gettime gettimeofday fgetln getline madvise poll posix_memalign pselect pthread_setaffinity_np regcomp select setgroups])
# Check for cpu_set_t/cpuset_t compatibility
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[cpu_set_t set; CPU_ZERO(&set);]])],
......
dnl @synopsis AX_MSG_WAITFORONE
dnl @summary Test if the libc/kernel have working recvmmsg MSG_WAITFORONE implementation
dnl @category Misc
dnl
dnl We need recvmmsg to support MSG_WAITFORONE. RHEL 6 (and derivates)
dnl are know for broken implementation
dnl
dnl @version 2013-03-12
dnl @license GPL
dnl @author Ondřej Surý <ondrej@sury.org> and Marek Vavruša <marek@vavrusa.com>
AC_DEFUN([AX_MSG_WAITFORONE],
[
AC_REQUIRE([AC_PROG_CC])
AC_LANG_PUSH([C])
AC_CACHE_CHECK([for recv_mmsg support], [ax_cv_have_msg_waitforone],
[
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/ip.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
volatile int _intr = 0;
void sighandle(int s) {
_intr = 1;
}
]],[[
#ifndef MSG_WAITFORONE
return 3; /* Not supported. */
#else
int port = 35353;
int fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) return 1;
struct mmsghdr msgs[2];
struct iovec iovecs[2];
char bufs[2][64];
unsigned i = 0;
memset(msgs, 0, sizeof(msgs));
for (i = 0; i < 2; i++) {
iovecs[i].iov_base = bufs[i];
iovecs[i].iov_len = 64;
msgs[i].msg_hdr.msg_iov = &iovecs[i];
msgs[i].msg_hdr.msg_iovlen = 1;
}
struct sockaddr_in sa; /* Bind to socket. */
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
sa.sin_port = htons(port); /* Find free port. */
while (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
if (errno == EADDRINUSE) sa.sin_port = ++port;
else break;
}
int cfd = socket(AF_INET, SOCK_DGRAM, 0); /* Send datagram. */
char pkt[32] = { '\xdf' };
sendto(cfd, pkt, sizeof(pkt), 0, (struct sockaddr*)&sa, sizeof(sa));
/* Broken implementation doesn't respect recvmmsg timeout. */
struct sigaction aset;
memset(&aset, 0, sizeof(struct sigaction));
aset.sa_handler = sighandle;
sigaction(SIGALRM, &aset, NULL);
alarm(1);
int ret = recvmmsg(fd, msgs, 2, MSG_WAITFORONE, NULL);
close(cfd);
close(fd);
if (ret < 0) { /* Completely failed. */
return 2;
}
return _intr; /* OK if not interrupted. */
#endif
]])],
[ax_cv_have_msg_waitforone=yes],
[ax_cv_have_msg_waitforone=no],
[ax_cv_have_msg_waitforone=no])])
AC_LANG_POP([C])
])
......@@ -340,7 +340,7 @@ static int udp_recvfrom_send(void *d)
return 0;
}
#ifdef ENABLE_RECVMMSG
#ifdef HAVE_RECVMMSG
/*! \brief Pointer to selected UDP send implementation. */
static int (*_send_mmsg)(int, sockaddr_t *, struct mmsghdr *, size_t) = 0;
......@@ -370,7 +370,7 @@ static inline int sendmmsg(int fd, struct mmsghdr *mmsg, unsigned vlen,
{
return syscall(SYS_sendmmsg, fd, mmsg, vlen, flags, NULL);
}
#endif
#endif /* HAVE_SENDMMSG */
/*!
* \brief Send multiple packets.
......@@ -382,7 +382,7 @@ int udp_sendmmsg(int sock, sockaddr_t *_, struct mmsghdr *msgs, size_t count)
UNUSED(_);
return sendmmsg(sock, msgs, count, 0);
}
#endif
#endif /* ENABLE_SENDMMSG */
/* UDP recvmmsg() request struct. */
struct udp_recvmmsg {
......@@ -483,7 +483,7 @@ static int udp_recvmmsg_send(void *d)
}
return rc;
}
#endif
#endif /* HAVE_RECVMMSG */
/*! \brief Initialize UDP master routine on run-time. */
void __attribute__ ((constructor)) udp_master_init()
......@@ -496,7 +496,7 @@ void __attribute__ ((constructor)) udp_master_init()
_udp_handle = udp_recvfrom_handle;
/* Optimized functions. */
#ifdef ENABLE_RECVMMSG
#ifdef HAVE_RECVMMSG
/* Check for recvmmsg() support. */
if (dlsym(RTLD_DEFAULT, "recvmmsg") != 0) {
recvmmsg(0, NULL, 0, 0, 0);
......@@ -517,7 +517,7 @@ void __attribute__ ((constructor)) udp_master_init()
_send_mmsg = udp_sendmmsg;
}
#endif /* ENABLE_SENDMMSG */
#endif /* ENABLE_RECVMMSG */
#endif /* HAVE_RECVMMSG */
}
int udp_reader(iohandler_t *h, dthread_t *thread)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment