commit - ee568cc4440015b45d7fd12b00974c4d1fba658c
commit + 5c782302835e19ac1373ccd574070b8ff9003517
blob - e16e248444a455aca7319c6340fadf08df013d25
blob + f723e2bcf516da90ad3c99989b7d0f691b7ec00b
--- ChangeLog
+++ ChangeLog
ngIRCd HEAD
+ - When using epoll() IO interface, compile in the select() interface as
+ well and fall back to it when epoll() isn't available on runtime.
+ - New configure option "--without-select" to disable select() IO API
+ (even when using epoll(), see above).
- Added support for IO APIs "poll()" and "/dev/poll".
- Reorganized internal handling of invite and ban lists.
--
-$Id: ChangeLog,v 1.311 2006/12/17 21:00:30 alex Exp $
+$Id: ChangeLog,v 1.312 2006/12/26 16:00:45 alex Exp $
blob - 9b2c7128fa259c642d4d199b665a8380ca6a6a7d
blob + 51841e7a862ac236c42867833b6ca7d736d724a7
--- configure.in
+++ configure.in
# (at your option) any later version.
# Please read the file COPYING, README and AUTHORS for more information.
#
-# $Id: configure.in,v 1.124 2006/10/02 21:57:13 fw Exp $
+# $Id: configure.in,v 1.125 2006/12/26 16:00:45 alex Exp $
#
# -- Initialisation --
AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat)
-AC_CHECK_FUNCS(select,[AC_CHECK_HEADERS(sys/select.h)],
- AC_MSG_ERROR([required function select() is missing!])
-)
-
# -- Configuration options --
+# use syslog?
+
x_syslog_on=no
AC_ARG_WITH(syslog,
[ --without-syslog disable syslog (autodetected by default)],
AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
fi
+# use zlib compression?
+
x_zlib_on=no
AC_ARG_WITH(zlib,
[ --without-zlib disable zlib compression (autodetected by default)],
AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
fi
+# detect which IO API to use:
-x_io_backend=select\(\)
+x_io_backend=none
+
+AC_ARG_WITH(select,
+ [ --without-select disable select IO support (autodetected by default)],
+ [ if test "$withval" != "no"; then
+ if test "$withval" != "yes"; then
+ CFLAGS="-I$withval/include $CFLAGS"
+ CPPFLAGS="-I$withval/include $CPPFLAGS"
+ LDFLAGS="-L$withval/lib $LDFLAGS"
+ fi
+ AC_CHECK_FUNCS(select, x_io_select=yes,
+ AC_MSG_ERROR([Can't enable select IO support!])
+ )
+ fi
+ ],
+ [
+ AC_CHECK_FUNCS(select, x_io_select=yes)
+ ]
+)
+
AC_ARG_WITH(poll,
[ --without-poll disable poll support (autodetected by default)],
[ if test "$withval" != "no"; then
LDFLAGS="-L$withval/lib $LDFLAGS"
fi
AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
- AC_MSG_ERROR([Can't enable poll support!])
+ AC_MSG_ERROR([Can't enable poll IO support!])
)
fi
],
]
)
-
AC_ARG_WITH(devpoll,
- [ --without-devpoll disable /dev/poll support (autodetected by default)],
+ [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
[ if test "$withval" != "no"; then
if test "$withval" != "yes"; then
CFLAGS="-I$withval/include $CFLAGS"
fi
],
[
- AC_CHECK_HEADERS(sys/devpoll.h,x_io_backend=/dev/poll,)
+ AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
]
)
AC_ARG_WITH(epoll,
- [ --without-epoll disable epoll support (autodetected by default)],
+ [ --without-epoll disable epoll IO support (autodetected by default)],
[ if test "$withval" != "no"; then
if test "$withval" != "yes"; then
CFLAGS="-I$withval/include $CFLAGS"
CPPFLAGS="-I$withval/include $CPPFLAGS"
LDFLAGS="-L$withval/lib $LDFLAGS"
fi
- AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll\(\),
- AC_MSG_ERROR([Can't enable epoll support!])
+ AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
+ AC_MSG_ERROR([Can't enable epoll IO support!])
)
fi
],
[
- AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll\(\))
+ AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
]
)
-
AC_ARG_WITH(kqueue,
- [ --without-kqueue disable kqueue support (autodetected by default)],
+ [ --without-kqueue disable kqueue IO support (autodetected by default)],
[ if test "$withval" != "no"; then
if test "$withval" != "yes"; then
CFLAGS="-I$withval/include $CFLAGS"
LDFLAGS="-L$withval/lib $LDFLAGS"
fi
AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
- AC_MSG_ERROR([Can't enable kqueue support!])
+ AC_MSG_ERROR([Can't enable kqueue IO support!])
)
fi
],
AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
]
)
+
+if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
+ # when epoll() and select() are available, we'll use both!
+ x_io_backend="epoll(), select()"
+else
+ if test "$x_io_epoll" = "yes"; then
+ # we prefere epoll() if it is available
+ x_io_backend="epoll()"
+ else
+ if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
+ # we'll use select, when available and no "better"
+ # interface has been detected ...
+ x_io_backend="select()"
+ fi
+ fi
+fi
+if test "$x_io_backend" = "none"; then
+ AC_MSG_ERROR([No useabe IO API activated/found!?])
+fi
+# use TCP wrappers?
+
x_tcpwrap_on=no
AC_ARG_WITH(tcp-wrappers,
[ --with-tcp-wrappers enable TCP wrappers support],
fi
]
)
+
+# include support for "zeroconf"?
x_zeroconf_on=no
AC_ARG_WITH(zeroconf,
AC_DEFINE(ZEROCONF, 1)
fi
+# do IDENT requests using libident?
+
x_identauth_on=no
AC_ARG_WITH(ident,
[ --with-ident enable "IDENT" ("AUTH") protocol support],
AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
fi
+# compile in IRC+ protocol support?
+
x_ircplus_on=yes
AC_ARG_ENABLE(ircplus,
[ --disable-ircplus disable IRC+ protocol],
AC_DEFINE(IRCPLUS, 1)
fi
+# compile in IRC "sniffer"?
+
x_sniffer_on=no; x_debug_on=no
AC_ARG_ENABLE(sniffer,
[ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
fi
)
+# enable additional debugging code?
+
AC_ARG_ENABLE(debug,
[ --enable-debug show additional debug output],
if test "$enableval" = "yes"; then x_debug_on=yes; fi
test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
fi
+# enable "strict RFC rules"?
+
x_strict_rfc_on=no
AC_ARG_ENABLE(strict-rfc,
[ --enable-strict-rfc strict RFC conformance -- may break clients!],
blob - 61f73fdb2614991bb261faeded5c752b46170e79
blob + 71ec3b40ccc2c5035d224d1bc37da021b6ecf7ce
--- src/ngircd/io.c
+++ src/ngircd/io.c
#include "portab.h"
-static char UNUSED id[] = "$Id: io.c,v 1.22 2006/12/16 22:48:34 fw Exp $";
+static char UNUSED id[] = "$Id: io.c,v 1.23 2006/12/26 16:00:46 alex Exp $";
#include <assert.h>
#include <stdlib.h>
short what;
} io_event;
-#define INIT_IOEVENT { NULL, -1, 0, NULL }
-#define IO_ERROR 4
+#define INIT_IOEVENT { NULL, -1, 0, NULL }
+#define IO_ERROR 4
#ifdef HAVE_EPOLL_CREATE
-#define IO_USE_EPOLL 1
+# define IO_USE_EPOLL 1
+# ifdef HAVE_SELECT
+# define IO_USE_SELECT 1
+# endif
#else
-# ifdef HAVE_KQUEUE
-#define IO_USE_KQUEUE 1
-# else
-# ifdef HAVE_SYS_DEVPOLL_H
-#define IO_USE_DEVPOLL 1
-# else
-# ifdef HAVE_POLL
-#define IO_USE_POLL 1
+# ifdef HAVE_KQUEUE
+# define IO_USE_KQUEUE 1
+# else
+# ifdef HAVE_SYS_DEVPOLL_H
+# define IO_USE_DEVPOLL 1
+# else
+# ifdef HAVE_POLL
+# define IO_USE_POLL 1
+# else
+# ifdef HAVE_SELECT
+# define IO_USE_SELECT 1
# else
-#define IO_USE_SELECT 1
+# error "no IO API available!?"
+# endif /* HAVE_SELECT */
# endif /* HAVE_POLL */
# endif /* HAVE_SYS_DEVPOLL_H */
-# endif /* HAVE_KQUEUE */
+# endif /* HAVE_KQUEUE */
#endif /* HAVE_EPOLL_CREATE */
-static bool library_initialized;
+static bool library_initialized = false;
#ifdef IO_USE_EPOLL
#include <sys/epoll.h>
-static int io_masterfd;
+static int io_masterfd = -1;
static bool io_event_change_epoll(int fd, short what, const int action);
static int io_dispatch_epoll(struct timeval *tv);
#endif
static fd_set writers;
static int select_maxfd; /* the select() interface sucks badly */
static int io_dispatch_select(struct timeval *tv);
+
+#ifndef IO_USE_EPOLL
+#define io_masterfd -1
#endif
+#endif /* IO_USE_SELECT */
static array io_events;
if (ecreate_hint <= 0)
ecreate_hint = 128;
io_masterfd = epoll_create(ecreate_hint);
- Log(LOG_INFO,
- "IO subsystem: epoll (hint size %d, initial maxfd %u, masterfd %d).",
- ecreate_hint, eventsize, io_masterfd);
- if (io_masterfd >= 0)
+ if (io_masterfd >= 0) {
library_initialized = true;
+ Log(LOG_INFO,
+ "IO subsystem: epoll (hint size %d, initial maxfd %u, masterfd %d).",
+ ecreate_hint, eventsize, io_masterfd);
+ }
}
#endif
eventsize = 0;
#ifdef IO_USE_EPOLL
io_library_init_epoll(eventsize);
+#ifdef IO_USE_SELECT
+ if (io_masterfd < 0)
+ Log(LOG_INFO, "Can't initialize epoll() IO interface, falling back to select() ...");
#endif
+#endif
#ifdef IO_USE_KQUEUE
io_library_init_kqueue(eventsize);
#endif
io_library_init_poll(eventsize);
#endif
#ifdef IO_USE_SELECT
- io_library_init_select(eventsize);
+ if (! library_initialized)
+ io_library_init_select(eventsize);
#endif
return library_initialized;
}
FD_ZERO(&writers);
#endif
#ifdef IO_USE_EPOLL
- close(io_masterfd);
+ if (io_masterfd >= 0)
+ close(io_masterfd);
io_masterfd = -1;
#endif
#ifdef IO_USE_KQUEUE
ret = io_event_change_kqueue(fd, what, EV_ADD|EV_ENABLE);
#endif
#ifdef IO_USE_SELECT
- ret = io_event_add(fd, what);
+ if (io_masterfd < 0)
+ ret = io_event_add(fd, what);
#endif
if (ret) i->what = what;
return ret;
#endif
i->what |= what;
#ifdef IO_USE_EPOLL
- return io_event_change_epoll(fd, i->what, EPOLL_CTL_MOD);
+ if (io_masterfd >= 0)
+ return io_event_change_epoll(fd, i->what, EPOLL_CTL_MOD);
#endif
#ifdef IO_USE_KQUEUE
io_close_select(int fd)
{
io_event *i;
+
+ if (io_masterfd >= 0) /* Are we using epoll()? */
+ return;
+
FD_CLR(fd, &writers);
FD_CLR(fd, &readers);
return io_event_change_poll(fd, i->what);
#endif
#ifdef IO_USE_EPOLL
- return io_event_change_epoll(fd, i->what, EPOLL_CTL_MOD);
+ if (io_masterfd >= 0)
+ return io_event_change_epoll(fd, i->what, EPOLL_CTL_MOD);
#endif
#ifdef IO_USE_KQUEUE
int
io_dispatch(struct timeval *tv)
{
+#ifdef IO_USE_EPOLL
+ if (io_masterfd >= 0)
+ return io_dispatch_epoll(tv);
+#endif
#ifdef IO_USE_SELECT
return io_dispatch_select(tv);
#endif
#ifdef IO_USE_POLL
return io_dispatch_poll(tv);
#endif
-#ifdef IO_USE_EPOLL
- return io_dispatch_epoll(tv);
-#endif
}