]> err.no Git - varnish/commitdiff
Fix a couple of glaring errors in vca_pollspace().
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 11 Mar 2008 11:10:19 +0000 (11:10 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 11 Mar 2008 11:10:19 +0000 (11:10 +0000)
Noticed by: Jyri J. Virkki <jyri@virkki.com>

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2592 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_acceptor_poll.c

index 3566f88910b526e30665f78107f2844fa73cea4c..167d77c796cf485f06a303c073f80b5906a05165 100644 (file)
@@ -56,23 +56,21 @@ static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
 static void
 vca_pollspace(unsigned fd)
 {
-       struct pollfd *p;
-       unsigned u, v;
+       struct pollfd *newpollfd;
+       unsigned newnpoll;
 
        if (fd < npoll)
                return;
-       if (npoll == 0)
-               npoll = 16;
-       for (u = npoll; fd >= u; )
-               u += u;
-       VSL(SLT_Debug, 0, "Acceptor Pollspace %u", u);
-       p = realloc(pollfd, u * sizeof *p);
-       XXXAN(p);       /* close offending fd */
-       memset(p + npoll, 0, (u - npoll) * sizeof *p);
-       for (v = npoll ; v <= u; v++)
-               p->fd = -1;
-       pollfd = p;
-       npoll = u;
+       newnpoll = npoll;
+       while (fd >= newnpoll)
+               newnpoll = newnpoll * 2 + 1;
+       VSL(SLT_Debug, 0, "Acceptor poll space increased to %u", newnpoll);
+       newpollfd = realloc(pollfd, newnpoll * sizeof *pollfd);
+       XXXAN(newpollfd);       /* close offending fd */
+       pollfd = newpollfd;
+       memset(pollfd + npoll, 0, (newnpoll - npoll) * sizeof *pollfd);
+       while (npoll < newnpoll)
+               pollfd[npoll++].fd = -1;
 }
 
 /*--------------------------------------------------------------------*/