Commit 4e5828d8 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

move vbc from bo to bo->htc

parent 7ffb0afa
......@@ -254,6 +254,7 @@ struct http_conn {
ssize_t content_length;
enum body_status body_status;
struct vfp_ctx vfc[1];
struct vbc *vbc;
};
/*--------------------------------------------------------------------*/
......@@ -489,7 +490,6 @@ struct busyobj {
struct ws ws[1];
char *ws_bo;
struct vbc *vbc;
struct http *bereq0;
struct http *bereq;
struct http *beresp;
......
......@@ -353,20 +353,20 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo)
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
AZ(bo->htc);
bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc);
memset(bo->htc, 0, sizeof *bo->htc);
bo->htc->magic = HTTP_CONN_MAGIC;
vc = vbe_GetVbe(bo, vs);
if (vc != NULL) {
FIND_TMO(first_byte_timeout,
vc->first_byte_timeout, bo, vs->vrt);
FIND_TMO(between_bytes_timeout,
vc->between_bytes_timeout, bo, vs->vrt);
}
if (vc == NULL)
if (vc == NULL) {
VSLb(bo->vsl, SLT_FetchError, "no backend connection");
return (NULL);
}
if (bo->htc == NULL)
bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc);
memset(bo->htc, 0, sizeof *bo->htc);
bo->htc->magic = HTTP_CONN_MAGIC;
bo->htc->vbc = vc;
bo->htc->fd = vc->fd;
FIND_TMO(first_byte_timeout, vc->first_byte_timeout, bo, vs->vrt);
FIND_TMO(between_bytes_timeout, vc->between_bytes_timeout, bo, vs->vrt);
return (vc);
}
......@@ -388,15 +388,15 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
struct busyobj *bo)
{
int i;
struct vbc *vbc;
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
bo->vbc = vbe_dir_getfd(d, bo);
if (bo->vbc == NULL) {
vbc = vbe_dir_getfd(d, bo);
if (vbc == NULL) {
VSLb(bo->vsl, SLT_FetchError, "no backend connection");
bo->htc = NULL;
return (-1);
}
......@@ -407,11 +407,11 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
* Do a single retry in that case.
*/
if (i == 1) {
AZ(bo->vbc);
AZ(bo->htc);
VSC_C_main->backend_retry++;
bo->doclose = SC_NULL;
bo->vbc = vbe_dir_getfd(d, bo);
if (bo->vbc == NULL) {
bo->htc->vbc = vbe_dir_getfd(d, bo);
if (bo->htc->vbc == NULL) {
VSLb(bo->vsl, SLT_FetchError, "no backend connection");
bo->htc = NULL;
return (-1);
......@@ -420,9 +420,9 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
}
if (i != 0) {
bo->doclose = SC_NULL;
AZ(bo->vbc);
AZ(bo->htc);
} else {
AN(bo->vbc);
AN(bo->htc->vbc);
}
return (i);
}
......@@ -451,26 +451,26 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
bo->htc = NULL;
if (bo->vbc == NULL)
if (bo->htc->vbc == NULL)
return;
bp = bo->vbc->backend;
bp = bo->htc->vbc->backend;
if (bo->doclose != SC_NULL) {
VSLb(bo->vsl, SLT_BackendClose, "%d %s", bo->vbc->fd,
VSLb(bo->vsl, SLT_BackendClose, "%d %s", bo->htc->vbc->fd,
bp->display_name);
VTCP_close(&bo->vbc->fd);
VTCP_close(&bo->htc->vbc->fd);
VBE_DropRefConn(bp, &bo->acct);
bo->vbc->backend = NULL;
VBE_ReleaseConn(bo->vbc);
bo->htc->vbc->backend = NULL;
VBE_ReleaseConn(bo->htc->vbc);
} else {
VSLb(bo->vsl, SLT_BackendReuse, "%d %s", bo->vbc->fd,
VSLb(bo->vsl, SLT_BackendReuse, "%d %s", bo->htc->vbc->fd,
bp->display_name);
Lck_Lock(&bp->mtx);
VSC_C_main->backend_recycle++;
VTAILQ_INSERT_HEAD(&bp->connlist, bo->vbc, list);
VTAILQ_INSERT_HEAD(&bp->connlist, bo->htc->vbc, list);
VBE_DropRefLocked(bp, &bo->acct);
}
bo->vbc = NULL;
bo->htc->vbc = NULL;
bo->htc = NULL;
}
static struct suckaddr * __match_proto__(vdi_suckaddr_f)
......@@ -481,8 +481,8 @@ vbe_dir_suckaddr(const struct director *d, struct worker *wrk,
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
if (bo->vbc != NULL)
return(bo->vbc->addr);
if (bo->htc->vbc != NULL)
return(bo->htc->vbc->addr);
return (NULL);
}
......
......@@ -200,7 +200,7 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
VSL_End(bo->vsl);
AZ(bo->vbc);
AZ(bo->htc);
if (bo->fetch_objcore != NULL) {
AN(wrk);
......
......@@ -338,8 +338,8 @@ pan_busyobj(const struct busyobj *bo)
VSB_printf(pan_vsp, "\n");
}
VSB_printf(pan_vsp, " },\n");
if (VALID_OBJ(bo->vbc, BACKEND_MAGIC))
pan_vbc(bo->vbc);
if (VALID_OBJ(bo->htc->vbc, BACKEND_MAGIC))
pan_vbc(bo->htc->vbc);
if (bo->bereq->ws != NULL)
pan_http("bereq", bo->bereq, 4);
if (bo->beresp->ws != NULL)
......
......@@ -88,12 +88,12 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(bo->htc->vbc, VBC_MAGIC);
CHECK_OBJ_ORNULL(bo->req, REQ_MAGIC);
htc = bo->htc;
hp = bo->bereq;
vc = bo->vbc;
vc = htc->vbc;
if (vc->recycled)
retry = 1;
......
......@@ -120,12 +120,13 @@ V1P_Process(struct req *req, struct busyobj *bo)
SES_Close(req->sp, SC_OVERLOAD);
return;
}
bo->vbc = vc; /* For panic dumping */
CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
assert(bo->htc->fd >= 0);
bo->wrk = req->wrk;
bo->director_state = DIR_S_BODY;
(void)VTCP_blocking(vc->fd);
(void)VTCP_blocking(bo->htc->fd);
WRW_Reserve(wrk, &vc->fd, bo->vsl, req->t_req);
WRW_Reserve(wrk, &bo->htc->fd, bo->vsl, req->t_req);
hdrbytes = HTTP1_Write(wrk, bo->bereq, HTTP1_Req);
if (req->htc->pipeline_b != NULL)
......@@ -142,7 +143,7 @@ V1P_Process(struct req *req, struct busyobj *bo)
if (i == 0) {
memset(fds, 0, sizeof fds);
fds[0].fd = vc->fd;
fds[0].fd = bo->htc->fd;
fds[0].events = POLLIN | POLLERR;
fds[1].fd = req->sp->fd;
fds[1].events = POLLIN | POLLERR;
......@@ -155,20 +156,20 @@ V1P_Process(struct req *req, struct busyobj *bo)
if (i < 1)
break;
if (fds[0].revents &&
rdf(vc->fd, req->sp->fd, &acct_pipe.out)) {
rdf(bo->htc->fd, req->sp->fd, &acct_pipe.out)) {
if (fds[1].fd == -1)
break;
(void)shutdown(vc->fd, SHUT_RD);
(void)shutdown(bo->htc->fd, SHUT_RD);
(void)shutdown(req->sp->fd, SHUT_WR);
fds[0].events = 0;
fds[0].fd = -1;
}
if (fds[1].revents &&
rdf(req->sp->fd, vc->fd, &acct_pipe.in)) {
rdf(req->sp->fd, bo->htc->fd, &acct_pipe.in)) {
if (fds[0].fd == -1)
break;
(void)shutdown(req->sp->fd, SHUT_RD);
(void)shutdown(vc->fd, SHUT_WR);
(void)shutdown(bo->htc->fd, SHUT_WR);
fds[1].events = 0;
fds[1].fd = -1;
}
......
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