r2126 - trunk/varnish-cache/bin/varnishd
des at projects.linpro.no
des at projects.linpro.no
Fri Oct 19 11:09:18 CEST 2007
Author: des
Date: 2007-10-19 11:09:17 +0200 (Fri, 19 Oct 2007)
New Revision: 2126
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
Move malloc() / free() out of the loop, and plug a leak. Ideally, we
shouldn't need to malloc() / free() at all, but I don't have time to
figure out how to avoid it right now.
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 09:05:10 UTC (rev 2125)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 09:09:17 UTC (rev 2126)
@@ -298,18 +298,19 @@
if (http_GetHdr(sp->http, H_Content_Length, &ptr)) {
content_length = strtoul(ptr, &endp, 10);
/* XXX should check result of conversion */
+ p = malloc(content_length);
while (content_length) {
- p = malloc(content_length);
read = HTC_Read(sp->htc, p, content_length);
WRK_Write(w, p, read);
if (WRK_Flush(w)) {
VBE_UpdateHealth(sp, vc, -1);
VBE_ClosedFd(sp->wrk, vc);
+ free(p);
return (__LINE__);
}
content_length -= read;
- free(p);
}
+ free(p);
}
if (WRK_Flush(w)) {
More information about the varnish-commit
mailing list