r121 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Apr 6 09:50:58 CEST 2006


Author: phk
Date: 2006-04-06 09:50:58 +0200 (Thu, 06 Apr 2006)
New Revision: 121

Modified:
   trunk/varnish-cache/bin/varnishd/cache_pass.c
   trunk/varnish-cache/bin/varnishd/cache_pipe.c
Log:
Use HttpdBuildSbuf()

Enable Id keyword


Modified: trunk/varnish-cache/bin/varnishd/cache_pass.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-04-06 07:50:05 UTC (rev 120)
+++ trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-04-06 07:50:58 UTC (rev 121)
@@ -42,65 +42,32 @@
 	fd = VBE_GetFd(sp->backend, &fd_token);
 	assert(fd != -1);
 
-	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(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(w->sb, "\r\n");
-	sbuf_finish(w->sb);
+	HttpdBuildSbuf(0, 1, w->sb, sp);
+
 	i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
 	assert(i == sbuf_len(w->sb));
 
+	/* XXX: copy any contents */
+
+
 	memset(&sp2, 0, sizeof sp2);
 	sp2.rd_e = &w->e1;
 	sp2.fd = fd;
 	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(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(w->sb, "\r\n");
-	sbuf_finish(w->sb);
+
+	HttpdBuildSbuf(1, 1, w->sb, &sp2);
 	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);
 		i = fcntl(sp2.fd, F_GETFL);
 		i &= ~O_NONBLOCK;
 		i = fcntl(sp2.fd, F_SETFL, i);
 		assert(i != -1);
 		i = sp2.rcv_len - sp2.hdr_end;
 		if (i > 0) {
-			VSL(SLT_Debug, 0, "Wr1 %d", i);
 			j = write(sp->fd, sp2.rcv + sp2.hdr_end, i);
 			assert(j == i);
 			cl -= i;
@@ -112,14 +79,15 @@
 			i = recv(sp2.fd, buf, j, 0);
 			assert(i >= 0);
 			if (i > 0) {
-				VSL(SLT_Debug, 0, "Rd %d", i);
 				cl -= i;
 				j = write(sp->fd, buf, i);
 				assert(j == i);
 			} else if (i == 0) {
-				VSL(SLT_Debug, 0, "EOF %d", i);
 				break;
 			}
 		}
 	}
+
+	/* XXX: move remaining input in sp->rcv */
+	/* XXX: return session to acceptor */
 }


Property changes on: trunk/varnish-cache/bin/varnishd/cache_pass.c
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c	2006-04-06 07:50:05 UTC (rev 120)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c	2006-04-06 07:50:58 UTC (rev 121)
@@ -44,37 +44,21 @@
 void
 PipeSession(struct worker *w, struct sess *sp)
 {
-	int fd, i;
+	int fd, i, j;
 	void *fd_token;
 	struct edir e1, e2;
 
 	fd = VBE_GetFd(sp->backend, &fd_token);
 	assert(fd != -1);
 
-	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(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 (sp->http.b != NULL) {			\
-			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(w->sb, "\r\n");
-	sbuf_finish(w->sb);
+	HttpdBuildSbuf(0, 0, w->sb, sp);
 	i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
 	assert(i == sbuf_len(w->sb));
+	i = sp->rcv_len - sp->hdr_end;
+	if (i > 0) {
+		j = write(sp->fd, sp->rcv + sp->hdr_end, i);
+		assert(j == i);
+	}
 
 	e1.fd = fd;
 	e2.fd = sp->fd;


Property changes on: trunk/varnish-cache/bin/varnishd/cache_pipe.c
___________________________________________________________________
Name: svn:keywords
   + Id




More information about the varnish-commit mailing list