Commit 2291418c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Rename the backend connections two http's "bereq" and "beresp"


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1621 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 23d37582
......@@ -185,8 +185,8 @@ struct vbe_conn {
TAILQ_ENTRY(vbe_conn) list;
struct backend *backend;
int fd;
struct http *http;
struct http *http2;
struct http *bereq;
struct http *beresp;
struct http http_mem[2];
};
......
......@@ -89,13 +89,13 @@ vbe_new_conn(void)
return (NULL);
VSL_stats->n_vbe_conn++;
vbc->magic = VBE_CONN_MAGIC;
vbc->http = &vbc->http_mem[0];
vbc->http2 = &vbc->http_mem[1];
vbc->bereq = &vbc->http_mem[0];
vbc->beresp = &vbc->http_mem[1];
vbc->fd = -1;
p = (void *)(vbc + 1);
http_Setup(vbc->http, p, space);
http_Setup(vbc->bereq, p, space);
p += space;
http_Setup(vbc->http2, p, space);
http_Setup(vbc->beresp, p, space);
return (vbc);
}
......@@ -337,8 +337,8 @@ VBE_ClosedFd(struct worker *w, struct vbe_conn *vc, int already)
AZ(close(vc->fd));
vc->fd = -1;
vc->backend = NULL;
WS_Reset(vc->http->ws);
WS_Reset(vc->http2->ws);
WS_Reset(vc->bereq->ws);
WS_Reset(vc->beresp->ws);
LOCK(&vbemtx);
TAILQ_INSERT_HEAD(&vbe_head, vc, list);
VSL_stats->backend_unused++;
......@@ -355,8 +355,8 @@ VBE_RecycleFd(struct worker *w, struct vbe_conn *vc)
assert(vc->fd >= 0);
AN(vc->backend);
WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
WS_Reset(vc->http->ws);
WS_Reset(vc->http2->ws);
WS_Reset(vc->bereq->ws);
WS_Reset(vc->beresp->ws);
LOCK(&vbemtx);
VSL_stats->backend_recycle++;
TAILQ_INSERT_HEAD(&vc->backend->connlist, vc, list);
......
......@@ -275,20 +275,20 @@ Fetch(struct sess *sp)
if (vc == NULL)
return (1);
http_ClrHeader(vc->http);
vc->http->logtag = HTTP_Tx;
http_GetReq(w, vc->fd, vc->http, sp->http);
http_FilterHeader(w, vc->fd, vc->http, sp->http, HTTPH_R_FETCH);
http_PrintfHeader(w, vc->fd, vc->http, "X-Varnish: %u", sp->xid);
http_PrintfHeader(w, vc->fd, vc->http,
http_ClrHeader(vc->bereq);
vc->bereq->logtag = HTTP_Tx;
http_GetReq(w, vc->fd, vc->bereq, sp->http);
http_FilterHeader(w, vc->fd, vc->bereq, sp->http, HTTPH_R_FETCH);
http_PrintfHeader(w, vc->fd, vc->bereq, "X-Varnish: %u", sp->xid);
http_PrintfHeader(w, vc->fd, vc->bereq,
"X-Forwarded-for: %s", sp->addr);
if (!http_GetHdr(vc->http, H_Host, &b)) {
http_PrintfHeader(w, vc->fd, vc->http, "Host: %s",
if (!http_GetHdr(vc->bereq, H_Host, &b)) {
http_PrintfHeader(w, vc->fd, vc->bereq, "Host: %s",
sp->backend->hostname);
}
WRK_Reset(w, &vc->fd);
http_Write(w, vc->http, 0);
http_Write(w, vc->bereq, 0);
if (WRK_Flush(w)) {
/* XXX: cleanup */
return (1);
......@@ -298,11 +298,11 @@ Fetch(struct sess *sp)
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
if (http_RecvHead(vc->http, vc->fd)) {
if (http_RecvHead(vc->bereq, vc->fd)) {
/* XXX: cleanup */
return (1);
}
if (http_DissectResponse(sp->wrk, vc->http, vc->fd)) {
if (http_DissectResponse(sp->wrk, vc->bereq, vc->fd)) {
/* XXX: cleanup */
return (1);
}
......@@ -315,22 +315,22 @@ Fetch(struct sess *sp)
assert(sp->obj->busy != 0);
if (http_GetHdr(vc->http, H_Last_Modified, &b))
if (http_GetHdr(vc->bereq, H_Last_Modified, &b))
sp->obj->last_modified = TIM_parse(b);
hp = vc->http2;
hp = vc->beresp;
http_ClrHeader(hp);
hp->logtag = HTTP_Obj;
http_CopyResp(sp->wrk, sp->fd, hp, vc->http);
http_FilterHeader(sp->wrk, sp->fd, hp, vc->http, HTTPH_A_INS);
http_CopyResp(sp->wrk, sp->fd, hp, vc->bereq);
http_FilterHeader(sp->wrk, sp->fd, hp, vc->bereq, HTTPH_A_INS);
if (body) {
if (http_GetHdr(vc->http, H_Content_Length, &b))
cls = fetch_straight(sp, vc->fd, vc->http, b);
else if (http_HdrIs(vc->http, H_Transfer_Encoding, "chunked"))
cls = fetch_chunked(sp, vc->fd, vc->http);
if (http_GetHdr(vc->bereq, H_Content_Length, &b))
cls = fetch_straight(sp, vc->fd, vc->bereq, b);
else if (http_HdrIs(vc->bereq, H_Transfer_Encoding, "chunked"))
cls = fetch_chunked(sp, vc->fd, vc->bereq);
else
cls = fetch_eof(sp, vc->fd, vc->http);
cls = fetch_eof(sp, vc->fd, vc->bereq);
http_PrintfHeader(sp->wrk, sp->fd, hp,
"Content-Length: %u", sp->obj->len);
} else
......@@ -359,7 +359,7 @@ Fetch(struct sess *sp)
http_CopyHttp(&sp->obj->http, hp);
if (http_GetHdr(vc->http, H_Connection, &b) && !strcasecmp(b, "close"))
if (http_GetHdr(vc->bereq, H_Connection, &b) && !strcasecmp(b, "close"))
cls = 1;
if (cls)
......
......@@ -87,19 +87,19 @@ PipeSession(struct sess *sp)
vc = VBE_GetFd(sp);
if (vc == NULL)
return;
vc->http->logtag = HTTP_Tx;
vc->bereq->logtag = HTTP_Tx;
http_CopyReq(w, vc->fd, vc->http, sp->http);
http_FilterHeader(w, vc->fd, vc->http, sp->http, HTTPH_R_PIPE);
http_PrintfHeader(w, vc->fd, vc->http, "X-Varnish: %u", sp->xid);
http_PrintfHeader(w, vc->fd, vc->http,
http_CopyReq(w, vc->fd, vc->bereq, sp->http);
http_FilterHeader(w, vc->fd, vc->bereq, sp->http, HTTPH_R_PIPE);
http_PrintfHeader(w, vc->fd, vc->bereq, "X-Varnish: %u", sp->xid);
http_PrintfHeader(w, vc->fd, vc->bereq,
"X-Forwarded-for: %s", sp->addr);
if (!http_GetHdr(vc->http, H_Host, &b)) {
http_PrintfHeader(w, vc->fd, vc->http, "Host: %s",
if (!http_GetHdr(vc->bereq, H_Host, &b)) {
http_PrintfHeader(w, vc->fd, vc->bereq, "Host: %s",
sp->backend->hostname);
}
WRK_Reset(w, &vc->fd);
http_Write(w, vc->http, 0);
http_Write(w, vc->bereq, 0);
if (http_GetTail(sp->http, 0, &b, &e) && b != e)
WRK_Write(w, b, e - b);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment