Commit 0d58f56e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Second pass to tag VSL's with backend or client bits.

parent 009eb1c5
......@@ -763,17 +763,18 @@ unsigned http_Write(struct worker *w, unsigned vsl_id, const struct http *hp,
void http_CopyResp(struct http *to, const struct http *fm);
void http_SetResp(struct http *to, const char *proto, uint16_t status,
const char *response);
void http_FilterFields(struct worker *w, int fd, struct http *to,
void http_FilterFields(struct worker *w, unsigned vsl_id, struct http *to,
const struct http *fm, unsigned how);
void http_FilterHeader(const struct sess *sp, unsigned how);
void http_PutProtocol(struct worker *w, int fd, const struct http *to,
void http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to,
const char *protocol);
void http_PutStatus(struct http *to, uint16_t status);
void http_PutResponse(struct worker *w, int fd, const struct http *to,
void http_PutResponse(struct worker *w, unsigned vsl_id, const struct http *to,
const char *response);
void http_PrintfHeader(struct worker *w, int fd, struct http *to,
void http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to,
const char *fmt, ...);
void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr);
void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to,
const char *hdr);
void http_SetH(const struct http *to, unsigned n, const char *fm);
void http_ForceGet(const struct http *to);
void http_Setup(struct http *ht, struct ws *ws);
......@@ -790,7 +791,7 @@ uint16_t http_DissectRequest(struct sess *sp);
uint16_t http_DissectResponse(struct worker *w, const struct http_conn *htc,
struct http *sp);
const char *http_DoConnection(const struct http *hp);
void http_CopyHome(struct worker *w, int fd, const struct http *hp);
void http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
void http_CollectHdr(struct http *hp, const char *hdr);
......
......@@ -130,10 +130,10 @@ VCA_Prep(struct sess *sp)
AZ(getsockname(sp->fd, (void*)&sp->mysockaddr, &sp->mysockaddrlen));
VTCP_name(&sp->mysockaddr, sp->mysockaddrlen,
addr, sizeof addr, port, sizeof port);
VSL(SLT_SessionOpen, sp->fd, "%s %s %s %s",
WSP(sp, SLT_SessionOpen, "%s %s %s %s",
sp->addr, sp->port, addr, port);
} else {
VSL(SLT_SessionOpen, sp->fd, "%s %s %s",
WSP(sp, SLT_SessionOpen, "%s %s %s",
sp->addr, sp->port, sp->mylsock->name);
}
sp->acct_ses.first = sp->t_open;
......
......@@ -70,7 +70,7 @@ VDI_AddHostHeader(const struct sess *sp)
CHECK_OBJ_NOTNULL(sp->wrk->bereq, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbc->vdis, VDI_SIMPLE_MAGIC);
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->bereq,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->bereq,
"Host: %s", sp->vbc->vdis->vrt->hosthdr);
}
......@@ -357,7 +357,7 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs)
return (vc);
}
VSC_C_main->backend_toolate++;
WSL(sp->wrk, SLT_BackendClose, vc->fd, "%s", bp->vcl_name);
WSL(sp->wrk, SLT_BackendClose, vc->vsl_id, "%s", bp->vcl_name);
/* Checkpoint log to flush all info related to this connection
before the OS reuses the FD */
......
......@@ -104,7 +104,7 @@ cnt_wait(struct sess *sp)
i = HTC_Rx(sp->htc);
}
if (i == 0) {
WSL(sp->wrk, SLT_Debug, sp->fd, "herding");
WSP(sp, SLT_Debug, "herding");
sp->wrk->stats.sess_herd++;
SES_Charge(sp);
sp->wrk = NULL;
......@@ -464,16 +464,16 @@ cnt_error(struct sess *sp)
if (sp->err_code < 100 || sp->err_code > 999)
sp->err_code = 501;
http_PutProtocol(w, sp->fd, h, "HTTP/1.1");
http_PutProtocol(w, sp->vsl_id, h, "HTTP/1.1");
http_PutStatus(h, sp->err_code);
TIM_format(TIM_real(), date);
http_PrintfHeader(w, sp->fd, h, "Date: %s", date);
http_PrintfHeader(w, sp->fd, h, "Server: Varnish");
http_PrintfHeader(w, sp->vsl_id, h, "Date: %s", date);
http_PrintfHeader(w, sp->vsl_id, h, "Server: Varnish");
if (sp->err_reason != NULL)
http_PutResponse(w, sp->fd, h, sp->err_reason);
http_PutResponse(w, sp->vsl_id, h, sp->err_reason);
else
http_PutResponse(w, sp->fd, h,
http_PutResponse(w, sp->vsl_id, h,
http_StatusMessage(sp->err_code));
VCL_error_method(sp);
......@@ -728,7 +728,7 @@ cnt_fetchbody(struct sess *sp)
/* If we do gzip, add the C-E header */
if (sp->wrk->do_gzip)
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->beresp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->beresp,
"Content-Encoding: %s", "gzip");
/* But we can't do both at the same time */
......@@ -1194,7 +1194,7 @@ cnt_miss(struct sess *sp)
* the minority of clients which don't.
*/
http_Unset(sp->wrk->bereq, H_Accept_Encoding);
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->bereq,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->bereq,
"Accept-Encoding: gzip");
}
sp->wrk->connect_timeout = 0;
......@@ -1398,7 +1398,7 @@ cnt_recv(struct sess *sp)
(recv_handling != VCL_RET_PASS)) {
if (RFC2616_Req_Gzip(sp)) {
http_Unset(sp->http, H_Accept_Encoding);
http_PrintfHeader(sp->wrk, sp->fd, sp->http,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->http,
"Accept-Encoding: gzip");
} else {
http_Unset(sp->http, H_Accept_Encoding);
......
......@@ -48,7 +48,7 @@ VDI_CloseFd(struct sess *sp)
bp = sp->vbc->backend;
WSL(sp->wrk, SLT_BackendClose, sp->vbc->fd, "%s", bp->vcl_name);
WSL(sp->wrk, SLT_BackendClose, sp->vbc->vsl_id, "%s", bp->vcl_name);
/* Checkpoint log to flush all info related to this connection
before the OS reuses the FD */
......@@ -76,7 +76,7 @@ VDI_RecycleFd(struct sess *sp)
bp = sp->vbc->backend;
WSL(sp->wrk, SLT_BackendReuse, sp->vbc->fd, "%s", bp->vcl_name);
WSL(sp->wrk, SLT_BackendReuse, sp->vbc->vsl_id, "%s", bp->vcl_name);
/*
* Flush the shmlog, so that another session reusing this backend
* will log chronologically later than our use of it.
......
......@@ -72,7 +72,7 @@ ved_include(struct sess *sp, const char *src, const char *host)
if (host != NULL && *host != '\0') {
http_Unset(sp->http, H_Host);
http_Unset(sp->http, H_If_Modified_Since);
http_SetHeader(w, sp->fd, sp->http, host);
http_SetHeader(w, sp->vsl_id, sp->http, host);
}
/*
* XXX: We should decide if we should cache the director
......
......@@ -63,8 +63,7 @@ vfp_nop_begin(struct sess *sp, size_t estimate)
if (fetchfrag > 0) {
estimate = fetchfrag;
WSL(sp->wrk, SLT_Debug, sp->fd,
"Fetch %d byte segments:", fetchfrag);
WSP(sp, SLT_Debug, "Fetch %d byte segments:", fetchfrag);
}
if (estimate > 0)
(void)FetchStorage(sp, estimate);
......@@ -355,7 +354,7 @@ FetchReqBody(struct sess *sp)
}
if (http_GetHdr(sp->http, H_Transfer_Encoding, NULL)) {
/* XXX: Handle chunked encoding. */
WSL(sp->wrk, SLT_Debug, sp->fd, "Transfer-Encoding in request");
WSP(sp, SLT_Debug, "Transfer-Encoding in request");
return (1);
}
return (0);
......@@ -542,7 +541,7 @@ FetchBody(struct sess *sp)
*/
AZ(vfp_nop_end(sp));
WSL(w, SLT_Fetch_Body, sp->vbc->fd, "%u(%s) cls %d mklen %u",
WSL(w, SLT_Fetch_Body, sp->vbc->vsl_id, "%u(%s) cls %d mklen %u",
w->body_status, body_status(w->body_status),
cls, mklen);
......@@ -567,7 +566,7 @@ FetchBody(struct sess *sp)
if (cls == 0 && w->do_close)
cls = 1;
WSL(w, SLT_Length, sp->vbc->fd, "%u", sp->obj->len);
WSL(w, SLT_Length, sp->vbc->vsl_id, "%u", sp->obj->len);
{
/* Sanity check fetch methods accounting */
......@@ -585,7 +584,7 @@ FetchBody(struct sess *sp)
if (mklen > 0) {
http_Unset(sp->obj->http, H_Content_Length);
http_PrintfHeader(w, sp->fd, sp->obj->http,
http_PrintfHeader(w, sp->vsl_id, sp->obj->http,
"Content-Length: %jd", (intmax_t)sp->obj->len);
}
......
......@@ -77,7 +77,7 @@ http2shmlog(const struct http *hp, int t)
}
static void
WSLH(struct worker *w, int vsl_id, const struct http *hp, unsigned hdr)
WSLH(struct worker *w, unsigned vsl_id, const struct http *hp, unsigned hdr)
{
AN(vsl_id & (VSL_CLIENTMARKER|VSL_BACKENDMARKER));
......@@ -486,7 +486,7 @@ http_GetReq(const struct http *hp)
*/
static uint16_t
http_dissect_hdrs(struct worker *w, struct http *hp, int vsl_id, char *p,
http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p,
const struct http_conn *htc)
{
char *q, *r;
......@@ -562,7 +562,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, int vsl_id, char *p,
*/
static uint16_t
http_splitline(struct worker *w, int vsl_id, struct http *hp,
http_splitline(struct worker *w, unsigned vsl_id, struct http *hp,
const struct http_conn *htc, int h1, int h2, int h3)
{
char *p, *q;
......@@ -792,7 +792,7 @@ http_SetResp(struct http *to, const char *proto, uint16_t status,
}
static void
http_copyheader(struct worker *w, int vsl_id, struct http *to,
http_copyheader(struct worker *w, unsigned vsl_id, struct http *to,
const struct http *fm, unsigned n)
{
......@@ -843,7 +843,7 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd)
/*--------------------------------------------------------------------*/
void
http_FilterFields(struct worker *w, int vsl_id, struct http *to,
http_FilterFields(struct worker *w, unsigned vsl_id, struct http *to,
const struct http *fm, unsigned how)
{
unsigned u;
......@@ -893,7 +893,7 @@ http_FilterHeader(const struct sess *sp, unsigned how)
*/
void
http_CopyHome(struct worker *w, int vsl_id, const struct http *hp)
http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp)
{
unsigned u, l;
char *p;
......@@ -939,7 +939,8 @@ http_ClrHeader(struct http *to)
/*--------------------------------------------------------------------*/
void
http_SetHeader(struct worker *w, int vsl_id, struct http *to, const char *hdr)
http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to,
const char *hdr)
{
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
......@@ -954,8 +955,8 @@ http_SetHeader(struct worker *w, int vsl_id, struct http *to, const char *hdr)
/*--------------------------------------------------------------------*/
static void
http_PutField(struct worker *w, int vsl_id, const struct http *to, int field,
const char *string)
http_PutField(struct worker *w, unsigned vsl_id, const struct http *to,
int field, const char *string)
{
char *p;
unsigned l;
......@@ -977,7 +978,7 @@ http_PutField(struct worker *w, int vsl_id, const struct http *to, int field,
}
void
http_PutProtocol(struct worker *w, int vsl_id, const struct http *to,
http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to,
const char *protocol)
{
......@@ -993,7 +994,7 @@ http_PutStatus(struct http *to, uint16_t status)
}
void
http_PutResponse(struct worker *w, int vsl_id, const struct http *to,
http_PutResponse(struct worker *w, unsigned vsl_id, const struct http *to,
const char *response)
{
......@@ -1001,7 +1002,7 @@ http_PutResponse(struct worker *w, int vsl_id, const struct http *to,
}
void
http_PrintfHeader(struct worker *w, int vsl_id, struct http *to,
http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to,
const char *fmt, ...)
{
va_list ap;
......
......@@ -92,12 +92,12 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
if (low > high)
return;
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
"Content-Range: bytes %jd-%jd/%jd",
(intmax_t)low, (intmax_t)high, (intmax_t)sp->obj->len);
http_Unset(sp->wrk->resp, H_Content_Length);
assert(sp->wrk->res_mode & RES_LEN);
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
"Content-Length: %jd", (intmax_t)(1 + high - low));
http_SetResp(sp->wrk->resp, "HTTP/1.1", 206, "Partial Content");
......@@ -118,34 +118,34 @@ RES_BuildHttp(const struct sess *sp)
http_ClrHeader(sp->wrk->resp);
sp->wrk->resp->logtag = HTTP_Tx;
http_CopyResp(sp->wrk->resp, sp->obj->http);
http_FilterFields(sp->wrk, sp->fd, sp->wrk->resp, sp->obj->http,
http_FilterFields(sp->wrk, sp->vsl_id, sp->wrk->resp, sp->obj->http,
HTTPH_A_DELIVER);
if (!(sp->wrk->res_mode & RES_LEN)) {
http_Unset(sp->wrk->resp, H_Content_Length);
} else if (params->http_range_support) {
/* We only accept ranges if we know the length */
http_SetHeader(sp->wrk, sp->fd, sp->wrk->resp,
http_SetHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
"Accept-Ranges: bytes");
}
if (sp->wrk->res_mode & RES_CHUNKED)
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
"Transfer-Encoding: chunked");
TIM_format(TIM_real(), time_str);
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Date: %s", time_str);
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp, "Date: %s", time_str);
if (sp->xid != sp->obj->xid)
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
"X-Varnish: %u %u", sp->xid, sp->obj->xid);
else
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
"X-Varnish: %u", sp->xid);
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Age: %.0f",
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp, "Age: %.0f",
sp->obj->exp.age + sp->t_resp - sp->obj->exp.entered);
http_SetHeader(sp->wrk, sp->fd, sp->wrk->resp, "Via: 1.1 varnish");
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Connection: %s",
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",
sp->doclose ? "close" : "keep-alive");
}
......@@ -348,7 +348,7 @@ RES_StreamStart(struct sess *sp)
if (!(sp->wrk->res_mode & RES_CHUNKED) &&
sp->wrk->h_content_length != NULL)
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->resp,
"Content-Length: %s", sp->wrk->h_content_length);
sp->wrk->acct_tmp.hdrbytes +=
......
......@@ -86,7 +86,7 @@ VRT_count(const struct sess *sp, unsigned u)
void
VRT_acl_log(const struct sess *sp, const char *msg)
{
WSL(sp->wrk, SLT_VCL_acl, sp->fd, msg);
WSP(sp, SLT_VCL_acl, msg);
}
/*--------------------------------------------------------------------*/
......@@ -232,7 +232,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
WSP(sp, SLT_LostHeader, "%s", hdr + 1);
} else {
http_Unset(hp, hdr);
http_SetHeader(sp->wrk, sp->fd, hp, b);
http_SetHeader(sp->wrk, sp->vsl_id, hp, b);
}
}
va_end(ap);
......@@ -418,7 +418,7 @@ VRT_synth_page(const struct sess *sp, unsigned flags, const char *str, ...)
va_end(ap);
SMS_Finish(sp->obj);
http_Unset(sp->obj->http, H_Content_Length);
http_PrintfHeader(sp->wrk, sp->fd, sp->obj->http,
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->obj->http,
"Content-Length: %d", sp->obj->len);
}
......
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