Commit a3c3e4ef authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Have http_conn point to the fd rather than carry a copy

parent 42fb7e96
......@@ -218,7 +218,7 @@ struct http_conn {
unsigned magic;
#define HTTP_CONN_MAGIC 0x3e19edd1
int fd;
int *rfd;
enum sess_close doclose;
enum body_status body_status;
struct ws *ws;
......
......@@ -373,7 +373,7 @@ vca_make_session(struct worker *wrk, void *arg)
req = Req_New(wrk, sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
req->htc->fd = sp->fd;
req->htc->rfd = &sp->fd;
SES_SetTransport(wrk, sp, req, wa->acceptlsock->transport);
}
......
......@@ -119,7 +119,7 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo)
INIT_OBJ(bo->htc, HTTP_CONN_MAGIC);
bo->htc->priv = vc;
bo->htc->fd = vc->fd;
bo->htc->rfd = &vc->fd;
FIND_TMO(first_byte_timeout,
bo->htc->first_byte_timeout, bo, bp);
FIND_TMO(between_bytes_timeout,
......
......@@ -183,7 +183,8 @@ pan_htc(struct vsb *vsb, const struct http_conn *htc)
return;
VSB_indent(vsb, 2);
PAN_CheckMagic(vsb, htc, HTTP_CONN_MAGIC);
VSB_printf(vsb, "fd = %d,\n", htc->fd);
if (htc->rfd != NULL)
VSB_printf(vsb, "fd = %d (@%p),\n", *htc->rfd, htc->rfd);
VSB_printf(vsb, "doclose = %s,\n", sess_close_2str(htc->doclose, 0));
pan_ws(vsb, htc->ws);
VSB_printf(vsb, "{rxbuf_b, rxbuf_e} = {%p, %p},\n",
......
......@@ -68,7 +68,6 @@ Req_New(const struct worker *wrk, struct sess *sp)
req->top = req; // esi overrides
INIT_OBJ(req->htc, HTTP_CONN_MAGIC);
req->htc->fd = -1;
e = (char*)req + sz;
p = (char*)(req + 1);
......
......@@ -238,6 +238,8 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func,
int i;
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
AN(htc->rfd);
assert(*htc->rfd > 0);
AN(htc->ws->r);
AN(htc->rxbuf_b);
assert(htc->rxbuf_b <= htc->rxbuf_e);
......@@ -294,7 +296,7 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func,
}
if (tmo <= 0.0)
tmo = 1e-3;
i = VTCP_read(htc->fd, htc->rxbuf_e, i, tmo);
i = VTCP_read(*htc->rfd, htc->rxbuf_e, i, tmo);
if (i == 0 || i == -1) {
WS_ReleaseP(htc->ws, htc->rxbuf_b);
return (HTC_S_EOF);
......
......@@ -88,6 +88,7 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr,
CHECK_OBJ_ORNULL(bo->req, REQ_MAGIC);
htc = bo->htc;
assert(*htc->rfd > 0);
hp = bo->bereq;
if (bo->req != NULL &&
......@@ -96,11 +97,11 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr,
do_chunked = 1;
}
VTCP_hisname(htc->fd, abuf, sizeof abuf, pbuf, sizeof pbuf);
VTCP_hisname(*htc->rfd, abuf, sizeof abuf, pbuf, sizeof pbuf);
VSLb(bo->vsl, SLT_BackendStart, "%s %s", abuf, pbuf);
(void)VTCP_blocking(htc->fd); /* XXX: we should timeout instead */
V1L_Reserve(wrk, wrk->aws, &htc->fd, bo->vsl, bo->t_prev);
(void)VTCP_blocking(*htc->rfd); /* XXX: we should timeout instead */
V1L_Reserve(wrk, wrk->aws, htc->rfd, bo->vsl, bo->t_prev);
*ctr += HTTP1_Write(wrk, hp, HTTP1_Req);
/* Deal with any message-body the request might (still) have */
......@@ -150,6 +151,7 @@ V1F_FetchRespHdr(struct busyobj *bo)
CHECK_OBJ_ORNULL(bo->req, REQ_MAGIC);
htc = bo->htc;
assert(*htc->rfd > 0);
VSC_C_main->backend_req++;
......@@ -189,7 +191,7 @@ V1F_FetchRespHdr(struct busyobj *bo)
}
return (htc->rxbuf_e == htc->rxbuf_b ? 1 : -1);
}
VTCP_set_read_timeout(htc->fd, htc->between_bytes_timeout);
VTCP_set_read_timeout(*htc->rfd, htc->between_bytes_timeout);
hp = bo->beresp;
......
......@@ -130,7 +130,7 @@ http1_unwait(struct worker *wrk, void *arg)
WS_Release(sp->ws, 0);
req = Req_New(wrk, sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
req->htc->fd = sp->fd;
req->htc->rfd = &sp->fd;
HTC_RxInit(req->htc, req->ws);
http1_setstate(sp, H1NEWREQ);
wrk->task.func = http1_req;
......
......@@ -73,7 +73,7 @@ v1f_read(const struct vfp_ctx *vc, struct http_conn *htc, void *d, ssize_t len)
htc->pipeline_b = htc->pipeline_e = NULL;
}
if (len > 0) {
i = read(htc->fd, p, len);
i = read(*htc->rfd, p, len);
if (i < 0) {
// XXX: VTCP_Assert(i); // but also: EAGAIN
VSLb(vc->wrk->vsl, SLT_FetchError,
......
......@@ -136,7 +136,7 @@ h2_new_sess(const struct worker *wrk, struct sess *sp, struct req *srq)
h2->ws = srq->ws;
h2->vsl = srq->vsl;
h2->vsl->wid = sp->vxid;
h2->htc->fd = sp->fd;
h2->htc->rfd = &sp->fd;
h2->sess = sp;
VTAILQ_INIT(&h2->streams);
#define H2_SETTINGS(n,v,d) \
......@@ -496,7 +496,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2)
enum h2frame ft;
struct h2_req *r2 = NULL;
(void)VTCP_blocking(h2->htc->fd);
(void)VTCP_blocking(*h2->htc->rfd);
h2->sess->t_idle = VTIM_real();
hs = HTC_RxStuff(h2->htc, h2_frame_complete,
NULL, NULL, NAN,
......
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