From: phk Date: Thu, 20 Jul 2006 08:29:14 +0000 (+0000) Subject: Remove explicit worker thread arguments. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86d99133a456455f3f75a6819c2429f7bccbfd99;p=varnish Remove explicit worker thread arguments. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@512 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index a14ec761..e759968f 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -335,10 +335,10 @@ void VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...); #endif /* cache_response.c */ -void RES_Error(struct worker *w, struct sess *sp, int error, const char *msg); +void RES_Error(struct sess *sp, int error, const char *msg); void RES_Flush(struct sess *sp); void RES_Write(struct sess *sp, void *ptr, size_t len); -void RES_WriteObj(struct worker *w, struct sess *sp); +void RES_WriteObj(struct sess *sp); /* cache_vcl.c */ void VCL_Init(void); diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 93049355..0f22293d 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -61,7 +61,7 @@ static int cnt_deliver(struct sess *sp) { - RES_WriteObj(sp->wrk, sp); + RES_WriteObj(sp); HSH_Deref(sp->obj); sp->obj = NULL; sp->step = STP_DONE; @@ -253,7 +253,7 @@ cnt_hit(struct sess *sp) sp->handling = VCL_RET_PASS; if (sp->handling == VCL_RET_DELIVER) { - RES_WriteObj(sp->wrk, sp); + RES_WriteObj(sp); HSH_Deref(sp->obj); sp->obj = NULL; sp->step = STP_DONE; @@ -522,7 +522,7 @@ cnt_recv(struct sess *sp) done = http_DissectRequest(sp->http, sp->fd); if (done != 0) { - RES_Error(sp->wrk, sp, done, NULL); + RES_Error(sp, done, NULL); sp->step = STP_DONE; return (0); } diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index 7c07ecb0..4fb384be 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -15,9 +15,12 @@ /*--------------------------------------------------------------------*/ void -RES_Error(struct worker *w, struct sess *sp, int error, const char *msg) +RES_Error(struct sess *sp, int error, const char *msg) { char buf[40]; + struct sbuf *sb; + + sb = sp->wrk->sb; if (msg == NULL) { switch (error) { @@ -27,11 +30,11 @@ RES_Error(struct worker *w, struct sess *sp, int error, const char *msg) } } - sbuf_clear(w->sb); - sbuf_printf(w->sb, "HTTP/1.1 %03d %s\r\n", error, msg); + sbuf_clear(sb); + sbuf_printf(sb, "HTTP/1.1 %03d %s\r\n", error, msg); TIM_format(sp->t_req, buf); - sbuf_printf(w->sb, "Date: %s\r\n", buf); - sbuf_cat(w->sb, + sbuf_printf(sb, "Date: %s\r\n", buf); + sbuf_cat(sb, "Server: Varnish\r\n" "Connection: close\r\n" "content-Type: text/html; charset=iso-8859-1\r\n" @@ -39,30 +42,30 @@ RES_Error(struct worker *w, struct sess *sp, int error, const char *msg) "\r\n" "\r\n" " \r\n"); - sbuf_printf(w->sb, " %03d %s\r\n", error, msg); - sbuf_cat(w->sb, + sbuf_printf(sb, " %03d %s\r\n", error, msg); + sbuf_cat(sb, " \r\n" " \r\n"); - sbuf_printf(w->sb, "

Error %03d %s

\r\n", error, msg); + sbuf_printf(sb, "

Error %03d %s

\r\n", error, msg); switch(error) { case 400: - sbuf_cat(w->sb, + sbuf_cat(sb, " Your HTTP protocol request did not make sense.\r\n"); break; case 500: default: - sbuf_cat(w->sb, + sbuf_cat(sb, " Something unexpected happened.\r\n"); break; } - sbuf_cat(w->sb, + sbuf_cat(sb, "

\r\n" " \r\n" " Varnish\r\n" " \r\n" "\r\n"); - sbuf_finish(w->sb); - RES_Write(sp, sbuf_data(w->sb), sbuf_len(w->sb)); + sbuf_finish(sb); + RES_Write(sp, sbuf_data(sb), sbuf_len(sb)); RES_Flush(sp); vca_close_session(sp, msg); } @@ -105,29 +108,32 @@ RES_Write(struct sess *sp, void *ptr, size_t len) } void -RES_WriteObj(struct worker *w, struct sess *sp) +RES_WriteObj(struct sess *sp) { struct storage *st; + struct sbuf *sb; unsigned u = 0; uint64_t bytes = 0; + sb = sp->wrk->sb; + VSL(SLT_Status, sp->fd, "%u", sp->obj->response); VSL(SLT_Length, sp->fd, "%u", sp->obj->len); RES_Write(sp, sp->obj->header, strlen(sp->obj->header)); - sbuf_clear(w->sb); - sbuf_printf(w->sb, "Age: %u\r\n", + sbuf_clear(sb); + sbuf_printf(sb, "Age: %u\r\n", sp->obj->age + sp->t_req - sp->obj->entered); - sbuf_printf(w->sb, "Via: 1.1 varnish\r\n"); - sbuf_printf(w->sb, "X-Varnish: xid %u\r\n", sp->obj->xid); + sbuf_printf(sb, "Via: 1.1 varnish\r\n"); + sbuf_printf(sb, "X-Varnish: xid %u\r\n", sp->obj->xid); if (strcmp(sp->http->proto, "HTTP/1.1")) - sbuf_printf(w->sb, "Connection: close\r\n"); - sbuf_printf(w->sb, "\r\n"); - sbuf_finish(w->sb); - RES_Write(sp, sbuf_data(w->sb), sbuf_len(w->sb)); - bytes += sbuf_len(w->sb); + sbuf_printf(sb, "Connection: close\r\n"); + sbuf_printf(sb, "\r\n"); + sbuf_finish(sb); + RES_Write(sp, sbuf_data(sb), sbuf_len(sb)); + bytes += sbuf_len(sb); /* XXX: conditional request handling */ if (!strcmp(sp->http->req, "GET")) { TAILQ_FOREACH(st, &sp->obj->store, list) {