]> err.no Git - varnish/commitdiff
Account for the last byte of the header.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 5 Apr 2006 09:40:22 +0000 (09:40 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 5 Apr 2006 09:40:22 +0000 (09:40 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@118 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/autogen.sh
varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_httpd.c
varnish-cache/bin/varnishd/cache_pass.c
varnish-cache/bin/varnishd/cache_pipe.c
varnish-cache/bin/varnishd/cache_pool.c

index d8330d3173464270d74b72cc8c4b90e1af692281..9fa4d1a95109f96a6dc72420ae9aff0649db9501 100755 (executable)
@@ -3,6 +3,8 @@
 # $Id$
 #
 
+set -ex
+
 if [ -d /usr/local/gnu-autotools/bin ] ; then
        PATH=${PATH}:/usr/local/gnu-autotools/bin
        export PATH
@@ -10,6 +12,7 @@ fi
 
 base=$(cd $(dirname $0) && pwd)
 for dir in $base $base/contrib/libevent ; do
+       (
        echo $dir
        cd $dir
        aclocal
@@ -17,4 +20,14 @@ for dir in $base $base/contrib/libevent ; do
        autoheader
        automake --add-missing --copy --force --foreign
        autoconf
+       )
 done
+
+sh configure \
+       --enable-pedantic \
+       --enable-wall  \
+       --enable-werror  \
+       --enable-dependency-tracking
+
+# This is a safety-measure during development
+( cd lib/libvcl && ./*.tcl )
index 156eb5bd4b5b1a4666ef066b0d4da6ea184df3d0..cc0742c63c523011afd053b7077a2c0878155eb2 100644 (file)
@@ -4,6 +4,16 @@
 
 struct event_base;
 
+#ifdef EV_TIMEOUT
+struct worker {
+       struct event_base       *eb;
+       struct event            e1, e2;
+       struct sbuf             *sb;
+};
+#else
+struct worker;
+#endif
+
 /* cache_acceptor.c */
 void *vca_main(void *arg);
 void vca_retire_session(struct sess *sp);
@@ -22,10 +32,10 @@ void HttpdGetHead(struct sess *sp, struct event_base *eb, sesscb_f *func);
 pthread_mutex_t        sessmtx;
 
 /* cache_pass.c */
-void PassSession(struct sess *sp);
+void PassSession(struct worker *w, struct sess *sp);
 
 /* cache_pipe.c */
-void PipeSession(struct sess *sp);
+void PipeSession(struct worker *w, struct sess *sp);
 
 /* cache_pool.c */
 void CacheInitPool(void);
index 32ddbd6558ac9563452ff45ef9e13c0d71ae9bc1..c8897a71af2c68ae8c3725e60e66a76a185d8389 100644 (file)
@@ -163,7 +163,7 @@ http_read_f(int fd, short event, void *arg)
                        continue;
                break;
        }
-       sp->hdr_end = p - sp->rcv;
+       sp->hdr_end = ++p - sp->rcv;
        VSL(SLT_Debug, 0, "HTTP %u %u", sp->rcv_len, sp->hdr_end);
        event_del(sp->rd_e);
        sp->sesscb(sp);
index 43606d66558dcae4f283d6947dc982a30b70bb93..1e6fb11d68de5e38b6c8aa236970f3e36735a111 100644 (file)
@@ -31,71 +31,66 @@ PassReturn(struct sess *sp)
 
 /*--------------------------------------------------------------------*/
 void
-PassSession(struct sess *sp)
+PassSession(struct worker *w, struct sess *sp)
 {
        int fd, i, j;
        void *fd_token;
-       struct sbuf *sb;
-       struct event_base *eb;
        struct sess sp2;
-       struct event ev;
        char buf[BUFSIZ];
        off_t   cl;
 
        fd = VBE_GetFd(sp->backend, &fd_token);
        assert(fd != -1);
 
-       sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
-       assert(sb != NULL);
-       sbuf_cat(sb, sp->http.req);
-       sbuf_cat(sb, " ");
-       sbuf_cat(sb, sp->http.url);
-       sbuf_cat(sb, " ");
-       sbuf_cat(sb, sp->http.proto);
-       sbuf_cat(sb, "\r\n");
+       sbuf_clear(w->sb);
+       assert(w->sb != NULL);
+       sbuf_cat(w->sb, sp->http.req);
+       sbuf_cat(w->sb, " ");
+       sbuf_cat(w->sb, sp->http.url);
+       sbuf_cat(w->sb, " ");
+       sbuf_cat(w->sb, sp->http.proto);
+       sbuf_cat(w->sb, "\r\n");
 #define HTTPH(a, b, c, d, e, f, g)                             \
        do {                                                    \
                if (d && sp->http.b != NULL) {                  \
-                       sbuf_cat(sb, a ": ");                   \
-                       sbuf_cat(sb, sp->http.b);               \
-                       sbuf_cat(sb, "\r\n");                   \
+                       sbuf_cat(w->sb, a ": ");                \
+                       sbuf_cat(w->sb, sp->http.b);            \
+                       sbuf_cat(w->sb, "\r\n");                \
                }                                               \
        } while (0);
 #include "http_headers.h"
 #undef HTTPH
-       sbuf_cat(sb, "\r\n");
-       sbuf_finish(sb);
-       i = write(fd, sbuf_data(sb), sbuf_len(sb));
-       assert(i == sbuf_len(sb));
+       sbuf_cat(w->sb, "\r\n");
+       sbuf_finish(w->sb);
+       i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
+       assert(i == sbuf_len(w->sb));
 
        memset(&sp2, 0, sizeof sp2);
-       memset(&ev, 0, sizeof ev);
-       sp2.rd_e = &ev;
+       sp2.rd_e = &w->e1;
        sp2.fd = fd;
-       eb = event_init();
-       HttpdGetHead(&sp2, eb, PassReturn);
-       event_base_loop(eb, 0);
-       sbuf_clear(sb);
-       sbuf_cat(sb, sp2.http.proto);
-       sbuf_cat(sb, " ");
-       sbuf_cat(sb, sp2.http.status);
-       sbuf_cat(sb, " ");
-       sbuf_cat(sb, sp2.http.response);
-       sbuf_cat(sb, "\r\n");
+       HttpdGetHead(&sp2, w->eb, PassReturn);
+       event_base_loop(w->eb, 0);
+       sbuf_clear(w->sb);
+       sbuf_cat(w->sb, sp2.http.proto);
+       sbuf_cat(w->sb, " ");
+       sbuf_cat(w->sb, sp2.http.status);
+       sbuf_cat(w->sb, " ");
+       sbuf_cat(w->sb, sp2.http.response);
+       sbuf_cat(w->sb, "\r\n");
 #define HTTPH(a, b, c, d, e, f, g)                             \
        do {                                                    \
                if (d && sp2.http.b != NULL) {                  \
-                       sbuf_cat(sb, a ": ");                   \
-                       sbuf_cat(sb, sp2.http.b);               \
-                       sbuf_cat(sb, "\r\n");                   \
+                       sbuf_cat(w->sb, a ": ");                \
+                       sbuf_cat(w->sb, sp2.http.b);            \
+                       sbuf_cat(w->sb, "\r\n");                \
                }                                               \
        } while (0);
 #include "http_headers.h"
 #undef HTTPH
-       sbuf_cat(sb, "\r\n");
-       sbuf_finish(sb);
-       i = write(sp->fd, sbuf_data(sb), sbuf_len(sb));
-       assert(i == sbuf_len(sb));
+       sbuf_cat(w->sb, "\r\n");
+       sbuf_finish(w->sb);
+       i = write(sp->fd, sbuf_data(w->sb), sbuf_len(w->sb));
+       assert(i == sbuf_len(w->sb));
        if (sp2.http.H_Content_Length != NULL) {
                cl = strtoumax(sp2.http.H_Content_Length, NULL, 0);
                VSL(SLT_Debug, 0, "CL %ju %u %u", cl, sp->rcv_len, sp->hdr_end);
index 80eae135c9ab25416615e6c4ece1b30d43095c21..a8257d0580355d3dda4174e3ca11ea6f48bc1046 100644 (file)
@@ -42,55 +42,51 @@ rdf(int fd, short event, void *arg)
 }
 
 void
-PipeSession(struct sess *sp)
+PipeSession(struct worker *w, struct sess *sp)
 {
        int fd, i;
        void *fd_token;
-       struct sbuf *sb;
-       struct event_base *eb;
        struct edir e1, e2;
 
        fd = VBE_GetFd(sp->backend, &fd_token);
        assert(fd != -1);
 
-       sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
-       assert(sb != NULL);
-       sbuf_cat(sb, sp->http.req);
-       sbuf_cat(sb, " ");
-       sbuf_cat(sb, sp->http.url);
+       sbuf_clear(w->sb);
+       assert(w->sb != NULL);
+       sbuf_cat(w->sb, sp->http.req);
+       sbuf_cat(w->sb, " ");
+       sbuf_cat(w->sb, sp->http.url);
        if (sp->http.proto != NULL) {
-               sbuf_cat(sb, " ");
-               sbuf_cat(sb, sp->http.proto);
+               sbuf_cat(w->sb, " ");
+               sbuf_cat(w->sb, sp->http.proto);
        }
-       sbuf_cat(sb, "\r\n");
+       sbuf_cat(w->sb, "\r\n");
 #define HTTPH(a, b, c, d, e, f, g)                             \
        do {                                                    \
                if (sp->http.b != NULL) {                       \
-                       sbuf_cat(sb, a ": ");                   \
-                       sbuf_cat(sb, sp->http.b);               \
-                       sbuf_cat(sb, "\r\n");                   \
+                       sbuf_cat(w->sb, a ": ");                \
+                       sbuf_cat(w->sb, sp->http.b);            \
+                       sbuf_cat(w->sb, "\r\n");                \
                }                                               \
        } while (0);
 #include "http_headers.h"
 #undef HTTPH
-       sbuf_cat(sb, "\r\n");
-       sbuf_finish(sb);
-       i = write(fd, sbuf_data(sb), sbuf_len(sb));
-       assert(i == sbuf_len(sb));
+       sbuf_cat(w->sb, "\r\n");
+       sbuf_finish(w->sb);
+       i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
+       assert(i == sbuf_len(w->sb));
 
        e1.fd = fd;
        e2.fd = sp->fd;
-       eb = event_init();
        event_set(&e1.ev, sp->fd, EV_READ | EV_PERSIST, rdf, &e1);
-       event_base_set(eb, &e1.ev);
+       event_base_set(w->eb, &e1.ev);
        event_set(&e2.ev, fd,     EV_READ | EV_PERSIST, rdf, &e2);
-       event_base_set(eb, &e2.ev);
+       event_base_set(w->eb, &e2.ev);
        event_add(&e1.ev, NULL);
        event_add(&e2.ev, NULL);
-       event_base_loop(eb, 0);
+       event_base_loop(w->eb, 0);
        close (fd);
        close (sp->fd);
-       /* XXX: Delete eb */
        VBE_ClosedFd(fd_token);
        sp->fd = -1;
 }
index d1a15939df9ee1bc39e35e4a50dd6b907703586f..04a4b8d4b110d6fe125fe7364fbd247582c1f0a6 100644 (file)
@@ -3,9 +3,13 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include <assert.h>
 #include <pthread.h>
 #include <queue.h>
+#include <sys/time.h>
+#include <sbuf.h>
+#include <event.h>
 
 #include "libvarnish.h"
 #include "vcl_lang.h"
@@ -19,7 +23,14 @@ static void *
 CacheWorker(void *priv)
 {
        struct sess *sp;
+       struct worker w;
 
+       memset(&w, 0, sizeof w);
+       w.eb = event_init();
+       assert(w.eb != NULL);
+       w.sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
+       assert(w.sb != NULL);
+       
        (void)priv;
        AZ(pthread_mutex_lock(&sessmtx));
        while (1) {
@@ -42,9 +53,9 @@ CacheWorker(void *priv)
                printf("Handling: %d\n", sp->handling);
 
                if (0) {
-                       PipeSession(sp);
+                       PipeSession(&w, sp);
                } else {
-                       PassSession(sp);
+                       PassSession(&w, sp);
                }
 
                AZ(pthread_mutex_lock(&sessmtx));