From: phk Date: Tue, 4 Apr 2006 07:30:32 +0000 (+0000) Subject: Get "Pass" mode moving X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27e54f8beed15e69d8ca5abea78a483d4a95e5b6;p=varnish Get "Pass" mode moving git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@109 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/Makefile.am b/varnish-cache/bin/varnishd/Makefile.am index 7a0d4a60..5e99d917 100644 --- a/varnish-cache/bin/varnishd/Makefile.am +++ b/varnish-cache/bin/varnishd/Makefile.am @@ -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 \ diff --git a/varnish-cache/bin/varnishd/cache_backend.c b/varnish-cache/bin/varnishd/cache_backend.c index db8ed424..432cbbd9 100644 --- a/varnish-cache/bin/varnishd/cache_backend.c +++ b/varnish-cache/bin/varnishd/cache_backend.c @@ -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 index 00000000..183482ed --- /dev/null +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -0,0 +1,76 @@ +/* + * $Id$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 29baee3d..4ce35172 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -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); diff --git a/varnish-cache/include/http_headers.h b/varnish-cache/include/http_headers.h index c798ce54..4092208d 100644 --- a/varnish-cache/include/http_headers.h +++ b/varnish-cache/include/http_headers.h @@ -12,24 +12,24 @@ * 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) diff --git a/varnish-cache/lib/libvcl/vcl_fixed_token.c b/varnish-cache/lib/libvcl/vcl_fixed_token.c index f21c63e4..fc0b8f75 100644 --- a/varnish-cache/lib/libvcl/vcl_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcl_fixed_token.c @@ -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 \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);