From b9e671c0f5354cd31f08611aba6677f80473f023 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 1 Jan 2013 21:01:34 -0700 Subject: [PATCH] kqueue: update status from experimental to fully available net I/O method kqueue has been in use on FreeBSD and maybe others for some time now and has less bugs than epoll. So the issues on record should not be held against it. The attached patch adds auto-detection for the kqueue dependencies and enables it by default when it can build. Unfortunately due to the dependencies we cannot add it to maximus layer for force-enable, but the default layer will test it on FreeBSD at least. It is still less preferred than epoll(), but more than select() and poll(). Also fixes bug 3716 "build error on FreeBSD in kqueue" --- configure.ac | 30 ++++++++++++++++++++---------- src/comm/ModKqueue.cc | 1 + 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index ec671e6f71..b84eca8fd2 100644 --- a/configure.ac +++ b/configure.ac @@ -1313,18 +1313,29 @@ test "x$enableval" = "xyes" && squid_opt_io_loop_engine="poll" ]) AC_MSG_NOTICE([enabling poll syscall for net I/O: ${enable_poll:=auto}]) -# kqueue support is still experiemntal and unstable. Not enabled by default. AC_ARG_ENABLE(kqueue, - AS_HELP_STRING([--enable-kqueue], - [Enable kqueue(2) support (experimental).]), [ + AS_HELP_STRING([--disable-kqueue], + [Disable kqueue(2) support.]), [ SQUID_YESNO($enableval,[--enable-kqueue takes no extra argument]) ]) -if test "x${enable_kqueue:=no}" = "xyes" ; then - AC_CHECK_HEADERS([sys/event.h],[], - [ AC_MSG_ERROR([kqueue support requires sys/event.h header file.]) ]) - squid_opt_io_loop_engine="kqueue" +if test "x${enable_kqueue:=auto}" != "xno" ; then + AC_CHECK_HEADERS([sys/event.h],[],[ + if test "x${enable_kqueue}" = "xyes" ; then + AC_MSG_ERROR([kqueue support requires sys/event.h header file.]) + fi + ]) + AC_CHECK_FUNCS(kqueue,[],[ + if test "x${enable_kqueue}" = "xyes" ; then + AC_MSG_ERROR([kqueue support missing in libc library.]) + fi + ]) + if test "x$ac_cv_func_kqueue" = "xyes" -a "x$ac_cv_header_sys_event_h" = "xyes" ; then + squid_opt_io_loop_engine="kqueue" + else + enable_kqueue="no" + fi fi -AC_MSG_NOTICE([enabling kqueue for net I/O: $enable_kqueue]) +AC_MSG_NOTICE([enabling kqueue for net I/O: ${enable_kqueue:=auto}]) dnl Enable epoll() AC_ARG_ENABLE(epoll, @@ -3160,7 +3171,6 @@ AC_CHECK_FUNCS(\ glob \ htobe16 \ htole16 \ - kqueue\ lrand48 \ mallinfo \ mallocblksize \ @@ -3228,7 +3238,7 @@ if test "x$squid_opt_io_loop_engine" != "x"; then AC_MSG_NOTICE([choosing user-specified net I/O API $squid_opt_io_loop_engine]) elif test "x$enable_epoll" != "xno" -a "x$squid_cv_epoll_works" = "xyes" ; then squid_opt_io_loop_engine="epoll" -elif test "x$enable_kqueue" != "xno" -a "x$ac_cv_func_kqueue" = "xyes" ; then +elif test "x$enable_kqueue" != "xno" ; then squid_opt_io_loop_engine="kqueue" elif test "x$enable_devpoll" != "xno" ; then squid_opt_io_loop_engine="devpoll" diff --git a/src/comm/ModKqueue.cc b/src/comm/ModKqueue.cc index e8703c612c..8b722246db 100644 --- a/src/comm/ModKqueue.cc +++ b/src/comm/ModKqueue.cc @@ -55,6 +55,7 @@ #if USE_KQUEUE #include "comm/Loops.h" #include "fde.h" +#include "globals.h" #include "SquidTime.h" #include "StatCounters.h" #include "Store.h" -- 2.47.2