r2063 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Sun Sep 30 22:16:28 CEST 2007
Author: phk
Date: 2007-09-30 22:16:28 +0200 (Sun, 30 Sep 2007)
New Revision: 2063
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
More caching of HTTP status
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 20:08:26 UTC (rev 2062)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 20:16:28 UTC (rev 2063)
@@ -300,24 +300,6 @@
i = Fetch(sp);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
- /* Experimental. Set time for last check of backend health.
- * If the backend replied with 200, it is obviously up and running,
- * increase health parameter. If we got a 504 back, it would imply
- * that the backend is not reachable. Decrease health parameter.
- */
- sp->backend->last_check = TIM_mono();
- sp->backend->minute_limit = 1;
- if (!i){
- if (http_GetStatus(sp->bereq->http) == 200) {
- if (sp->backend->health < 10000)
- sp->backend->health++;
- } else if(http_GetStatus(sp->bereq->http) == 504) {
- if (sp->backend->health > -10000)
- sp->backend->health--;
- }
- }
-
-
VBE_free_bereq(sp->bereq);
sp->bereq = NULL;
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-30 20:08:26 UTC (rev 2062)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-30 20:16:28 UTC (rev 2063)
@@ -282,6 +282,7 @@
WRK_Reset(w, &vc->fd);
http_Write(w, hp, 0);
if (WRK_Flush(w)) {
+ VBE_UpdateHealth(sp, vc, -1);
VBE_ClosedFd(sp->wrk, vc);
/* XXX: other cleanup ? */
return (1);
@@ -296,6 +297,7 @@
while (i == 0);
if (http_DissectResponse(sp->wrk, htc, hp)) {
+ VBE_UpdateHealth(sp, vc, -2);
VBE_ClosedFd(sp->wrk, vc);
/* XXX: other cleanup ? */
return (1);
@@ -335,6 +337,7 @@
} else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
/* XXX: AUGH! */
WSL(sp->wrk, SLT_Debug, vc->fd, "Invalid Transfer-Encoding");
+ VBE_UpdateHealth(sp, vc, -3);
VBE_ClosedFd(sp->wrk, vc);
return (-1);
} else if (strcmp(http_GetProto(hp), "HTTP/1.1")) {
@@ -355,6 +358,7 @@
VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
}
+ VBE_UpdateHealth(sp, vc, -4);
VBE_ClosedFd(sp->wrk, vc);
return (-1);
}
@@ -376,10 +380,7 @@
if (http_GetHdr(hp, H_Connection, &b) && !strcasecmp(b, "close"))
cls = 1;
- if (http_GetStatus(sp->bereq->http) == 200)
- VBE_UpdateHealth(sp, vc, 1);
- else if(http_GetStatus(sp->bereq->http) == 504)
- VBE_UpdateHealth(sp, vc, -1);
+ VBE_UpdateHealth(sp, vc, http_GetStatus(sp->bereq->http));
if (cls)
VBE_ClosedFd(sp->wrk, vc);
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-30 20:08:26 UTC (rev 2062)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-30 20:16:28 UTC (rev 2063)
@@ -327,9 +327,6 @@
{
Tcheck(hp->hd[HTTP_HDR_STATUS]);
- if (hp->status == 0)
- hp->status = strtoul(hp->hd[HTTP_HDR_STATUS].b,
- NULL /* XXX */, 10));
return (hp->status);
}
@@ -506,6 +503,7 @@
if (i != 0 || memcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.", 7))
WSLR(w, SLT_HttpGarbage, htc->fd, htc->rxbuf);
+ hp->status = strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10);
return (i);
}
@@ -738,6 +736,7 @@
assert(status >= 0 && status <= 999);
sprintf(stat, "%d", status);
http_PutField(w, fd, to, HTTP_HDR_STATUS, stat);
+ to->status = status;
}
void
More information about the varnish-commit
mailing list