Commit 0836714d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Keep track of the highest fd so we don't give poll(2) more pfd's to

chew than necessary.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2096 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 6e9a2543
......@@ -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 @@ vca_poll(int fd)
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_unpoll(int fd)
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_main(void *arg)
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment