Commit 35b4c5ce authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Get "Pass" mode moving


git-svn-id: http://www.varnish-cache.org/svn/trunk@109 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 60be693b
......@@ -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 \
......
......@@ -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);
}
}
}
}
/*--------------------------------------------------------------------*/
......
/*
* $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);
}
......@@ -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);
......
......@@ -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)
......@@ -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);
......
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