From: phk Date: Mon, 18 Sep 2006 06:26:56 +0000 (+0000) Subject: Minor cleanups X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf7bc8dc211dbe65bf7fa7b572bb4e34abf537fd;p=varnish Minor cleanups git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1056 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 3e11e50c..b2bbfedb 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -654,7 +654,8 @@ cnt_recv(struct sess *sp) clock_gettime(CLOCK_REALTIME, &sp->t_req); sp->wrk->idle = sp->t_req.tv_sec; sp->xid = ++xids; - WSL(sp->wrk, SLT_ReqStart, sp->fd, "%s %s %u", sp->addr, sp->port, sp->xid); + WSL(sp->wrk, SLT_ReqStart, sp->fd, + "%s %s %u", sp->addr, sp->port, sp->xid); AZ(sp->vcl); VCL_Refresh(&sp->wrk->vcl); diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index 09708f00..bb7e8467 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -17,6 +17,7 @@ static struct http_msg { unsigned nbr; const char *txt; + const char *expl; } http_msg[] = { { 101, "Switching Protocols" }, { 200, "OK" }, @@ -71,35 +72,29 @@ RES_Error(struct sess *sp, int code, const char *expl) struct http_msg *mp; const char *msg; + assert(code >= 100 && code <= 999); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); clock_gettime(CLOCK_REALTIME, &sp->t_resp); msg = "Unknown error"; - for (mp = http_msg; mp->nbr != 0 && mp->nbr <= code; mp++) - if (mp->nbr == code) { - msg = mp->txt; + for (mp = http_msg; mp->nbr != 0 && mp->nbr <= code; mp++) { + if (mp->nbr < code) + continue; + if (mp->nbr > code) break; - } + msg = mp->txt; + if (expl == NULL) + expl = mp->expl; + break; + } + if (expl == NULL) + expl = msg; + AN(expl); + AN(msg); sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); XXXAN(sb); - assert(code >= 100 && code <= 999); - - if (msg == NULL) { - switch (code) { - case 400: msg = "Bad Request"; break; - case 500: msg = "Internal Error"; break; - default: msg = "HTTP request error"; break; - } - } - if (expl == NULL) { - switch (code) { - case 400: expl = "Your HTTP protocol request did not make sense."; break; - case 404: expl = "The document you requested was not found."; break; - default: expl = "Something unexpected happened."; break; - } - } vsb_clear(sb); vsb_printf(sb, "HTTP/1.1 %03d %s\r\n", code, msg);