On Thu, Aug 03, 2006 at 01:45:44AM +0200, Luigi Gangitano wrote:
> Il giorno 02/ago/06, alle ore 22:48, Steve Langasek ha scritto:
> >On Wed, Aug 02, 2006 at 11:56:45AM +0200, Luigi Gangitano wrote:
> >>Could user application 'deal somehow' with 2.4 kernels making the
> >>administrator aware that they will need a 2.6 kernel to work at all?
> >When will you make the administrator aware of this that won't make the
> >upgrade path ugly?
> >- if you error out in the preinst, the old version of squid continues
> > running, but the dist-upgrade will break in the middle
> >- if you error out in the postinst, the dist-upgrade completes, but
> >the
> > administrator may then be looking at unexpected downtime related
> >to trying
> > to upgrade the kernel before squid will run again
> Could it be stated in the Release Notes? Something like 'Upgrading
> from sarge with a 2.4 kernel expect some daemons to stop working
> until a new kernel is installed'.
As mentioned, the release notes are not a reliable method of communicating
with our users because users take a perverse pleasure in not looking at the
documentation until *after* something breaks.
> >>In alternative a new comm module based on libevent could be added.
> >>libevent would support both epoll() and poll() and is in debian as of
> >>now. I don't have the skills to create such a patch, but would
> >>happily propose it upstream and include in the debian package.
> >Well, unlike the patch I just created, writing this would require
> >understanding the APIs of both libevent and squid's internal comm
> >interface.
> >That would take a bit longer to write & debug, compared with just
> >providing
> >a basic plugin interface. <shrug>
> I simply gave you the answer I got from upstream when asking for the
> same question. libevent was easier and preferred.
> Can I have a look at your patch and, if you will, permission to
> submit it upstream?
Absolutely. A preliminary patch is attached; if upstream is interested in
this approach, please give me the opportunity to clean it up a bit more and
port all of the comm implementations to it, but otherwise you may consider
it available under the same license as squid itself.
Cheers,
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
[EMAIL PROTECTED] http://www.debian.org/
#! /bin/sh /usr/share/dpatch/dpatch-run
## epoll,-its-whats-for-dinner.dpatch by Steve Langasek <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: support for building in more than one select interface at a time
## DP: and switching between them at runtime
@DPATCH@
diff -urNad squid-2.6.1~/src/Makefile.am squid-2.6.1/src/Makefile.am
--- squid-2.6.1~/src/Makefile.am 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/Makefile.am 2006-08-02 03:11:11.000000000 -0700
@@ -62,20 +62,19 @@
WIN32SOURCE =
endif
+if USE_SELECT_WIN32
+COMMLOOP_SOURCE = comm_select_win32.c
+else
+COMMLOOP_SOURCE = comm_select.c
+endif
if USE_POLL
-COMMLOOP_SOURCE = comm_poll.c
+COMMLOOP_SOURCE += comm_poll.c
endif
if USE_EPOLL
-COMMLOOP_SOURCE = comm_epoll.c
-endif
-if USE_SELECT
-COMMLOOP_SOURCE = comm_select.c
-endif
-if USE_SELECT_WIN32
-COMMLOOP_SOURCE = comm_select_win32.c
+COMMLOOP_SOURCE += comm_epoll.c
endif
if USE_KQUEUE
-COMMLOOP_SOURCE = comm_kqueue.c
+COMMLOOP_SOURCE += comm_kqueue.c
endif
SUBDIRS = fs repl auth
diff -urNad squid-2.6.1~/src/Makefile.in squid-2.6.1/src/Makefile.in
--- squid-2.6.1~/src/Makefile.in 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/Makefile.in 2006-08-02 03:11:11.000000000 -0700
@@ -17,7 +17,7 @@
#
# Makefile for the Squid Object Cache server
#
-# $Id: Makefile.in,v 1.272 2006/06/12 06:10:08 hno Exp $
+# $Id: Makefile.am,v 1.51 2006/06/11 17:06:25 serassio Exp $
#
# Uncomment and customize the following to suit your needs:
#
@@ -45,6 +45,9 @@
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
[EMAIL PROTECTED]@am__append_1 = comm_poll.c
[EMAIL PROTECTED]@am__append_2 = comm_epoll.c
[EMAIL PROTECTED]@am__append_3 = comm_kqueue.c
EXTRA_PROGRAMS = unlinkd$(EXEEXT) pinger$(EXEEXT) dnsserver$(EXEEXT)
noinst_PROGRAMS = cf_gen$(EXEEXT)
sbin_PROGRAMS = squid$(EXEEXT)
@@ -83,8 +86,8 @@
pinger_DEPENDENCIES =
am__squid_SOURCES_DIST = access_log.c acl.c asn.c authenticate.c \
cache_cf.c CacheDigest.c cache_manager.c carp.c cbdata.c \
- client_db.c client_side.c comm.c comm_epoll.c comm_kqueue.c \
- comm_poll.c comm_select.c comm_select_win32.c debug.c \
+ client_db.c client_side.c comm.c comm_select.c comm_poll.c \
+ comm_epoll.c comm_kqueue.c comm_select_win32.c debug.c \
defines.h delay_pools.c disk.c dns_internal.c dns.c enums.h \
errorpage.c event.c errormap.c external_acl.c fd.c filemap.c \
forward.c fqdncache.c ftp.c globals.h gopher.c helper.c htcp.c \
@@ -102,39 +105,42 @@
store_rebuild.c store_swapin.c store_swapmeta.c \
store_swapout.c structs.h tools.c typedefs.h unlinkd.c url.c \
urn.c useragent.c wais.c wccp.c wccp2.c whois.c win32.c
[EMAIL PROTECTED]@@USE_KQUEUE_FALSE@@USE_POLL_FALSE@@USE_SELECT_FALSE@@[EMAIL
PROTECTED] = comm_select_win32.$(OBJEXT)
[EMAIL PROTECTED]@@USE_KQUEUE_FALSE@@USE_POLL_FALSE@@[EMAIL PROTECTED] =
comm_select.$(OBJEXT)
[EMAIL PROTECTED]@@USE_KQUEUE_FALSE@@[EMAIL PROTECTED] = comm_poll.$(OBJEXT)
[EMAIL PROTECTED]@@[EMAIL PROTECTED] = \
[EMAIL PROTECTED]@@USE_KQUEUE_TRUE@ comm_kqueue.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_1 = comm_epoll.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_2 = delay_pools.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_3 = dns_internal.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_3 = dns.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_4 = htcp.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_5 = leakfinder.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_6 = snmp_core.$(OBJEXT) \
[EMAIL PROTECTED]@am__objects_1 = comm_poll.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_2 = comm_epoll.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_3 = comm_kqueue.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_4 = comm_select.$(OBJEXT) \
[EMAIL PROTECTED]@ $(am__objects_1) $(am__objects_2) \
[EMAIL PROTECTED]@ $(am__objects_3)
[EMAIL PROTECTED]@am__objects_4 = comm_select_win32.$(OBJEXT) \
[EMAIL PROTECTED]@ $(am__objects_1) $(am__objects_2) \
[EMAIL PROTECTED]@ $(am__objects_3)
[EMAIL PROTECTED]@am__objects_5 = delay_pools.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_6 = dns_internal.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_6 = dns.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_7 = htcp.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_8 = leakfinder.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_9 = snmp_core.$(OBJEXT) \
@USE_SNMP_TRUE@ snmp_agent.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_7 = ssl_support.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_8 = unlinkd.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_9 = win32.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_10 = ssl_support.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_11 = unlinkd.$(OBJEXT)
[EMAIL PROTECTED]@am__objects_12 = win32.$(OBJEXT)
am_squid_OBJECTS = access_log.$(OBJEXT) acl.$(OBJEXT) asn.$(OBJEXT) \
authenticate.$(OBJEXT) cache_cf.$(OBJEXT) \
CacheDigest.$(OBJEXT) cache_manager.$(OBJEXT) carp.$(OBJEXT) \
cbdata.$(OBJEXT) client_db.$(OBJEXT) client_side.$(OBJEXT) \
- comm.$(OBJEXT) $(am__objects_1) debug.$(OBJEXT) \
- $(am__objects_2) disk.$(OBJEXT) $(am__objects_3) \
+ comm.$(OBJEXT) $(am__objects_4) debug.$(OBJEXT) \
+ $(am__objects_5) disk.$(OBJEXT) $(am__objects_6) \
errorpage.$(OBJEXT) event.$(OBJEXT) errormap.$(OBJEXT) \
external_acl.$(OBJEXT) fd.$(OBJEXT) filemap.$(OBJEXT) \
forward.$(OBJEXT) fqdncache.$(OBJEXT) ftp.$(OBJEXT) \
- gopher.$(OBJEXT) helper.$(OBJEXT) $(am__objects_4) \
+ gopher.$(OBJEXT) helper.$(OBJEXT) $(am__objects_7) \
http.$(OBJEXT) HttpStatusLine.$(OBJEXT) HttpHdrCc.$(OBJEXT) \
HttpHdrRange.$(OBJEXT) HttpHdrContRange.$(OBJEXT) \
HttpHeader.$(OBJEXT) HttpHeaderTools.$(OBJEXT) \
HttpBody.$(OBJEXT) HttpMsg.$(OBJEXT) HttpReply.$(OBJEXT) \
HttpRequest.$(OBJEXT) icmp.$(OBJEXT) icp_v2.$(OBJEXT) \
icp_v3.$(OBJEXT) ident.$(OBJEXT) internal.$(OBJEXT) \
- ipc.$(OBJEXT) ipcache.$(OBJEXT) $(am__objects_5) \
+ ipc.$(OBJEXT) ipcache.$(OBJEXT) $(am__objects_8) \
locrewrite.$(OBJEXT) logfile.$(OBJEXT) main.$(OBJEXT) \
mem.$(OBJEXT) MemPool.$(OBJEXT) MemBuf.$(OBJEXT) \
mime.$(OBJEXT) multicast.$(OBJEXT) neighbors.$(OBJEXT) \
@@ -142,17 +148,17 @@
peer_digest.$(OBJEXT) peer_monitor.$(OBJEXT) \
peer_select.$(OBJEXT) peer_sourcehash.$(OBJEXT) \
peer_userhash.$(OBJEXT) redirect.$(OBJEXT) referer.$(OBJEXT) \
- refresh.$(OBJEXT) send-announce.$(OBJEXT) $(am__objects_6) \
- ssl.$(OBJEXT) $(am__objects_7) stat.$(OBJEXT) \
+ refresh.$(OBJEXT) send-announce.$(OBJEXT) $(am__objects_9) \
+ ssl.$(OBJEXT) $(am__objects_10) stat.$(OBJEXT) \
StatHist.$(OBJEXT) String.$(OBJEXT) stmem.$(OBJEXT) \
store.$(OBJEXT) store_io.$(OBJEXT) store_client.$(OBJEXT) \
store_digest.$(OBJEXT) store_dir.$(OBJEXT) \
store_key_md5.$(OBJEXT) store_log.$(OBJEXT) \
store_rebuild.$(OBJEXT) store_swapin.$(OBJEXT) \
store_swapmeta.$(OBJEXT) store_swapout.$(OBJEXT) \
- tools.$(OBJEXT) $(am__objects_8) url.$(OBJEXT) urn.$(OBJEXT) \
+ tools.$(OBJEXT) $(am__objects_11) url.$(OBJEXT) urn.$(OBJEXT) \
useragent.$(OBJEXT) wais.$(OBJEXT) wccp.$(OBJEXT) \
- wccp2.$(OBJEXT) whois.$(OBJEXT) $(am__objects_9)
+ wccp2.$(OBJEXT) whois.$(OBJEXT) $(am__objects_12)
nodist_squid_OBJECTS = repl_modules.$(OBJEXT) auth_modules.$(OBJEXT) \
store_modules.$(OBJEXT) globals.$(OBJEXT) \
string_arrays.$(OBJEXT)
@@ -242,6 +248,7 @@
EXEEXT = @EXEEXT@
EXTERNAL_ACL_HELPERS = @EXTERNAL_ACL_HELPERS@
FALSE = @FALSE@
+GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -325,8 +332,6 @@
XTRA_LIBS = @XTRA_LIBS@
XTRA_OBJS = @XTRA_OBJS@
ac_ct_CC = @ac_ct_CC@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
@@ -341,24 +346,31 @@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
+htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
+localedir = @localedir@
localstatedir = @localstatedir@
makesnmplib = @makesnmplib@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
+psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
@@ -384,11 +396,12 @@
@[EMAIL PROTECTED] = ssl_support.c
@[EMAIL PROTECTED] =
@[EMAIL PROTECTED] = win32.c
[EMAIL PROTECTED]@COMMLOOP_SOURCE = comm_epoll.c
[EMAIL PROTECTED]@COMMLOOP_SOURCE = comm_kqueue.c
[EMAIL PROTECTED]@COMMLOOP_SOURCE = comm_poll.c
[EMAIL PROTECTED]@COMMLOOP_SOURCE = comm_select.c
[EMAIL PROTECTED]@COMMLOOP_SOURCE = comm_select_win32.c
[EMAIL PROTECTED]@COMMLOOP_SOURCE = comm_select.c \
[EMAIL PROTECTED]@ $(am__append_1) $(am__append_2) \
[EMAIL PROTECTED]@ $(am__append_3)
[EMAIL PROTECTED]@COMMLOOP_SOURCE = comm_select_win32.c \
[EMAIL PROTECTED]@ $(am__append_1) $(am__append_2) \
[EMAIL PROTECTED]@ $(am__append_3)
SUBDIRS = fs repl auth
INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
cf_gen_SOURCES = cf_gen.c defines.h debug.c
@@ -622,9 +635,9 @@
exit 1;; \
esac; \
done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
cd $(top_srcdir) && \
- $(AUTOMAKE) --foreign src/Makefile
+ $(AUTOMAKE) --gnu src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
diff -urNad squid-2.6.1~/src/client_side.c squid-2.6.1/src/client_side.c
--- squid-2.6.1~/src/client_side.c 2006-08-02 03:11:11.000000000 -0700
+++ squid-2.6.1/src/client_side.c 2006-08-02 03:11:11.000000000 -0700
@@ -3785,7 +3785,7 @@
ConnStateData *conn = data;
if (conn->body.size_left && !F->flags.socket_eof) {
if (conn->in.offset >= conn->in.size - 1) {
- commDeferFD(fd);
+ comm->deferfd(fd);
return 1;
} else {
return 0;
@@ -3794,7 +3794,7 @@
if (conn->defer.until > squid_curtime) {
/* This is a second resolution timer, so commEpollBackon will
* handle the resume for this defer call */
- commDeferFD(fd);
+ comm->deferfd(fd);
return 1;
} else {
return 0;
@@ -4205,7 +4205,7 @@
conn->in.offset -= size;
/* Resume the fd if necessary */
if (conn->in.offset < conn->in.size - 1)
- commResumeFD(conn->fd);
+ comm->resumefd(conn->fd);
if (conn->in.offset > 0)
xmemmove(conn->in.buf, conn->in.buf + size, conn->in.offset);
/* Remove request link if this is the last part of the body, as
diff -urNad squid-2.6.1~/src/comm.c squid-2.6.1/src/comm.c
--- squid-2.6.1~/src/comm.c 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/comm.c 2006-08-02 03:11:11.000000000 -0700
@@ -345,7 +345,7 @@
return 0;
}
/* We are about to close the fd (dup2 over it). Unregister from the event
loop */
- commSetEvents(cs->fd, 0, 0);
+ comm->setEvents(cs->fd, 0, 0);
#ifdef _SQUID_MSWIN_
/* On Windows dup2() can't work correctly on Sockets, the */
/* workaround is to close the destination Socket before call them. */
@@ -831,7 +831,7 @@
break;
}
}
- commSetEvents(fd, need_read, need_write);
+ comm->setEvents(fd, need_read, need_write);
}
void
@@ -1179,3 +1179,31 @@
}
}
}
+
+static comm_interface_t *select_implementations[] = {
+#ifdef USE_EPOLL
+ &comm_epoll,
+#endif
+#ifdef USE_KQUEUE
+ &comm_kqueue,
+#endif
+#ifdef USE_POLL
+ &comm_poll,
+#endif
+ &comm_default,
+ NULL
+};
+
+comm_interface_t *comm_select_init(void)
+{
+ int i;
+
+ for (i = 0; select_implementations[i]; i++) {
+ if (select_implementations[i]->init())
+ return select_implementations[i];
+ }
+ fatalf("comm_select_init: no support found for polling file
descriptors\n");
+
+ return NULL;
+}
+
diff -urNad squid-2.6.1~/src/comm.h squid-2.6.1/src/comm.h
--- squid-2.6.1~/src/comm.h 1969-12-31 16:00:00.000000000 -0800
+++ squid-2.6.1/src/comm.h 2006-08-02 03:11:11.000000000 -0700
@@ -0,0 +1,17 @@
+typedef struct {
+ int (*init)();
+ void (*shutdown)();
+ void (*setEvents)(int,int,int);
+ int (*select)(int);
+ void (*quick_poll_required)();
+ void (*deferfd)(int);
+ void (*resumefd)(int);
+} comm_interface_t;
+
+extern comm_interface_t *comm;
+
+#ifdef USE_EPOLL
+extern comm_interface_t comm_epoll;
+#endif
+
+extern comm_interface_t comm_default;
diff -urNad squid-2.6.1~/src/comm_epoll.c squid-2.6.1/src/comm_epoll.c
--- squid-2.6.1~/src/comm_epoll.c 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/comm_epoll.c 2006-08-02 03:11:11.000000000 -0700
@@ -65,19 +65,22 @@
}
}
-void
+static int
comm_select_init()
{
kdpfd = epoll_create(Squid_MaxFD);
- if (kdpfd < 0)
- fatalf("comm_select_init: epoll_create(): %s\n", xstrerror());
+ if (kdpfd < 0) {
+ fprintf(debug_log,"comm_select_init: epoll_create(): %s\n",
xstrerror());
+ return 0;
+ }
fd_open(kdpfd, FD_UNKNOWN, "epoll ctl");
commSetCloseOnExec(kdpfd);
epoll_state = xcalloc(Squid_MaxFD, sizeof(*epoll_state));
+ return 1;
}
-void
+static void
comm_select_shutdown()
{
fd_close(kdpfd);
@@ -86,7 +89,7 @@
safe_free(epoll_state);
}
-void
+static void
commSetEvents(int fd, int need_read, int need_write)
{
int epoll_ctl_type = 0;
@@ -141,7 +144,7 @@
}
}
-int
+static int
comm_select(int msec)
{
static time_t last_timeout = 0;
@@ -196,3 +199,13 @@
return COMM_TIMEOUT;
}
}
+
+comm_interface_t comm_epoll = {
+ comm_select_init,
+ comm_select_shutdown,
+ commSetEvents,
+ comm_select,
+ comm_quick_poll_required,
+ commDeferFD,
+ commResumeFD,
+};
diff -urNad squid-2.6.1~/src/comm_generic.c squid-2.6.1/src/comm_generic.c
--- squid-2.6.1~/src/comm_generic.c 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/comm_generic.c 2006-08-02 03:11:11.000000000 -0700
@@ -40,7 +40,7 @@
static int MAX_POLL_TIME = 1000; /* see also comm_quick_poll_required()
*/
/* Defer reads from this fd */
-void
+static void
commDeferFD(int fd)
{
fde *F = &fd_table[fd];
@@ -56,7 +56,7 @@
}
/* Resume reading from the given fd */
-void
+static void
commResumeFD(int fd)
{
fde *F = &fd_table[fd];
@@ -198,7 +198,7 @@
/* Called by async-io or diskd to speed up the polling */
-void
+static void
comm_quick_poll_required(void)
{
MAX_POLL_TIME = 10;
diff -urNad squid-2.6.1~/src/comm_kqueue.c squid-2.6.1/src/comm_kqueue.c
--- squid-2.6.1~/src/comm_kqueue.c 2006-08-02 03:11:11.000000000 -0700
+++ squid-2.6.1/src/comm_kqueue.c 2006-08-02 03:11:11.000000000 -0700
@@ -42,11 +42,13 @@
#if defined (__FreeBSD_kernel__) && defined (__GLIBC__)
#include <sys/syscall.h>
+static
int kqueue(void)
{
return syscall(SYS_kqueue);
};
+static
int kevent(int kq, struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents,
const struct timespec *timeout)
@@ -68,7 +70,7 @@
static int kqoff; /* offset into the buffer */
static unsigned *kqueue_state; /* keep track of the kqueue state */
-void
+static void
comm_select_init()
{
kq = kqueue();
@@ -83,7 +85,7 @@
zero_timespec.tv_nsec = 0;
}
-void
+static void
comm_select_shutdown()
{
fd_close(kq);
@@ -92,7 +94,7 @@
safe_free(kqueue_state);
}
-void
+static void
commSetEvents(int fd, int need_read, int need_write)
{
struct kevent *kep;
@@ -129,7 +131,7 @@
}
}
-int
+static int
comm_select(int msec)
{
static time_t last_timeout = 0;
@@ -200,3 +202,14 @@
statCounter.select_time += (current_dtime - start);
return COMM_OK;
}
+
+comm_interface_t comm_kqueue = {
+ comm_select_init,
+ comm_select_shutdown,
+ commSetEvents,
+ comm_select,
+ comm_quick_poll_required,
+ commDeferFD,
+ commResumeFD,
+};
+
diff -urNad squid-2.6.1~/src/comm_select.c squid-2.6.1/src/comm_select.c
--- squid-2.6.1~/src/comm_select.c 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/comm_select.c 2006-08-02 03:11:39.000000000 -0700
@@ -288,7 +288,7 @@
#define DEBUG_FDBITS 0
/* Select on all sockets; call handlers for those that are ready. */
-int
+static int
comm_select(int msec)
{
fd_set readfds;
@@ -555,7 +555,7 @@
statHistCount(&statCounter.comm_dns_incoming, nevents);
}
-void
+static int
comm_select_init(void)
{
zero_tv.tv_sec = 0;
@@ -566,9 +566,10 @@
FD_ZERO(&global_readfds);
FD_ZERO(&global_writefds);
nreadfds = nwritefds = 0;
+ return 1;
}
-void
+static void
comm_select_shutdown(void)
{
}
@@ -659,7 +660,7 @@
statHistDump(&f->comm_http_incoming, sentry, statHistIntDumper);
}
-void
+static void
commSetEvents(int fd, int need_read, int need_write)
{
if (need_read && !FD_ISSET(fd, &global_readfds)) {
@@ -716,22 +717,33 @@
/* Called by async-io or diskd to speed up the polling */
-void
+static void
comm_quick_poll_required(void)
{
MAX_POLL_TIME = 10;
}
/* Defer reads from this fd */
-void
+static void
commDeferFD(int fd)
{
/* Not implemented */
}
/* Resume reading from the given fd */
-void
+static void
commResumeFD(int fd)
{
/* Not implemented */
}
+
+comm_interface_t comm_default = {
+ comm_select_init,
+ comm_select_shutdown,
+ commSetEvents,
+ comm_select,
+ comm_quick_poll_required,
+ commDeferFD,
+ commResumeFD,
+};
+
diff -urNad squid-2.6.1~/src/fd.c squid-2.6.1/src/fd.c
--- squid-2.6.1~/src/fd.c 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/fd.c 2006-08-02 03:11:11.000000000 -0700
@@ -90,7 +90,7 @@
assert(F->write_handler == NULL);
}
debug(51, 3) ("fd_close FD %d %s\n", fd, F->desc);
- commSetEvents(fd, 0, 0);
+ comm->setEvents(fd, 0, 0);
F->flags.open = 0;
fdUpdateBiggest(fd, 0);
Number_FD--;
diff -urNad squid-2.6.1~/src/forward.c squid-2.6.1/src/forward.c
--- squid-2.6.1~/src/forward.c 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/forward.c 2006-08-02 03:11:11.000000000 -0700
@@ -904,7 +904,7 @@
* Will get changed the day delay pools interact nicely
* with the store..
*/
- commDeferFD(fd);
+ comm->deferfd(fd);
return 1;
}
/* was: rc = -(rc != INT_MAX); */
@@ -915,7 +915,7 @@
}
#endif
if (EBIT_TEST(e->flags, ENTRY_DEFER_READ)) {
- commDeferFD(mem->serverfd);
+ comm->deferfd(mem->serverfd);
return 1;
}
if (EBIT_TEST(e->flags, ENTRY_FWD_HDR_WAIT))
diff -urNad squid-2.6.1~/src/fs/diskd/store_dir_diskd.c
squid-2.6.1/src/fs/diskd/store_dir_diskd.c
--- squid-2.6.1~/src/fs/diskd/store_dir_diskd.c 2006-08-02 03:06:31.000000000
-0700
+++ squid-2.6.1/src/fs/diskd/store_dir_diskd.c 2006-08-02 03:11:11.000000000
-0700
@@ -435,7 +435,7 @@
started_clean_event = 1;
}
(void) storeDirGetBlkSize(sd->path, &sd->fs.blksize);
- comm_quick_poll_required();
+ comm->quick_poll_required();
}
diff -urNad squid-2.6.1~/src/main.c squid-2.6.1/src/main.c
--- squid-2.6.1~/src/main.c 2006-08-02 03:11:11.000000000 -0700
+++ squid-2.6.1/src/main.c 2006-08-02 03:11:11.000000000 -0700
@@ -81,6 +81,8 @@
static void mainSetCwd(void);
static int checkRunningPid(void);
+comm_interface_t *comm;
+
#ifndef _SQUID_MSWIN_
static const char *squid_start_script = "squid_start";
#endif
@@ -781,7 +783,7 @@
#if TEST_ACCESS
comm_init();
- comm_select_init();
+ comm = comm_select_init();
mainInitialize();
test_access();
return 0;
@@ -816,7 +818,7 @@
/* init comm module */
comm_init();
- comm_select_init();
+ comm = comm_select_init();
if (opt_no_daemon) {
/* we have to init fdstat here. */
@@ -858,7 +860,7 @@
eventRun();
if ((loop_delay = eventNextTime()) < 0)
loop_delay = 0;
- switch (comm_select(loop_delay)) {
+ switch (comm->select(loop_delay)) {
case COMM_OK:
errcount = 0; /* reset if successful */
break;
@@ -1160,7 +1162,7 @@
fd_close(2);
}
#endif
- comm_select_shutdown();
+ comm->shutdown();
fdDumpOpen();
fdFreeMemory();
memClean();
diff -urNad squid-2.6.1~/src/protos.h squid-2.6.1/src/protos.h
--- squid-2.6.1~/src/protos.h 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/protos.h 2006-08-02 03:11:11.000000000 -0700
@@ -161,8 +161,6 @@
extern int comm_openex(int, int, struct in_addr, u_short, int, unsigned char
TOS, const char *);
extern u_short comm_local_port(int fd);
-extern void commDeferFD(int fd);
-extern void commResumeFD(int fd);
extern void commSetSelect(int, unsigned int, PF *, void *, time_t);
extern void comm_add_close_handler(int fd, PF *, void *);
extern void comm_remove_close_handler(int fd, PF *, void *);
@@ -184,13 +182,9 @@
/*
* comm_select.c
*/
-extern void comm_select_shutdown(void);
-extern int comm_select(int);
extern void commUpdateEvents(int fd);
-extern void commSetEvents(int fd, int need_read, int need_write);
extern void commUpdateReadHandler(int, PF *, void *);
extern void commUpdateWriteHandler(int, PF *, void *);
-extern void comm_quick_poll_required(void);
extern void packerToStoreInit(Packer * p, StoreEntry * e);
extern void packerToMemInit(Packer * p, MemBuf * mb);
diff -urNad squid-2.6.1~/src/squid.h squid-2.6.1/src/squid.h
--- squid-2.6.1~/src/squid.h 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/squid.h 2006-08-02 03:11:11.000000000 -0700
@@ -395,6 +395,8 @@
#include "Stack.h"
+#include "comm.h"
+
/* Needed for poll() on Linux at least */
#if USE_POLL
#ifndef POLLRDNORM
diff -urNad squid-2.6.1~/src/ssl.c squid-2.6.1/src/ssl.c
--- squid-2.6.1~/src/ssl.c 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/ssl.c 2006-08-02 03:11:11.000000000 -0700
@@ -139,7 +139,7 @@
if (i == INT_MAX)
return 0;
if (i == 0) {
- commDeferFD(fd);
+ comm->deferfd(fd);
return 1;
}
return -1;
diff -urNad squid-2.6.1~/src/store.c squid-2.6.1/src/store.c
--- squid-2.6.1~/src/store.c 2006-08-02 03:06:31.000000000 -0700
+++ squid-2.6.1/src/store.c 2006-08-02 03:11:11.000000000 -0700
@@ -1952,7 +1952,7 @@
EBIT_SET(e->flags, ENTRY_DEFER_READ);
if (fd >= 0) {
mem->serverfd = fd;
- commDeferFD(fd);
+ comm->deferfd(fd);
}
}
@@ -1963,7 +1963,7 @@
MemObject *mem = e->mem_obj;
EBIT_CLR(e->flags, ENTRY_DEFER_READ);
if (mem->serverfd != -1) {
- commResumeFD(mem->serverfd);
+ comm->resumefd(mem->serverfd);
mem->serverfd = -1;
}
}