From: phk Date: Thu, 6 Apr 2006 09:33:19 +0000 (+0000) Subject: Rename hdr_end to a more sensible rcv_ptr which points to the first X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcfaa108bdaee8ca3a9214a084f8c3772b1790df;p=varnish Rename hdr_end to a more sensible rcv_ptr which points to the first unaccounted for character in the buffer. Do Id Keyword git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@132 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_httpd.c b/varnish-cache/bin/varnishd/cache_httpd.c index 6e9ff74d..00fa0758 100644 --- a/varnish-cache/bin/varnishd/cache_httpd.c +++ b/varnish-cache/bin/varnishd/cache_httpd.c @@ -165,7 +165,7 @@ http_read_f(int fd, short event, void *arg) continue; break; } - sp->hdr_end = ++p - sp->rcv; + sp->rcv_ptr = ++p - sp->rcv; event_del(sp->rd_e); sp->sesscb(sp); diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index 6e951835..64a7c58d 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -45,11 +45,13 @@ PassSession(struct worker *w, struct sess *sp) * If client wants only this one request, piping is safer * and cheaper */ + VSL(SLT_HandlingPass, sp->fd, "pipe"); PipeSession(w, sp); return; } fd = VBE_GetFd(sp->backend, &fd_token); assert(fd != -1); + VSL(SLT_HandlingPass, sp->fd, "%d", fd); HttpdBuildSbuf(0, 1, w->sb, sp); i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb)); @@ -60,6 +62,10 @@ PassSession(struct worker *w, struct sess *sp) memset(&sp2, 0, sizeof sp2); sp2.rd_e = &w->e1; sp2.fd = fd; + /* + * XXX: It might be cheaper to avoid the event_engine and simply + * XXX: read(2) the header + */ HttpdGetHead(&sp2, w->eb, PassReturn); event_base_loop(w->eb, 0); HttpdAnalyze(&sp2, 2); @@ -74,11 +80,12 @@ PassSession(struct worker *w, struct sess *sp) i &= ~O_NONBLOCK; i = fcntl(sp2.fd, F_SETFL, i); assert(i != -1); - i = sp2.rcv_len - sp2.hdr_end; + i = sp2.rcv_len - sp2.rcv_ptr; if (i > 0) { - j = write(sp->fd, sp2.rcv + sp2.hdr_end, i); + j = write(sp->fd, sp2.rcv + sp2.rcv_ptr, i); assert(j == i); cl -= i; + sp2.rcv_ptr += i; } while (cl > 0) { j = sizeof buf; @@ -97,13 +104,10 @@ PassSession(struct worker *w, struct sess *sp) assert(cl == 0); } - if (sp->rcv_len > sp->hdr_end) { - memmove(sp->rcv, sp->rcv + sp->hdr_end, - sp->rcv_len - sp->hdr_end); - sp->rcv_len -= sp->hdr_end; - sp->rcv[sp->rcv_len] = '\0'; - } else { - sp->rcv_len = 0; - sp->rcv[sp->rcv_len] = '\0'; - } + /* XXX: this really belongs in the acceptor */ + if (sp->rcv_len > sp->rcv_ptr) + memmove(sp->rcv, sp->rcv + sp->rcv_ptr, + sp->rcv_len - sp->rcv_ptr); + sp->rcv_len -= sp->rcv_ptr; + sp->rcv_ptr = 0; } diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 6ce7b1d9..4211c7e4 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -14,6 +14,7 @@ #include #include "libvarnish.h" +#include "shmlog.h" #include "vcl_lang.h" #include "cache.h" @@ -50,13 +51,14 @@ PipeSession(struct worker *w, struct sess *sp) fd = VBE_GetFd(sp->backend, &fd_token); assert(fd != -1); + VSL(SLT_HandlingPipe, sp->fd, "%d", fd); HttpdBuildSbuf(0, 0, w->sb, sp); i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb)); assert(i == sbuf_len(w->sb)); - i = sp->rcv_len - sp->hdr_end; + i = sp->rcv_len - sp->rcv_ptr; if (i > 0) { - j = write(sp->fd, sp->rcv + sp->hdr_end, i); + j = write(sp->fd, sp->rcv + sp->rcv_ptr, i); assert(j == i); } diff --git a/varnish-cache/include/vcl_lang.h b/varnish-cache/include/vcl_lang.h index c8a17f80..8b63c08f 100644 --- a/varnish-cache/include/vcl_lang.h +++ b/varnish-cache/include/vcl_lang.h @@ -49,7 +49,7 @@ struct sess { /* Receive buffer for HTTP header */ char rcv[VCA_RXBUFSIZE + 1]; unsigned rcv_len; - unsigned hdr_end; + unsigned rcv_ptr; /* HTTP request info, points into rcv */ struct httphdr http; diff --git a/varnish-cache/lib/libvcl/vcl_fixed_token.c b/varnish-cache/lib/libvcl/vcl_fixed_token.c index 99bc7754..09d262b1 100644 --- a/varnish-cache/lib/libvcl/vcl_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcl_fixed_token.c @@ -477,7 +477,7 @@ vcl_output_lang_h(FILE *f) fputs(" /* Receive buffer for HTTP header */\n", f); fputs(" char rcv[VCA_RXBUFSIZE + 1];\n", f); fputs(" unsigned rcv_len;\n", f); - fputs(" unsigned hdr_end;\n", f); + fputs(" unsigned rcv_ptr;\n", f); fputs("\n", f); fputs(" /* HTTP request info, points into rcv */\n", f); fputs(" struct httphdr http;\n", f);