## Process this file with automake to produce Makefile.in
#
-# $Id: Makefile.am,v 1.24 2007/04/16 14:12:06 hno Exp $
+# $Id: Makefile.am,v 1.25 2007/04/24 06:30:37 wessels Exp $
#
DIST_SUBDIRS = libTrie
util.c \
uudecode.c \
assert.c \
+ xusleep.c \
$(XPROF_STATS_SOURCE) \
$(WIN32SRC)
libmiscutil_a_LIBADD = \
--- /dev/null
+#include "config.h"
+#include "profiling.h"
+#include "xusleep.h"
+
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+
+/*
+ * xusleep, as usleep but accepts longer pauses
+ */
+int
+xusleep(unsigned int usec)
+{
+ /* XXX emulation of usleep() */
+ struct timeval sl;
+ sl.tv_sec = usec / 1000000;
+ sl.tv_usec = usec % 1000000;
+ return select(0, NULL, NULL, NULL, &sl);
+}
/*
- * $Id: unlinkd.cc,v 1.59 2007/04/12 23:51:56 wessels Exp $
+ * $Id: unlinkd.cc,v 1.60 2007/04/24 06:30:37 wessels Exp $
*
* DEBUG: section 2 Unlink Daemon
* AUTHOR: Duane Wessels
#include "SquidTime.h"
#include "fde.h"
+#include "xusleep.h"
/* This code gets linked to Squid */
}
/*
- * If the queue length is greater than our limit, then
- * we pause for up to 100ms, hoping that unlinkd
- * has some feedback for us. Maybe it just needs a slice
- * of the CPU's time.
- */
+ * If the queue length is greater than our limit, then we pause
+ * for a small amount of time, hoping that unlinkd has some
+ * feedback for us. Maybe it just needs a slice of the CPU's
+ * time.
+ */
if (queuelen >= UNLINKD_QUEUE_LIMIT) {
-
+#if defined(USE_EPOLL) || defined(USE_KQUEUE)
+ /*
+ * DPW 2007-04-23
+ * We can't use fd_set when using epoll() or kqueue(). In
+ * these cases we block for 10 ms.
+ */
+ xusleep(10000);
+#else
+ /*
+ * DPW 2007-04-23
+ * When we can use select, block for up to 100 ms.
+ */
struct timeval to;
fd_set R;
FD_ZERO(&R);
to.tv_sec = 0;
to.tv_usec = 100000;
select(unlinkd_rfd + 1, &R, NULL, NULL, &to);
+#endif
}
/*
{
const char *args[2];
- struct timeval slp;
args[0] = "(unlinkd)";
args[1] = NULL;
pid = ipcCreate(
if (pid < 0)
fatal("Failed to create unlinkd subprocess");
- slp.tv_sec = 0;
-
- slp.tv_usec = 250000;
-
- select(0, NULL, NULL, NULL, &slp);
+ xusleep(250000);
fd_note(unlinkd_wfd, "squid -> unlinkd");