r1057 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Sep 18 08:41:57 CEST 2006


Author: phk
Date: 2006-09-18 08:41:57 +0200 (Mon, 18 Sep 2006)
New Revision: 1057

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_pass.c
   trunk/varnish-cache/bin/varnishd/cache_pipe.c
   trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Unify backend error handling


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-09-18 06:26:56 UTC (rev 1056)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-09-18 06:41:57 UTC (rev 1057)
@@ -297,7 +297,7 @@
 
 /* cache_backend.c */
 void VBE_Init(void);
-struct vbe_conn *VBE_GetFd(struct backend *bp, unsigned xid);
+struct vbe_conn *VBE_GetFd(struct sess *sp);
 void VBE_ClosedFd(struct vbe_conn *vc, int already);
 void VBE_RecycleFd(struct vbe_conn *vc);
 
@@ -367,7 +367,7 @@
 void PassBody(struct sess *sp);
 
 /* cache_pipe.c */
-void PipeSession(struct sess *sp);
+int PipeSession(struct sess *sp);
 
 /* cache_pool.c */
 void WRK_Init(void);

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-09-18 06:26:56 UTC (rev 1056)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-09-18 06:41:57 UTC (rev 1057)
@@ -175,12 +175,15 @@
  * new connection.
  */
 
-struct vbe_conn *
-VBE_GetFd(struct backend *bp, unsigned xid)
+static struct vbe_conn *
+vbe_nextfd(struct sess *sp)
 {
 	struct vbe_conn *vc, *vc2;
 	struct pollfd pfd;
+	struct backend *bp;
 
+	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	bp = sp->backend;
 	CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
 	while (1) {
 		/*
@@ -245,12 +248,29 @@
 	if (vc != NULL ) {
 		assert(vc->fd >= 0);
 		VSL_stats->backend_conn++;
-		VSL(SLT_BackendXID, vc->fd, "%u", xid);
+		WSL(sp->wrk, SLT_BackendXID, vc->fd, "%u", sp->xid);
 		AN(vc->backend);
 	}
 	return (vc);
 }
 
+/*--------------------------------------------------------------------*/
+
+struct vbe_conn *
+VBE_GetFd(struct sess *sp)
+{
+	struct vbe_conn *vc;
+
+	vc = vbe_nextfd(sp);
+	if (vc != NULL) {
+		WSL(sp->wrk, SLT_Backend, sp->fd, "%d %s", vc->fd,
+		    sp->backend->vcl_name);
+		return (vc);
+	}
+	RES_Error(sp, 503, "Backend did not respond.");
+	return (NULL);
+}
+
 /* Close a connection ------------------------------------------------*/
 
 void

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2006-09-18 06:26:56 UTC (rev 1056)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2006-09-18 06:41:57 UTC (rev 1057)
@@ -530,7 +530,14 @@
 		INCOMPL();
 	if (sp->handling == VCL_RET_FETCH) {
 		AZ(sp->vbc);
-		FetchHeaders(sp);
+		if (FetchHeaders(sp)) {
+			sp->obj->cacheable = 0;
+			HSH_Unbusy(sp->obj);
+			HSH_Deref(sp->obj);
+			sp->obj = NULL;
+			sp->step = STP_DONE;
+			return (0);
+		}
 		sp->step = STP_FETCH;
 		AN(sp->vbc);
 		return (0);
@@ -613,7 +620,7 @@
 {
 
 	sp->wrk->acct.pipe++;
-	PipeSession(sp);
+	(void)PipeSession(sp);
 	sp->step = STP_DONE;
 	return (0);
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-09-18 06:26:56 UTC (rev 1056)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-09-18 06:41:57 UTC (rev 1057)
@@ -290,11 +290,9 @@
 
 	sp->obj->xid = sp->xid;
 
-	vc = VBE_GetFd(sp->backend, sp->xid);
+	vc = VBE_GetFd(sp);
 	if (vc == NULL)
-		vc = VBE_GetFd(sp->backend, sp->xid);
-	XXXAN(vc);
-	WSL(w, SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
+		return (1);
 
 	http_ClrHeader(vc->http);
 	vc->http->logtag = HTTP_Tx;

Modified: trunk/varnish-cache/bin/varnishd/cache_pass.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-09-18 06:26:56 UTC (rev 1056)
+++ trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-09-18 06:41:57 UTC (rev 1057)
@@ -202,12 +202,9 @@
 	CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
 	w = sp->wrk;
 
-	vc = VBE_GetFd(sp->backend, sp->xid);
-	if (vc == NULL) {
-		RES_Error(sp, 503, "Backend did not respond.");
+	vc = VBE_GetFd(sp);
+	if (vc == NULL)
 		return (1);
-	}
-	WSL(w, SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
 
 	http_CopyReq(w, vc->fd, vc->http, sp->http);
 	http_FilterHeader(w, vc->fd, vc->http, sp->http, HTTPH_R_PASS);

Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c	2006-09-18 06:26:56 UTC (rev 1056)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c	2006-09-18 06:41:57 UTC (rev 1057)
@@ -40,7 +40,7 @@
 	}
 }
 
-void
+int
 PipeSession(struct sess *sp)
 {
 	struct vbe_conn *vc;
@@ -53,12 +53,9 @@
 	CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
 	w = sp->wrk;
 
-	vc = VBE_GetFd(sp->backend, sp->xid);
-	if (vc == NULL) {
-		RES_Error(sp, 503, "Backend did not respond.");
-		return;
-	}
-	VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
+	vc = VBE_GetFd(sp);
+	if (vc == NULL)
+		return (1);
 	vc->http->logtag = HTTP_Tx;
 
 	http_CopyReq(w, vc->fd, vc->http, sp->http);

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c	2006-09-18 06:26:56 UTC (rev 1056)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c	2006-09-18 06:41:57 UTC (rev 1057)
@@ -103,7 +103,7 @@
 	vsb_cat(sb,
 		"Server: Varnish\r\n"
 		"Connection: close\r\n"
-		"content-Type: text/html; charset=iso-8859-1\r\n"
+		"Content-Type: text/html; charset=iso-8859-1\r\n"
 		"\r\n"
 		"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
 		"<HTML>\r\n"




More information about the varnish-commit mailing list