From e6f7a0cb0dc8ec7a95aff038b21f2bc809cb682b Mon Sep 17 00:00:00 2001 From: des Date: Tue, 11 Mar 2008 11:25:28 +0000 Subject: [PATCH] Slightly more elegant version of the previous commit, which also fixed a tiny braino. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2593 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_acceptor_poll.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_acceptor_poll.c b/varnish-cache/bin/varnishd/cache_acceptor_poll.c index 167d77c7..171179d2 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor_poll.c +++ b/varnish-cache/bin/varnishd/cache_acceptor_poll.c @@ -56,8 +56,8 @@ static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead); static void vca_pollspace(unsigned fd) { - struct pollfd *newpollfd; - unsigned newnpoll; + struct pollfd *newpollfd = pollfd; + unsigned newnpoll = npoll; if (fd < npoll) return; @@ -65,10 +65,10 @@ vca_pollspace(unsigned fd) while (fd >= newnpoll) newnpoll = newnpoll * 2 + 1; VSL(SLT_Debug, 0, "Acceptor poll space increased to %u", newnpoll); - newpollfd = realloc(pollfd, newnpoll * sizeof *pollfd); + newpollfd = realloc(newpollfd, newnpoll * sizeof *newpollfd); XXXAN(newpollfd); /* close offending fd */ + memset(newpollfd + npoll, 0, (newnpoll - npoll) * sizeof *newpollfd); pollfd = newpollfd; - memset(pollfd + npoll, 0, (newnpoll - npoll) * sizeof *pollfd); while (npoll < newnpoll) pollfd[npoll++].fd = -1; } -- 2.39.5