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;
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);
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);
} 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")) {
VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
}
+ VBE_UpdateHealth(sp, vc, -4);
VBE_ClosedFd(sp->wrk, vc);
return (-1);
}
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);
{
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);
}
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);
}
assert(status >= 0 && status <= 999);
sprintf(stat, "%d", status);
http_PutField(w, fd, to, HTTP_HDR_STATUS, stat);
+ to->status = status;
}
void