From d474c7a6d3e2f458ec067172f4193e094d5cdde6 Mon Sep 17 00:00:00 2001 From: hno <> Date: Sun, 10 Jun 2007 18:07:28 +0000 Subject: [PATCH] Clean up configure magics selecting which comm loop to use, promote epoll to stable This is basically a copy from Squid-2, making configure a bit smarter in selecting which comm loop to use, and automatically enabling epoll if it seems usable. kqueue is still not activated automatically even if defected as the comm_kqueue implementation is still experimental and known to have issues --- configure.in | 94 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 79 insertions(+), 15 deletions(-) diff --git a/configure.in b/configure.in index 71d5d6f187..36b19aa04f 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl Configuration input file for Squid dnl -dnl $Id: configure.in,v 1.456 2007/06/02 23:46:00 hno Exp $ +dnl $Id: configure.in,v 1.457 2007/06/10 12:07:28 hno Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AM_CONFIG_HEADER(include/autoconf.h) AC_CONFIG_AUX_DIR(cfgaux) AC_CONFIG_SRCDIR([src/main.cc]) AM_INIT_AUTOMAKE([tar-ustar]) -AC_REVISION($Revision: 1.456 $)dnl +AC_REVISION($Revision: 1.457 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -1060,6 +1060,7 @@ AC_ARG_ENABLE(poll, yes) echo "Forcing poll() to be enabled" ac_cv_func_poll='yes' + SELECT_TYPE="poll" ;; no) echo "Forcing poll() to be disabled" @@ -1078,6 +1079,7 @@ AC_ARG_ENABLE(select, yes) echo "Forcing select() to be enabled" ac_cv_func_select='yes' + SELECT_TYPE="select" ;; no) echo "Forcing select() to be disabled" @@ -1096,6 +1098,7 @@ AC_ARG_ENABLE(kqueue, yes) echo "Forcing kqueue() to be enabled" ac_cv_func_kqueue='yes' + SELECT_TYPE="kqueue" ;; no) echo "Forcing kqueue() to be disabled" @@ -1113,11 +1116,12 @@ AC_ARG_ENABLE(epoll, case "$enableval" in yes) echo "Forcing epoll() to be enabled" - ac_cv_func_epoll='yes' + ac_cv_func_epoll_ctl='yes' + SELECT_TYPE="epoll" ;; no) echo "Forcing epoll() to be disabled" - ac_cv_func_epoll='no' + ac_cv_func_epoll_ctl='no' ;; esac ]) @@ -2569,6 +2573,7 @@ AC_CHECK_FUNCS(\ gettimeofday \ htobe16 \ htole16 \ + kqueue\ lrand48 \ mallinfo \ mallocblksize \ @@ -2612,32 +2617,64 @@ AC_CHECK_FUNCS(\ vsnprintf \ ) +# Check for libepoll +EPOLL_LIB= +AC_CHECK_LIB(epoll, epoll_ctl, [EPOLL_LIBS="-lepoll"]) +AC_SUBST(EPOLL_LIBS) + +# Check for epoll_ctl, may need -lepoll +SAVED_LIBS="$LIBS" +LIBS="$LIBS $LIB_EPOLL" +AC_CHECK_FUNCS(epoll_ctl) +LIBS="$SAVED_LIBS" + +dnl Verify that epoll really works +if test $ac_cv_func_epoll_ctl = yes; then + AC_CACHE_CHECK(if epoll works, ac_cv_epoll_works, + AC_TRY_RUN([ +#include +#include +#include +int main(int argc, char **argv) +{ + int fd = epoll_create(256); + if (fd < 0) { + perror("epoll_create:"); + exit(1); + } + exit(0); +} + ], [ac_cv_epoll_works=yes], [ac_cv_epoll_works=no])) + if test ac_cv_epoll_works = no && test ac_force_epoll = yes; then + echo "Error - no epoll found"; + echo "Try running 'sh ./scripts/get_epoll-lib.sh'"; + echo "then run configure again"; + exit -1 + fi +fi + dnl Magic which checks whether we are forcing a type of comm loop we dnl are actually going to (ab)use dnl Actually do the define magic now dnl mostly ripped from squid-commloops, thanks to adrian and benno -if test "$ac_cv_func_kqueue" = "yes" ; then - SELECT_TYPE="kqueue" - AC_DEFINE(USE_KQUEUE,1,[Use kqueue() for the IO loop]) -elif test "$ac_cv_func_epoll" = "yes" ; then +if test -n "$SELECT_TYPE"; then + : # Already decided above. Nothing to do here +elif test "$ac_cv_epoll_works" = "yes" ; then SELECT_TYPE="epoll" - AC_DEFINE(USE_EPOLL,1,[Use epoll() for the IO loop]) - AC_CHECK_LIB(epoll, epoll_create, [EPOLL_LIBS="-lepoll"]) - AC_SUBST(EPOLL_LIBS) +#comm_kqueue a bit broken. Don't enable automatically +#elif test "$ac_cv_func_kqueue" = "yes" ; then +# SELECT_TYPE="kqueue" elif test "$ac_cv_func_poll" = "yes" ; then SELECT_TYPE="poll" - AC_DEFINE(USE_POLL,1,[Use poll() for the IO loop]) elif test "$ac_cv_func_select" = "yes" ; then case "$host_os" in mingw|mingw32) SELECT_TYPE="select_win32" - AC_DEFINE(USE_SELECT_WIN32,1,[Use Winsock select() for the IO loop]) ;; *) SELECT_TYPE="select" - AC_DEFINE(USE_SELECT,1,[Use select() for the IO loop]) ;; esac else @@ -2646,7 +2683,34 @@ else SELECT_TYPE="select" AC_DEFINE(USE_SELECT,1) fi -echo "Using ${SELECT_TYPE} for select loop." + +echo "Using ${SELECT_TYPE} for the IO loop." + +AM_CONDITIONAL([USE_POLL], [test $SELECT_TYPE = poll]) +AM_CONDITIONAL([USE_EPOLL], [test $SELECT_TYPE = epoll]) +AM_CONDITIONAL([USE_SELECT], [test $SELECT_TYPE = select]) +AM_CONDITIONAL([USE_SELECT_SIMPLE], [test $SELECT_TYPE = select_simple]) +AM_CONDITIONAL([USE_SELECT_WIN32], [test $SELECT_TYPE = select_win32]) +AM_CONDITIONAL([USE_KQUEUE], [test $SELECT_TYPE = kqueue]) +AM_CONDITIONAL([USE_DEVPOLL], [test $SELECT_TYPE = devpoll]) + +case $SELECT_TYPE in +epoll) + AC_DEFINE(USE_EPOLL,1,[Use epoll() for the IO loop]) + ;; +poll) + AC_DEFINE(USE_POLL,1,[Use poll() for the IO loop]) + ;; +kqueue) + AC_DEFINE(USE_KQUEUE,1,[Use kqueue() for the IO loop]) + ;; +select_win32) + AC_DEFINE(USE_SELECT_WIN32,1,[Use Winsock select() for the IO loop]) + ;; +select) + AC_DEFINE(USE_SELECT,1,[Use select() for the IO loop]) + ;; +esac dnl Yay! Another Linux brokenness. Its not good enough -- 2.47.2