r109 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Tue Apr 4 09:30:32 CEST 2006


Author: phk
Date: 2006-04-04 09:30:32 +0200 (Tue, 04 Apr 2006)
New Revision: 109

Added:
   trunk/varnish-cache/bin/varnishd/cache_pass.c
Modified:
   trunk/varnish-cache/bin/varnishd/Makefile.am
   trunk/varnish-cache/bin/varnishd/cache_backend.c
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/include/http_headers.h
   trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c
Log:
Get "Pass" mode moving


Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am	2006-04-04 07:29:45 UTC (rev 108)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am	2006-04-04 07:30:32 UTC (rev 109)
@@ -10,6 +10,7 @@
 	cache_httpd.c \
 	cache_main.c \
 	cache_pool.c \
+	cache_pass.c \
 	cache_pipe.c \
 	cache_shmlog.c \
 	cache_vcl.c \

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-04-04 07:29:45 UTC (rev 108)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-04-04 07:30:32 UTC (rev 109)
@@ -139,54 +139,7 @@
 	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);
-		}
-	} 
-
-	}
-}
-
 /*--------------------------------------------------------------------*/
 
 void

Added: trunk/varnish-cache/bin/varnishd/cache_pass.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-04-04 07:29:45 UTC (rev 108)
+++ trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-04-04 07:30:32 UTC (rev 109)
@@ -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);
+}

Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-04-04 07:29:45 UTC (rev 108)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-04-04 07:30:32 UTC (rev 109)
@@ -39,7 +39,11 @@
 
 		printf("Handling: %d\n", sp->handling);
 
-		PipeSession(sp);
+		if (0) {
+			PipeSession(sp);
+		} else {
+			PassSession(sp);
+		}
 
 		AZ(pthread_mutex_lock(&sessmtx));
 		RelVCL(sp->vcl);

Modified: trunk/varnish-cache/include/http_headers.h
===================================================================
--- trunk/varnish-cache/include/http_headers.h	2006-04-04 07:29:45 UTC (rev 108)
+++ trunk/varnish-cache/include/http_headers.h	2006-04-04 07:30:32 UTC (rev 109)
@@ -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)

Modified: trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c	2006-04-04 07:29:45 UTC (rev 108)
+++ trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c	2006-04-04 07:30:32 UTC (rev 109)
@@ -389,6 +389,9 @@
 	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 @@
 	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 @@
 	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);




More information about the varnish-commit mailing list