From 985fb06ef789b5fa171f14c95036379ecd3f7b01 Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 17 Sep 2006 20:26:35 +0000 Subject: [PATCH] Use workerthres log buffer much more extensively git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1054 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 15 ++--- varnish-cache/bin/varnishd/cache_center.c | 2 + varnish-cache/bin/varnishd/cache_fetch.c | 16 +++--- varnish-cache/bin/varnishd/cache_http.c | 62 ++++++++++----------- varnish-cache/bin/varnishd/cache_pass.c | 14 ++--- varnish-cache/bin/varnishd/cache_pipe.c | 6 +- varnish-cache/bin/varnishd/cache_response.c | 36 ++++++------ varnish-cache/bin/varnishd/cache_session.c | 3 +- varnish-cache/bin/varnishd/cache_vcl.c | 4 +- varnish-cache/bin/varnishd/cache_vrt.c | 6 +- varnish-cache/bin/varnishd/shmlog.c | 9 +++ varnish-cache/include/stat_field.h | 2 + 12 files changed, 95 insertions(+), 80 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 0c261458..f8cd81ac 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -120,6 +120,7 @@ struct worker { struct acct acct; unsigned char wlog[WLOGSPACE]; unsigned char *wlp, *wle; + unsigned wlr; }; struct workreq { @@ -334,13 +335,13 @@ void HTTP_Init(void); void http_ClrHeader(struct http *to); void http_CopyHttp(struct http *to, struct http *fm); unsigned http_Write(struct worker *w, struct http *hp, int resp); -void http_GetReq(int fd, struct http *to, struct http *fm); -void http_CopyReq(int fd, struct http *to, struct http *fm); -void http_CopyResp(int fd, struct http *to, struct http *fm); -void http_SetResp(int fd, struct http *to, const char *proto, const char *status, const char *response); -void http_FilterHeader(int fd, struct http *to, struct http *fm, unsigned how); -void http_PrintfHeader(int fd, struct http *to, const char *fmt, ...); -void http_SetHeader(int fd, struct http *to, const char *hdr); +void http_GetReq(struct worker *w, int fd, struct http *to, struct http *fm); +void http_CopyReq(struct worker *w, int fd, struct http *to, struct http *fm); +void http_CopyResp(struct worker *w, int fd, struct http *to, struct http *fm); +void http_SetResp(struct worker *w, int fd, struct http *to, const char *proto, const char *status, const char *response); +void http_FilterHeader(struct worker *w, int fd, struct http *to, struct http *fm, unsigned how); +void http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...); +void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr); int http_IsHdr(struct http_hdr *hh, char *hdr); void http_Setup(struct http *ht, void *space, unsigned len); int http_GetHdr(struct http *hp, const char *hdr, char **ptr); diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index ee743523..3e11e50c 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -156,6 +156,7 @@ cnt_done(struct sess *sp) if (sp->fd < 0) { VSL_stats->sess_closed++; sp->wrk->idle = sp->t_open.tv_sec; + sp->wrk = NULL; vca_return_session(sp); return (1); } @@ -172,6 +173,7 @@ cnt_done(struct sess *sp) } VSL_stats->sess_herd++; sp->wrk->idle = sp->t_open.tv_sec; + sp->wrk = NULL; vca_return_session(sp); return (1); } diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index 9c2f8583..1ad353f1 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -233,8 +233,8 @@ FetchBody(struct sess *sp) hp = vc->http2; http_ClrHeader(hp); hp->logtag = HTTP_Obj; - http_CopyResp(sp->fd, hp, vc->http); - http_FilterHeader(sp->fd, hp, vc->http, HTTPH_A_INS); + http_CopyResp(sp->wrk, sp->fd, hp, vc->http); + http_FilterHeader(sp->wrk, sp->fd, hp, vc->http, HTTPH_A_INS); if (body) { if (http_GetHdr(vc->http, H_Content_Length, &b)) @@ -243,7 +243,7 @@ FetchBody(struct sess *sp) cls = fetch_chunked(sp, vc->fd, vc->http); else cls = fetch_eof(sp, vc->fd, vc->http); - http_PrintfHeader(sp->fd, hp, + http_PrintfHeader(sp->wrk, sp->fd, hp, "Content-Length: %u", sp->obj->len); } else cls = 0; @@ -294,15 +294,15 @@ FetchHeaders(struct sess *sp) if (vc == NULL) vc = VBE_GetFd(sp->backend, sp->xid); XXXAN(vc); - VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); + WSL(w, SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); http_ClrHeader(vc->http); vc->http->logtag = HTTP_Tx; - http_GetReq(vc->fd, vc->http, sp->http); - http_FilterHeader(vc->fd, vc->http, sp->http, HTTPH_R_FETCH); - http_PrintfHeader(vc->fd, vc->http, "X-Varnish: %u", sp->xid); + 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); if (!http_GetHdr(vc->http, H_Host, &b)) { - http_PrintfHeader(vc->fd, vc->http, "Host: %s", + http_PrintfHeader(w, vc->fd, vc->http, "Host: %s", sp->backend->hostname); } diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index 5d671b26..54cdf7b0 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -625,7 +625,7 @@ http_CopyHttp(struct http *to, struct http *fm) /*--------------------------------------------------------------------*/ static void -http_seth(int fd, struct http *to, unsigned n, enum httptag tag, const char *fm) +http_seth(struct worker *w, int fd, struct http *to, unsigned n, enum httptag tag, const char *fm) { assert(n < HTTP_HDR_MAX); @@ -633,11 +633,11 @@ http_seth(int fd, struct http *to, unsigned n, enum httptag tag, const char *fm) to->hd[n].b = (void*)(uintptr_t)fm; to->hd[n].e = (void*)(uintptr_t)strchr(fm, '\0'); to->hdf[n] = 0; - VSLH(tag, fd, to, n); + WSLH(w, tag, fd, to, n); } static void -http_copyh(int fd, struct http *to, struct http *fm, unsigned n, enum httptag tag) +http_copyh(struct worker *w, int fd, struct http *to, struct http *fm, unsigned n, enum httptag tag) { assert(n < HTTP_HDR_MAX); @@ -645,54 +645,54 @@ http_copyh(int fd, struct http *to, struct http *fm, unsigned n, enum httptag ta to->hd[n].b = fm->hd[n].b; to->hd[n].e = fm->hd[n].e; to->hdf[n] = fm->hdf[n]; - VSLH(tag, fd, to, n); + WSLH(w, tag, fd, to, n); } void -http_GetReq(int fd, struct http *to, struct http *fm) +http_GetReq(struct worker *w, int fd, struct http *to, struct http *fm) { CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); - http_seth(fd, to, HTTP_HDR_REQ, HTTP_T_Request, "GET"); - http_copyh(fd, to, fm, HTTP_HDR_URL, HTTP_T_URL); - http_seth(fd, to, HTTP_HDR_PROTO, HTTP_T_Protocol, "HTTP/1.1"); + http_seth(w, fd, to, HTTP_HDR_REQ, HTTP_T_Request, "GET"); + http_copyh(w, fd, to, fm, HTTP_HDR_URL, HTTP_T_URL); + http_seth(w, fd, to, HTTP_HDR_PROTO, HTTP_T_Protocol, "HTTP/1.1"); } void -http_CopyReq(int fd, struct http *to, struct http *fm) +http_CopyReq(struct worker *w, int fd, struct http *to, struct http *fm) { CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); - http_copyh(fd, to, fm, HTTP_HDR_REQ, HTTP_T_Request); - http_copyh(fd, to, fm, HTTP_HDR_URL, HTTP_T_URL); - http_copyh(fd, to, fm, HTTP_HDR_PROTO, HTTP_T_Protocol); + http_copyh(w, fd, to, fm, HTTP_HDR_REQ, HTTP_T_Request); + http_copyh(w, fd, to, fm, HTTP_HDR_URL, HTTP_T_URL); + http_copyh(w, fd, to, fm, HTTP_HDR_PROTO, HTTP_T_Protocol); } void -http_CopyResp(int fd, struct http *to, struct http *fm) +http_CopyResp(struct worker *w, int fd, struct http *to, struct http *fm) { CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); - http_copyh(fd, to, fm, HTTP_HDR_PROTO, HTTP_T_Protocol); - http_copyh(fd, to, fm, HTTP_HDR_STATUS, HTTP_T_Status); - http_copyh(fd, to, fm, HTTP_HDR_RESPONSE, HTTP_T_Response); + http_copyh(w, fd, to, fm, HTTP_HDR_PROTO, HTTP_T_Protocol); + http_copyh(w, fd, to, fm, HTTP_HDR_STATUS, HTTP_T_Status); + http_copyh(w, fd, to, fm, HTTP_HDR_RESPONSE, HTTP_T_Response); } void -http_SetResp(int fd, struct http *to, const char *proto, const char *status, const char *response) +http_SetResp(struct worker *w, int fd, struct http *to, const char *proto, const char *status, const char *response) { CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); - http_seth(fd, to, HTTP_HDR_PROTO, HTTP_T_Protocol, proto); - http_seth(fd, to, HTTP_HDR_STATUS, HTTP_T_Status, status); - http_seth(fd, to, HTTP_HDR_RESPONSE, HTTP_T_Response, response); + http_seth(w, fd, to, HTTP_HDR_PROTO, HTTP_T_Protocol, proto); + http_seth(w, fd, to, HTTP_HDR_STATUS, HTTP_T_Status, status); + http_seth(w, fd, to, HTTP_HDR_RESPONSE, HTTP_T_Response, response); } static void -http_copyheader(int fd, struct http *to, struct http *fm, unsigned n) +http_copyheader(struct worker *w, int fd, struct http *to, struct http *fm, unsigned n) { CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); @@ -702,18 +702,18 @@ http_copyheader(int fd, struct http *to, struct http *fm, unsigned n) if (to->nhd < HTTP_HDR_MAX) { to->hd[to->nhd].b = fm->hd[n].b; to->hd[to->nhd].e = fm->hd[n].e; - VSLH(HTTP_T_Header, fd, to, to->nhd); + WSLH(w, HTTP_T_Header, fd, to, to->nhd); to->nhd++; } else { VSL_stats->losthdr++; - VSLH(HTTP_T_LostHeader, fd, fm, n); + WSLH(w, HTTP_T_LostHeader, fd, fm, n); } } /*--------------------------------------------------------------------*/ void -http_FilterHeader(int fd, struct http *to, struct http *fm, unsigned how) +http_FilterHeader(struct worker *w, int fd, struct http *to, struct http *fm, unsigned how) { unsigned u; @@ -728,7 +728,7 @@ http_FilterHeader(int fd, struct http *to, struct http *fm, unsigned how) continue; #include "http_headers.h" #undef HTTPH - http_copyheader(fd, to, fm, u); + http_copyheader(w, fd, to, fm, u); } } @@ -747,22 +747,22 @@ http_ClrHeader(struct http *to) /*--------------------------------------------------------------------*/ void -http_SetHeader(int fd, struct http *to, const char *hdr) +http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr) { CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); if (to->nhd >= HTTP_HDR_MAX) { VSL_stats->losthdr++; - VSL(T(to, HTTP_T_LostHeader), fd, "%s", hdr); + WSL(w, T(to, HTTP_T_LostHeader), fd, "%s", hdr); return; } - http_seth(fd, to, to->nhd++, HTTP_T_Header, hdr); + http_seth(w, fd, to, to->nhd++, HTTP_T_Header, hdr); } /*--------------------------------------------------------------------*/ void -http_PrintfHeader(int fd, struct http *to, const char *fmt, ...) +http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...) { va_list ap; unsigned l, n; @@ -773,13 +773,13 @@ http_PrintfHeader(int fd, struct http *to, const char *fmt, ...) n = vsnprintf(to->f, l, fmt, ap); if (n + 1 > l || to->nhd >= HTTP_HDR_MAX) { VSL_stats->losthdr++; - VSL(T(to, HTTP_T_LostHeader), fd, "%s", to->f); + WSL(w, T(to, HTTP_T_LostHeader), fd, "%s", to->f); } else { assert(to->f < to->e); to->hd[to->nhd].b = to->f; to->hd[to->nhd].e = to->f + n; to->f += n + 1; - VSLH(HTTP_T_Header, fd, to, to->nhd); + WSLH(w, HTTP_T_Header, fd, to, to->nhd); to->nhd++; } va_end(ap); diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index 00e324e2..dca4425f 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -157,12 +157,12 @@ PassBody(struct sess *sp) clock_gettime(CLOCK_REALTIME, &sp->t_resp); http_ClrHeader(sp->http); - http_CopyResp(sp->fd, sp->http, vc->http); - http_FilterHeader(sp->fd, sp->http, vc->http, HTTPH_A_PASS); - http_PrintfHeader(sp->fd, sp->http, "X-Varnish: %u", sp->xid); + http_CopyResp(sp->wrk, sp->fd, sp->http, vc->http); + http_FilterHeader(sp->wrk, sp->fd, sp->http, vc->http, HTTPH_A_PASS); + http_PrintfHeader(sp->wrk, sp->fd, sp->http, "X-Varnish: %u", sp->xid); /* XXX */ if (http_HdrIs(vc->http, H_Transfer_Encoding, "chunked")) - http_PrintfHeader(sp->fd, sp->http, "Transfer-Encoding: chunked"); + http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Transfer-Encoding: chunked"); WRK_Reset(sp->wrk, &sp->fd); sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); @@ -209,9 +209,9 @@ PassSession(struct sess *sp) } WSL(w, SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); - http_CopyReq(vc->fd, vc->http, sp->http); - http_FilterHeader(vc->fd, vc->http, sp->http, HTTPH_R_PASS); - http_PrintfHeader(vc->fd, vc->http, "X-Varnish: %u", sp->xid); + http_CopyReq(w, vc->fd, vc->http, sp->http); + http_FilterHeader(w, vc->fd, vc->http, sp->http, HTTPH_R_PASS); + http_PrintfHeader(w, vc->fd, vc->http, "X-Varnish: %u", sp->xid); WRK_Reset(w, &vc->fd); http_Write(w, vc->http, 0); i = WRK_Flush(w); diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 40839934..78c58986 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -61,9 +61,9 @@ PipeSession(struct sess *sp) VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); vc->http->logtag = HTTP_Tx; - http_CopyReq(vc->fd, vc->http, sp->http); - http_FilterHeader(vc->fd, vc->http, sp->http, HTTPH_R_PIPE); - http_PrintfHeader(vc->fd, vc->http, "X-Varnish: %u", sp->xid); + 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); WRK_Reset(w, &vc->fd); http_Write(w, vc->http, 0); diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index f0dcacea..09708f00 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -129,9 +129,9 @@ RES_Error(struct sess *sp, int code, const char *expl) WRK_Reset(sp->wrk, &sp->fd); sp->wrk->acct.hdrbytes += WRK_Write(sp->wrk, vsb_data(sb), vsb_len(sb)); WRK_Flush(sp->wrk); - VSL(SLT_TxStatus, sp->id, "%d", code); - VSL(SLT_TxProtocol, sp->id, "HTTP/1.1"); - VSL(SLT_TxResponse, sp->id, msg); + WSL(sp->wrk, SLT_TxStatus, sp->id, "%d", code); + WSL(sp->wrk, SLT_TxProtocol, sp->id, "HTTP/1.1"); + WSL(sp->wrk, SLT_TxResponse, sp->id, msg); vca_close_session(sp, expl); vsb_delete(sb); } @@ -144,19 +144,19 @@ res_do_304(struct sess *sp) { char lm[64]; - VSL(SLT_Length, sp->fd, "%u", 0); + WSL(sp->wrk, SLT_Length, sp->fd, "%u", 0); http_ClrHeader(sp->http); sp->http->logtag = HTTP_Tx; - http_SetResp(sp->fd, sp->http, "HTTP/1.1", "304", "Not Modified"); + http_SetResp(sp->wrk, sp->fd, sp->http, "HTTP/1.1", "304", "Not Modified"); TIM_format(sp->t_req.tv_sec, lm); - http_PrintfHeader(sp->fd, sp->http, "Date: %s", lm); - http_SetHeader(sp->fd, sp->http, "Via: 1.1 varnish"); - http_PrintfHeader(sp->fd, sp->http, "X-Varnish: %u", sp->xid); + http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Date: %s", lm); + http_SetHeader(sp->wrk, sp->fd, sp->http, "Via: 1.1 varnish"); + http_PrintfHeader(sp->wrk, sp->fd, sp->http, "X-Varnish: %u", sp->xid); TIM_format(sp->obj->last_modified, lm); - http_PrintfHeader(sp->fd, sp->http, "Last-Modified: %s", lm); + http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Last-Modified: %s", lm); if (sp->doclose != NULL) - http_SetHeader(sp->fd, sp->http, "Connection: close"); + http_SetHeader(sp->wrk, sp->fd, sp->http, "Connection: close"); WRK_Reset(sp->wrk, &sp->fd); sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); if (WRK_Flush(sp->wrk)) @@ -199,22 +199,22 @@ RES_WriteObj(struct sess *sp) if (sp->obj->response == 200 && sp->http->conds && res_do_conds(sp)) return; - VSL(SLT_Length, sp->fd, "%u", sp->obj->len); + WSL(sp->wrk, SLT_Length, sp->fd, "%u", sp->obj->len); http_ClrHeader(sp->http); sp->http->logtag = HTTP_Tx; - http_CopyResp(sp->fd, sp->http, &sp->obj->http); - http_FilterHeader(sp->fd, sp->http, &sp->obj->http, HTTPH_A_DELIVER); + http_CopyResp(sp->wrk, sp->fd, sp->http, &sp->obj->http); + http_FilterHeader(sp->wrk, sp->fd, sp->http, &sp->obj->http, HTTPH_A_DELIVER); if (sp->xid != sp->obj->xid) - http_PrintfHeader(sp->fd, sp->http, + http_PrintfHeader(sp->wrk, sp->fd, sp->http, "X-Varnish: %u %u", sp->xid, sp->obj->xid); else - http_PrintfHeader(sp->fd, sp->http, "X-Varnish: %u", sp->xid); - http_PrintfHeader(sp->fd, sp->http, "Age: %u", + http_PrintfHeader(sp->wrk, sp->fd, sp->http, "X-Varnish: %u", sp->xid); + http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Age: %u", sp->obj->age + sp->t_req.tv_sec - sp->obj->entered); - http_SetHeader(sp->fd, sp->http, "Via: 1.1 varnish"); + http_SetHeader(sp->wrk, sp->fd, sp->http, "Via: 1.1 varnish"); if (sp->doclose != NULL) - http_SetHeader(sp->fd, sp->http, "Connection: close"); + http_SetHeader(sp->wrk, sp->fd, sp->http, "Connection: close"); WRK_Reset(sp->wrk, &sp->fd); sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); diff --git a/varnish-cache/bin/varnishd/cache_session.c b/varnish-cache/bin/varnishd/cache_session.c index 0ed3cadd..2dc01d9e 100644 --- a/varnish-cache/bin/varnishd/cache_session.c +++ b/varnish-cache/bin/varnishd/cache_session.c @@ -205,7 +205,8 @@ SES_Charge(struct sess *sp) ses_sum_acct(&sp->srcaddr->acct, a); b = sp->srcaddr->acct; UNLOCK(&sp->srcaddr->sah->mtx); - VSL(SLT_StatAddr, 0, "%s 0 %d %ju %ju %ju %ju %ju %ju %ju", + WSL(sp->wrk, SLT_StatAddr, 0, + "%s 0 %d %ju %ju %ju %ju %ju %ju %ju", sp->srcaddr->addr, sp->t_end.tv_sec - b.first, b.sess, b.req, b.pipe, b.pass, b.fetch, b.hdrbytes, b.bodybytes); diff --git a/varnish-cache/bin/varnishd/cache_vcl.c b/varnish-cache/bin/varnishd/cache_vcl.c index 01a55147..f8c17d1c 100644 --- a/varnish-cache/bin/varnishd/cache_vcl.c +++ b/varnish-cache/bin/varnishd/cache_vcl.c @@ -278,9 +278,9 @@ VCL_##func##_method(struct sess *sp) \ { \ \ sp->handling = 0; \ - VSL(SLT_VCL_call, sp->fd, "%s", #func); \ + WSL(sp->wrk, SLT_VCL_call, sp->fd, "%s", #func); \ sp->vcl->func##_func(sp); \ - VSL(SLT_VCL_return, sp->fd, "%s", \ + WSL(sp->wrk, SLT_VCL_return, sp->fd, "%s", \ vcl_handlingname(sp->handling)); \ assert(sp->handling & bitmap); \ assert(!(sp->handling & ~bitmap)); \ diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 86c24d9a..065b80dd 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -23,7 +23,7 @@ VRT_error(struct sess *sp, unsigned code, const char *expl) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - VSL(SLT_Debug, 0, "VCL_error(%u, %s)", code, expl); + WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, expl); sp->err_code = code; sp->err_expl = expl; } @@ -36,7 +36,7 @@ VRT_count(struct sess *sp, unsigned u) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (params->vcl_trace) - VSL(SLT_VCL_trace, sp->fd, "%u %d.%d", u, + WSL(sp->wrk, SLT_VCL_trace, sp->fd, "%u %d.%d", u, sp->vcl->ref[u].line, sp->vcl->ref[u].pos); } @@ -150,7 +150,7 @@ VRT_l_obj_ttl(struct sess *sp, double a) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ - VSL(SLT_TTL, sp->fd, "%u VCL %.0f %u", + WSL(sp->wrk, SLT_TTL, sp->fd, "%u VCL %.0f %u", sp->obj->xid, a, sp->t_req.tv_sec); if (a < 0) a = 0; diff --git a/varnish-cache/bin/varnishd/shmlog.c b/varnish-cache/bin/varnishd/shmlog.c index e54ffaf8..8a6ad565 100644 --- a/varnish-cache/bin/varnishd/shmlog.c +++ b/varnish-cache/bin/varnishd/shmlog.c @@ -74,6 +74,8 @@ VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e) /* Only hold the lock while we find our space */ LOCKSHM(&vsl_mtx); + VSL_stats->shm_writes++; + VSL_stats->shm_records++; assert(loghead->ptr < loghead->size); /* Wrap if necessary */ @@ -112,6 +114,8 @@ VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...) } LOCKSHM(&vsl_mtx); + VSL_stats->shm_writes++; + VSL_stats->shm_records++; assert(loghead->ptr < loghead->size); /* Wrap if we cannot fit a full size record */ @@ -153,6 +157,8 @@ WSL_Flush(struct worker *w) return; l = w->wlp - w->wlog; LOCKSHM(&vsl_mtx); + VSL_stats->shm_writes++; + VSL_stats->shm_records += w->wlr; if (loghead->ptr + l + 1 >= loghead->size) vsl_wrap(); p = logstart + loghead->ptr; @@ -163,6 +169,7 @@ WSL_Flush(struct worker *w) p[0] = w->wlog[0]; UNLOCKSHM(&vsl_mtx); w->wlp = w->wlog; + w->wlr = 0; } /*--------------------------------------------------------------------*/ @@ -200,6 +207,7 @@ WSLR(struct worker *w, enum shmlogtag tag, unsigned id, const char *b, const cha memcpy(p + 4, b, l); p[4 + l] = '\0'; p[0] = tag; + w->wlr++; } /*--------------------------------------------------------------------*/ @@ -241,6 +249,7 @@ WSL(struct worker *w, enum shmlogtag tag, unsigned id, const char *fmt, ...) w->wlp += 5 + n; assert(w->wlp < w->wle); + w->wlr++; va_end(ap); } diff --git a/varnish-cache/include/stat_field.h b/varnish-cache/include/stat_field.h index f85ec996..f20ac59b 100644 --- a/varnish-cache/include/stat_field.h +++ b/varnish-cache/include/stat_field.h @@ -49,4 +49,6 @@ MAC_STAT(sess_pipeline, uint64_t, "u", "Session Pipeline") MAC_STAT(sess_readahead, uint64_t, "u", "Session Read Ahead") MAC_STAT(sess_herd, uint64_t, "u", "Session herd") +MAC_STAT(shm_records, uint64_t, "u", "SHM records") +MAC_STAT(shm_writes, uint64_t, "u", "SHM writes") MAC_STAT(shm_cont, uint64_t, "u", "SHM MTX contention") -- 2.39.5