Commit bde60d08 authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Use an 8 kB stack buffer instead of a heap buffer.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2130 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 4eb2e253
...@@ -260,10 +260,8 @@ Fetch(struct sess *sp) ...@@ -260,10 +260,8 @@ Fetch(struct sess *sp)
struct bereq *bereq; struct bereq *bereq;
int mklen, is_head; int mklen, is_head;
struct http_conn htc[1]; struct http_conn htc[1];
unsigned long content_length; int i;
int i, read;
char *ptr, *endp; char *ptr, *endp;
char *p = NULL;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
...@@ -296,21 +294,26 @@ Fetch(struct sess *sp) ...@@ -296,21 +294,26 @@ Fetch(struct sess *sp)
* pipelined bytes to the backend as well * pipelined bytes to the backend as well
*/ */
if (http_GetHdr(sp->http, H_Content_Length, &ptr)) { if (http_GetHdr(sp->http, H_Content_Length, &ptr)) {
unsigned long content_length;
char buf[8192];
int read;
content_length = strtoul(ptr, &endp, 10); content_length = strtoul(ptr, &endp, 10);
/* XXX should check result of conversion */ /* XXX should check result of conversion */
p = malloc(content_length);
while (content_length) { while (content_length) {
read = HTC_Read(sp->htc, p, content_length); if (content_length > sizeof buf)
WRK_Write(w, p, read); read = sizeof buf;
else
read = content_length;
read = HTC_Read(sp->htc, buf, read);
WRK_Write(w, buf, read);
if (WRK_Flush(w)) { if (WRK_Flush(w)) {
VBE_UpdateHealth(sp, vc, -1); VBE_UpdateHealth(sp, vc, -1);
VBE_ClosedFd(sp->wrk, vc); VBE_ClosedFd(sp->wrk, vc);
free(p);
return (__LINE__); return (__LINE__);
} }
content_length -= read; content_length -= read;
} }
free(p);
} }
if (WRK_Flush(w)) { if (WRK_Flush(w)) {
......
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