]> err.no Git - varnish/commitdiff
Get "Pass" mode moving
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 4 Apr 2006 07:30:32 +0000 (07:30 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 4 Apr 2006 07:30:32 +0000 (07:30 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@109 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/Makefile.am
varnish-cache/bin/varnishd/cache_backend.c
varnish-cache/bin/varnishd/cache_pass.c [new file with mode: 0644]
varnish-cache/bin/varnishd/cache_pool.c
varnish-cache/include/http_headers.h
varnish-cache/lib/libvcl/vcl_fixed_token.c

index 7a0d4a6078d9ced8ce9ea91884892951cf159ab3..5e99d917dea16fffbe1a86ef66ad41ccaae2e1ed 100644 (file)
@@ -10,6 +10,7 @@ varnishd_SOURCES = \
        cache_httpd.c \
        cache_main.c \
        cache_pool.c \
+       cache_pass.c \
        cache_pipe.c \
        cache_shmlog.c \
        cache_vcl.c \
index db8ed424ecd8c9605d2eed2d972f50ca06198fd4..432cbbd9cfa159556c46fb0a96369af6237f0b91 100644 (file)
@@ -139,53 +139,6 @@ VBE_ClosedFd(void *ptr)
        free(vc);
 }
 
-/*--------------------------------------------------------------------*/
-void
-VBE_Pass(struct sess *sp)
-{
-       int fd, i;
-       void *fd_token;
-       struct sbuf *sb;
-
-       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");
-#define HTTPH(a, b, c, d, e, f, g)                             \
-       do {                                                    \
-               if (c && sp->http.b != NULL) {                  \
-                       sbuf_cat(sb, a ": ");                   \
-                       sbuf_cat(sb, sp->http.b);               \
-                       sbuf_cat(sb, "\r\n");                   \
-               }                                               \
-       } while (0);
-#include "http_headers.h"
-#undef HTTPH
-       sbuf_cat(sb, "\r\n");
-       sbuf_finish(sb);
-       printf("REQ: <%s>\n", sbuf_data(sb));
-       i = write(fd, sbuf_data(sb), sbuf_len(sb));
-       assert(i == sbuf_len(sb));
-       {
-       char buf[101];
-
-       for(;;) {
-               i = read(fd, buf, 100);
-               if (i > 0) {
-                       buf[i] = '\0';
-                       printf("RESP: <%s>\n", buf);
-               }
-       } 
-
-       }
-}
 
 /*--------------------------------------------------------------------*/
 
diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c
new file mode 100644 (file)
index 0000000..183482e
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * $Id$
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <sbuf.h>
+#include <event.h>
+
+#include "libvarnish.h"
+#include "shmlog.h"
+#include "vcl_lang.h"
+#include "cache.h"
+
+static void
+PassReturn(struct sess *sp)
+{
+
+       HERE();
+       HttpdAnalyze(sp);
+}
+
+/*--------------------------------------------------------------------*/
+void
+PassSession(struct sess *sp)
+{
+       int fd, i;
+       void *fd_token;
+       struct sbuf *sb;
+       struct event_base *eb;
+       struct sess sp2;
+       struct event ev;
+
+       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");
+#define HTTPH(a, b, c, d, e, f, g)                             \
+       do {                                                    \
+               if (c && sp->http.b != NULL) {                  \
+                       sbuf_cat(sb, a ": ");                   \
+                       sbuf_cat(sb, sp->http.b);               \
+                       sbuf_cat(sb, "\r\n");                   \
+               }                                               \
+       } while (0);
+#include "http_headers.h"
+#undef HTTPH
+       sbuf_cat(sb, "\r\n");
+       sbuf_finish(sb);
+       printf("REQ: <%s>\n", sbuf_data(sb));
+       i = write(fd, sbuf_data(sb), sbuf_len(sb));
+       assert(i == sbuf_len(sb));
+
+       memset(&sp2, 0, sizeof sp2);
+       memset(&ev, 0, sizeof ev);
+       sp2.rd_e = &ev;
+       sp2.fd = fd;
+       eb = event_init();
+       HttpdGetHead(&sp2, eb, PassReturn);
+       event_base_loop(eb, 0);
+}
index 29baee3d9b619b59d2a63c7dd597d02dd4202d38..4ce3517256405b2b3263983df75bb4bbf3a63d85 100644 (file)
@@ -39,7 +39,11 @@ CacheWorker(void *priv __unused)
 
                printf("Handling: %d\n", sp->handling);
 
-               PipeSession(sp);
+               if (0) {
+                       PipeSession(sp);
+               } else {
+                       PassSession(sp);
+               }
 
                AZ(pthread_mutex_lock(&sessmtx));
                RelVCL(sp->vcl);
index c798ce5446499cd344d015de983d0118829a4161..4092208da9f09260bd48d8b5fa7be535ab49c852 100644 (file)
  *    a                         b                       c  d  e  f  g 
  *--------------------------------------------------------------------
  */
-HTTPH("Accept-Charset",                H_Accept_Charset,       0, 0, 0, 0, 0)
-HTTPH("Accept-Encoding",       H_Accept_Encoding,      0, 0, 0, 0, 0)
-HTTPH("Accept-Language",       H_Accept_Language,      0, 0, 0, 0, 0)
-HTTPH("Accept",                        H_Accept,               0, 0, 0, 0, 0)
-HTTPH("Authorization",         H_Authorization,        0, 0, 0, 0, 0)
-HTTPH("Connection",            H_Connection,           1, 0, 0, 0, 0)
-HTTPH("Expect",                        H_Expect,               0, 0, 0, 0, 0)
-HTTPH("From",                  H_From,                 0, 0, 0, 0, 0)
+HTTPH("Accept-Charset",                H_Accept_Charset,       1, 0, 0, 0, 0)
+HTTPH("Accept-Encoding",       H_Accept_Encoding,      1, 0, 0, 0, 0)
+HTTPH("Accept-Language",       H_Accept_Language,      1, 0, 0, 0, 0)
+HTTPH("Accept",                        H_Accept,               1, 0, 0, 0, 0)
+HTTPH("Authorization",         H_Authorization,        1, 0, 0, 0, 0)
+HTTPH("Connection",            H_Connection,           0, 0, 0, 0, 0)
+HTTPH("Expect",                        H_Expect,               1, 0, 0, 0, 0)
+HTTPH("From",                  H_From,                 1, 0, 0, 0, 0)
 HTTPH("Host",                  H_Host,                 1, 0, 0, 0, 0)
-HTTPH("If-Match",              H_If_Match,             0, 0, 0, 0, 0)
-HTTPH("If-Modified-Since",     H_If_Modified_Since,    0, 0, 0, 0, 0)
-HTTPH("If-None-Match",         H_If_None_Match,        0, 0, 0, 0, 0)
-HTTPH("If-Range",              H_If_Range,             0, 0, 0, 0, 0)
-HTTPH("If-Unmodified-Since",   H_If_Unmodifed_Since,   0, 0, 0, 0, 0)
+HTTPH("If-Match",              H_If_Match,             1, 0, 0, 0, 0)
+HTTPH("If-Modified-Since",     H_If_Modified_Since,    1, 0, 0, 0, 0)
+HTTPH("If-None-Match",         H_If_None_Match,        1, 0, 0, 0, 0)
+HTTPH("If-Range",              H_If_Range,             1, 0, 0, 0, 0)
+HTTPH("If-Unmodified-Since",   H_If_Unmodifed_Since,   1, 0, 0, 0, 0)
 HTTPH("Keep-Alive",            H_Keep_Alive,           0, 0, 0, 0, 0)
-HTTPH("Max-Forwards",          H_Max_Forwards,         0, 0, 0, 0, 0)
-HTTPH("Proxy-Authorization",   H_Proxy_Authorization,  0, 0, 0, 0, 0)
-HTTPH("Range",                 H_Range,                0, 0, 0, 0, 0)
-HTTPH("Referer",               H_Referer,              0, 0, 0, 0, 0)
-HTTPH("TE",                    H_TE,                   0, 0, 0, 0, 0)
+HTTPH("Max-Forwards",          H_Max_Forwards,         1, 0, 0, 0, 0)
+HTTPH("Proxy-Authorization",   H_Proxy_Authorization,  1, 0, 0, 0, 0)
+HTTPH("Range",                 H_Range,                1, 0, 0, 0, 0)
+HTTPH("Referer",               H_Referer,              1, 0, 0, 0, 0)
+HTTPH("TE",                    H_TE,                   1, 0, 0, 0, 0)
 HTTPH("User-Agent",            H_User_Agent,           1, 0, 0, 0, 0)
index f21c63e4736ba6c1e466b6795207f641df265ee8..fc0b8f75adfc740600787767c0f341809c22d84e 100644 (file)
@@ -389,6 +389,9 @@ vcl_output_lang_h(FILE *f)
        fputs("/* XXX: This include is bad.  The VCL compiler shouldn't know about it. */\n", f);
        fputs("#include <sys/queue.h>\n", f);
        fputs("\n", f);
+       fputs("struct sess;\n", f);
+       fputs("typedef void sesscb_f(struct sess *sp);\n", f);
+       fputs("\n", f);
        fputs("struct vcl_ref {\n", f);
        fputs(" unsigned        line;\n", f);
        fputs(" unsigned        pos;\n", f);
@@ -424,26 +427,26 @@ vcl_output_lang_h(FILE *f)
        fputs(" *    a                         b                       c  d  e  f  g \n", f);
        fputs(" *--------------------------------------------------------------------\n", f);
        fputs(" */\n", f);
-       fputs("HTTPH(\"Accept-Charset\",                H_Accept_Charset,       0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Accept-Encoding\",       H_Accept_Encoding,      0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Accept-Language\",       H_Accept_Language,      0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Accept\",                        H_Accept,               0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Authorization\",         H_Authorization,        0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Connection\",            H_Connection,           1, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Expect\",                        H_Expect,               0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"From\",                  H_From,                 0, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Accept-Charset\",                H_Accept_Charset,       1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Accept-Encoding\",       H_Accept_Encoding,      1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Accept-Language\",       H_Accept_Language,      1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Accept\",                        H_Accept,               1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Authorization\",         H_Authorization,        1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Connection\",            H_Connection,           0, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Expect\",                        H_Expect,               1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"From\",                  H_From,                 1, 0, 0, 0, 0)\n", f);
        fputs("HTTPH(\"Host\",                  H_Host,                 1, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"If-Match\",              H_If_Match,             0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"If-Modified-Since\",     H_If_Modified_Since,    0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"If-None-Match\",         H_If_None_Match,        0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"If-Range\",              H_If_Range,             0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"If-Unmodified-Since\",   H_If_Unmodifed_Since,   0, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"If-Match\",              H_If_Match,             1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"If-Modified-Since\",     H_If_Modified_Since,    1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"If-None-Match\",         H_If_None_Match,        1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"If-Range\",              H_If_Range,             1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"If-Unmodified-Since\",   H_If_Unmodifed_Since,   1, 0, 0, 0, 0)\n", f);
        fputs("HTTPH(\"Keep-Alive\",            H_Keep_Alive,           0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Max-Forwards\",          H_Max_Forwards,         0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Proxy-Authorization\",   H_Proxy_Authorization,  0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Range\",                 H_Range,                0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"Referer\",               H_Referer,              0, 0, 0, 0, 0)\n", f);
-       fputs("HTTPH(\"TE\",                    H_TE,                   0, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Max-Forwards\",          H_Max_Forwards,         1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Proxy-Authorization\",   H_Proxy_Authorization,  1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Range\",                 H_Range,                1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"Referer\",               H_Referer,              1, 0, 0, 0, 0)\n", f);
+       fputs("HTTPH(\"TE\",                    H_TE,                   1, 0, 0, 0, 0)\n", f);
        fputs("HTTPH(\"User-Agent\",            H_User_Agent,           1, 0, 0, 0, 0)\n", f);
        fputs("#undef HTTPH\n", f);
        fputs(" const char              *uhdr[VCA_UNKNOWNHDR];\n", f);
@@ -474,6 +477,8 @@ vcl_output_lang_h(FILE *f)
        fputs("\n", f);
        fputs(" TAILQ_ENTRY(sess)       list;\n", f);
        fputs("\n", f);
+       fputs(" sesscb_f                *sesscb;\n", f);
+       fputs("\n", f);
        fputs(" struct backend          *backend;\n", f);
        fputs(" struct VCL_conf         *vcl;\n", f);
        fputs("\n", f);