Mailing List Archive

r1056 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2006-09-18 08:26:56 +0200 (Mon, 18 Sep 2006)
New Revision: 1056

Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Minor cleanups


Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2006-09-17 21:48:04 UTC (rev 1055)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2006-09-18 06:26:56 UTC (rev 1056)
@@ -654,7 +654,8 @@
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);

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2006-09-17 21:48:04 UTC (rev 1055)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2006-09-18 06:26:56 UTC (rev 1056)
@@ -17,6 +17,7 @@
static struct http_msg {
unsigned nbr;
const char *txt;
+ const char *expl;
} http_msg[] = {
{ 101, "Switching Protocols" },
{ 200, "OK" },
@@ -71,36 +72,30 @@
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);
TIM_format(sp->t_req.tv_sec, buf);