The unified diff between revisions [0b1b35ce..] and [14a5ae7c..] is displayed below. It can also be downloaded as a raw diff.
#
#
# add_file "src/comm_kqueue.c"
# content [f513f3b3d07e675ac06e4380826484fe9f061535]
#
# patch "src/client_side.c"
# from [f2f0d2e1e191ffeec9c101a29a66353d9b9cdc0d]
# to [0b08448d363c94b62457c0905f5f31ea7e4d61af]
#
# patch "src/comm.c"
# from [60b1db3bbcf7cf37a4cd94927dcf7ebdcba155f9]
# to [3caa5a087f556b00a76deaef0a5096f42fd4075b]
#
# patch "src/comm_select.c"
# from [16d275ec06f5529b6ed8e6cd5387b17ecf02121e]
# to [4fdf649d1a0cb837d69227cf82d7a45bd0f86ba3]
#
# patch "src/defines.h"
# from [08e8eabf94987fa896a8142ea38284b8e353a180]
# to [073499a21f1b8819fe797df5ba9f838bfd1fca45]
#
# patch "src/fd.c"
# from [a78d990ac2b23f41b521bb9df7e02e237bf0a4dd]
# to [c0397e2cf56d652a95b8ee1d2e66ead7a4f4e181]
#
# patch "src/forward.c"
# from [0cd445517e0ef996cf13bf0240590d59f635a1ac]
# to [90a8d9272641b587aaa42128812e4142fca9005a]
#
# patch "src/main.c"
# from [f1f95d82be8b07f2c138a6074caf14beec54ab4d]
# to [43e16e09d15d87c04e64187553ac2e56b6fa9046]
#
# patch "src/protos.h"
# from [aa65dda706bf16d368332b30fcdf514d4a6ed0b3]
# to [ecfd0bcf3229e6ad3df49aaf178a1ee35692ec0b]
#
# patch "src/ssl.c"
# from [4e4baeaa9028adce8636dae06b842b1a374298fd]
# to [226e2d05ef6712fbd8c6efaebaa97f9447828d95]
#
# patch "src/store_client.c"
# from [d961bf8e2ac9cf641164b0dd9c6b5d0cef3688f0]
# to [6ae4e504944cb80432494f5f7d48661e0306e3a8]
#
# patch "src/store_swapout.c"
# from [046d42687481bea3009756fb9218564605761e02]
# to [1ea4fa48e24da2f7f2e87031881b4cb4bddb6cd5]
#
# patch "src/structs.h"
# from [2cc0257c851aa9f3899204538a4037888a0465cf]
# to [54f1dc039ccb7f431a72bbf25e11e74a5964b3de]
#
============================================================
--- src/comm_kqueue.c f513f3b3d07e675ac06e4380826484fe9f061535
+++ src/comm_kqueue.c f513f3b3d07e675ac06e4380826484fe9f061535
@@ -0,0 +1,53 @@
+/* FreeBSD kqueue support - Adrian Chadd */
+/* [insert GPL copyright here] */
+
+/*
+ * For now this is #include'd from comm_select.c - this'll happen until
+ * I or someone duplicates benno's work and breaks out the poll/select/epoll
+ * support into separate files.
+ */
+
+static void checkTimeouts(void);
+
+
+/* Defer reads from this fd */
+void
+commDeferFD(int fd)
+{
+}
+
+
+/* Resume reading from the given fd */
+void
+commResumeFD(int fd)
+{
+}
+
+void
+comm_select_init()
+{
+}
+
+void
+commUpdateReadBits(int fd, PF *handler)
+{
+ /* Not implemented */
+}
+
+void
+commUpdateWriteBits(int fd, PF *handler)
+{
+ /* Not implemented */
+}
+
+void
+commSetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t timeout)
+{
+}
+
+int
+comm_kqueue(int msec)
+{
+ checkTimeouts();
+ return 0;
+}
============================================================
--- src/client_side.c f2f0d2e1e191ffeec9c101a29a66353d9b9cdc0d
+++ src/client_side.c 0b08448d363c94b62457c0905f5f31ea7e4d61af
@@ -2990,7 +2990,7 @@ clientReadDefer(int fd, void *data)
ConnStateData *conn = data;
if (conn->body.size_left && !F->flags.socket_eof) {
if(conn->in.offset >= conn->in.size - 1) {
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
/* The commResumeFD function is called in this file */
conn->in.clientfd=fd;
commDeferFD(fd);
@@ -3005,7 +3005,7 @@ clientReadDefer(int fd, void *data)
else
{
if (conn->defer.until > squid_curtime ) {
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
/* This is a second resolution timer, so commEpollBackon will
handle the resume for this defer call */
commDeferFD(fd);
@@ -3419,7 +3419,7 @@ clientProcessBody(ConnStateData * conn)
conn->body.size_left -= size;
/* Move any remaining data */
conn->in.offset -= size;
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
/* Resume the fd if necessary */
if ( conn->in.clientfd ) {
if(conn->in.offset < conn->in.size - 1) {
============================================================
--- src/comm.c 60b1db3bbcf7cf37a4cd94927dcf7ebdcba155f9
+++ src/comm.c 3caa5a087f556b00a76deaef0a5096f42fd4075b
@@ -375,7 +375,7 @@ commResetFD(ConnectStateData * cs)
commSetTcpNoDelay(cs->fd);
#endif
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
// If we are using epoll(), we need to make sure that this fd will be polled
commSetSelect(cs->fd,0,NULL,NULL,0);
#endif
@@ -705,7 +705,7 @@ commSetDefer(int fd, DEFER * func, void
}
/* Epoll redefines this function in comm_select.c */
-#if !HAVE_EPOLL
+#if !HAVE_EVENTNETIO
void
commSetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t timeout)
{
============================================================
--- src/comm_select.c 16d275ec06f5529b6ed8e6cd5387b17ecf02121e
+++ src/comm_select.c 4fdf649d1a0cb837d69227cf82d7a45bd0f86ba3
@@ -32,11 +32,15 @@
*
*/
+#define HAVE_SELECT_OR_POLL (HAVE_POLL && (!HAVE_KQUEUE) && (!HAVE_EPOLL))
+#define HAVE_SELECT (!HAVE_POLL && !HAVE_EPOLL && !HAVE_KQUEUE)
+#define HAVE_EVENTNETIO (HAVE_KQUEUE || HAVE_EPOLL)
+
#include "squid.h"
static int MAX_POLL_TIME = 1000; /* see also comm_quick_poll_required() */
-#if !HAVE_EPOLL
+#if HAVE_SELECT_OR_POLL
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
@@ -48,7 +52,7 @@ static int MAX_POLL_TIME = 1000; /* see
#define FD_MASK_BITS (FD_MASK_BYTES*NBBY)
/* STATIC */
-#if !HAVE_POLL
+#if HAVE_SELECT
static int examine_select(fd_set *, fd_set *);
#endif
static int fdIsHttp(int fd);
@@ -65,7 +69,7 @@ static void comm_select_dns_incoming(voi
static void comm_select_dns_incoming(void);
#endif
-#if !HAVE_POLL
+#if HAVE_SELECT
static struct timeval zero_tv;
#endif
static fd_set global_readfds;
@@ -936,7 +940,7 @@ comm_select_init(void)
void
comm_select_init(void)
{
-#if !HAVE_POLL
+#if HAVE_SELECT
zero_tv.tv_sec = 0;
zero_tv.tv_usec = 0;
#endif
@@ -948,7 +952,7 @@ comm_select_init(void)
nreadfds = nwritefds = 0;
}
-#if !HAVE_POLL
+#if HAVE_SELECT
/*
* examine_select - debug routine.
*
@@ -1072,7 +1076,7 @@ commUpdateWriteBits(int fd, PF * handler
}
}
-#else /* HAVE_EPOLL */
+#elif HAVE_EPOLL /* HAVE_EPOLL */
/* epoll structs */
static int kdpfd;
static struct epoll_event *pevents;
@@ -1469,7 +1473,12 @@ WRITE_EVENT:
debug(5, 8) ("comm_epoll: time out: %ld.\n", (long int) squid_curtime);
return COMM_TIMEOUT;
}
-#endif /* HAVE_EPOLL */
+#elif HAVE_KQUEUE
+/* Yes, this is a hack for now! - [ahc] */
+#include "comm_kqueue.c"
+#else
+#error HAVE_KQUEUE, HAVE_EPOLL, HAVE_POLL (and no select!) wasn't defined!
+#endif
static int
commDeferRead(int fd)
============================================================
--- src/defines.h 08e8eabf94987fa896a8142ea38284b8e353a180
+++ src/defines.h 073499a21f1b8819fe797df5ba9f838bfd1fca45
@@ -308,4 +308,10 @@
#define FILE_MODE(x) ((x)&(O_RDONLY|O_WRONLY|O_RDWR))
#endif
+/* Commloops-related stuff */
+#define HAVE_SELECT_OR_POLL (HAVE_POLL && (!HAVE_KQUEUE) && (!HAVE_EPOLL))
+#define HAVE_SELECT (!HAVE_POLL && !HAVE_EPOLL && !HAVE_KQUEUE)
+#define HAVE_EVENTNETIO (HAVE_KQUEUE || HAVE_EPOLL)
+
+
#endif /* SQUID_DEFINES_H */
============================================================
--- src/fd.c a78d990ac2b23f41b521bb9df7e02e237bf0a4dd
+++ src/fd.c c0397e2cf56d652a95b8ee1d2e66ead7a4f4e181
@@ -84,7 +84,7 @@ fd_close(int fd)
assert(F->write_handler == NULL);
}
debug(51, 3) ("fd_close FD %d %s\n", fd, F->desc);
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
/* the epoll code needs to update the descriptor before flags.ope is 0 */
commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
============================================================
--- src/forward.c 0cd445517e0ef996cf13bf0240590d59f635a1ac
+++ src/forward.c 90a8d9272641b587aaa42128812e4142fca9005a
@@ -741,7 +741,7 @@ fwdCheckDeferRead(int fd, void *data)
else {
int i = delayMostBytesWanted(mem, INT_MAX);
if (0 == i) {
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
mem->serverfd=fd;
commDeferFD(fd);
#endif
@@ -766,7 +766,7 @@ fwdCheckDeferRead(int fd, void *data)
*/
if (mem->inmem_hi - mem->inmem_lo > SM_PAGE_SIZE + Config.Store.maxInMemObjSize + READ_AHEAD_GAP) {
EBIT_SET(e->flags, ENTRY_DEFER_READ);
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
mem->serverfd=fd;
commDeferFD(fd);
#endif
@@ -775,7 +775,7 @@ fwdCheckDeferRead(int fd, void *data)
}
if (mem->inmem_hi - storeLowestMemReaderOffset(e) > READ_AHEAD_GAP) {
EBIT_SET(e->flags, ENTRY_DEFER_READ);
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
mem->serverfd=fd;
commDeferFD(fd);
#endif
============================================================
--- src/main.c f1f95d82be8b07f2c138a6074caf14beec54ab4d
+++ src/main.c 43e16e09d15d87c04e64187553ac2e56b6fa9046
@@ -773,6 +773,8 @@ main(int argc, char **argv)
switch (comm_epoll(loop_delay)) {
#elif HAVE_POLL
switch (comm_poll(loop_delay)) {
+#elif HAVE_KQUEUE
+ switch (comm_kqueue(loop_delay)) {
#else
switch (comm_select(loop_delay)) {
#endif
============================================================
--- src/protos.h aa65dda706bf16d368332b30fcdf514d4a6ed0b3
+++ src/protos.h ecfd0bcf3229e6ad3df49aaf178a1ee35692ec0b
@@ -162,7 +162,7 @@ extern u_short comm_local_port(int fd);
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);
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
extern void commDeferFD(int fd);
extern void commResumeFD(int fd);
#endif
@@ -192,6 +192,8 @@ extern int comm_poll(int);
extern int comm_epoll(int);
#elif HAVE_POLL
extern int comm_poll(int);
+#elif HAVE_KQUEUE
+extern int comm_kqueue(int);
#else
extern int comm_select(int);
#endif
============================================================
--- src/ssl.c 4e4baeaa9028adce8636dae06b842b1a374298fd
+++ src/ssl.c 226e2d05ef6712fbd8c6efaebaa97f9447828d95
@@ -139,7 +139,7 @@ sslDeferServerRead(int fd, void *data)
if (i == INT_MAX)
return 0;
if (i == 0) {
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
commDeferFD(fd);
#endif
return 1;
============================================================
--- src/store_client.c d961bf8e2ac9cf641164b0dd9c6b5d0cef3688f0
+++ src/store_client.c 6ae4e504944cb80432494f5f7d48661e0306e3a8
@@ -285,7 +285,7 @@ storeClientCopy3(StoreEntry * e, store_c
debug(20, 3) ("storeClientCopy3: %s - clearing ENTRY_DEFER_READ\n",e->mem_obj->url);
/* Clear the flag and re-poll the fd */
EBIT_CLR(e->flags, ENTRY_DEFER_READ);
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
if(mem->serverfd !=0) {
commResumeFD(mem->serverfd);
mem->serverfd=0;
============================================================
--- src/store_swapout.c 046d42687481bea3009756fb9218564605761e02
+++ src/store_swapout.c 1ea4fa48e24da2f7f2e87031881b4cb4bddb6cd5
@@ -152,7 +152,7 @@ storeSwapOutMaintainMemObject(StoreEntry
if (mem->inmem_hi - mem->inmem_lo <= READ_AHEAD_GAP) {
EBIT_CLR(e->flags, ENTRY_DEFER_READ);
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
if(mem->serverfd !=0) {
commResumeFD(mem->serverfd);
mem->serverfd=0;
============================================================
--- src/structs.h 2cc0257c851aa9f3899204538a4037888a0465cf
+++ src/structs.h 54f1dc039ccb7f431a72bbf25e11e74a5964b3de
@@ -1145,7 +1145,7 @@ struct _ConnStateData {
char *buf;
size_t offset;
size_t size;
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
int clientfd; /* Record the client's fd if we have too much
data waiting to send to the server */
#endif
@@ -1540,7 +1540,7 @@ struct _MemObject {
mem_hdr data_hdr;
squid_off_t inmem_hi;
squid_off_t inmem_lo;
-#if HAVE_EPOLL
+#if HAVE_EVENTNETIO
int serverfd; /* Record the server's fd if we have too much
data waiting to send to the client */
#endif