r2051 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Fri Sep 28 12:29:12 CEST 2007


Author: phk
Date: 2007-09-28 12:29:12 +0200 (Fri, 28 Sep 2007)
New Revision: 2051

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_backend.c
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishd/cache_http.c
   trunk/varnish-cache/bin/varnishd/cache_session.c
Log:
Preparation for implementation of restarts: Move the ws from http to
the containing object (session or obj).


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2007-09-28 10:29:12 UTC (rev 2051)
@@ -117,7 +117,7 @@
 	unsigned		magic;
 #define HTTP_MAGIC		0x6428b5c9
 
-	struct ws		ws[1];
+	struct ws		*ws;
 	txt			rx;		/* Received Request */
 	txt			pl;		/* Pipelined bytes */
 
@@ -186,8 +186,7 @@
 	unsigned		magic;
 #define BEREQ_MAGIC		0x3b6d250c
 	VTAILQ_ENTRY(bereq)	list;
-	void			*space;
-	unsigned		len;
+	struct ws		ws[1];
 	struct http		http[1];
 };
 
@@ -217,6 +216,7 @@
 	unsigned		xid;
 	struct objhead		*objhead;
 
+	struct ws		ws_o[1];
 	unsigned char		*vary;
 
 	unsigned		heap_idx;
@@ -285,6 +285,7 @@
 	/* HTTP request */
 	const char		*doclose;
 	struct http		*http;
+	struct ws		ws[1];
 
 	/* Timestamps, all on TIM_real() timescale */
 	double			t_open;
@@ -460,7 +461,7 @@
 void http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...);
 void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr);
 void http_SetH(struct http *to, unsigned n, const char *fm);
-void http_Setup(struct http *ht, void *space, unsigned len);
+void http_Setup(struct http *ht, struct ws *ws);
 int http_GetHdr(const struct http *hp, const char *hdr, char **ptr);
 int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr);
 int http_GetStatus(const struct http *hp);
@@ -475,7 +476,7 @@
 int http_RecvHead(struct http *hp, int fd);
 int http_DissectRequest(struct worker *w, struct http *sp, int fd);
 int http_DissectResponse(struct worker *w, struct http *sp, int fd);
-void http_DoConnection(struct sess *sp);
+const char *http_DoConnection(struct http *hp);
 void http_CopyHome(struct worker *w, int fd, struct http *hp);
 void http_Unset(struct http *hp, const char *hdr);
 

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c	2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c	2007-09-28 10:29:12 UTC (rev 2051)
@@ -147,10 +147,9 @@
 		if (bereq == NULL)
 			return (NULL);
 		bereq->magic = BEREQ_MAGIC;
-		bereq->space = bereq + 1;
-		bereq->len = len;
+		WS_Init(bereq->ws, bereq + 1, len);
 	}
-	http_Setup(bereq->http, bereq->space, bereq->len);
+	http_Setup(bereq->http, bereq->ws);
 	return (bereq);
 }
 

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2007-09-28 10:29:12 UTC (rev 2051)
@@ -763,7 +763,7 @@
 		return (0);
 	}
 
-	http_DoConnection(sp);
+	sp->doclose = http_DoConnection(sp->http);
 
 	/* By default we use the first backend */
 	AZ(sp->backend);

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2007-09-28 10:29:12 UTC (rev 2051)
@@ -332,7 +332,8 @@
 	CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
 	b = malloc(len);
 	AN(b);
-	http_Setup(hp2, b, len);
+	WS_Init(sp->obj->ws_o, b, len);
+	http_Setup(hp2, sp->obj->ws_o);
 
 	CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
 	hp2->logtag = HTTP_Obj;

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2007-09-28 10:29:12 UTC (rev 2051)
@@ -160,13 +160,12 @@
 /*--------------------------------------------------------------------*/
 
 void
-http_Setup(struct http *hp, void *space, unsigned len)
+http_Setup(struct http *hp, struct ws *ws)
 {
 
-	assert(len > 0);
 	memset(hp, 0, sizeof *hp);
 	hp->magic = HTTP_MAGIC;
-	WS_Init(hp->ws, space, len);
+	hp->ws = ws;
 	hp->nhd = HTTP_HDR_FIRST;
 }
 
@@ -266,18 +265,19 @@
 
 /*--------------------------------------------------------------------*/
 
-void
-http_DoConnection(struct sess *sp)
+const char *
+http_DoConnection(struct http *hp)
 {
-	struct http *hp = sp->http;
 	char *p, *q;
+	const char *ret;
 	unsigned u;
 
 	if (!http_GetHdr(hp, H_Connection, &p)) {
 		if (strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1"))
-			sp->doclose = "not HTTP/1.1";
-		return;
+			return ("not HTTP/1.1");
+		return (NULL);
 	}
+	ret = NULL;
 	for (; *p; p++) {
 		if (isspace(*p))
 			continue;
@@ -288,7 +288,7 @@
 				break;
 		u = pdiff(p, q);
 		if (u == 5 && !strncasecmp(p, "close", u))
-			sp->doclose = "Connection: close";
+			ret = "Connection: close";
 		u = http_findhdr(hp, u, p);
 		if (u != 0)
 			hp->hdf[u] |= HDF_FILTER;
@@ -296,6 +296,7 @@
 			break;
 		p = q;
 	}
+	return (ret);
 }
 
 /*--------------------------------------------------------------------*/

Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c	2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c	2007-09-28 10:29:12 UTC (rev 2051)
@@ -302,7 +302,6 @@
 	memset(sp, 0, sizeof *sp);
 	sp->magic = SESS_MAGIC;
 	sp->mem = sm;
-	sp->http = &sm->http;
 	sp->sockaddr = (void*)(&sm->sockaddr[0]);
 	sp->sockaddrlen = sizeof(sm->sockaddr[0]);
 	sp->mysockaddr = (void*)(&sm->sockaddr[1]);
@@ -319,7 +318,9 @@
 		sp->sockaddrlen = len;
 	}
 
-	http_Setup(&sm->http, (void *)(sm + 1), sm->workspace);
+	WS_Init(sp->ws, (void *)(sm + 1), sm->workspace);
+	sp->http = &sm->http;
+	http_Setup(sp->http, sp->ws);
 
 	return (sp);
 }




More information about the varnish-commit mailing list