r2096 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Tue Oct 9 09:22:48 CEST 2007
Author: phk
Date: 2007-10-09 09:22:46 +0200 (Tue, 09 Oct 2007)
New Revision: 2096
Modified:
trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
Log:
Keep track of the highest fd so we don't give poll(2) more pfd's to
chew than necessary.
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-10-08 19:15:41 UTC (rev 2095)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-10-09 07:22:46 UTC (rev 2096)
@@ -46,7 +46,7 @@
static pthread_t vca_poll_thread;
static struct pollfd *pollfd;
-static unsigned npoll;
+static unsigned npoll, hpoll;
static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
@@ -82,6 +82,8 @@
assert(fd >= 0);
vca_pollspace((unsigned)fd);
+ if (hpoll < fd)
+ hpoll = fd;
pollfd[fd].fd = fd;
pollfd[fd].events = POLLIN;
}
@@ -94,6 +96,10 @@
vca_pollspace((unsigned)fd);
pollfd[fd].fd = -1;
pollfd[fd].events = 0;
+ if (hpoll == fd) {
+ while (pollfd[--hpoll].fd == -1)
+ continue;
+ }
}
/*--------------------------------------------------------------------*/
@@ -111,7 +117,7 @@
vca_poll(vca_pipes[0]);
while (1) {
- v = poll(pollfd, npoll, 100);
+ v = poll(pollfd, hpoll + 1, 100);
if (v && pollfd[vca_pipes[0]].revents) {
v--;
i = read(vca_pipes[0], &sp, sizeof sp);
More information about the varnish-commit
mailing list