Commit 372312e0 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move resp.* to workspace_client and struct req

Retire a tiresome testcase to .disabled.

Constify some VRT prototypes.
parent 718e8772
......@@ -329,9 +329,6 @@ struct worker {
struct ws ws[1];
struct http *resp;
struct object *obj;
struct objcore *objcore;
struct busyobj *busyobj;
......@@ -622,6 +619,7 @@ struct req {
/* HTTP request */
struct http *http;
struct http *http0;
struct http *resp;
struct ws ws[1];
};
......
......@@ -281,7 +281,7 @@ cnt_prepresp(struct sess *sp)
wrk->obj->last_lru = sp->req->t_resp;
wrk->obj->last_use = sp->req->t_resp; /* XXX: locking ? */
}
http_Setup(wrk->resp, wrk->ws);
http_Setup(sp->req->resp, sp->req->ws);
RES_BuildHttp(sp);
VCL_deliver_method(sp);
switch (sp->req->handling) {
......@@ -301,7 +301,7 @@ cnt_prepresp(struct sess *sp)
AZ(wrk->obj);
sp->req->restarts++;
sp->req->director = NULL;
http_Setup(wrk->resp, NULL);
http_Setup(sp->req->resp, NULL);
sp->step = STP_RECV;
return (0);
default:
......@@ -349,7 +349,7 @@ cnt_deliver(struct sess *sp)
assert(WRW_IsReleased(wrk));
assert(wrk->wrw.ciov == wrk->wrw.siov);
(void)HSH_Deref(wrk, NULL, &wrk->obj);
http_Setup(wrk->resp, NULL);
http_Setup(sp->req->resp, NULL);
sp->step = STP_DONE;
return (0);
}
......@@ -1012,7 +1012,7 @@ cnt_streambody(struct sess *sp)
assert(wrk->wrw.ciov == wrk->wrw.siov);
(void)HSH_Deref(wrk, NULL, &wrk->obj);
VBO_DerefBusyObj(wrk, &wrk->busyobj);
http_Setup(wrk->resp, NULL);
http_Setup(sp->req->resp, NULL);
sp->step = STP_DONE;
return (0);
}
......
......@@ -201,8 +201,6 @@ pan_wrk(const struct worker *wrk)
pan_http("bereq", wrk->busyobj->bereq, 4);
if (wrk->busyobj != NULL && wrk->busyobj->beresp->ws != NULL)
pan_http("beresp", wrk->busyobj->beresp, 4);
if (wrk->resp->ws != NULL)
pan_http("resp", wrk->resp, 4);
VSB_printf(pan_vsp, " },\n");
}
......@@ -267,6 +265,8 @@ pan_sess(const struct sess *sp)
pan_ws(sp->req->ws, 2);
pan_http("req", sp->req->http, 2);
if (sp->req->resp->ws != NULL)
pan_http("resp", sp->req->resp, 4);
if (sp->wrk != NULL)
pan_wrk(sp->wrk);
......
......@@ -194,7 +194,6 @@ Pool_Work_Thread(void *priv, struct worker *w)
w->do_what = pool_do_inval;
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(w->resp, HTTP_MAGIC);
WS_Reset(w->ws, NULL);
......@@ -267,7 +266,6 @@ Pool_Work_Thread(void *priv, struct worker *w)
WS_Assert(w->ws);
AZ(w->busyobj);
AZ(w->resp->ws);
AZ(w->wrw.wfd);
AZ(w->storage_hint);
assert(w->wlp == w->wlb);
......
......@@ -87,14 +87,14 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
if (low > high)
return;
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp,
"Content-Range: bytes %jd-%jd/%jd",
(intmax_t)low, (intmax_t)high, (intmax_t)sp->wrk->obj->len);
http_Unset(sp->wrk->resp, H_Content_Length);
http_Unset(sp->req->resp, H_Content_Length);
assert(sp->wrk->res_mode & RES_LEN);
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp,
"Content-Length: %jd", (intmax_t)(1 + high - low));
http_SetResp(sp->wrk->resp, "HTTP/1.1", 206, "Partial Content");
http_SetResp(sp->req->resp, "HTTP/1.1", 206, "Partial Content");
*plow = low;
*phigh = high;
......@@ -110,39 +110,39 @@ RES_BuildHttp(const struct sess *sp)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
http_ClrHeader(sp->wrk->resp);
sp->wrk->resp->logtag = HTTP_Tx;
http_CopyResp(sp->wrk->resp, sp->wrk->obj->http);
http_FilterFields(sp->wrk, sp->vsl_id, sp->wrk->resp,
http_ClrHeader(sp->req->resp);
sp->req->resp->logtag = HTTP_Tx;
http_CopyResp(sp->req->resp, sp->wrk->obj->http);
http_FilterFields(sp->wrk, sp->vsl_id, sp->req->resp,
sp->wrk->obj->http, HTTPH_A_DELIVER);
if (!(sp->wrk->res_mode & RES_LEN)) {
http_Unset(sp->wrk->resp, H_Content_Length);
http_Unset(sp->req->resp, H_Content_Length);
} else if (cache_param->http_range_support) {
/* We only accept ranges if we know the length */
http_SetHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
http_SetHeader(sp->wrk, sp->vsl_id, sp->req->resp,
"Accept-Ranges: bytes");
}
if (sp->wrk->res_mode & RES_CHUNKED)
http_SetHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
http_SetHeader(sp->wrk, sp->vsl_id, sp->req->resp,
"Transfer-Encoding: chunked");
VTIM_format(VTIM_real(), time_str);
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp,
"Date: %s", time_str);
if (sp->req->xid != sp->wrk->obj->xid)
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp,
"X-Varnish: %u %u", sp->req->xid, sp->wrk->obj->xid);
else
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp,
"X-Varnish: %u", sp->req->xid);
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp, "Age: %.0f",
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp, "Age: %.0f",
sp->wrk->obj->exp.age + sp->req->t_resp -
sp->wrk->obj->exp.entered);
http_SetHeader(sp->wrk, sp->vsl_id, sp->wrk->resp, "Via: 1.1 varnish");
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp, "Connection: %s",
http_SetHeader(sp->wrk, sp->vsl_id, sp->req->resp, "Via: 1.1 varnish");
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp, "Connection: %s",
sp->req->doclose ? "close" : "keep-alive");
}
......@@ -263,9 +263,9 @@ RES_WriteObj(struct sess *sp)
sp->req->http->conds &&
RFC2616_Do_Cond(sp)) {
sp->req->wantbody = 0;
http_SetResp(sp->wrk->resp, "HTTP/1.1", 304, "Not Modified");
http_Unset(sp->wrk->resp, H_Content_Length);
http_Unset(sp->wrk->resp, H_Transfer_Encoding);
http_SetResp(sp->req->resp, "HTTP/1.1", 304, "Not Modified");
http_Unset(sp->req->resp, H_Content_Length);
http_Unset(sp->req->resp, H_Transfer_Encoding);
}
/*
......@@ -286,14 +286,14 @@ RES_WriteObj(struct sess *sp)
* Always remove C-E if client don't grok it
*/
if (sp->wrk->res_mode & RES_GUNZIP)
http_Unset(sp->wrk->resp, H_Content_Encoding);
http_Unset(sp->req->resp, H_Content_Encoding);
/*
* Send HTTP protocol header, unless interior ESI object
*/
if (!(sp->wrk->res_mode & RES_ESI_CHILD))
sp->wrk->acct_tmp.hdrbytes +=
http_Write(sp->wrk, sp->vsl_id, sp->wrk->resp, 1);
http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1);
if (!sp->req->wantbody)
sp->wrk->res_mode &= ~RES_CHUNKED;
......@@ -344,15 +344,15 @@ RES_StreamStart(struct sess *sp)
* Always remove C-E if client don't grok it
*/
if (sp->wrk->res_mode & RES_GUNZIP)
http_Unset(sp->wrk->resp, H_Content_Encoding);
http_Unset(sp->req->resp, H_Content_Encoding);
if (!(sp->wrk->res_mode & RES_CHUNKED) &&
sp->wrk->busyobj->h_content_length != NULL)
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp,
"Content-Length: %s", sp->wrk->busyobj->h_content_length);
sp->wrk->acct_tmp.hdrbytes +=
http_Write(sp->wrk, sp->vsl_id, sp->wrk->resp, 1);
http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1);
if (sp->wrk->res_mode & RES_CHUNKED)
WRW_Chunked(sp->wrk);
......
......@@ -270,14 +270,18 @@ SES_GetReq(struct sess *sp)
nhttp = (uint16_t)cache_param->http_max_hdr;
hl = HTTP_estimate(nhttp);
xxxassert(sz > 2 * hl + 128);
xxxassert(sz > 3 * hl + 128);
sp->req->http = HTTP_create(p, nhttp);
p += hl;
p += hl; // XXX: align ?
sz -= hl;
sp->req->http0 = HTTP_create(p, nhttp);
p += hl;
p += hl; // XXX: align ?
sz -= hl;
sp->req->resp = HTTP_create(p, nhttp);
p += hl; // XXX: align ?
sz -= hl;
WS_Init(sp->req->ws, "req", p, sz);
......
......@@ -52,7 +52,7 @@ const void * const vrt_magic_string_end = &vrt_magic_string_end;
/*--------------------------------------------------------------------*/
void
VRT_error(struct sess *sp, unsigned code, const char *reason)
VRT_error(const struct sess *sp, unsigned code, const char *reason)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
......@@ -106,7 +106,7 @@ vrt_selecthttp(const struct sess *sp, enum gethdr_e where)
hp = sp->wrk->busyobj->beresp;
break;
case HDR_RESP:
hp = sp->wrk->resp;
hp = sp->req->resp;
break;
case HDR_OBJ:
CHECK_OBJ_NOTNULL(sp->wrk->obj, OBJECT_MAGIC);
......@@ -239,7 +239,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
/*--------------------------------------------------------------------*/
void
VRT_handling(struct sess *sp, unsigned hand)
VRT_handling(const struct sess *sp, unsigned hand)
{
if (sp == NULL) {
......@@ -368,7 +368,7 @@ VRT_bool_string(const struct sess *sp, unsigned val)
/*--------------------------------------------------------------------*/
void
VRT_Rollback(struct sess *sp)
VRT_Rollback(const struct sess *sp)
{
HTTP_Copy(sp->req->http, sp->req->http0);
......
......@@ -90,8 +90,8 @@ VRT_DO_HDR(bereq, url, sp->wrk->busyobj->bereq, HTTP_HDR_URL)
VRT_DO_HDR(bereq, proto, sp->wrk->busyobj->bereq, HTTP_HDR_PROTO)
VRT_DO_HDR(obj, proto, sp->wrk->obj->http, HTTP_HDR_PROTO)
VRT_DO_HDR(obj, response, sp->wrk->obj->http, HTTP_HDR_RESPONSE)
VRT_DO_HDR(resp, proto, sp->wrk->resp, HTTP_HDR_PROTO)
VRT_DO_HDR(resp, response, sp->wrk->resp, HTTP_HDR_RESPONSE)
VRT_DO_HDR(resp, proto, sp->req->resp, HTTP_HDR_PROTO)
VRT_DO_HDR(resp, response, sp->req->resp, HTTP_HDR_RESPONSE)
VRT_DO_HDR(beresp, proto, sp->wrk->busyobj->beresp, HTTP_HDR_PROTO)
VRT_DO_HDR(beresp, response, sp->wrk->busyobj->beresp, HTTP_HDR_RESPONSE)
......@@ -116,7 +116,7 @@ VRT_r_##obj##_status(const struct sess *sp) \
VRT_DO_STATUS(obj, sp->wrk->obj->http)
VRT_DO_STATUS(beresp, sp->wrk->busyobj->beresp)
VRT_DO_STATUS(resp, sp->wrk->resp)
VRT_DO_STATUS(resp, sp->req->resp)
/*--------------------------------------------------------------------*/
......@@ -205,8 +205,8 @@ VBERESP(beresp, unsigned, do_stream, busyobj->do_stream)
/*--------------------------------------------------------------------*/
const char * __match_proto__()
VRT_r_client_identity(struct sess *sp)
const char *
VRT_r_client_identity(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (sp->req->client_identity != NULL)
......@@ -216,7 +216,7 @@ VRT_r_client_identity(struct sess *sp)
}
void
VRT_l_client_identity(struct sess *sp, const char *str, ...)
VRT_l_client_identity(const struct sess *sp, const char *str, ...)
{
va_list ap;
char *b;
......@@ -304,14 +304,14 @@ VRT_l_beresp_storage(struct sess *sp, const char *str, ...)
/*--------------------------------------------------------------------*/
void
VRT_l_req_backend(struct sess *sp, struct director *be)
VRT_l_req_backend(const struct sess *sp, struct director *be)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
sp->req->director = be;
}
struct director * __match_proto__()
VRT_r_req_backend(struct sess *sp)
struct director *
VRT_r_req_backend(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
return (sp->req->director);
......@@ -320,7 +320,7 @@ VRT_r_req_backend(struct sess *sp)
/*--------------------------------------------------------------------*/
void
VRT_l_req_esi(struct sess *sp, unsigned process_esi)
VRT_l_req_esi(const struct sess *sp, unsigned process_esi)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
/*
......@@ -331,8 +331,8 @@ VRT_l_req_esi(struct sess *sp, unsigned process_esi)
sp->req->disable_esi = !process_esi;
}
unsigned __match_proto__()
VRT_r_req_esi(struct sess *sp)
unsigned
VRT_r_req_esi(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
return (!sp->req->disable_esi);
......
......@@ -133,13 +133,12 @@ WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func, void *priv)
static void *
wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace,
uint16_t nhttp, unsigned http_space, unsigned siov)
unsigned siov)
{
struct worker *w, ww;
uint32_t wlog[shm_workspace / 4];
/* XXX: can we trust these to be properly aligned ? */
unsigned char ws[sess_workspace];
unsigned char http2[http_space];
struct iovec iov[siov];
struct SHA256Context sha256;
......@@ -151,7 +150,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace,
w->wlb = w->wlp = wlog;
w->wle = wlog + (sizeof wlog) / 4;
w->sha256ctx = &sha256;
w->resp = HTTP_create(http2, nhttp);
w->wrw.iov = iov;
w->wrw.siov = siov;
w->wrw.ciov = siov;
......@@ -187,8 +185,7 @@ WRK_thread(void *priv)
siov = IOV_MAX;
return (wrk_thread_real(priv,
cache_param->shm_workspace,
cache_param->wthread_workspace,
nhttp, HTTP_estimate(nhttp), siov));
cache_param->wthread_workspace, siov));
}
void
......
......@@ -156,14 +156,14 @@ void VRT_purge(const struct sess *sp, double ttl, double grace);
void VRT_count(const struct sess *, unsigned);
int VRT_rewrite(const char *, const char *);
void VRT_error(struct sess *, unsigned, const char *);
void VRT_error(const struct sess *, unsigned, const char *);
int VRT_switch_config(const char *);
enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP };
char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *);
void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *,
const char *, ...);
void VRT_handling(struct sess *sp, unsigned hand);
void VRT_handling(const struct sess *sp, unsigned hand);
void VRT_hashdata(const struct sess *sp, const char *str, ...);
......@@ -172,7 +172,7 @@ int VRT_strcmp(const char *s1, const char *s2);
void VRT_memmove(void *dst, const void *src, unsigned len);
void VRT_ESI(const struct sess *sp);
void VRT_Rollback(struct sess *sp);
void VRT_Rollback(const struct sess *sp);
/* Synthetic pages */
void VRT_synth_page(const struct sess *sp, unsigned flags, const char *, ...);
......
......@@ -113,7 +113,7 @@ sp_variables = (
'STRING',
( 'proc',),
( 'proc',),
'struct sess *'
'const struct sess *'
),
('server.ip',
'IP',
......@@ -167,7 +167,7 @@ sp_variables = (
'BACKEND',
( 'proc',),
( 'proc',),
'struct sess *'
'const struct sess *'
),
('req.restarts',
'INT',
......@@ -209,7 +209,7 @@ sp_variables = (
'BOOL',
( 'recv', 'fetch', 'deliver', 'error',),
( 'recv', 'fetch', 'deliver', 'error',),
'struct sess *'
'const struct sess *'
),
('req.can_gzip',
'BOOL',
......
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