From phk at projects.linpro.no Mon Oct 1 07:21:27 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Oct 2007 09:21:27 +0200 (CEST) Subject: r2070 - trunk/varnish-cache/bin/varnishd Message-ID: <20071001072127.127271EC290@projects.linpro.no> Author: phk Date: 2007-10-01 09:21:26 +0200 (Mon, 01 Oct 2007) New Revision: 2070 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: We always want to go through vcl_fetch(), even on error 503 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 21:27:16 UTC (rev 2069) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-01 07:21:26 UTC (rev 2070) @@ -304,39 +304,35 @@ VBE_free_bereq(sp->bereq); sp->bereq = NULL; - if (0 && i) { - SYN_ErrorPage(sp, 503, "Error talking to backend", 30); - } else { - if (!i) - RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */ - else - sp->obj->http.status = 503; + if (!i) + RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */ + else + http_PutStatus(sp->wrk, sp->fd, &sp->obj->http, 503); - VCL_fetch_method(sp); + VCL_fetch_method(sp); - switch (sp->handling) { - case VCL_RET_ERROR: - case VCL_RET_RESTART: - sp->obj->ttl = 0; - sp->obj->cacheable = 0; - HSH_Unbusy(sp->obj); - HSH_Deref(sp->obj); - sp->obj = NULL; - if (sp->handling == VCL_RET_ERROR) - sp->step = STP_ERROR; - else { - sp->restarts++; - sp->step = STP_RECV; - } - return (0); - case VCL_RET_PASS: - sp->obj->pass = 1; - break; - case VCL_RET_INSERT: - break; - default: - INCOMPL(); + switch (sp->handling) { + case VCL_RET_ERROR: + case VCL_RET_RESTART: + sp->obj->ttl = 0; + sp->obj->cacheable = 0; + HSH_Unbusy(sp->obj); + HSH_Deref(sp->obj); + sp->obj = NULL; + if (sp->handling == VCL_RET_ERROR) + sp->step = STP_ERROR; + else { + sp->restarts++; + sp->step = STP_RECV; } + return (0); + case VCL_RET_PASS: + sp->obj->pass = 1; + break; + case VCL_RET_INSERT: + break; + default: + INCOMPL(); } sp->obj->cacheable = 1; From phk at projects.linpro.no Mon Oct 1 07:27:38 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Oct 2007 09:27:38 +0200 (CEST) Subject: r2071 - trunk/varnish-cache/bin/varnishd Message-ID: <20071001072738.0F54D1EC2F1@projects.linpro.no> Author: phk Date: 2007-10-01 09:27:37 +0200 (Mon, 01 Oct 2007) New Revision: 2071 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_fetch.c trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/cache_response.c trunk/varnish-cache/bin/varnishd/cache_synthetic.c trunk/varnish-cache/bin/varnishd/cache_vary.c trunk/varnish-cache/bin/varnishd/cache_vrt.c Log: Eliminate a & which I tend to forget every single time. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-01 07:21:26 UTC (rev 2070) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-01 07:27:37 UTC (rev 2071) @@ -246,7 +246,7 @@ double last_modified; - struct http http; + struct http http[1]; VTAILQ_ENTRY(object) list; VTAILQ_ENTRY(object) deathrow; Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-01 07:21:26 UTC (rev 2070) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-01 07:27:37 UTC (rev 2071) @@ -305,9 +305,9 @@ sp->bereq = NULL; if (!i) - RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */ + RFC2616_cache_policy(sp, sp->obj->http); /* XXX -> VCL */ else - http_PutStatus(sp->wrk, sp->fd, &sp->obj->http, 503); + http_PutStatus(sp->wrk, sp->fd, sp->obj->http, 503); VCL_fetch_method(sp); Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-01 07:21:26 UTC (rev 2070) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-01 07:27:37 UTC (rev 2071) @@ -309,7 +309,7 @@ sp->obj->last_modified = TIM_parse(b); /* Filter into object */ - hp2 = &sp->obj->http; + hp2 = sp->obj->http; len = Tlen(htc->rxbuf); len += 256; /* XXX: margin for content-length etc */ Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-01 07:21:26 UTC (rev 2070) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-01 07:27:37 UTC (rev 2071) @@ -87,7 +87,7 @@ w->nobj = calloc(sizeof *w->nobj, 1); XXXAN(w->nobj); w->nobj->magic = OBJECT_MAGIC; - w->nobj->http.magic = HTTP_MAGIC; + w->nobj->http->magic = HTTP_MAGIC; w->nobj->busy = 1; w->nobj->refcnt = 1; VTAILQ_INIT(&w->nobj->store); @@ -304,8 +304,8 @@ if (r != 0) return; - if (o->http.ws != NULL && o->http.ws->s != NULL) - free(o->http.ws->s); + if (o->http->ws != NULL && o->http->ws->s != NULL) + free(o->http->ws->s); if (o->vary != NULL) free(o->vary); Modified: trunk/varnish-cache/bin/varnishd/cache_response.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-10-01 07:21:26 UTC (rev 2070) +++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-10-01 07:27:37 UTC (rev 2071) @@ -123,8 +123,8 @@ http_ClrHeader(sp->http); sp->http->logtag = HTTP_Tx; - http_CopyResp(sp->http, &sp->obj->http); - http_FilterFields(sp->wrk, sp->fd, sp->http, &sp->obj->http, + http_CopyResp(sp->http, sp->obj->http); + http_FilterFields(sp->wrk, sp->fd, sp->http, sp->obj->http, HTTPH_A_DELIVER); TIM_format(TIM_real(), time_str); Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-01 07:21:26 UTC (rev 2070) +++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-01 07:27:37 UTC (rev 2071) @@ -60,14 +60,14 @@ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - CHECK_OBJ_NOTNULL(&sp->obj->http, HTTP_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj->http, HTTP_MAGIC); assert(sp->obj->busy > 0); /* shortcuts */ w = sp->wrk; fd = sp->fd; o = sp->obj; - h = &o->http; + h = o->http; now = TIM_real(); /* look up HTTP response */ Modified: trunk/varnish-cache/bin/varnishd/cache_vary.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vary.c 2007-10-01 07:21:26 UTC (rev 2070) +++ trunk/varnish-cache/bin/varnishd/cache_vary.c 2007-10-01 07:27:37 UTC (rev 2071) @@ -76,7 +76,7 @@ AN(sbh); /* No Vary: header, no worries */ - if (!http_GetHdr(&sp->obj->http, H_Vary, &v)) + if (!http_GetHdr(sp->obj->http, H_Vary, &v)) return; for (p = v; *p; p++) { Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-10-01 07:21:26 UTC (rev 2070) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-10-01 07:27:37 UTC (rev 2071) @@ -91,7 +91,7 @@ hp = sp->http; break; case HDR_OBJ: - hp = &sp->obj->http; + hp = sp->obj->http; break; default: INCOMPL(); @@ -215,8 +215,8 @@ VRT_DO_HDR(bereq, request, sp->bereq->http, HTTP_HDR_REQ) VRT_DO_HDR(bereq, url, sp->bereq->http, HTTP_HDR_URL) VRT_DO_HDR(bereq, proto, sp->bereq->http, HTTP_HDR_PROTO) -VRT_DO_HDR(obj, proto, &sp->obj->http, HTTP_HDR_PROTO) -VRT_DO_HDR(obj, response, &sp->obj->http, HTTP_HDR_RESPONSE) +VRT_DO_HDR(obj, proto, sp->obj->http, HTTP_HDR_PROTO) +VRT_DO_HDR(obj, response, sp->obj->http, HTTP_HDR_RESPONSE) VRT_DO_HDR(resp, proto, sp->http, HTTP_HDR_PROTO) VRT_DO_HDR(resp, response, sp->http, HTTP_HDR_RESPONSE) @@ -226,12 +226,12 @@ char *p; assert(num >= 100 && num <= 999); - p = WS_Alloc(sp->obj->http.ws, 4); + p = WS_Alloc(sp->obj->http->ws, 4); if (p == NULL) WSP(sp, SLT_LostHeader, "%s", "obj.status"); else sprintf(p, "%d", num); - http_SetH(&sp->obj->http, HTTP_HDR_STATUS, p); + http_SetH(sp->obj->http, HTTP_HDR_STATUS, p); } int @@ -240,9 +240,9 @@ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX: use http_GetStatus() */ - if (sp->obj->http.status) - return (sp->obj->http.status); - return (atoi(sp->obj->http.hd[HTTP_HDR_STATUS].b)); + if (sp->obj->http->status) + return (sp->obj->http->status); + return (atoi(sp->obj->http->hd[HTTP_HDR_STATUS].b)); } void @@ -374,7 +374,7 @@ { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - return (sp->obj->http.hd[HTTP_HDR_PROTO].b); + return (sp->obj->http->hd[HTTP_HDR_PROTO].b); } const char * @@ -382,7 +382,7 @@ { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - return (sp->obj->http.hd[HTTP_HDR_RESPONSE].b); + return (sp->obj->http->hd[HTTP_HDR_RESPONSE].b); } int @@ -390,7 +390,7 @@ { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - return (atoi(sp->obj->http.hd[HTTP_HDR_STATUS].b)); + return (atoi(sp->obj->http->hd[HTTP_HDR_STATUS].b)); } /*--------------------------------------------------------------------*/ From phk at projects.linpro.no Mon Oct 1 07:46:00 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Oct 2007 09:46:00 +0200 (CEST) Subject: r2072 - trunk/varnish-cache/bin/varnishd Message-ID: <20071001074600.734931ECDEA@projects.linpro.no> Author: phk Date: 2007-10-01 09:45:58 +0200 (Mon, 01 Oct 2007) New Revision: 2072 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_expire.c trunk/varnish-cache/bin/varnishd/cache_main.c trunk/varnish-cache/bin/varnishd/cache_pool.c trunk/varnish-cache/bin/varnishd/shmlog.c Log: Move the workerthreads log from malloc to stack. Dump sizes of various structures on startup. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-01 07:27:37 UTC (rev 2071) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-01 07:45:58 UTC (rev 2072) @@ -176,9 +176,8 @@ struct srcaddr *srcaddr; struct acct acct; - unsigned char *wlp, *wle; + unsigned char *wlb, *wlp, *wle; unsigned wlr; - unsigned char wlog[WLOGSPACE]; }; struct workreq { Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-10-01 07:27:37 UTC (rev 2071) +++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-10-01 07:45:58 UTC (rev 2072) @@ -165,6 +165,7 @@ double t; struct sess *sp; struct object *o2; + unsigned char log[1024]; /* XXX size ? */ (void)arg; @@ -172,8 +173,8 @@ XXXAN(sp); sp->wrk = &ww; ww.magic = WORKER_MAGIC; - ww.wlp = ww.wlog; - ww.wle = ww.wlog + sizeof ww.wlog; + ww.wlp = ww.wlb = log; + ww.wle = log + sizeof log; AZ(sleep(10)); /* XXX: Takes time for VCL to arrive */ VCL_Get(&sp->vcl); Modified: trunk/varnish-cache/bin/varnishd/cache_main.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_main.c 2007-10-01 07:27:37 UTC (rev 2071) +++ trunk/varnish-cache/bin/varnishd/cache_main.c 2007-10-01 07:45:58 UTC (rev 2072) @@ -51,6 +51,22 @@ setbuf(stderr, NULL); printf("Child starts\n"); +#define SZOF(foo) printf("sizeof(%s) = %d\n", #foo, sizeof(foo)); + SZOF(struct ws); + SZOF(struct http); + SZOF(struct http_conn); + SZOF(struct acct); + SZOF(struct worker); + SZOF(struct workreq); + SZOF(struct bereq); + SZOF(struct storage); + SZOF(struct object); + SZOF(struct objhead); + SZOF(struct sess); + SZOF(struct vbe_conn); + SZOF(struct backend); + + CNT_Init(); VCL_Init(); Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-10-01 07:27:37 UTC (rev 2071) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-10-01 07:45:58 UTC (rev 2072) @@ -202,13 +202,14 @@ struct worker w[1]; struct wq *qp; char c; + unsigned char wlog[8192]; /* XXX: size */ qp = priv; memset(w, 0, sizeof *w); w->magic = WORKER_MAGIC; w->used = TIM_real(); - w->wlp = w->wlog; - w->wle = w->wlog + sizeof w->wlog; + w->wlb = w->wlp = wlog; + w->wle = wlog + sizeof wlog; AZ(pipe(w->pipe)); VSL(SLT_WorkThread, 0, "%p start", w); Modified: trunk/varnish-cache/bin/varnishd/shmlog.c =================================================================== --- trunk/varnish-cache/bin/varnishd/shmlog.c 2007-10-01 07:27:37 UTC (rev 2071) +++ trunk/varnish-cache/bin/varnishd/shmlog.c 2007-10-01 07:45:58 UTC (rev 2072) @@ -175,7 +175,7 @@ unsigned char *p; unsigned l; - l = pdiff(w->wlog, w->wlp); + l = pdiff(w->wlb, w->wlp); if (l == 0) return; LOCKSHM(&vsl_mtx); @@ -184,14 +184,14 @@ if (loghead->ptr + l + 1 >= loghead->size) vsl_wrap(); p = logstart + loghead->ptr; - memcpy(p + 1, w->wlog + 1, l - 1); + memcpy(p + 1, w->wlb + 1, l - 1); p[l] = SLT_ENDMARKER; loghead->ptr += l; assert(loghead->ptr < loghead->size); /* XXX: memory barrier here */ - p[0] = w->wlog[0]; + p[0] = w->wlb[0]; UNLOCKSHM(&vsl_mtx); - w->wlp = w->wlog; + w->wlp = w->wlb; w->wlr = 0; } From phk at projects.linpro.no Mon Oct 1 08:54:27 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Oct 2007 10:54:27 +0200 (CEST) Subject: r2073 - trunk/varnish-cache/bin/varnishd Message-ID: <20071001085427.6C62A1EC290@projects.linpro.no> Author: phk Date: 2007-10-01 10:54:26 +0200 (Mon, 01 Oct 2007) New Revision: 2073 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_fetch.c trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/cache_pool.c Log: Move the objects and their http header into storage instead of malloc'ing them. This should reduce the N(nobj) swap-loading considerably. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-01 07:45:58 UTC (rev 2072) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-01 08:54:26 UTC (rev 2073) @@ -222,6 +222,7 @@ unsigned refcnt; unsigned xid; struct objhead *objhead; + struct storage *objstore; struct ws ws_o[1]; unsigned char *vary; @@ -448,7 +449,7 @@ int Fetch(struct sess *sp); /* cache_hash.c */ -void HSH_Prealloc(const struct sess *sp); +void HSH_Prealloc(struct sess *sp); int HSH_Compare(const struct sess *sp, const struct objhead *o); void HSH_Copy(const struct sess *sp, const struct objhead *o); struct object *HSH_Lookup(struct sess *sp); Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-01 07:45:58 UTC (rev 2072) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-01 08:54:26 UTC (rev 2073) @@ -259,7 +259,6 @@ struct storage *st; struct bereq *bereq; int mklen, is_head; - unsigned len; struct http_conn htc[1]; int i; @@ -276,6 +275,13 @@ sp->obj->xid = sp->xid; + /* Set up obj's workspace */ + st = sp->obj->objstore; + WS_Init(sp->obj->ws_o, st->ptr + st->len, st->space - st->len); + st->len = st->space; + WS_Assert(sp->obj->ws_o); + http_Setup(sp->obj->http, sp->obj->ws_o); + vc = VBE_GetFd(sp); if (vc == NULL) return (1); @@ -310,14 +316,7 @@ /* Filter into object */ hp2 = sp->obj->http; - len = Tlen(htc->rxbuf); - len += 256; /* XXX: margin for content-length etc */ - b = malloc(len); - AN(b); - WS_Init(sp->obj->ws_o, b, len); - http_Setup(hp2, sp->obj->ws_o); - hp2->logtag = HTTP_Obj; http_CopyResp(hp2, hp); http_FilterFields(sp->wrk, sp->fd, hp2, hp, HTTPH_A_INS); Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-01 07:45:58 UTC (rev 2072) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-01 08:54:26 UTC (rev 2073) @@ -67,9 +67,10 @@ /* Precreate an objhead and object for later use */ void -HSH_Prealloc(const struct sess *sp) +HSH_Prealloc(struct sess *sp) { struct worker *w; + struct storage *st; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); w = sp->wrk; @@ -84,8 +85,12 @@ } else CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC); if (w->nobj == NULL) { - w->nobj = calloc(sizeof *w->nobj, 1); - XXXAN(w->nobj); + st = STV_alloc(sp, params->mem_workspace); + XXXAN(st); + w->nobj = (void *)st->ptr; + st->len = sizeof *w->nobj; + memset(w->nobj, 0, sizeof *w->nobj); + w->nobj->objstore = st; w->nobj->magic = OBJECT_MAGIC; w->nobj->http->magic = HTTP_MAGIC; w->nobj->busy = 1; @@ -304,14 +309,11 @@ if (r != 0) return; - if (o->http->ws != NULL && o->http->ws->s != NULL) - free(o->http->ws->s); - if (o->vary != NULL) free(o->vary); HSH_Freestore(o); - FREE_OBJ(o); + STV_free(o->objstore); VSL_stats->n_object--; if (oh == NULL) Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-10-01 07:45:58 UTC (rev 2072) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-10-01 08:54:26 UTC (rev 2073) @@ -56,6 +56,7 @@ #include "vcl.h" #include "cli_priv.h" #include "cache.h" +#include "stevedore.h" VTAILQ_HEAD(workerhead, worker); @@ -261,7 +262,7 @@ FREE_OBJ(w->nobjhead); } if (w->nobj!= NULL) - FREE_OBJ(w->nobj); + STV_free(w->nobj->objstore); return (NULL); } From phk at projects.linpro.no Mon Oct 1 09:04:16 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Oct 2007 11:04:16 +0200 (CEST) Subject: r2074 - trunk/varnish-cache/bin/varnishd Message-ID: <20071001090416.5137B1EC1D1@projects.linpro.no> Author: phk Date: 2007-10-01 11:04:15 +0200 (Mon, 01 Oct 2007) New Revision: 2074 Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c Log: Initialize the obj->ws before we use it. Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-01 08:54:26 UTC (rev 2073) +++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-01 09:04:15 UTC (rev 2074) @@ -70,6 +70,13 @@ h = o->http; now = TIM_real(); + /* Set up obj's workspace */ + st = o->objstore; + WS_Init(o->ws_o, st->ptr + st->len, st->space - st->len); + st->len = st->space; + WS_Assert(o->ws_o); + http_Setup(o->http, o->ws_o); + /* look up HTTP response */ msg = http_StatusMessage(status); if (reason == NULL) From phk at projects.linpro.no Mon Oct 1 12:25:38 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Oct 2007 14:25:38 +0200 (CEST) Subject: r2075 - trunk/varnish-cache/bin/varnishd Message-ID: <20071001122538.6A88F1EC47D@projects.linpro.no> Author: phk Date: 2007-10-01 14:25:37 +0200 (Mon, 01 Oct 2007) New Revision: 2075 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_fetch.c trunk/varnish-cache/bin/varnishd/cache_http.c trunk/varnish-cache/bin/varnishd/cache_synthetic.c trunk/varnish-cache/bin/varnishd/mgt_vcc.c trunk/varnish-cache/bin/varnishd/rfc2616.c Log: Remember to move numeric status when we filter one http to another. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-01 09:04:15 UTC (rev 2074) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-01 12:25:37 UTC (rev 2075) @@ -309,6 +309,8 @@ else http_PutStatus(sp->wrk, sp->fd, sp->obj->http, 503); + sp->err_code = http_GetStatus(sp->obj->http); +WSP(sp, SLT_Debug, "i %d err %d v %d c %d", i, sp->err_code, sp->obj->valid, sp->obj->cacheable); VCL_fetch_method(sp); switch (sp->handling) { Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-01 09:04:15 UTC (rev 2074) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-01 12:25:37 UTC (rev 2075) @@ -284,14 +284,14 @@ vc = VBE_GetFd(sp); if (vc == NULL) - return (1); + return (__LINE__); WRK_Reset(w, &vc->fd); http_Write(w, hp, 0); if (WRK_Flush(w)) { VBE_UpdateHealth(sp, vc, -1); VBE_ClosedFd(sp->wrk, vc); /* XXX: other cleanup ? */ - return (1); + return (__LINE__); } /* XXX is this the right place? */ @@ -306,7 +306,7 @@ VBE_UpdateHealth(sp, vc, -2); VBE_ClosedFd(sp->wrk, vc); /* XXX: other cleanup ? */ - return (1); + return (__LINE__); } sp->obj->entered = TIM_real(); @@ -338,7 +338,7 @@ WSL(sp->wrk, SLT_Debug, vc->fd, "Invalid Transfer-Encoding"); VBE_UpdateHealth(sp, vc, -3); VBE_ClosedFd(sp->wrk, vc); - return (-1); + return (__LINE__); } else if (strcmp(http_GetProto(hp), "HTTP/1.1")) { switch (http_GetStatus(hp)) { case 200: @@ -359,7 +359,7 @@ } VBE_UpdateHealth(sp, vc, -4); VBE_ClosedFd(sp->wrk, vc); - return (-1); + return (__LINE__); } { Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-01 09:04:15 UTC (rev 2074) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-01 12:25:37 UTC (rev 2075) @@ -598,6 +598,7 @@ CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); to->nhd = HTTP_HDR_FIRST; + to->status = fm->status; for (u = HTTP_HDR_FIRST; u < fm->nhd; u++) { if (fm->hdf[u] & HDF_FILTER) continue; Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-01 09:04:15 UTC (rev 2074) +++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-01 12:25:37 UTC (rev 2075) @@ -56,6 +56,7 @@ double now; int fd; + WSL_Flush(sp->wrk); assert(status >= 100 && status <= 999); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-10-01 09:04:15 UTC (rev 2074) +++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-10-01 12:25:37 UTC (rev 2075) @@ -98,15 +98,11 @@ "\n" "sub vcl_hash {\n" " set req.hash += req.url;\n" -#if 1 - " set req.hash += req.http.host;\n" -#else " if (req.http.host) {\n" " set req.hash += req.http.host;\n" " } else {\n" - " set req.hash += server.ip;\n" /* XXX: see ticket 137 */ + " set req.hash += server.ip;\n" " }\n" -#endif " hash;\n" "}\n" "\n" Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c =================================================================== --- trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-10-01 09:04:15 UTC (rev 2074) +++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-10-01 12:25:37 UTC (rev 2075) @@ -172,6 +172,7 @@ * We do not support ranges yet, so 206 is out. */ sp->obj->response = http_GetStatus(hp); +WSP(sp, SLT_Debug, "resp: %d", sp->obj->response); switch (sp->obj->response) { case 200: /* OK */ case 203: /* Non-Authoritative Information */ From phk at projects.linpro.no Mon Oct 1 12:27:49 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Oct 2007 14:27:49 +0200 (CEST) Subject: r2076 - trunk/varnish-cache/bin/varnishd Message-ID: <20071001122749.C8F561EC290@projects.linpro.no> Author: phk Date: 2007-10-01 14:27:49 +0200 (Mon, 01 Oct 2007) New Revision: 2076 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_synthetic.c trunk/varnish-cache/bin/varnishd/rfc2616.c Log: Oops, last commit included some debugging Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-01 12:25:37 UTC (rev 2075) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-01 12:27:49 UTC (rev 2076) @@ -310,7 +310,6 @@ http_PutStatus(sp->wrk, sp->fd, sp->obj->http, 503); sp->err_code = http_GetStatus(sp->obj->http); -WSP(sp, SLT_Debug, "i %d err %d v %d c %d", i, sp->err_code, sp->obj->valid, sp->obj->cacheable); VCL_fetch_method(sp); switch (sp->handling) { Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-01 12:25:37 UTC (rev 2075) +++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-01 12:27:49 UTC (rev 2076) @@ -56,7 +56,6 @@ double now; int fd; - WSL_Flush(sp->wrk); assert(status >= 100 && status <= 999); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c =================================================================== --- trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-10-01 12:25:37 UTC (rev 2075) +++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-10-01 12:27:49 UTC (rev 2076) @@ -172,7 +172,6 @@ * We do not support ranges yet, so 206 is out. */ sp->obj->response = http_GetStatus(hp); -WSP(sp, SLT_Debug, "resp: %d", sp->obj->response); switch (sp->obj->response) { case 200: /* OK */ case 203: /* Non-Authoritative Information */ From phk at projects.linpro.no Mon Oct 1 12:44:19 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Oct 2007 14:44:19 +0200 (CEST) Subject: r2077 - trunk/varnish-cache/bin/varnishd Message-ID: <20071001124419.CBE871EC1D1@projects.linpro.no> Author: phk Date: 2007-10-01 14:44:19 +0200 (Mon, 01 Oct 2007) New Revision: 2077 Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c Log: Go over pipe's polling code and try to do it right in one go by actually paying attention to what goes on. Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-10-01 12:27:49 UTC (rev 2076) +++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-10-01 12:44:19 UTC (rev 2077) @@ -43,15 +43,15 @@ #include "cache.h" static void -rdf(struct pollfd *fds, int idx) +rdf(struct pollfd *fds, int idx, int fd0, int fd1) { int i, j; char buf[BUFSIZ], *p; i = read(fds[idx].fd, buf, sizeof buf); if (i <= 0 || fds[1-idx].events == 0) { - AZ(shutdown(fds[idx].fd, SHUT_RD)); - AZ(shutdown(fds[1-idx].fd, SHUT_WR)); + AZ(shutdown(fd0, SHUT_RD)); + AZ(shutdown(fd1, SHUT_WR)); fds[idx].fd = -1; fds[idx].events = 0; return; @@ -59,10 +59,10 @@ for (p = buf; i > 0; i -= j, p += j) { j = write(fds[1-idx].fd, p, i); if (j != i) { - AZ(shutdown(fds[idx].fd, SHUT_WR)); - AZ(shutdown(fds[1-idx].fd, SHUT_RD)); - fds[1-idx].fd = -1; - fds[1-idx].events = 0; + AZ(shutdown(fd0, SHUT_RD)); + AZ(shutdown(fd1, SHUT_WR)); + fds[idx].fd = -1; + fds[idx].events = 0; return; } } @@ -114,13 +114,21 @@ fds[0].revents = 0; fds[1].revents = 0; i = poll(fds, 2, params->pipe_timeout * 1000); - if (i != 1) + if (i < 1) break; if (fds[0].revents) - rdf(fds, 0); + rdf(fds, 0, vc->fd, sp->fd); if (fds[1].revents) - rdf(fds, 1); + rdf(fds, 1, sp->fd, vc->fd); } + if (fds[0].fd >= 0) { + AZ(shutdown(fds[0].fd, SHUT_RD)); + AZ(shutdown(fds[1].fd, SHUT_WR)); + } + if (fds[1].fd >= 0) { + AZ(shutdown(fds[1].fd, SHUT_RD)); + AZ(shutdown(fds[0].fd, SHUT_WR)); + } vca_close_session(sp, "pipe"); VBE_ClosedFd(sp->wrk, vc); } From ssm at projects.linpro.no Fri Oct 5 09:15:09 2007 From: ssm at projects.linpro.no (ssm at projects.linpro.no) Date: Fri, 5 Oct 2007 11:15:09 +0200 (CEST) Subject: r2078 - trunk/varnish-cache/debian Message-ID: <20071005091509.5DED91EC290@projects.linpro.no> Author: ssm Date: 2007-10-05 11:15:09 +0200 (Fri, 05 Oct 2007) New Revision: 2078 Modified: trunk/varnish-cache/debian/varnish.postinst Log: Fix ticket #166, debian package issues Modified: trunk/varnish-cache/debian/varnish.postinst =================================================================== --- trunk/varnish-cache/debian/varnish.postinst 2007-10-01 12:44:19 UTC (rev 2077) +++ trunk/varnish-cache/debian/varnish.postinst 2007-10-05 09:15:09 UTC (rev 2078) @@ -5,8 +5,12 @@ adduser --system --no-create-home --group varnish 2>&1 > /dev/null || exit 78 fi } +varnish_create_storagedir() { + install -o varnish -g varnish -d /var/lib/varnish/$(uname -n) || exit 78 +} varnish_setup_user +varnish_create_storagedir #DEBHELPER# # Automatically added by dh_installinit @@ -19,13 +23,3 @@ fi fi # End automatically added section -# Automatically added by dh_installinit -if [ -x "/etc/init.d/varnishlog" ]; then - update-rc.d varnishlog defaults >/dev/null - if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then - invoke-rc.d varnishlog start || exit $? - else - /etc/init.d/varnishlog start || exit $? - fi -fi -# End automatically added section From phk at projects.linpro.no Mon Oct 8 07:18:48 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 09:18:48 +0200 (CEST) Subject: r2079 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008071848.D916E1EC407@projects.linpro.no> Author: phk Date: 2007-10-08 09:18:48 +0200 (Mon, 08 Oct 2007) New Revision: 2079 Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c Log: Flush the threads shmlog before we try to make up a reponse, so that we know what transactions trigger problems in that code. Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-05 09:15:09 UTC (rev 2078) +++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-08 07:18:48 UTC (rev 2079) @@ -56,6 +56,7 @@ double now; int fd; + WSL_Flush(sp->wrk); assert(status >= 100 && status <= 999); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); From phk at projects.linpro.no Mon Oct 8 07:19:52 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 09:19:52 +0200 (CEST) Subject: r2080 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008071952.5CDC31EC2ED@projects.linpro.no> Author: phk Date: 2007-10-08 09:19:52 +0200 (Mon, 08 Oct 2007) New Revision: 2080 Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c Log: Try to make the pipe code even more robust Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-10-08 07:18:48 UTC (rev 2079) +++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-10-08 07:19:52 UTC (rev 2080) @@ -42,30 +42,25 @@ #include "heritage.h" #include "cache.h" -static void -rdf(struct pollfd *fds, int idx, int fd0, int fd1) +static int +rdf(int fd0, int fd1) { int i, j; char buf[BUFSIZ], *p; - i = read(fds[idx].fd, buf, sizeof buf); - if (i <= 0 || fds[1-idx].events == 0) { - AZ(shutdown(fd0, SHUT_RD)); - AZ(shutdown(fd1, SHUT_WR)); - fds[idx].fd = -1; - fds[idx].events = 0; - return; - } + i = read(fd0, buf, sizeof buf); + if (i <= 0) + return (1); for (p = buf; i > 0; i -= j, p += j) { - j = write(fds[1-idx].fd, p, i); - if (j != i) { - AZ(shutdown(fd0, SHUT_RD)); - AZ(shutdown(fd1, SHUT_WR)); - fds[idx].fd = -1; - fds[idx].events = 0; - return; + j = write(fd1, p, i); + if (j <= 0) + return (1); + if (i != j) { + printf("flunk %d %d\n", i, j); + usleep(100000); /* XXX hack */ } } + return (0); } void @@ -110,24 +105,32 @@ fds[1].fd = sp->fd; fds[1].events = POLLIN | POLLERR; - while (fds[0].events || fds[1].events) { + while (fds[0].fd > -1 || fds[1].fd > -1) { fds[0].revents = 0; fds[1].revents = 0; i = poll(fds, 2, params->pipe_timeout * 1000); if (i < 1) break; - if (fds[0].revents) - rdf(fds, 0, vc->fd, sp->fd); - if (fds[1].revents) - rdf(fds, 1, sp->fd, vc->fd); + if (fds[0].revents && rdf(vc->fd, sp->fd)) { + AZ(shutdown(vc->fd, SHUT_RD)); + AZ(shutdown(sp->fd, SHUT_WR)); + fds[0].events = 0; + fds[0].fd = -1; + } + if (fds[1].revents && rdf(sp->fd, vc->fd)) { + AZ(shutdown(sp->fd, SHUT_RD)); + AZ(shutdown(vc->fd, SHUT_WR)); + fds[1].events = 0; + fds[1].fd = -1; + } } if (fds[0].fd >= 0) { - AZ(shutdown(fds[0].fd, SHUT_RD)); - AZ(shutdown(fds[1].fd, SHUT_WR)); + AZ(shutdown(vc->fd, SHUT_RD)); + AZ(shutdown(sp->fd, SHUT_WR)); } if (fds[1].fd >= 0) { - AZ(shutdown(fds[1].fd, SHUT_RD)); - AZ(shutdown(fds[0].fd, SHUT_WR)); + AZ(shutdown(sp->fd, SHUT_RD)); + AZ(shutdown(vc->fd, SHUT_WR)); } vca_close_session(sp, "pipe"); VBE_ClosedFd(sp->wrk, vc); From phk at projects.linpro.no Mon Oct 8 07:49:26 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 09:49:26 +0200 (CEST) Subject: r2081 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008074926.3FAE51EC407@projects.linpro.no> Author: phk Date: 2007-10-08 09:49:26 +0200 (Mon, 08 Oct 2007) New Revision: 2081 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c Log: comments/style Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-08 07:19:52 UTC (rev 2080) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-08 07:49:26 UTC (rev 2081) @@ -226,9 +226,9 @@ i = HTC_Rx(sp->htc); /* XXX: fix retval */ - if (i == 0) + if (i == 0) /* more needed */ return (-1); - if (i == 1) + if (i == 1) /* Yes, done */ return (0); vca_close_session(sp, "err/poll"); return (1); @@ -259,7 +259,7 @@ if (sp->fd < 0) SES_Delete(sp); else - assert(sizeof sp == write(vca_pipes[1], &sp, sizeof sp)); + assert(sizeof sp == write(vca_pipes[1], &sp, sizeof sp)); } From phk at projects.linpro.no Mon Oct 8 07:50:31 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 09:50:31 +0200 (CEST) Subject: r2082 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008075031.4E6461EC2ED@projects.linpro.no> Author: phk Date: 2007-10-08 09:50:31 +0200 (Mon, 08 Oct 2007) New Revision: 2082 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c Log: Use HTC_Rx() directly instead of vca_pollsession() wrapper Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-10-08 07:49:26 UTC (rev 2081) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-10-08 07:50:31 UTC (rev 2082) @@ -98,14 +98,15 @@ } CAST_OBJ_NOTNULL(sp, kp->udata, SESS_MAGIC); if (kp->data > 0) { - i = vca_pollsession(sp); - if (i == -1) - return; + i = HTC_Rx(sp->htc); + if (i == 0) + return; /* more needed */ VTAILQ_REMOVE(&sesshead, sp, list); - if (i == 0) { + if (i > 0) { vca_kq_sess(sp, EV_DELETE); vca_handover(sp, i); } else { + vca_close_session(sp, "err/poll"); SES_Delete(sp); } return; From phk at projects.linpro.no Mon Oct 8 07:51:32 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 09:51:32 +0200 (CEST) Subject: r2083 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008075132.078AD1EC64C@projects.linpro.no> Author: phk Date: 2007-10-08 09:51:31 +0200 (Mon, 08 Oct 2007) New Revision: 2083 Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c Log: Bail normally instead of asserting on buffer full. Drop leading whitespace if so informed. Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 07:50:31 UTC (rev 2082) +++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 07:51:31 UTC (rev 2083) @@ -123,7 +123,13 @@ return (i); } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * Receive more HTTP protocol bytes + * Returns: + * -1 error + * 0 more needed + * 1 got complete HTTP header + */ int HTC_Rx(struct http_conn *htc) @@ -132,16 +138,18 @@ CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); i = (htc->ws->r - htc->rxbuf.e) - 1; /* space for NUL */ - assert(i > 0); - i = read(htc->fd, htc->rxbuf.e, i); - if (i < 0) { + if (i > 0) + i = read(htc->fd, htc->rxbuf.e, i); + if (i <= 0) { WS_ReleaseP(htc->ws, htc->rxbuf.b); return (-1); } htc->rxbuf.e += i; *htc->rxbuf.e = '\0'; i = htc_header_complete(&htc->rxbuf); - if (i == 0) + if (i < 0) + htc->rxbuf.e = htc->rxbuf.b; + if (i <= 0) return (0); WS_ReleaseP(htc->ws, htc->rxbuf.e); if (htc->rxbuf.b + i < htc->rxbuf.e) { From phk at projects.linpro.no Mon Oct 8 08:14:10 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 10:14:10 +0200 (CEST) Subject: r2084 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008081410.11BF51EC64C@projects.linpro.no> Author: phk Date: 2007-10-08 10:14:09 +0200 (Mon, 08 Oct 2007) New Revision: 2084 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/cache_acceptor.h trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_httpconn.c Log: More acceptor work: Make HTC_Rx() return a distinct value for overflow/blast. Teach vca_handover() to handle HTC_Rx() return status Use HTC_Rx/vca_handover this way in all three acceptors. Eliminate vca_pollsession() Teach CNT_First() about HTC_Rx states. Log which acceptor we use in shmlog Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-08 07:51:31 UTC (rev 2083) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-08 08:14:09 UTC (rev 2084) @@ -53,7 +53,6 @@ #include "cache.h" #include "cache_acceptor.h" - static struct acceptor *vca_acceptors[] = { #if defined(HAVE_KQUEUE) &acceptor_kqueue, @@ -204,38 +203,29 @@ /*--------------------------------------------------------------------*/ void -vca_handover(struct sess *sp, int bad) +vca_handover(struct sess *sp, int status) { - if (bad) { - vca_close_session(sp, - bad == 1 ? "overflow" : "no request"); + switch (status) { + case -2: + vca_close_session(sp, "blast"); SES_Delete(sp); - return; + break; + case -1: + vca_close_session(sp, "no request"); + SES_Delete(sp); + break; + case 1: + sp->step = STP_RECV; + WRK_QueueSession(sp); + break; + default: + INCOMPL(); } - sp->step = STP_RECV; - WRK_QueueSession(sp); } /*--------------------------------------------------------------------*/ -int -vca_pollsession(struct sess *sp) -{ - int i; - - i = HTC_Rx(sp->htc); - /* XXX: fix retval */ - if (i == 0) /* more needed */ - return (-1); - if (i == 1) /* Yes, done */ - return (0); - vca_close_session(sp, "err/poll"); - return (1); -} - -/*--------------------------------------------------------------------*/ - void vca_close_session(struct sess *sp, const char *why) { @@ -280,4 +270,5 @@ AZ(pipe(vca_pipes)); vca_act->init(); AZ(pthread_create(&vca_thread_acct, NULL, vca_acct, NULL)); + VSL(SLT_Debug, 0, "Acceptor is %s", vca_act->name); } Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.h 2007-10-08 07:51:31 UTC (rev 2083) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.h 2007-10-08 08:14:09 UTC (rev 2084) @@ -52,5 +52,3 @@ /* vca_acceptor.c */ void vca_handover(struct sess *sp, int bad); -int vca_pollsession(struct sess *sp); - Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2007-10-08 07:51:31 UTC (rev 2083) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2007-10-08 08:14:09 UTC (rev 2084) @@ -90,15 +90,11 @@ vca_add(sp->fd, sp); } else { CAST_OBJ_NOTNULL(sp, ev.data.ptr, SESS_MAGIC); - i = vca_pollsession(sp); - if (i >= 0) { + i = HTC_Rx(sp->htc); + if (i != 0) VTAILQ_REMOVE(&sesshead, sp, list); - if (sp->fd != -1) - vca_del(sp->fd); - if (i == 0) - vca_handover(sp, i); - else - SES_Delete(sp); + vca_del(sp->fd); + vca_handover(sp, i); } } } Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-10-08 07:51:31 UTC (rev 2083) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-10-08 08:14:09 UTC (rev 2084) @@ -102,13 +102,8 @@ if (i == 0) return; /* more needed */ VTAILQ_REMOVE(&sesshead, sp, list); - if (i > 0) { - vca_kq_sess(sp, EV_DELETE); - vca_handover(sp, i); - } else { - vca_close_session(sp, "err/poll"); - SES_Delete(sp); - } + vca_kq_sess(sp, EV_DELETE); + vca_handover(sp, i); return; } else if (kp->flags == EV_EOF) { VTAILQ_REMOVE(&sesshead, sp, list); Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-10-08 07:51:31 UTC (rev 2083) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-10-08 08:14:09 UTC (rev 2084) @@ -131,15 +131,12 @@ fd = sp->fd; if (pollfd[fd].revents) { v--; - i = vca_pollsession(sp); - if (i < 0) + i = HTC_Rx(sp->htc); + if (i == 0) continue; VTAILQ_REMOVE(&sesshead, sp, list); vca_unpoll(fd); - if (i == 0) - vca_handover(sp, i); - else - SES_Delete(sp); + vca_handover(sp, i); continue; } if (sp->t_open > deadline) Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-08 07:51:31 UTC (rev 2083) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-08 08:14:09 UTC (rev 2084) @@ -370,17 +370,21 @@ do i = HTC_Rx(sp->htc); while (i == 0); - if (i == 1) { + switch (i) { + case 1: sp->step = STP_RECV; - return (0); - } - if (i == -1) + break; + case -1: + vca_close_session(sp, "error"); + sp->step = STP_DONE; + break; + case -2: vca_close_session(sp, "blast"); - else if (i == 2) - vca_close_session(sp, "silent"); - else + sp->step = STP_DONE; + break; + default: INCOMPL(); - sp->step = STP_DONE; + } return (0); } Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 07:51:31 UTC (rev 2083) +++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 08:14:09 UTC (rev 2084) @@ -126,6 +126,7 @@ /*-------------------------------------------------------------------- * Receive more HTTP protocol bytes * Returns: + * -2 overflow * -1 error * 0 more needed * 1 got complete HTTP header @@ -138,10 +139,13 @@ CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); i = (htc->ws->r - htc->rxbuf.e) - 1; /* space for NUL */ - if (i > 0) - i = read(htc->fd, htc->rxbuf.e, i); if (i <= 0) { WS_ReleaseP(htc->ws, htc->rxbuf.b); + return (-2); + } + i = read(htc->fd, htc->rxbuf.e, i); + if (i < 0) { + WS_ReleaseP(htc->ws, htc->rxbuf.b); return (-1); } htc->rxbuf.e += i; From phk at projects.linpro.no Mon Oct 8 09:34:36 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 11:34:36 +0200 (CEST) Subject: r2085 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008093436.4ACFF1EC407@projects.linpro.no> Author: phk Date: 2007-10-08 11:34:36 +0200 (Mon, 08 Oct 2007) New Revision: 2085 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c Log: upd Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2007-10-08 08:14:09 UTC (rev 2084) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2007-10-08 09:34:36 UTC (rev 2085) @@ -91,7 +91,7 @@ } else { CAST_OBJ_NOTNULL(sp, ev.data.ptr, SESS_MAGIC); i = HTC_Rx(sp->htc); - if (i != 0) + if (i != 0) { VTAILQ_REMOVE(&sesshead, sp, list); vca_del(sp->fd); vca_handover(sp, i); From phk at phk.freebsd.dk Mon Oct 8 09:36:23 2007 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Mon, 08 Oct 2007 09:36:23 +0000 Subject: r2085 - trunk/varnish-cache/bin/varnishd In-Reply-To: Your message of "Mon, 08 Oct 2007 11:34:36 +0200." <20071008093436.4ACFF1EC407@projects.linpro.no> Message-ID: <32372.1191836183@critter.freebsd.dk> In message <20071008093436.4ACFF1EC407 at projects.linpro.no>, phk at projects.linpro .no writes: >Author: phk >Date: 2007-10-08 11:34:36 +0200 (Mon, 08 Oct 2007) >New Revision: 2085 > >Modified: > trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c >Log: >upd That should have read "ups" of course :-) > > >Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c >=================================================================== >--- trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2007-10-08 08:14:09 UTC (rev 2084) >+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2007-10-08 09:34:36 UTC (rev 2085) >@@ -91,7 +91,7 @@ > } else { > CAST_OBJ_NOTNULL(sp, ev.data.ptr, SESS_MAGIC); > i = HTC_Rx(sp->htc); >- if (i != 0) >+ if (i != 0) { > VTAILQ_REMOVE(&sesshead, sp, list); > vca_del(sp->fd); > vca_handover(sp, i); > >_______________________________________________ >varnish-commit mailing list >varnish-commit at projects.linpro.no >http://projects.linpro.no/mailman/listinfo/varnish-commit > -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From phk at projects.linpro.no Mon Oct 8 10:25:47 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 12:25:47 +0200 (CEST) Subject: r2086 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008102547.885321EC2ED@projects.linpro.no> Author: phk Date: 2007-10-08 12:25:47 +0200 (Mon, 08 Oct 2007) New Revision: 2086 Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c Log: Drop the asserts around shutdown(2), there are a number of legitimate error conditions. Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-10-08 09:34:36 UTC (rev 2085) +++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-10-08 10:25:47 UTC (rev 2086) @@ -112,25 +112,25 @@ if (i < 1) break; if (fds[0].revents && rdf(vc->fd, sp->fd)) { - AZ(shutdown(vc->fd, SHUT_RD)); - AZ(shutdown(sp->fd, SHUT_WR)); + shutdown(vc->fd, SHUT_RD); + shutdown(sp->fd, SHUT_WR); fds[0].events = 0; fds[0].fd = -1; } if (fds[1].revents && rdf(sp->fd, vc->fd)) { - AZ(shutdown(sp->fd, SHUT_RD)); - AZ(shutdown(vc->fd, SHUT_WR)); + shutdown(sp->fd, SHUT_RD); + shutdown(vc->fd, SHUT_WR); fds[1].events = 0; fds[1].fd = -1; } } if (fds[0].fd >= 0) { - AZ(shutdown(vc->fd, SHUT_RD)); - AZ(shutdown(sp->fd, SHUT_WR)); + shutdown(vc->fd, SHUT_RD); + shutdown(sp->fd, SHUT_WR); } if (fds[1].fd >= 0) { - AZ(shutdown(sp->fd, SHUT_RD)); - AZ(shutdown(vc->fd, SHUT_WR)); + shutdown(sp->fd, SHUT_RD); + shutdown(vc->fd, SHUT_WR); } vca_close_session(sp, "pipe"); VBE_ClosedFd(sp->wrk, vc); From phk at projects.linpro.no Mon Oct 8 10:33:47 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 12:33:47 +0200 (CEST) Subject: r2087 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008103347.325D71EC2F8@projects.linpro.no> Author: phk Date: 2007-10-08 12:33:46 +0200 (Mon, 08 Oct 2007) New Revision: 2087 Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c Log: Catch EOF on reads instead of looping. Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 10:25:47 UTC (rev 2086) +++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 10:33:46 UTC (rev 2087) @@ -144,7 +144,7 @@ return (-2); } i = read(htc->fd, htc->rxbuf.e, i); - if (i < 0) { + if (i <= 0) { WS_ReleaseP(htc->ws, htc->rxbuf.b); return (-1); } From phk at projects.linpro.no Mon Oct 8 11:28:11 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 13:28:11 +0200 (CEST) Subject: r2088 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008112811.75E9F1EC2ED@projects.linpro.no> Author: phk Date: 2007-10-08 13:28:11 +0200 (Mon, 08 Oct 2007) New Revision: 2088 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c Log: Add an assert for spotting ticket #162 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-10-08 10:33:46 UTC (rev 2087) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-10-08 11:28:11 UTC (rev 2088) @@ -88,6 +88,7 @@ while (i >= sizeof ss[0]) { CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC); assert(ss[j]->fd >= 0); + AZ(ss[j]->obj); VTAILQ_INSERT_TAIL(&sesshead, ss[j], list); vca_kq_sess(ss[j], EV_ADD); j++; From phk at projects.linpro.no Mon Oct 8 11:28:39 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 13:28:39 +0200 (CEST) Subject: r2089 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008112839.6305D1EC290@projects.linpro.no> Author: phk Date: 2007-10-08 13:28:39 +0200 (Mon, 08 Oct 2007) New Revision: 2089 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c Log: Only attempt to decode status integer if we have a good separation. Possibly ticket #164 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-08 11:28:11 UTC (rev 2088) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-08 11:28:39 UTC (rev 2089) @@ -503,7 +503,12 @@ if (i != 0 || memcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.", 7)) WSLR(w, SLT_HttpGarbage, htc->fd, htc->rxbuf); - hp->status = strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10); + if (i != 0 && hp->status == 0) { + hp->status = i; + } else { + hp->status = + strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10); + } return (i); } From phk at projects.linpro.no Mon Oct 8 11:32:31 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 13:32:31 +0200 (CEST) Subject: r2090 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008113231.237F31EC2ED@projects.linpro.no> Author: phk Date: 2007-10-08 13:32:30 +0200 (Mon, 08 Oct 2007) New Revision: 2090 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c Log: We may in fact not have any headers. Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-08 11:28:39 UTC (rev 2089) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-08 11:32:30 UTC (rev 2090) @@ -362,7 +362,7 @@ hp->nhd = HTTP_HDR_FIRST; hp->conds = 0; r = NULL; /* For FlexeLint */ - assert(p < t.e); /* http_header_complete() guarantees this */ + assert(p <= t.e); /* http_header_complete() guarantees this */ for (; p < t.e; p = r) { /* XXX: handle continuation lines */ q = strchr(p, '\n'); From phk at projects.linpro.no Mon Oct 8 13:20:57 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 15:20:57 +0200 (CEST) Subject: r2091 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008132058.013D41EC2F8@projects.linpro.no> Author: phk Date: 2007-10-08 15:20:57 +0200 (Mon, 08 Oct 2007) New Revision: 2091 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: EOF transfers are not limited to pre HTTP/1.1 backends, no idea why I thought so previously. Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-08 11:32:30 UTC (rev 2090) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-08 13:20:57 UTC (rev 2091) @@ -339,7 +339,7 @@ VBE_UpdateHealth(sp, vc, -3); VBE_ClosedFd(sp->wrk, vc); return (__LINE__); - } else if (strcmp(http_GetProto(hp), "HTTP/1.1")) { + } else { switch (http_GetStatus(hp)) { case 200: cls = fetch_eof(sp, htc); From phk at projects.linpro.no Mon Oct 8 14:12:06 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 16:12:06 +0200 (CEST) Subject: r2092 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008141206.9D24D1EC2ED@projects.linpro.no> Author: phk Date: 2007-10-08 16:12:06 +0200 (Mon, 08 Oct 2007) New Revision: 2092 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_httpconn.c Log: More asserts Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-08 13:20:57 UTC (rev 2091) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-08 14:12:06 UTC (rev 2092) @@ -789,6 +789,7 @@ CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); for (done = 0; !done; ) { + assert(sp->wrk == w); /* * This is a good place to be paranoid about the various * pointers still pointing to the things we expect. Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 13:20:57 UTC (rev 2091) +++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-08 14:12:06 UTC (rev 2092) @@ -138,6 +138,7 @@ int i; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); + AN(htc->ws->r); i = (htc->ws->r - htc->rxbuf.e) - 1; /* space for NUL */ if (i <= 0) { WS_ReleaseP(htc->ws, htc->rxbuf.b); From phk at projects.linpro.no Mon Oct 8 15:34:32 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 17:34:32 +0200 (CEST) Subject: r2093 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008153432.D3F071EC2ED@projects.linpro.no> Author: phk Date: 2007-10-08 17:34:32 +0200 (Mon, 08 Oct 2007) New Revision: 2093 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_pool.c Log: Don't use vca_return_session() when we can SES_Delete() Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-08 14:12:06 UTC (rev 2092) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-08 15:34:32 UTC (rev 2093) @@ -246,10 +246,8 @@ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); AZ(sp->obj); AZ(sp->vcl); - if (sp->fd < 0) - SES_Delete(sp); - else - assert(sizeof sp == write(vca_pipes[1], &sp, sizeof sp)); + assert(sp->fd >= 0); + assert(sizeof sp == write(vca_pipes[1], &sp, sizeof sp)); } Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-08 14:12:06 UTC (rev 2092) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-08 15:34:32 UTC (rev 2093) @@ -217,7 +217,7 @@ VSL_stats->sess_closed++; assert(!isnan(sp->wrk->used)); sp->wrk = NULL; - vca_return_session(sp); + SES_Delete(sp); return (1); } Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-10-08 14:12:06 UTC (rev 2092) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-10-08 15:34:32 UTC (rev 2093) @@ -313,7 +313,7 @@ UNLOCK(&tmtx); sp->t_end = TIM_real(); vca_close_session(sp, "dropped"); - vca_return_session(sp); + SES_Delete(sp); return; } /* From phk at projects.linpro.no Mon Oct 8 16:40:28 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 18:40:28 +0200 (CEST) Subject: r2094 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008164028.C8CC21EC290@projects.linpro.no> Author: phk Date: 2007-10-08 18:40:28 +0200 (Mon, 08 Oct 2007) New Revision: 2094 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Give the 503 returns a protocol and a response as well. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-08 15:34:32 UTC (rev 2093) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-08 16:40:28 UTC (rev 2094) @@ -306,8 +306,12 @@ if (!i) RFC2616_cache_policy(sp, sp->obj->http); /* XXX -> VCL */ - else + else { http_PutStatus(sp->wrk, sp->fd, sp->obj->http, 503); + http_PutProtocol(sp->wrk, sp->fd, sp->obj->http, "HTTP/1.1"); + http_PutResponse(sp->wrk, sp->fd, sp->obj->http, + "Backend error"); + } sp->err_code = http_GetStatus(sp->obj->http); VCL_fetch_method(sp); From phk at projects.linpro.no Mon Oct 8 19:15:42 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Oct 2007 21:15:42 +0200 (CEST) Subject: r2095 - trunk/varnish-cache/bin/varnishd Message-ID: <20071008191542.3CA811EC2F8@projects.linpro.no> Author: phk Date: 2007-10-08 21:15:41 +0200 (Mon, 08 Oct 2007) New Revision: 2095 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c Log: Try to optimize the poll acceptor by moving active entries to the front of the linked list where they will be found faster later on. Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-10-08 16:40:28 UTC (rev 2094) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-10-08 19:15:41 UTC (rev 2095) @@ -28,9 +28,6 @@ * * $Id$ * - * XXX: We need to pass sessions back into the event engine when they are - * reused. Not sure what the most efficient way is for that. For now - * write the session pointer to a pipe which the event engine monitors. */ #if defined(HAVE_POLL) @@ -132,9 +129,11 @@ if (pollfd[fd].revents) { v--; i = HTC_Rx(sp->htc); - if (i == 0) - continue; VTAILQ_REMOVE(&sesshead, sp, list); + if (i == 0) { + VTAILQ_INSERT_HEAD(&sesshead, sp, list); + continue; + } vca_unpoll(fd); vca_handover(sp, i); continue; From phk at projects.linpro.no Tue Oct 9 07:22:48 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 9 Oct 2007 09:22:48 +0200 (CEST) Subject: r2096 - trunk/varnish-cache/bin/varnishd Message-ID: <20071009072248.C066C1EC2ED@projects.linpro.no> Author: phk Date: 2007-10-09 09:22:46 +0200 (Tue, 09 Oct 2007) New Revision: 2096 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c Log: Keep track of the highest fd so we don't give poll(2) more pfd's to chew than necessary. Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-10-08 19:15:41 UTC (rev 2095) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-10-09 07:22:46 UTC (rev 2096) @@ -46,7 +46,7 @@ static pthread_t vca_poll_thread; static struct pollfd *pollfd; -static unsigned npoll; +static unsigned npoll, hpoll; static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead); @@ -82,6 +82,8 @@ assert(fd >= 0); vca_pollspace((unsigned)fd); + if (hpoll < fd) + hpoll = fd; pollfd[fd].fd = fd; pollfd[fd].events = POLLIN; } @@ -94,6 +96,10 @@ vca_pollspace((unsigned)fd); pollfd[fd].fd = -1; pollfd[fd].events = 0; + if (hpoll == fd) { + while (pollfd[--hpoll].fd == -1) + continue; + } } /*--------------------------------------------------------------------*/ @@ -111,7 +117,7 @@ vca_poll(vca_pipes[0]); while (1) { - v = poll(pollfd, npoll, 100); + v = poll(pollfd, hpoll + 1, 100); if (v && pollfd[vca_pipes[0]].revents) { v--; i = read(vca_pipes[0], &sp, sizeof sp); From des at projects.linpro.no Wed Oct 10 13:23:15 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Wed, 10 Oct 2007 15:23:15 +0200 (CEST) Subject: r2097 - trunk/varnish-cache Message-ID: <20071010132315.B53D61EC2F8@projects.linpro.no> Author: des Date: 2007-10-10 15:23:15 +0200 (Wed, 10 Oct 2007) New Revision: 2097 Modified: trunk/varnish-cache/configure.ac Log: Fix braino in Solaris compat bit. Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2007-10-09 07:22:46 UTC (rev 2096) +++ trunk/varnish-cache/configure.ac 2007-10-10 13:23:15 UTC (rev 2097) @@ -53,7 +53,7 @@ save_LIBS="${LIBS}" LIBS="" AC_CHECK_LIB(socket, socket) -AC_CHECK_LIB(getaddrinfo, ns) +AC_CHECK_LIB(nsl, getaddrinfo) NET_LIBS="${LIBS}" LIBS="${save_LIBS}" AC_SUBST(NET_LIBS) From phk at projects.linpro.no Tue Oct 16 09:00:23 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Oct 2007 11:00:23 +0200 (CEST) Subject: r2098 - trunk/varnish-cache/bin/varnishd Message-ID: <20071016090023.495791EC1F9@projects.linpro.no> Author: phk Date: 2007-10-16 11:00:22 +0200 (Tue, 16 Oct 2007) New Revision: 2098 Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c Log: Flexelint polish Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-10-10 13:23:15 UTC (rev 2097) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-10-16 09:00:22 UTC (rev 2098) @@ -200,11 +200,12 @@ static void * wrk_thread(void *priv) { - struct worker w[1]; + struct worker *w, ww; struct wq *qp; char c; unsigned char wlog[8192]; /* XXX: size */ + w = &ww; qp = priv; memset(w, 0, sizeof *w); w->magic = WORKER_MAGIC; From phk at projects.linpro.no Tue Oct 16 09:00:48 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Oct 2007 11:00:48 +0200 (CEST) Subject: r2099 - trunk/varnish-cache/bin/varnishd Message-ID: <20071016090048.98B351EC403@projects.linpro.no> Author: phk Date: 2007-10-16 11:00:48 +0200 (Tue, 16 Oct 2007) New Revision: 2099 Modified: trunk/varnish-cache/bin/varnishd/cache.h Log: Flexelint polish Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-16 09:00:22 UTC (rev 2098) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-16 09:00:48 UTC (rev 2099) @@ -61,9 +61,6 @@ /* Note: intentionally not IOV_MAX */ #define MAX_IOVS (HTTP_HDR_MAX * 2) -/* Amount of per-worker logspace */ -#define WLOGSPACE 8192 /* XXX: param ? */ - struct cli; struct vsb; struct sess; From phk at projects.linpro.no Tue Oct 16 09:03:18 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Oct 2007 11:03:18 +0200 (CEST) Subject: r2100 - trunk/varnish-cache/bin/varnishd Message-ID: <20071016090318.886DD1EC1F9@projects.linpro.no> Author: phk Date: 2007-10-16 11:03:18 +0200 (Tue, 16 Oct 2007) New Revision: 2100 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c Log: Reduce number of TIM_real() calls slightly in multi socket case. Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-16 09:00:48 UTC (rev 2099) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-16 09:03:18 UTC (rev 2100) @@ -138,6 +138,7 @@ struct pollfd *pfd; struct listen_sock *ls; unsigned u; + double now; (void)arg; @@ -171,6 +172,7 @@ &tv_rcvtimeo, sizeof tv_rcvtimeo)); } i = poll(pfd, heritage.nsocks, 1000); + now = TIM_real(); for (u = 0; u < heritage.nsocks; u++) { if (pfd[u].revents == 0) continue; @@ -191,7 +193,7 @@ sp->fd = i; sp->id = i; - sp->t_open = TIM_real(); + sp->t_open = now; HTC_Init(sp->htc, sp->ws, sp->fd); sp->step = STP_FIRST; From phk at projects.linpro.no Tue Oct 16 09:11:46 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Oct 2007 11:11:46 +0200 (CEST) Subject: r2101 - trunk/varnish-cache/bin/varnishd Message-ID: <20071016091146.0A6831EC2B2@projects.linpro.no> Author: phk Date: 2007-10-16 11:11:45 +0200 (Tue, 16 Oct 2007) New Revision: 2101 Modified: trunk/varnish-cache/bin/varnishd/storage_file.c Log: Flexelint polishing. Always enforce the 2GB filesize limit on 32bit architectures. Clean up a couple of messages Modified: trunk/varnish-cache/bin/varnishd/storage_file.c =================================================================== --- trunk/varnish-cache/bin/varnishd/storage_file.c 2007-10-16 09:03:18 UTC (rev 2100) +++ trunk/varnish-cache/bin/varnishd/storage_file.c 2007-10-16 09:11:45 UTC (rev 2101) @@ -122,7 +122,7 @@ uintmax_t l, fssize; unsigned bs; char suff[2]; - int i, explicit; + int i; off_t o; struct stat st; @@ -142,7 +142,6 @@ i = sscanf(size, "%ju%1s", &l, suff); /* can return -1, 0, 1 or 2 */ - explicit = i; if (i == 0) { fprintf(stderr, "Error: (-sfile) size \"%s\" not understood\n", size); @@ -217,18 +216,17 @@ exit (2); } - if (explicit < 3 && sizeof(void *) == 4 && l > INT32_MAX) { + if (sizeof(void *) == 4 && l > INT32_MAX) { /*lint !e506 !e774 */ fprintf(stderr, - "NB: Limiting size to 2GB on 32 bit architecture to" - " prevent running out of\naddress space." - " Specifiy explicit size to override.\n" + "NB: Storage size limited to 2GB on 32 bit architecture,\n" + "NB: otherwise we could run out of address space.\n" ); l = INT32_MAX; l -= (l % bs); } - printf("file %s size %ju bytes (%ju fs-blocks, %ju pages)\n", - sc->filename, l, l / fsst.f_bsize, l / sc->pagesize); + printf("storage_file: filename: %s size %ju MegaBytes.\n", + sc->filename, l / (1024 * 1024)); sc->filesize = l; } @@ -644,6 +642,7 @@ VSL_stats->sm_balloc += smf->size; VSL_stats->sm_bfree -= smf->size; UNLOCK(&sc->mtx); + CHECK_OBJ_NOTNULL(&smf->s, STORAGE_MAGIC); /*lint !e774 */ XXXAN(smf); assert(smf->size == size); smf->s.space = size; @@ -653,7 +652,6 @@ smf->s.stevedore = st; smf->s.fd = smf->sc->fd; smf->s.where = smf->offset; - CHECK_OBJ_NOTNULL(&smf->s, STORAGE_MAGIC); return (&smf->s); } From des at projects.linpro.no Tue Oct 16 09:43:07 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 16 Oct 2007 11:43:07 +0200 (CEST) Subject: r2102 - branches Message-ID: <20071016094307.C50E61EC403@projects.linpro.no> Author: des Date: 2007-10-16 11:43:07 +0200 (Tue, 16 Oct 2007) New Revision: 2102 Added: branches/1.2/ Log: Now that trunk is fairly stable, branch 1.2 so we have something to tide us over while we wait for 2.0. Copied: branches/1.2 (from rev 2101, trunk/varnish-cache) From des at projects.linpro.no Tue Oct 16 09:43:52 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 16 Oct 2007 11:43:52 +0200 (CEST) Subject: r2103 - branches/1.2 Message-ID: <20071016094352.EBE881EC2B2@projects.linpro.no> Author: des Date: 2007-10-16 11:43:52 +0200 (Tue, 16 Oct 2007) New Revision: 2103 Modified: branches/1.2/ branches/1.2/configure.ac Log: Bump. Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated + /trunk/varnish-cache:1-2101 Modified: branches/1.2/configure.ac =================================================================== --- branches/1.2/configure.ac 2007-10-16 09:43:07 UTC (rev 2102) +++ branches/1.2/configure.ac 2007-10-16 09:43:52 UTC (rev 2103) @@ -3,7 +3,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006-2007 Linpro AS / Verdens Gang AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [trunk], [varnish-dev at projects.linpro.no]) +AC_INIT([Varnish], [1.2], [varnish-dev at projects.linpro.no]) AC_CONFIG_SRCDIR(include/varnishapi.h) AM_CONFIG_HEADER(config.h) From des at linpro.no Tue Oct 16 09:59:11 2007 From: des at linpro.no (=?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?=) Date: Tue, 16 Oct 2007 11:59:11 +0200 Subject: r2102 - branches In-Reply-To: <20071016094307.C50E61EC403@projects.linpro.no> (des@projects.linpro.no's message of "Tue, 16 Oct 2007 11:43:07 +0200 (CEST)") References: <20071016094307.C50E61EC403@projects.linpro.no> Message-ID: des at projects.linpro.no writes: > Added: > branches/1.2/ > Log: > Now that trunk is fairly stable, branch 1.2 so we have something to tide us > over while we wait for 2.0. This does not necessarily mean that we will have a 1.2 release, but people who want something more than 1.1 but are worried that trunk will be too unstable once Poul-Henning starts adding ESI will at least have this branch. DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no From phk at projects.linpro.no Tue Oct 16 10:17:24 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Oct 2007 12:17:24 +0200 (CEST) Subject: r2104 - trunk/varnish-cache/bin/varnishd Message-ID: <20071016101724.6D0EB1EC403@projects.linpro.no> Author: phk Date: 2007-10-16 12:17:24 +0200 (Tue, 16 Oct 2007) New Revision: 2104 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c Log: Silence flexelint Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-16 09:43:52 UTC (rev 2103) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-16 10:17:24 UTC (rev 2104) @@ -89,7 +89,7 @@ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); if (t > HTTP_HDR_FIRST) t = HTTP_HDR_FIRST; - assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); + assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); /*lint !e685*/ assert(t >= HTTP_HDR_REQ && t <= HTTP_HDR_FIRST); return (logmtx[hp->logtag][t]); } From des at linpro.no Tue Oct 16 12:48:17 2007 From: des at linpro.no (=?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?=) Date: Tue, 16 Oct 2007 14:48:17 +0200 Subject: r2016 - trunk/varnish-cache/bin/varnishd In-Reply-To: <20070925065104.DB29F1EC405@projects.linpro.no> (phk@projects.linpro.no's message of "Tue, 25 Sep 2007 08:51:04 +0200 (CEST)") References: <20070925065104.DB29F1EC405@projects.linpro.no> Message-ID: phk at projects.linpro.no writes: > Log: > When we take the difference between two pointers, the result is technically > signed. pdiff() makes sure we never get a negative value. I don't understand the need for pdiff. If it is only to silence Flexelint, then I would suggest that Flexelint is broken. DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no From phk at phk.freebsd.dk Tue Oct 16 12:51:21 2007 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Tue, 16 Oct 2007 12:51:21 +0000 Subject: r2016 - trunk/varnish-cache/bin/varnishd In-Reply-To: Your message of "Tue, 16 Oct 2007 14:48:17 +0200." Message-ID: <12604.1192539081@critter.freebsd.dk> In message , =?iso-8859-1?Q?Dag-Erling_Sm=F8rg rav?= writes: >phk at projects.linpro.no writes: >> Log: >> When we take the difference between two pointers, the result is technical= >ly >> signed. pdiff() makes sure we never get a negative value. > >I don't understand the need for pdiff. If it is only to silence >Flexelint, then I would suggest that Flexelint is broken. Passing strings around in {begin,end} pointer pairs like we do doubles the number of pointers that can be bogotified, so I decided to preempt mistakes in this area and quench the flexelint warnings at the same time. So the assert in pdiff is actually the important part of this. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From des at projects.linpro.no Tue Oct 16 13:10:44 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 16 Oct 2007 15:10:44 +0200 (CEST) Subject: r2105 - trunk/varnish-cache/bin/varnishd Message-ID: <20071016131044.338D11EC511@projects.linpro.no> Author: des Date: 2007-10-16 15:10:43 +0200 (Tue, 16 Oct 2007) New Revision: 2105 Modified: trunk/varnish-cache/bin/varnishd/cache_main.c Log: Use %zd for size_t. Modified: trunk/varnish-cache/bin/varnishd/cache_main.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_main.c 2007-10-16 10:17:24 UTC (rev 2104) +++ trunk/varnish-cache/bin/varnishd/cache_main.c 2007-10-16 13:10:43 UTC (rev 2105) @@ -51,7 +51,7 @@ setbuf(stderr, NULL); printf("Child starts\n"); -#define SZOF(foo) printf("sizeof(%s) = %d\n", #foo, sizeof(foo)); +#define SZOF(foo) printf("sizeof(%s) = %zd\n", #foo, sizeof(foo)); SZOF(struct ws); SZOF(struct http); SZOF(struct http_conn); From des at linpro.no Tue Oct 16 13:37:09 2007 From: des at linpro.no (=?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?=) Date: Tue, 16 Oct 2007 15:37:09 +0200 Subject: r2016 - trunk/varnish-cache/bin/varnishd In-Reply-To: <12604.1192539081@critter.freebsd.dk> (Poul-Henning Kamp's message of "Tue, 16 Oct 2007 12:51:21 +0000") References: <12604.1192539081@critter.freebsd.dk> Message-ID: "Poul-Henning Kamp" writes: > So the assert in pdiff is actually the important part of this. OK, thanks. DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no From des at projects.linpro.no Tue Oct 16 14:12:23 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 16 Oct 2007 16:12:23 +0200 (CEST) Subject: r2106 - in trunk/varnish-cache: include include/compat lib/libvarnishcompat Message-ID: <20071016141223.D9AB31EC403@projects.linpro.no> Author: des Date: 2007-10-16 16:12:23 +0200 (Tue, 16 Oct 2007) New Revision: 2106 Added: trunk/varnish-cache/include/compat/daemon.h trunk/varnish-cache/lib/libvarnishcompat/daemon.c Modified: trunk/varnish-cache/include/Makefile.am trunk/varnish-cache/lib/libvarnishcompat/Makefile.am Log: Pull in FreeBSD's daemon(3) for platforms that lack it. Modified: trunk/varnish-cache/include/Makefile.am =================================================================== --- trunk/varnish-cache/include/Makefile.am 2007-10-16 13:10:43 UTC (rev 2105) +++ trunk/varnish-cache/include/Makefile.am 2007-10-16 14:12:23 UTC (rev 2106) @@ -7,12 +7,13 @@ stats.h \ varnishapi.h -noinst_HEADERS = \ +nobase_noinst_HEADERS = \ binary_heap.h \ cli.h \ cli_common.h \ cli_priv.h \ compat/asprintf.h \ + compat/daemon.h \ compat/setproctitle.h \ compat/srandomdev.h \ compat/strlcat.h \ Added: trunk/varnish-cache/include/compat/daemon.h =================================================================== --- trunk/varnish-cache/include/compat/daemon.h (rev 0) +++ trunk/varnish-cache/include/compat/daemon.h 2007-10-16 14:12:23 UTC (rev 2106) @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2007 Linpro AS + * All rights reserved. + * + * Author: Dag-Erling Sm?rgrav + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#ifndef COMPAT_DAEMON_H_INCLUDED +#define COMPAT_DAEMON_H_INCLUDED + +#ifndef HAVE_DAEMON +int daemon(int nochdir, int noclose); +#endif + +#endif Property changes on: trunk/varnish-cache/include/compat/daemon.h ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/lib/libvarnishcompat/Makefile.am =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/Makefile.am 2007-10-16 13:10:43 UTC (rev 2105) +++ trunk/varnish-cache/lib/libvarnishcompat/Makefile.am 2007-10-16 14:12:23 UTC (rev 2106) @@ -6,6 +6,7 @@ libvarnishcompat_la_SOURCES = \ asprintf.c \ + daemon.c \ vasprintf.c \ setproctitle.c \ srandomdev.c \ Added: trunk/varnish-cache/lib/libvarnishcompat/daemon.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/daemon.c (rev 0) +++ trunk/varnish-cache/lib/libvarnishcompat/daemon.c 2007-10-16 14:12:23 UTC (rev 2106) @@ -0,0 +1,92 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + * Derived from: + * $FreeBSD: src/lib/libc/gen/daemon.c,v 1.8 2007/01/09 00:27:53 imp Exp $ + */ + +#ifndef HAVE_DAEMON + +#include +#include +#include +#include +#include +#include + +#include "compat/daemon.h" + +int +daemon(int nochdir, int noclose) +{ + struct sigaction osa, sa; + int fd; + pid_t newgrp; + int oerrno; + int osa_ok; + + /* A SIGHUP may be thrown when the parent exits below. */ + sigemptyset(&sa.sa_mask); + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + osa_ok = sigaction(SIGHUP, &sa, &osa); + + switch (fork()) { + case -1: + return (-1); + case 0: + break; + default: + exit(0); + } + + newgrp = setsid(); + oerrno = errno; + if (osa_ok != -1) + sigaction(SIGHUP, &osa, NULL); + + if (newgrp == -1) { + errno = oerrno; + return (-1); + } + + if (!nochdir) + (void)chdir("/"); + + if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { + (void)dup2(fd, STDIN_FILENO); + (void)dup2(fd, STDOUT_FILENO); + (void)dup2(fd, STDERR_FILENO); + if (fd > 2) + (void)close(fd); + } + return (0); +} + +#endif Property changes on: trunk/varnish-cache/lib/libvarnishcompat/daemon.c ___________________________________________________________________ Name: svn:keywords + Id From des at projects.linpro.no Tue Oct 16 14:15:54 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 16 Oct 2007 16:15:54 +0200 (CEST) Subject: r2107 - trunk/varnish-cache/lib/libvarnish Message-ID: <20071016141554.B71641EC511@projects.linpro.no> Author: des Date: 2007-10-16 16:15:54 +0200 (Tue, 16 Oct 2007) New Revision: 2107 Modified: trunk/varnish-cache/lib/libvarnish/assert.c trunk/varnish-cache/lib/libvarnish/binary_heap.c trunk/varnish-cache/lib/libvarnish/crc32.c trunk/varnish-cache/lib/libvarnish/vss.c Log: Whitespace cleanup. Modified: trunk/varnish-cache/lib/libvarnish/assert.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/assert.c 2007-10-16 14:12:23 UTC (rev 2106) +++ trunk/varnish-cache/lib/libvarnish/assert.c 2007-10-16 14:15:54 UTC (rev 2107) @@ -57,4 +57,3 @@ " errno = %d (%s)\n", func, file, line, cond, err, strerror(err)); abort(); } - Modified: trunk/varnish-cache/lib/libvarnish/binary_heap.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/binary_heap.c 2007-10-16 14:12:23 UTC (rev 2106) +++ trunk/varnish-cache/lib/libvarnish/binary_heap.c 2007-10-16 14:15:54 UTC (rev 2107) @@ -298,7 +298,7 @@ #else struct foo { - unsigned idx; + unsigned idx; unsigned key; }; Modified: trunk/varnish-cache/lib/libvarnish/crc32.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/crc32.c 2007-10-16 14:12:23 UTC (rev 2106) +++ trunk/varnish-cache/lib/libvarnish/crc32.c 2007-10-16 14:15:54 UTC (rev 2107) @@ -99,4 +99,3 @@ crc = crc32(~0U, p1, l); return (crc ^ ~0U); } - Modified: trunk/varnish-cache/lib/libvarnish/vss.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vss.c 2007-10-16 14:12:23 UTC (rev 2106) +++ trunk/varnish-cache/lib/libvarnish/vss.c 2007-10-16 14:15:54 UTC (rev 2107) @@ -127,14 +127,14 @@ struct vss_addr **va; int i, ret; - memset(&hints, 0, sizeof hints); - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - ret = getaddrinfo(addr, port, &hints, &res0); - if (ret != 0) { - fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(ret)); - return (0); - } + memset(&hints, 0, sizeof hints); + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_PASSIVE; + ret = getaddrinfo(addr, port, &hints, &res0); + if (ret != 0) { + fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(ret)); + return (0); + } for (res = res0, i = 0; res != NULL; res = res->ai_next) ++i; va = calloc(i, sizeof *va); From phk at projects.linpro.no Tue Oct 16 22:23:45 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Oct 2007 00:23:45 +0200 (CEST) Subject: r2108 - trunk/varnish-cache/bin/varnishd Message-ID: <20071016222345.76D3F1EC403@projects.linpro.no> Author: phk Date: 2007-10-17 00:23:45 +0200 (Wed, 17 Oct 2007) New Revision: 2108 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Start pulling ESI:include stuff over from my private tree. This is the meat of the XML-dissecting code. In theory the task is pretty simple, but it gets complicated by the fact that the XML input can be split over multiple pieces of storage, with an element we care about straddling a boundary. I have not decided what to do about ESI violations or XML syntax errors, SHMlogging them, possibly controlled by a parameter might make sense. For now mark them in the source. Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-16 14:15:54 UTC (rev 2107) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-16 22:23:45 UTC (rev 2108) @@ -28,7 +28,16 @@ * * $Id: cache_vrt.c 2067 2007-09-30 20:57:30Z phk $ * - * Runtime support for compiled VCL programs + * Runtime support for compiled VCL programs ESI processing. + * + * The basic ESI 1.0 is a very simple specification: + * http://www.w3.org/TR/esi-lang + * But it seems that Oracle and Akamai has embrodiered it to be almost a new + * layer of scripting language in HTTP transmission chains. + * + * It is not obvious how much help the "advanced" features of ESI really + * are to users, so our aim is to pick the fruit starting with the lowest + * hanging, esi:include */ #include @@ -41,12 +50,235 @@ #include "vcl.h" #include "cache.h" +/*-------------------------------------------------------------------- + * Add one piece to the output, either verbatim or include + */ + +static void +add_piece(txt t, int kind) +{ + + printf("K%d \"%.*s\"\n", kind, t.e - t.b, t.b); +} + +/*-------------------------------------------------------------------- + * Zoom over a piece of object and dike out all releveant esi: pieces. + * The entire txt may not be processed because an interesting part + * could possibly span into the next chunk of storage. + * Return value: number of bytes processed. + */ + +static int +vxml(txt t) +{ + char *p, *q, *r; + txt o; + int celem; /* closing element */ + int remflg; /* inside */ + int incmt; /* inside comment */ + int i; + + o.b = t.b; + remflg = 0; + incmt = 0; + for (p = t.b; p < t.e; ) { + if (incmt && *p == '-') { + /* + * We are inside an when we see it. + */ + if (p + 2 >= t.e) { + /* XXX: need to return pending incmt */ + return (p - t.b); + } + if (!memcmp(p, "-->", 3)) { + incmt = 0; + o.e = p; + add_piece(o, 0); + p += 3; + o.b = p; + } else + p++; + continue; + } + + if (*p != '<') { + /* nothing happens until next element or comment */ + p++; + continue; + } + + i = t.e - p; + + if (i < 2) + return (p - t.b); + + if (remflg == 0 && !memcmp(p, " + * at least 10 char, but we only test on the + * first seven because the tail is handled + * by the incmt flag. + */ + if (i < 7) + return (p - t.b); + + o.e = p; + add_piece(o, 0); + + p += 7; + o.b = p; + incmt = 1; + continue; + } + + if (!memcmp(p, " at least 7 char + */ + if (i < 7) + return (p - t.b); + for (q = p + 4; ; q++) { + if (q + 2 >= t.e) + return (p - t.b); + if (!memcmp(q, "-->", 3)) + break; + } + p = q + 3; + continue; + } + + if (!memcmp(p, " 9 ? 9 : i)) { + /* + * cdata at least 12 char + */ + if (i < 12) + return (p - t.b); + for (q = p + 9; ; q++) { + if (q + 2 >= t.e) + return (p - t.b); + if (!memcmp(q, "]]>", 3)) + break; + } + p = q + 3; + continue; + } + + if (p[1] == '!') { + /* Ignore unrecognized '; q++) + continue; + if (*q != '>') + return (p - t.b); + + /* Opening/empty or closing element ? */ + if (p[1] == '/') { + celem = 1; + r = p + 2; + if (q[-1] == '/') { + /* XML violation, ignore this ? */ + } + } else { + celem = 0; + r = p + 1; + } + + if (r + 9 < q && !memcmp(r, "esi:remove", 10)) { + + if (celem != remflg) { + /* ESI 1.0 violation, ignore this element */ + if (!remflg) { + o.e = p; + add_piece(o, 0); + } + } else if (!celem && q[-1] == '/') { + /* empty element */ + o.e = p; + add_piece(o, 0); + } else if (!celem) { + /* open element */ + o.e = p; + add_piece(o, 0); + remflg = !celem; + } else { + /* close element */ + remflg = !celem; + } + p = q + 1; + o.b = p; + continue; + } + + if (remflg && r + 3 < q && !memcmp(r, "esi:", 4)) { + /* ESI 1.0 violation, no nesting in esi:remove */ + p = q + 1; + continue; + } + + if (r + 10 < q && !memcmp(r, "esi:include", 11)) { + + o.e = p; + add_piece(o, 0); + + if (celem == 0) { + o.b = r + 11; + o.e = q; + add_piece(o, 1); + if (q[-1] != '/') { + /* ESI 1.0 violation */ + } + } else { + /* ESI 1.0 violation */ + } + p = q + 1; + o.b = p; + continue; + } + + if (r + 3 < q && !memcmp(r, "esi:", 4)) { + /* + * Unimplemented ESI element, ignore + */ + o.e = p; + add_piece(o, 0); + p = q + 1; + o.b = p; + continue; + } + + /* Not an element we care about */ + p = q + 1; + } + o.e = p; + add_piece(o, 0); + return (p - t.b); +} + /*--------------------------------------------------------------------*/ void VRT_ESI(struct sess *sp) { + struct storage *st; + txt t; + int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - INCOMPL(); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); + VTAILQ_FOREACH(st, &sp->obj->store, list) { + t.b = (void*)st->ptr; + t.e = t.b + st->len; + i = vxml(t); + printf("VXML(%p+%d) = %d", st->ptr, st->len, i); + if (i < st->len) + printf(" \"%.*s\"", st->len - i, st->ptr + i); + printf("\n"); + } } + +/*--------------------------------------------------------------------*/ From phk at projects.linpro.no Tue Oct 16 22:35:35 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Oct 2007 00:35:35 +0200 (CEST) Subject: r2109 - trunk/varnish-cache/lib/libvcl Message-ID: <20071016223535.A99CC1EC28D@projects.linpro.no> Author: phk Date: 2007-10-17 00:35:35 +0200 (Wed, 17 Oct 2007) New Revision: 2109 Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c Log: Fix parsing of "esi" command. Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-10-16 22:23:45 UTC (rev 2108) +++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-10-16 22:35:35 UTC (rev 2109) @@ -323,8 +323,6 @@ vcc_NextToken(tl); Fb(tl, 1, "VRT_ESI(sp);\n"); - Expect(tl, ';'); - vcc_NextToken(tl); } /*--------------------------------------------------------------------*/ From phk at projects.linpro.no Wed Oct 17 08:32:20 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Oct 2007 10:32:20 +0200 (CEST) Subject: r2110 - in trunk/varnish-cache: bin/varnishd include Message-ID: <20071017083220.6B8781EC420@projects.linpro.no> Author: phk Date: 2007-10-17 10:32:19 +0200 (Wed, 17 Oct 2007) New Revision: 2110 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c trunk/varnish-cache/include/shmlog_tags.h Log: Add error messages from the XML/ESI parser Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-16 22:35:35 UTC (rev 2109) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-17 08:32:19 UTC (rev 2110) @@ -61,6 +61,54 @@ printf("K%d \"%.*s\"\n", kind, t.e - t.b, t.b); } +static void +vxml_error(struct sess *sp, const char *p, txt t, size_t off, int i, const char *err) +{ + int ellipsis = 0; + char buf[256], *q; + + if (i == 0) { + i = t.e - p; + } + if (i > 20) { + i = 20; + ellipsis = 1; + } + q = buf; + q += sprintf(buf, "at %d: %s \"", off + (p - t.b), err); + while (i > 0) { + if (*p >= ' ' && *p <= '~') { + *q++ = *p; + } else if (*p == '\n') { + *q++ = '\\'; + *q++ = 'n'; + } else if (*p == '\r') { + *q++ = '\\'; + *q++ = 'r'; + } else if (*p == '\t') { + *q++ = '\\'; + *q++ = 't'; + } else { + /* XXX: use %%%02x instead ? */ + q += sprintf(q, "\\x%02x", *p); + } + p++; + i--; + } + if (ellipsis) { + *q++ = '['; + *q++ = '.'; + *q++ = '.'; + *q++ = '.'; + *q++ = ']'; + } + *q++ = '"'; + *q++ = '\0'; + t.b = buf; + t.e = q; + WSPR(sp, SLT_ESI_xmlerror, t); +} + /*-------------------------------------------------------------------- * Zoom over a piece of object and dike out all releveant esi: pieces. * The entire txt may not be processed because an interesting part @@ -69,7 +117,7 @@ */ static int -vxml(txt t) +vxml(struct sess *sp, txt t, size_t off) { char *p, *q, *r; txt o; @@ -165,7 +213,11 @@ } if (p[1] == '!') { - /* Ignore unrecognized obj, OBJECT_MAGIC); + o = 1; VTAILQ_FOREACH(st, &sp->obj->store, list) { t.b = (void*)st->ptr; t.e = t.b + st->len; - i = vxml(t); + i = vxml(sp, t, o); + o += st->len; printf("VXML(%p+%d) = %d", st->ptr, st->len, i); if (i < st->len) printf(" \"%.*s\"", st->len - i, st->ptr + i); Modified: trunk/varnish-cache/include/shmlog_tags.h =================================================================== --- trunk/varnish-cache/include/shmlog_tags.h 2007-10-16 22:35:35 UTC (rev 2109) +++ trunk/varnish-cache/include/shmlog_tags.h 2007-10-17 08:32:19 UTC (rev 2110) @@ -92,3 +92,6 @@ SLTM(ExpKill) SLTM(WorkThread) SLTM(Terminate) + +SLTM(ESItrace) +SLTM(ESI_xmlerror) From des at linpro.no Thu Oct 18 10:39:22 2007 From: des at linpro.no (=?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?=) Date: Thu, 18 Oct 2007 12:39:22 +0200 Subject: r2108 - trunk/varnish-cache/bin/varnishd In-Reply-To: <20071016222345.76D3F1EC403@projects.linpro.no> (phk@projects.linpro.no's message of "Wed, 17 Oct 2007 00:23:45 +0200 (CEST)") References: <20071016222345.76D3F1EC403@projects.linpro.no> Message-ID: phk at projects.linpro.no writes: > Log: > Start pulling ESI:include stuff over from my private tree. > > This is the meat of the XML-dissecting code. > > In theory the task is pretty simple, but it gets complicated by the fact > that the XML input can be split over multiple pieces of storage, with > an element we care about straddling a boundary. > > I have not decided what to do about ESI violations or XML syntax errors, > SHMlogging them, possibly controlled by a parameter might make sense. > For now mark them in the source. An ESI document doesn't need to be well-formed XML (it could be SGML, or JavaScript, or plain text, or whatever), basically you just want to grep for and ignore everything else. DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no From phk at phk.freebsd.dk Thu Oct 18 10:46:23 2007 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Thu, 18 Oct 2007 10:46:23 +0000 Subject: r2108 - trunk/varnish-cache/bin/varnishd In-Reply-To: Your message of "Thu, 18 Oct 2007 12:39:22 +0200." Message-ID: <55308.1192704383@critter.freebsd.dk> In message , =?iso-8859-1?Q?Dag-Erling_Sm=F8rg rav?= writes: >An ESI document doesn't need to be well-formed XML (it could be SGML, >or JavaScript, or plain text, or whatever), basically you just want to >grep for and ignore everything else. Not quite, I've read up on ESI, both on w3c, oracle and akamai, and my conclusion is that ESI, with one exception, does not stand outside the XML (SGML ?) syntax of the basic document, if it has one. (The one execption is the comment construct) If the basic document does not have XML/SGML syntax, there's obvious trouble with '<' characters. The parser I've created for ESI in varnish understands the basic syntax of XML/SGML, but ignores everything higher level than the <...> element syntax and comment format, unless the element in question is in the esi: namespace. That's how I interpret the standards intent. In any case, you will have to explicitly tell VCL to do ESI processing of documents, so any odd-ball cases can be included/excluded as needed. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From des at linpro.no Thu Oct 18 10:55:05 2007 From: des at linpro.no (=?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?=) Date: Thu, 18 Oct 2007 12:55:05 +0200 Subject: r2108 - trunk/varnish-cache/bin/varnishd In-Reply-To: <55308.1192704383@critter.freebsd.dk> (Poul-Henning Kamp's message of "Thu, 18 Oct 2007 10:46:23 +0000") References: <55308.1192704383@critter.freebsd.dk> Message-ID: "Poul-Henning Kamp" writes: > Dag-Erling Sm?rgrav writes: > > An ESI document doesn't need to be well-formed XML (it could be > > SGML, or JavaScript, or plain text, or whatever), basically you > > just want to grep for and ignore everything else. > Not quite, I've read up on ESI, both on w3c, oracle and akamai, and > my conclusion is that ESI, with one exception, does not stand > outside the XML (SGML ?) syntax of the basic document, if it has > one. They key here is "if it has one" - not to mention that what the spec says is not necessarily an accurate reflection of what you will see in the wild. DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no From phk at phk.freebsd.dk Thu Oct 18 11:01:22 2007 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Thu, 18 Oct 2007 11:01:22 +0000 Subject: r2108 - trunk/varnish-cache/bin/varnishd In-Reply-To: Your message of "Thu, 18 Oct 2007 12:55:05 +0200." Message-ID: <55449.1192705282@critter.freebsd.dk> In message , =?iso-8859-1?Q?Dag-Erling_Sm=F8rg rav?= writes: >"Poul-Henning Kamp" writes: >> Dag-Erling Sm=F8rgrav writes: >> > An ESI document doesn't need to be well-formed XML (it could be >> > SGML, or JavaScript, or plain text, or whatever), basically you >> > just want to grep for and ignore everything else. >> Not quite, I've read up on ESI, both on w3c, oracle and akamai, and >> my conclusion is that ESI, with one exception, does not stand >> outside the XML (SGML ?) syntax of the basic document, if it has >> one. > >They key here is "if it has one" - not to mention that what the spec >says is not necessarily an accurate reflection of what you will see in >the wild. I've done my best to accomodate the "if it has one" scenario, but there is no excaping that the ESI standard is expressed in XML syntax. Provided you don't have too things in your file which will foul up the XML aspect of ESI, then my parser will work correctly. Having in the middle of a file which is all javascript will work, as long as the main contents of the file does not make it impossible to find the XML esi specification. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From des at projects.linpro.no Thu Oct 18 11:10:25 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Thu, 18 Oct 2007 13:10:25 +0200 (CEST) Subject: r2111 - trunk/varnish-cache/bin/varnishd Message-ID: <20071018111025.62DFB1EC417@projects.linpro.no> Author: des Date: 2007-10-18 13:10:25 +0200 (Thu, 18 Oct 2007) New Revision: 2111 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: I like code that compiles Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-17 08:32:19 UTC (rev 2110) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-18 11:10:25 UTC (rev 2111) @@ -58,7 +58,7 @@ add_piece(txt t, int kind) { - printf("K%d \"%.*s\"\n", kind, t.e - t.b, t.b); + printf("K%d \"%.*s\"\n", kind, (int)(t.e - t.b), t.b); } static void @@ -75,7 +75,7 @@ ellipsis = 1; } q = buf; - q += sprintf(buf, "at %d: %s \"", off + (p - t.b), err); + q += sprintf(buf, "at %d: %s \"", (int)(off + (p - t.b)), err); while (i > 0) { if (*p >= ' ' && *p <= '~') { *q++ = *p; From des at projects.linpro.no Thu Oct 18 11:51:33 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Thu, 18 Oct 2007 13:51:33 +0200 (CEST) Subject: r2112 - in branches/1.2: . bin/varnishd include include/compat lib/libvarnish lib/libvarnishcompat Message-ID: <20071018115133.0C6EB1EC403@projects.linpro.no> Author: des Date: 2007-10-18 13:51:32 +0200 (Thu, 18 Oct 2007) New Revision: 2112 Added: branches/1.2/include/compat/daemon.h branches/1.2/lib/libvarnishcompat/daemon.c Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_http.c branches/1.2/bin/varnishd/cache_main.c branches/1.2/include/Makefile.am branches/1.2/lib/libvarnish/assert.c branches/1.2/lib/libvarnish/binary_heap.c branches/1.2/lib/libvarnish/crc32.c branches/1.2/lib/libvarnish/vss.c branches/1.2/lib/libvarnishcompat/Makefile.am Log: Merged revisions 2104-2107 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2104 | phk | 2007-10-16 12:17:24 +0200 (Tue, 16 Oct 2007) | 2 lines Silence flexelint ........ r2105 | des | 2007-10-16 15:10:43 +0200 (Tue, 16 Oct 2007) | 2 lines Use %zd for size_t. ........ r2106 | des | 2007-10-16 16:12:23 +0200 (Tue, 16 Oct 2007) | 2 lines Pull in FreeBSD's daemon(3) for platforms that lack it. ........ r2107 | des | 2007-10-16 16:15:54 +0200 (Tue, 16 Oct 2007) | 2 lines Whitespace cleanup. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101 + /trunk/varnish-cache:1-2101,2104-2107 Modified: branches/1.2/bin/varnishd/cache_http.c =================================================================== --- branches/1.2/bin/varnishd/cache_http.c 2007-10-18 11:10:25 UTC (rev 2111) +++ branches/1.2/bin/varnishd/cache_http.c 2007-10-18 11:51:32 UTC (rev 2112) @@ -89,7 +89,7 @@ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); if (t > HTTP_HDR_FIRST) t = HTTP_HDR_FIRST; - assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); + assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); /*lint !e685*/ assert(t >= HTTP_HDR_REQ && t <= HTTP_HDR_FIRST); return (logmtx[hp->logtag][t]); } Modified: branches/1.2/bin/varnishd/cache_main.c =================================================================== --- branches/1.2/bin/varnishd/cache_main.c 2007-10-18 11:10:25 UTC (rev 2111) +++ branches/1.2/bin/varnishd/cache_main.c 2007-10-18 11:51:32 UTC (rev 2112) @@ -51,7 +51,7 @@ setbuf(stderr, NULL); printf("Child starts\n"); -#define SZOF(foo) printf("sizeof(%s) = %d\n", #foo, sizeof(foo)); +#define SZOF(foo) printf("sizeof(%s) = %zd\n", #foo, sizeof(foo)); SZOF(struct ws); SZOF(struct http); SZOF(struct http_conn); Modified: branches/1.2/include/Makefile.am =================================================================== --- branches/1.2/include/Makefile.am 2007-10-18 11:10:25 UTC (rev 2111) +++ branches/1.2/include/Makefile.am 2007-10-18 11:51:32 UTC (rev 2112) @@ -7,12 +7,13 @@ stats.h \ varnishapi.h -noinst_HEADERS = \ +nobase_noinst_HEADERS = \ binary_heap.h \ cli.h \ cli_common.h \ cli_priv.h \ compat/asprintf.h \ + compat/daemon.h \ compat/setproctitle.h \ compat/srandomdev.h \ compat/strlcat.h \ Copied: branches/1.2/include/compat/daemon.h (from rev 2107, trunk/varnish-cache/include/compat/daemon.h) =================================================================== --- branches/1.2/include/compat/daemon.h (rev 0) +++ branches/1.2/include/compat/daemon.h 2007-10-18 11:51:32 UTC (rev 2112) @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2007 Linpro AS + * All rights reserved. + * + * Author: Dag-Erling Sm?rgrav + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#ifndef COMPAT_DAEMON_H_INCLUDED +#define COMPAT_DAEMON_H_INCLUDED + +#ifndef HAVE_DAEMON +int daemon(int nochdir, int noclose); +#endif + +#endif Modified: branches/1.2/lib/libvarnish/assert.c =================================================================== --- branches/1.2/lib/libvarnish/assert.c 2007-10-18 11:10:25 UTC (rev 2111) +++ branches/1.2/lib/libvarnish/assert.c 2007-10-18 11:51:32 UTC (rev 2112) @@ -57,4 +57,3 @@ " errno = %d (%s)\n", func, file, line, cond, err, strerror(err)); abort(); } - Modified: branches/1.2/lib/libvarnish/binary_heap.c =================================================================== --- branches/1.2/lib/libvarnish/binary_heap.c 2007-10-18 11:10:25 UTC (rev 2111) +++ branches/1.2/lib/libvarnish/binary_heap.c 2007-10-18 11:51:32 UTC (rev 2112) @@ -298,7 +298,7 @@ #else struct foo { - unsigned idx; + unsigned idx; unsigned key; }; Modified: branches/1.2/lib/libvarnish/crc32.c =================================================================== --- branches/1.2/lib/libvarnish/crc32.c 2007-10-18 11:10:25 UTC (rev 2111) +++ branches/1.2/lib/libvarnish/crc32.c 2007-10-18 11:51:32 UTC (rev 2112) @@ -99,4 +99,3 @@ crc = crc32(~0U, p1, l); return (crc ^ ~0U); } - Modified: branches/1.2/lib/libvarnish/vss.c =================================================================== --- branches/1.2/lib/libvarnish/vss.c 2007-10-18 11:10:25 UTC (rev 2111) +++ branches/1.2/lib/libvarnish/vss.c 2007-10-18 11:51:32 UTC (rev 2112) @@ -127,14 +127,14 @@ struct vss_addr **va; int i, ret; - memset(&hints, 0, sizeof hints); - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - ret = getaddrinfo(addr, port, &hints, &res0); - if (ret != 0) { - fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(ret)); - return (0); - } + memset(&hints, 0, sizeof hints); + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_PASSIVE; + ret = getaddrinfo(addr, port, &hints, &res0); + if (ret != 0) { + fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(ret)); + return (0); + } for (res = res0, i = 0; res != NULL; res = res->ai_next) ++i; va = calloc(i, sizeof *va); Modified: branches/1.2/lib/libvarnishcompat/Makefile.am =================================================================== --- branches/1.2/lib/libvarnishcompat/Makefile.am 2007-10-18 11:10:25 UTC (rev 2111) +++ branches/1.2/lib/libvarnishcompat/Makefile.am 2007-10-18 11:51:32 UTC (rev 2112) @@ -6,6 +6,7 @@ libvarnishcompat_la_SOURCES = \ asprintf.c \ + daemon.c \ vasprintf.c \ setproctitle.c \ srandomdev.c \ Copied: branches/1.2/lib/libvarnishcompat/daemon.c (from rev 2107, trunk/varnish-cache/lib/libvarnishcompat/daemon.c) =================================================================== --- branches/1.2/lib/libvarnishcompat/daemon.c (rev 0) +++ branches/1.2/lib/libvarnishcompat/daemon.c 2007-10-18 11:51:32 UTC (rev 2112) @@ -0,0 +1,92 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + * Derived from: + * $FreeBSD: src/lib/libc/gen/daemon.c,v 1.8 2007/01/09 00:27:53 imp Exp $ + */ + +#ifndef HAVE_DAEMON + +#include +#include +#include +#include +#include +#include + +#include "compat/daemon.h" + +int +daemon(int nochdir, int noclose) +{ + struct sigaction osa, sa; + int fd; + pid_t newgrp; + int oerrno; + int osa_ok; + + /* A SIGHUP may be thrown when the parent exits below. */ + sigemptyset(&sa.sa_mask); + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + osa_ok = sigaction(SIGHUP, &sa, &osa); + + switch (fork()) { + case -1: + return (-1); + case 0: + break; + default: + exit(0); + } + + newgrp = setsid(); + oerrno = errno; + if (osa_ok != -1) + sigaction(SIGHUP, &osa, NULL); + + if (newgrp == -1) { + errno = oerrno; + return (-1); + } + + if (!nochdir) + (void)chdir("/"); + + if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { + (void)dup2(fd, STDIN_FILENO); + (void)dup2(fd, STDOUT_FILENO); + (void)dup2(fd, STDERR_FILENO); + if (fd > 2) + (void)close(fd); + } + return (0); +} + +#endif From cecilihf at projects.linpro.no Thu Oct 18 13:24:35 2007 From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no) Date: Thu, 18 Oct 2007 15:24:35 +0200 (CEST) Subject: r2113 - trunk/varnish-tools/regress/lib/Varnish/Test/Case Message-ID: <20071018132435.8E2451EC403@projects.linpro.no> Author: cecilihf Date: 2007-10-18 15:24:35 +0200 (Thu, 18 Oct 2007) New Revision: 2113 Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm Log: Run the passPOST test first. Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-18 11:51:32 UTC (rev 2112) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-18 13:24:35 UTC (rev 2113) @@ -43,7 +43,7 @@ # latter receives the Varnish Guru Meditation intended for the former. # This seems to be a bug in either IO::Multiplex or Varnish::Test. # -our @TESTS = qw(testPipePOST testCachePOST testPassPOST); +our @TESTS = qw(testPassPOST testCachePOST testPipePOST); our $VCL = < Author: des Date: 2007-10-18 15:30:52 +0200 (Thu, 18 Oct 2007) New Revision: 2114 Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm Log: Revert previous change and fix the comment that explains why it has to be the way it is. Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-18 13:24:35 UTC (rev 2113) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-18 13:30:52 UTC (rev 2114) @@ -39,11 +39,11 @@ # testCachePOST and testPassPOST are known to fail, and it is not # clear at this point whether that is a bug or a feature. # -# More interestingly, if you run testPassPOST after testPipePOST, the +# More interestingly, if you run testPassPOST before testPipePOST, the # latter receives the Varnish Guru Meditation intended for the former. # This seems to be a bug in either IO::Multiplex or Varnish::Test. # -our @TESTS = qw(testPassPOST testCachePOST testPipePOST); +our @TESTS = qw(testPipePOST testCachePOST testPassPOST); our $VCL = < Author: cecilihf Date: 2007-10-18 15:38:45 +0200 (Thu, 18 Oct 2007) New Revision: 2115 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Make pass mode work for POST requests. Solves ticket #47. Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-18 13:30:52 UTC (rev 2114) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-18 13:38:45 UTC (rev 2115) @@ -261,6 +261,9 @@ int mklen, is_head; struct http_conn htc[1]; int i; + int content_length; + char hdr[20]; + char *ptr; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); @@ -287,6 +290,17 @@ return (__LINE__); WRK_Reset(w, &vc->fd); http_Write(w, hp, 0); + + /* If a POST request was passed to fetch, we must send + * any pipelined bytes to the backend as well */ + if (!strcmp(http_GetReq(sp->http), "POST")) { + sprintf(hdr, "%ccontent-length:", 15); + assert(http_GetHdr(sp->http, hdr, &ptr)); + content_length = atoi(ptr); + if (sp->htc->pipeline.b != NULL && content_length > 0) + WRK_Write(w, sp->htc->pipeline.b, content_length); + } + if (WRK_Flush(w)) { VBE_UpdateHealth(sp, vc, -1); VBE_ClosedFd(sp->wrk, vc); From phk at phk.freebsd.dk Thu Oct 18 13:48:47 2007 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Thu, 18 Oct 2007 13:48:47 +0000 Subject: r2115 - trunk/varnish-cache/bin/varnishd In-Reply-To: Your message of "Thu, 18 Oct 2007 15:38:45 +0200." <20071018133845.707CA1EC403@projects.linpro.no> Message-ID: <56065.1192715327@critter.freebsd.dk> In message <20071018133845.707CA1EC403 at projects.linpro.no>, cecilihf at projects.l inpro.no writes: >Author: cecilihf >Date: 2007-10-18 15:38:45 +0200 (Thu, 18 Oct 2007) >New Revision: 2115 > >Modified: > trunk/varnish-cache/bin/varnishd/cache_fetch.c >Log: >Make pass mode work for POST requests. Solves ticket #47. Uhm, that is not enough, the pipelined contents may not contain the full post request body. >+ if (!strcmp(http_GetReq(sp->http), "POST")) { >+ sprintf(hdr, "%ccontent-length:", 15); >+ assert(http_GetHdr(sp->http, hdr, &ptr)); I might have tipped my hat for you, you you had written: hdr[0] = sprintf(hdr + 1, "content-length:"); assert(http_GetHdr(sp->http, hdr, &ptr)); Or even: assert(http_GetHdr(sp->http, "\017content-length:", &ptr)); But we already have magically predefined constants for all the usual headers, so the correct way is: assert(http_GetHdr(sp->http, H_Content_Length, &ptr)); ... apart from the "assert" which is probably needlessly draconian. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From des at linpro.no Thu Oct 18 13:50:28 2007 From: des at linpro.no (=?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?=) Date: Thu, 18 Oct 2007 15:50:28 +0200 Subject: r2115 - trunk/varnish-cache/bin/varnishd In-Reply-To: <20071018133845.707CA1EC403@projects.linpro.no> (cecilihf@projects.linpro.no's message of "Thu, 18 Oct 2007 15:38:45 +0200 (CEST)") References: <20071018133845.707CA1EC403@projects.linpro.no> Message-ID: cecilihf at projects.linpro.no writes: > @@ -287,6 +290,17 @@ > return (__LINE__); > WRK_Reset(w, &vc->fd); > http_Write(w, hp, 0); > + > + /* If a POST request was passed to fetch, we must send > + * any pipelined bytes to the backend as well */ > + if (!strcmp(http_GetReq(sp->http), "POST")) { > + sprintf(hdr, "%ccontent-length:", 15); > + assert(http_GetHdr(sp->http, hdr, &ptr)); > + content_length = atoi(ptr); > + if (sp->htc->pipeline.b != NULL && content_length > 0) > + WRK_Write(w, sp->htc->pipeline.b, content_length); > + } > + > if (WRK_Flush(w)) { > VBE_UpdateHealth(sp, vc, -1); > VBE_ClosedFd(sp->wrk, vc); > This should not be predicated on the request method being POST, but rather on the presence of a Content-Length header. atoi() is not safe, BTW, as it gives no error indication. Use strto*() instead. Your code does not check that there is enough data in the pipeline, and will not handle large requests (like a file upload) where we might have to refill the pipeline several times to get the entire body. DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no From des at projects.linpro.no Thu Oct 18 15:18:43 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Thu, 18 Oct 2007 17:18:43 +0200 (CEST) Subject: r2116 - in trunk/varnish-cache: . bin/varnishd lib/libvarnishapi Message-ID: <20071018151843.3A1E31EC1D8@projects.linpro.no> Author: des Date: 2007-10-18 17:18:42 +0200 (Thu, 18 Oct 2007) New Revision: 2116 Modified: trunk/varnish-cache/bin/varnishd/Makefile.am trunk/varnish-cache/configure.ac trunk/varnish-cache/lib/libvarnishapi/Makefile.am Log: Make VARNISH_STATE_DIR work correctly when using the default prefix. Modified: trunk/varnish-cache/bin/varnishd/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishd/Makefile.am 2007-10-18 13:38:45 UTC (rev 2115) +++ trunk/varnish-cache/bin/varnishd/Makefile.am 2007-10-18 15:18:42 UTC (rev 2116) @@ -64,7 +64,8 @@ steps.h \ stevedore.h -varnishd_CFLAGS = -include config.h +varnishd_CFLAGS = -include config.h \ + -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' varnishd_LDFLAGS = -export-dynamic Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2007-10-18 13:38:45 UTC (rev 2115) +++ trunk/varnish-cache/configure.ac 2007-10-18 15:18:42 UTC (rev 2116) @@ -115,9 +115,8 @@ AC_CHECK_FUNCS([poll]) # Run-time directory -VARNISH_STATE_DIR=`eval "echo $localstatedir/varnish"` -AC_DEFINE_UNQUOTED(VARNISH_STATE_DIR, "$VARNISH_STATE_DIR", - [Base directory for run-time state]) +VARNISH_STATE_DIR="${localstatedir}/varnish" +AC_SUBST(VARNISH_STATE_DIR) # Now that we're done using the compiler to look for functions and # libraries, set CFLAGS to what we want them to be for our own code Modified: trunk/varnish-cache/lib/libvarnishapi/Makefile.am =================================================================== --- trunk/varnish-cache/lib/libvarnishapi/Makefile.am 2007-10-18 13:38:45 UTC (rev 2115) +++ trunk/varnish-cache/lib/libvarnishapi/Makefile.am 2007-10-18 15:18:42 UTC (rev 2116) @@ -9,4 +9,5 @@ instance.c \ shmlog.c -libvarnishapi_la_CFLAGS = -include config.h +libvarnishapi_la_CFLAGS = -include config.h \ + -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' From des at projects.linpro.no Thu Oct 18 15:40:31 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Thu, 18 Oct 2007 17:40:31 +0200 (CEST) Subject: r2117 - in branches/1.2: . bin/varnishd lib/libvarnishapi Message-ID: <20071018154031.8A81F1EC403@projects.linpro.no> Author: des Date: 2007-10-18 17:40:31 +0200 (Thu, 18 Oct 2007) New Revision: 2117 Modified: branches/1.2/ branches/1.2/bin/varnishd/Makefile.am branches/1.2/configure.ac branches/1.2/lib/libvarnishapi/Makefile.am Log: Merged revisions 2116 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2116 | des | 2007-10-18 17:18:42 +0200 (Thu, 18 Oct 2007) | 2 lines Make VARNISH_STATE_DIR work correctly when using the default prefix. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107 + /trunk/varnish-cache:1-2101,2104-2107,2116 Modified: branches/1.2/bin/varnishd/Makefile.am =================================================================== --- branches/1.2/bin/varnishd/Makefile.am 2007-10-18 15:18:42 UTC (rev 2116) +++ branches/1.2/bin/varnishd/Makefile.am 2007-10-18 15:40:31 UTC (rev 2117) @@ -64,7 +64,8 @@ steps.h \ stevedore.h -varnishd_CFLAGS = -include config.h +varnishd_CFLAGS = -include config.h \ + -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' varnishd_LDFLAGS = -export-dynamic Modified: branches/1.2/configure.ac =================================================================== --- branches/1.2/configure.ac 2007-10-18 15:18:42 UTC (rev 2116) +++ branches/1.2/configure.ac 2007-10-18 15:40:31 UTC (rev 2117) @@ -115,9 +115,8 @@ AC_CHECK_FUNCS([poll]) # Run-time directory -VARNISH_STATE_DIR=`eval "echo $localstatedir/varnish"` -AC_DEFINE_UNQUOTED(VARNISH_STATE_DIR, "$VARNISH_STATE_DIR", - [Base directory for run-time state]) +VARNISH_STATE_DIR="${localstatedir}/varnish" +AC_SUBST(VARNISH_STATE_DIR) # Now that we're done using the compiler to look for functions and # libraries, set CFLAGS to what we want them to be for our own code Modified: branches/1.2/lib/libvarnishapi/Makefile.am =================================================================== --- branches/1.2/lib/libvarnishapi/Makefile.am 2007-10-18 15:18:42 UTC (rev 2116) +++ branches/1.2/lib/libvarnishapi/Makefile.am 2007-10-18 15:40:31 UTC (rev 2117) @@ -9,4 +9,5 @@ instance.c \ shmlog.c -libvarnishapi_la_CFLAGS = -include config.h +libvarnishapi_la_CFLAGS = -include config.h \ + -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' From des at projects.linpro.no Thu Oct 18 15:45:34 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Thu, 18 Oct 2007 17:45:34 +0200 (CEST) Subject: r2118 - in trunk/varnish-tools/regress/lib/Varnish/Test: . Case Message-ID: <20071018154534.C1A541EC51C@projects.linpro.no> Author: des Date: 2007-10-18 17:45:34 +0200 (Thu, 18 Oct 2007) New Revision: 2118 Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm trunk/varnish-tools/regress/lib/Varnish/Test/Case/LRU.pm trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm trunk/varnish-tools/regress/lib/Varnish/Test/Case/RePurge.pm trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket102.pm trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket128.pm trunk/varnish-tools/regress/lib/Varnish/Test/Case/Vary.pm trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm Log: Separate the act of sending a request from that of receiving a response. This (along with earlier changes to the client code) allows us to send multiple requests, then receive the responses in order. Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/LRU.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/LRU.pm 2007-10-18 15:40:31 UTC (rev 2117) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/LRU.pm 2007-10-18 15:45:34 UTC (rev 2118) @@ -51,7 +51,8 @@ my $client = $self->new_client(); my $uri = __PACKAGE__ . "::$n"; - my $response = $self->get($client, $uri); + my $request = $self->get($client, $uri); + my $response = $self->wait(); $self->assert_body(qr/^(?:\Q$uri\E){$repeat}$/); $client->shutdown(); return $response; Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-18 15:40:31 UTC (rev 2117) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-18 15:45:34 UTC (rev 2118) @@ -79,6 +79,7 @@ my $client = $self->new_client; $self->post($client, "/pipe_me", [], $MAGIC_WORDS); + $self->wait(); $self->assert_ok(); $self->assert_no_xid(); $self->assert_body(qr/\Q$MAGIC_WORDS\E/); @@ -93,12 +94,14 @@ # Warm up the cache $self->post($client, "/cache_me"); + $self->wait(); $self->assert_ok(); $self->assert_uncached(); $self->assert_body(qr/\Q$NOTHING_HAPPENS\E/); # Verify that the request was cached $self->post($client, "/cache_me"); + $self->wait(); $self->assert_ok(); $self->assert_cached(); $self->assert_body(qr/\Q$NOTHING_HAPPENS\E/); Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/RePurge.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/RePurge.pm 2007-10-18 15:40:31 UTC (rev 2117) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/RePurge.pm 2007-10-18 15:45:34 UTC (rev 2118) @@ -58,26 +58,33 @@ # Warm up the cache $self->get($client, $KEEP_URL); + $self->wait(); $self->assert_ok(); $self->get($client, $PURGE_URL); + $self->wait(); $self->assert_ok(); # Verify the state of the cache $self->get($client, $KEEP_URL); + $self->wait(); $self->assert_ok(); $self->assert_cached(); $self->get($client, $PURGE_URL); + $self->wait(); $self->assert_ok(); $self->assert_cached(); # Send the purge request $self->request($client, 'REPURGE', $PURGE_RE); + $self->wait(); # Verify the state of the cache $self->get($client, $KEEP_URL); + $self->wait(); $self->assert_ok(); $self->assert_cached(); $self->get($client, $PURGE_URL); + $self->wait(); $self->assert_ok(); $self->assert_uncached(); Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket102.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket102.pm 2007-10-18 15:40:31 UTC (rev 2117) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket102.pm 2007-10-18 15:45:34 UTC (rev 2118) @@ -53,14 +53,17 @@ my $client = $self->new_client; $self->get($client, '/'); + $self->wait(); $self->assert_body($BODY); $self->assert_uncached(); $self->post($client, '/'); + $self->wait(); $self->assert_body($BODY); $self->assert_cached(); $self->head($client, '/'); + $self->wait(); $self->assert_no_body(); $self->assert_cached(); Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket128.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket128.pm 2007-10-18 15:40:31 UTC (rev 2117) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket128.pm 2007-10-18 15:45:34 UTC (rev 2118) @@ -49,6 +49,7 @@ my $client = $self->new_client; $self->get($client, '/'); + $self->wait(); $self->assert_code($CODE); $self->assert_body(qr/\Q$MESSAGE\E/); $client->shutdown(); Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Vary.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/Vary.pm 2007-10-18 15:40:31 UTC (rev 2117) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/Vary.pm 2007-10-18 15:45:34 UTC (rev 2118) @@ -49,12 +49,14 @@ foreach my $lang (keys %languages) { $self->get($client, '/', [ 'Accept-Language', $lang]); + $self->wait(); # $self->assert_uncached(); $self->assert_header('Language', $lang); $self->assert_body($languages{$lang}); } foreach my $lang (keys %languages) { $self->get($client, '/', [ 'Accept-Language', $lang]); + $self->wait(); $self->assert_cached(); $self->assert_body($languages{$lang}); } Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm 2007-10-18 15:40:31 UTC (rev 2117) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm 2007-10-18 15:45:34 UTC (rev 2118) @@ -346,6 +346,18 @@ $req->content($content); } $client->send_request($req, 4); + return $req; +} + +=head2 wait + +Wait for a response to a previously sent request. + +=cut + +sub wait($) { + my ($self) = @_; + my ($ev, $resp) = $self->run_loop('ev_server_timeout', 'ev_client_timeout', @@ -356,7 +368,6 @@ if $ev eq 'ev_client_timeout'; die "Internal error\n" unless $resp && ref($resp) && $resp->isa('HTTP::Response'); - $resp->request($req); return $self->{'cached_response'} = $resp; } Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm 2007-10-18 15:40:31 UTC (rev 2117) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm 2007-10-18 15:45:34 UTC (rev 2118) @@ -133,7 +133,13 @@ $self->{'responses'} += 1; $self->logf("%s %s", $response->code(), $response->message()); - $self->{'engine'}->ev_client_response($self, $response, shift(@{$self->{'pending'}})); + + # Associate the response with what we hope is the correct request + my $request = shift(@{$self->{'pending'}}) + or die "received response while no request pending\n"; + $response->request($request); + + $self->{'engine'}->ev_client_response($self, $response); } =head2 shutdown From des at projects.linpro.no Thu Oct 18 15:48:11 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Thu, 18 Oct 2007 17:48:11 +0200 (CEST) Subject: r2119 - trunk/varnish-tools/regress/lib/Varnish/Test/Case Message-ID: <20071018154811.90E093BC328@projects.linpro.no> Author: des Date: 2007-10-18 17:48:11 +0200 (Thu, 18 Oct 2007) New Revision: 2119 Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm Log: Add a missing wait(). Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-18 15:45:34 UTC (rev 2118) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-18 15:48:11 UTC (rev 2119) @@ -67,6 +67,7 @@ my $client = $self->new_client; $self->post($client, "/pass_me", [], $MAGIC_WORDS); + $self->wait(); $self->assert_ok(); $self->assert_xid(); $self->assert_body(qr/\Q$MAGIC_WORDS\E/); From des at projects.linpro.no Thu Oct 18 16:07:19 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Thu, 18 Oct 2007 18:07:19 +0200 (CEST) Subject: r2120 - trunk/varnish-tools/regress/lib/Varnish/Test/Case Message-ID: <20071018160719.E5E381EC1D8@projects.linpro.no> Author: des Date: 2007-10-18 18:07:19 +0200 (Thu, 18 Oct 2007) New Revision: 2120 Added: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm Log: Add a regression test for pipelining, which is currently broken in trunk. Added: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm (rev 0) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm 2007-10-18 16:07:19 UTC (rev 2120) @@ -0,0 +1,73 @@ +#!/usr/bin/perl -w +#- +# Copyright (c) 2007 Linpro AS +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer +# in this position and unchanged. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $Id$ +# + +package Varnish::Test::Case::Pipeline; + +use strict; +use base 'Varnish::Test::Case'; + +our $DESCR = "Tests Varnish's ability to handle pipelined requests."; + +our %CONTENT = ( + 'Gibson' => "The sky above the port was the color of television, tuned to a dead channel.", + 'Tolkien' => "In a hole in the ground there lived a hobbit.", + 'Williams' => "I have always depended upon the kindness of strangers.", +); + +sub testPipeline($) { + my ($self) = @_; + + my $client = $self->new_client; + foreach my $author (sort keys %CONTENT) { + $self->get($client, "/$author"); + } + foreach my $author (sort keys %CONTENT) { + $self->wait(); + $self->assert_ok(); + $self->assert_xid(); + $self->assert_body(qr/\Q$CONTENT{$author}\E/); + } + + return 'OK' +} + +sub server_get($$$) { + my ($self, $request, $response) = @_; + + my ($author) = ($request->uri =~ m/(\w+)$/); + if ($CONTENT{$author}) { + $response->content($CONTENT{$author}); + } else { + $response->code(404); + $response->content("Unknown author.\n"); + } +} + +1; Property changes on: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm ___________________________________________________________________ Name: svn:keywords + Id From phk at projects.linpro.no Thu Oct 18 19:09:34 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 18 Oct 2007 21:09:34 +0200 (CEST) Subject: r2121 - trunk/varnish-cache/bin/varnishd Message-ID: <20071018190934.6718C1EC51C@projects.linpro.no> Author: phk Date: 2007-10-18 21:09:33 +0200 (Thu, 18 Oct 2007) New Revision: 2121 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/cache_response.c trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Make ESI processing actually work. So far we support only the element. All other elements are ignored. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-18 16:07:19 UTC (rev 2120) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-18 19:09:33 UTC (rev 2121) @@ -68,6 +68,7 @@ struct objhead; struct workreq; struct addrinfo; +struct esi_bit; /*--------------------------------------------------------------------*/ @@ -252,6 +253,8 @@ VTAILQ_HEAD(, sess) waitinglist; + VTAILQ_HEAD(, esi_bit) esibits; + double lru_stamp; }; @@ -567,6 +570,11 @@ cli_func_t cli_func_dump_pool; #endif +/* cache_vrt_esi.c */ + +void ESI_Deliver(struct sess *); +void ESI_Destroy(struct object *); + /* cache_ws.c */ void WS_Init(struct ws *ws, void *space, unsigned len); Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-18 16:07:19 UTC (rev 2120) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-18 19:09:33 UTC (rev 2121) @@ -97,6 +97,7 @@ w->nobj->refcnt = 1; VTAILQ_INIT(&w->nobj->store); VTAILQ_INIT(&w->nobj->waitinglist); + VTAILQ_INIT(&w->nobj->esibits); VSL_stats->n_object++; } else CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC); @@ -312,6 +313,7 @@ if (o->vary != NULL) free(o->vary); + ESI_Destroy(o); HSH_Freestore(o); STV_free(o->objstore); VSL_stats->n_object--; Modified: trunk/varnish-cache/bin/varnishd/cache_response.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-10-18 16:07:19 UTC (rev 2120) +++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-10-18 19:09:33 UTC (rev 2121) @@ -157,7 +157,10 @@ sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - if (sp->wantbody) { + if (sp->wantbody && !VTAILQ_EMPTY(&sp->obj->esibits)) { + ESI_Deliver(sp); + } else if (sp->wantbody) { + VTAILQ_FOREACH(st, &sp->obj->store, list) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-18 16:07:19 UTC (rev 2120) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-18 19:09:33 UTC (rev 2121) @@ -50,32 +50,104 @@ #include "vcl.h" #include "cache.h" +#define NDEFELEM 10 + +/*--------------------------------------------------------------------*/ + +struct esi_bit { + VTAILQ_ENTRY(esi_bit) list; + char chunk_length[20]; + txt verbatim; + txt include; + int free_this; +}; + +VTAILQ_HEAD(esibithead, esi_bit); + +struct esi_work { + struct sess *sp; + size_t off; + struct storage *st; + txt dst; + struct esi_bit *eb; + struct esi_bit *ebl; /* list of */ + int neb; +}; + /*-------------------------------------------------------------------- + * Add ESI bit to object + */ + +static void +esi_addbit(struct esi_work *ew) +{ + + if (ew->neb == 0) { + ew->ebl = calloc(NDEFELEM, sizeof(struct esi_bit)); + XXXAN(ew->ebl); + ew->neb = NDEFELEM; + ew->ebl->free_this = 1; + } + ew->eb = ew->ebl; + ew->ebl++; + ew->neb--; + +printf("FIRST: %p\n", VTAILQ_FIRST(&ew->sp->obj->esibits)); +printf("ADD %p->%p\n", ew->sp->obj, ew->eb); + + VTAILQ_INSERT_TAIL(&ew->sp->obj->esibits, ew->eb, list); + ew->eb->verbatim = ew->dst; + sprintf(ew->eb->chunk_length, "%x\r\n", Tlen(ew->dst)); + VSL(SLT_Debug, ew->sp->fd, "AddBit: %.*s", Tlen(ew->dst), ew->dst.b); +} + + +/*-------------------------------------------------------------------- + * Add verbatim piece to output + */ + +static void +esi_addverbatim(struct esi_work *ew, txt t) +{ + + if (t.b != ew->dst.e) + memmove(ew->dst.e, t.b, Tlen(t)); + ew->dst.e += Tlen(t); +} + +/*-------------------------------------------------------------------- * Add one piece to the output, either verbatim or include */ static void -add_piece(txt t, int kind) +esi_addinclude(struct esi_work *ew, txt t) { - printf("K%d \"%.*s\"\n", kind, (int)(t.e - t.b), t.b); + VSL(SLT_Debug, 0, "Incl \"%.*s\"", t.e - t.b, t.b); + esi_addbit(ew); + ew->eb->include = t; } +/*-------------------------------------------------------------------- + * Report a parsing error + */ + static void -vxml_error(struct sess *sp, const char *p, txt t, size_t off, int i, const char *err) +esi_error(const struct esi_work *ew, const char *p, int i, const char *err) { int ellipsis = 0; char buf[256], *q; + txt t; - if (i == 0) { - i = t.e - p; - } + if (i == 0) + i = p - ((char *)ew->st->ptr + ew->st->len); if (i > 20) { i = 20; ellipsis = 1; } q = buf; - q += sprintf(buf, "at %d: %s \"", (int)(off + (p - t.b)), err); + q += sprintf(buf, "at %zd: %s \"", + ew->off + (p - (char*)ew->st->ptr), err); while (i > 0) { if (*p >= ' ' && *p <= '~') { *q++ = *p; @@ -106,7 +178,7 @@ *q++ = '\0'; t.b = buf; t.e = q; - WSPR(sp, SLT_ESI_xmlerror, t); + WSPR(ew->sp, SLT_ESI_xmlerror, t); } /*-------------------------------------------------------------------- @@ -117,18 +189,22 @@ */ static int -vxml(struct sess *sp, txt t, size_t off) +esi_parse(struct esi_work *ew) { char *p, *q, *r; - txt o; + txt t, o; int celem; /* closing element */ int remflg; /* inside */ int incmt; /* inside comment */ int i; - o.b = t.b; + t.b = (char *)ew->st->ptr; + t.e = t.b + ew->st->len; + ew->dst.b = t.b; + ew->dst.e = t.b; remflg = 0; incmt = 0; + o.b = t.b; for (p = t.b; p < t.e; ) { if (incmt && *p == '-') { /* @@ -142,7 +218,7 @@ if (!memcmp(p, "-->", 3)) { incmt = 0; o.e = p; - add_piece(o, 0); + esi_addverbatim(ew, o); p += 3; o.b = p; } else @@ -172,7 +248,7 @@ return (p - t.b); o.e = p; - add_piece(o, 0); + esi_addverbatim(ew, o); p += 7; o.b = p; @@ -216,7 +292,7 @@ /* * Unrecognized dst.b = q + 1; + ew->dst.e = q + 1; } else { - vxml_error(sp, p, t, off, 1 + q - p, + esi_error(ew, p, 1 + q - p, "ESI 1.0 closing esi:include illegal"); } p = q + 1; @@ -309,10 +387,10 @@ /* * Unimplemented ESI element, ignore */ - vxml_error(sp, p, t, off, 1 + q - p, + esi_error(ew, p, 1 + q - p, "ESI 1.0 unimplemented element"); o.e = p; - add_piece(o, 0); + esi_addverbatim(ew, o); p = q + 1; o.b = p; continue; @@ -322,7 +400,7 @@ p = q + 1; } o.e = p; - add_piece(o, 0); + esi_addverbatim(ew, o); return (p - t.b); } @@ -332,23 +410,76 @@ VRT_ESI(struct sess *sp) { struct storage *st; - txt t; + struct esi_work *ew, eww[1]; int i; - size_t o; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - o = 1; + ew = eww; + memset(eww, 0, sizeof eww); + ew->sp = sp; + ew->off = 1; + VTAILQ_FOREACH(st, &sp->obj->store, list) { - t.b = (void*)st->ptr; - t.e = t.b + st->len; - i = vxml(sp, t, o); - o += st->len; + ew->st = st; + i = esi_parse(ew); + ew->off += st->len; printf("VXML(%p+%d) = %d", st->ptr, st->len, i); - if (i < st->len) + if (i < st->len) { + /* XXX: Handle complications */ printf(" \"%.*s\"", st->len - i, st->ptr + i); + if (VTAILQ_NEXT(st, list)) + INCOMPL(); + } printf("\n"); + i = Tlen(ew->dst); } + if (Tlen(ew->dst)) + esi_addbit(ew); + + /* + * Our ESI implementation needs chunked encoding + * XXX: We should only do this if we find any ESI directives + */ + http_Unset(sp->obj->http, H_Content_Length); + http_PrintfHeader(sp->wrk, sp->fd, sp->obj->http, + "Transfer-Encoding: chunked"); + } /*--------------------------------------------------------------------*/ + +void +ESI_Deliver(struct sess *sp) +{ + + struct esi_bit *eb; + + VTAILQ_FOREACH(eb, &sp->obj->esibits, list) { + WRK_Write(sp->wrk, eb->chunk_length, -1); + WRK_Write(sp->wrk, eb->verbatim.b, Tlen(eb->verbatim)); + if (VTAILQ_NEXT(eb, list)) + WRK_Write(sp->wrk, "\r\n", -1); + else + WRK_Write(sp->wrk, "\r\n0\r\n", -1); + } +} + +/*--------------------------------------------------------------------*/ + +void +ESI_Destroy(struct object *o) +{ + struct esi_bit *eb; + + /* + * Delete esi_bits from behind and free(3) the ones that want to be. + */ + while (!VTAILQ_EMPTY(&o->esibits)) { + eb = VTAILQ_LAST(&o->esibits, esibithead); + VTAILQ_REMOVE(&o->esibits, eb, list); + if (eb->free_this) + free(eb); + } +} + From phk at projects.linpro.no Fri Oct 19 08:50:50 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 19 Oct 2007 10:50:50 +0200 (CEST) Subject: r2122 - trunk/varnish-cache/bin/varnishd Message-ID: <20071019085050.92BB61EC403@projects.linpro.no> Author: phk Date: 2007-10-19 10:50:50 +0200 (Fri, 19 Oct 2007) New Revision: 2122 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_httpconn.c Log: Fix pipelining: don't expect the fd to become readable before we look for complete requests. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-18 19:09:33 UTC (rev 2121) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-19 08:50:50 UTC (rev 2122) @@ -491,6 +491,7 @@ int HTC_Reinit(struct http_conn *htc); int HTC_Rx(struct http_conn *htc); int HTC_Read(struct http_conn *htc, void *d, unsigned len); +int HTC_Complete(struct http_conn *htc); #define HTTPH(a, b, c, d, e, f, g) extern char b[]; #include "http_headers.h" Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-18 19:09:33 UTC (rev 2121) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-19 08:50:50 UTC (rev 2122) @@ -89,9 +89,9 @@ assert(sp->xid == 0); - do + i = HTC_Complete(sp->htc); + while (i == 0) i = HTC_Rx(sp->htc); - while (i == 0); if (i == 1) { sp->step = STP_RECV; } else { Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-18 19:09:33 UTC (rev 2121) +++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-19 08:50:50 UTC (rev 2122) @@ -124,6 +124,30 @@ } /*-------------------------------------------------------------------- + * + */ + +int +HTC_Complete(struct http_conn *htc) +{ + int i; + + CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); + i = htc_header_complete(&htc->rxbuf); + if (i < 0) + htc->rxbuf.e = htc->rxbuf.b; + if (i <= 0) + return (0); + WS_ReleaseP(htc->ws, htc->rxbuf.e); + if (htc->rxbuf.b + i < htc->rxbuf.e) { + htc->pipeline.b = htc->rxbuf.b + i; + htc->pipeline.e = htc->rxbuf.e; + htc->rxbuf.e = htc->pipeline.b; + } + return (1); +} + +/*-------------------------------------------------------------------- * Receive more HTTP protocol bytes * Returns: * -2 overflow @@ -151,18 +175,7 @@ } htc->rxbuf.e += i; *htc->rxbuf.e = '\0'; - i = htc_header_complete(&htc->rxbuf); - if (i < 0) - htc->rxbuf.e = htc->rxbuf.b; - if (i <= 0) - return (0); - WS_ReleaseP(htc->ws, htc->rxbuf.e); - if (htc->rxbuf.b + i < htc->rxbuf.e) { - htc->pipeline.b = htc->rxbuf.b + i; - htc->pipeline.e = htc->rxbuf.e; - htc->rxbuf.e = htc->pipeline.b; - } - return (1); + return (HTC_Complete(htc)); } int From cecilihf at projects.linpro.no Fri Oct 19 08:51:41 2007 From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no) Date: Fri, 19 Oct 2007 10:51:41 +0200 (CEST) Subject: r2123 - trunk/varnish-cache/bin/varnishd Message-ID: <20071019085141.00F231EC21D@projects.linpro.no> Author: cecilihf Date: 2007-10-19 10:51:40 +0200 (Fri, 19 Oct 2007) New Revision: 2123 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Improved handling of pass for POST requests. Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 08:50:50 UTC (rev 2122) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 08:51:40 UTC (rev 2123) @@ -261,9 +261,10 @@ int mklen, is_head; struct http_conn htc[1]; int i; - int content_length; - char hdr[20]; - char *ptr; + int content_length, content_written; + int read; + char *ptr, *endp; + char *p = NULL; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); @@ -293,12 +294,21 @@ /* If a POST request was passed to fetch, we must send * any pipelined bytes to the backend as well */ - if (!strcmp(http_GetReq(sp->http), "POST")) { - sprintf(hdr, "%ccontent-length:", 15); - assert(http_GetHdr(sp->http, hdr, &ptr)); - content_length = atoi(ptr); - if (sp->htc->pipeline.b != NULL && content_length > 0) - WRK_Write(w, sp->htc->pipeline.b, content_length); + if(http_GetHdr(sp->http, H_Content_Length, &ptr)) { + endp = ptr + strlen(ptr); + content_length = (int)strtol(ptr, &endp, 10); + content_written = 0; + while (content_written < content_length) { + p = malloc(content_length); + read = HTC_Read(sp->htc, p, content_length); + content_written += WRK_Write(w, p, read); + if (WRK_Flush(w)) { + VBE_UpdateHealth(sp, vc, -1); + VBE_ClosedFd(sp->wrk, vc); + return (__LINE__); + } + free(p); + } } if (WRK_Flush(w)) { From des at projects.linpro.no Fri Oct 19 08:55:46 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 10:55:46 +0200 (CEST) Subject: r2124 - trunk/varnish-cache/bin/varnishd Message-ID: <20071019085546.AF7711EC21C@projects.linpro.no> Author: des Date: 2007-10-19 10:55:46 +0200 (Fri, 19 Oct 2007) New Revision: 2124 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Style & whitespace Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 08:51:40 UTC (rev 2123) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 08:55:46 UTC (rev 2124) @@ -291,10 +291,12 @@ return (__LINE__); WRK_Reset(w, &vc->fd); http_Write(w, hp, 0); - - /* If a POST request was passed to fetch, we must send - * any pipelined bytes to the backend as well */ - if(http_GetHdr(sp->http, H_Content_Length, &ptr)) { + + /* + * If a POST request was passed to fetch, we must send any + * pipelined bytes to the backend as well + */ + if (http_GetHdr(sp->http, H_Content_Length, &ptr)) { endp = ptr + strlen(ptr); content_length = (int)strtol(ptr, &endp, 10); content_written = 0; @@ -310,7 +312,7 @@ free(p); } } - + if (WRK_Flush(w)) { VBE_UpdateHealth(sp, vc, -1); VBE_ClosedFd(sp->wrk, vc); From des at projects.linpro.no Fri Oct 19 09:05:10 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 11:05:10 +0200 (CEST) Subject: r2125 - trunk/varnish-cache/bin/varnishd Message-ID: <20071019090510.A83211EC21D@projects.linpro.no> Author: des Date: 2007-10-19 11:05:10 +0200 (Fri, 19 Oct 2007) New Revision: 2125 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Simplify Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 08:55:46 UTC (rev 2124) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 09:05:10 UTC (rev 2125) @@ -260,9 +260,8 @@ struct bereq *bereq; int mklen, is_head; struct http_conn htc[1]; - int i; - int content_length, content_written; - int read; + unsigned long content_length; + int i, read; char *ptr, *endp; char *p = NULL; @@ -297,18 +296,18 @@ * pipelined bytes to the backend as well */ if (http_GetHdr(sp->http, H_Content_Length, &ptr)) { - endp = ptr + strlen(ptr); - content_length = (int)strtol(ptr, &endp, 10); - content_written = 0; - while (content_written < content_length) { + content_length = strtoul(ptr, &endp, 10); + /* XXX should check result of conversion */ + while (content_length) { p = malloc(content_length); read = HTC_Read(sp->htc, p, content_length); - content_written += WRK_Write(w, p, read); + WRK_Write(w, p, read); if (WRK_Flush(w)) { VBE_UpdateHealth(sp, vc, -1); VBE_ClosedFd(sp->wrk, vc); return (__LINE__); } + content_length -= read; free(p); } } From des at projects.linpro.no Fri Oct 19 09:09:18 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 11:09:18 +0200 (CEST) Subject: r2126 - trunk/varnish-cache/bin/varnishd Message-ID: <20071019090918.035521EC21C@projects.linpro.no> Author: des Date: 2007-10-19 11:09:17 +0200 (Fri, 19 Oct 2007) New Revision: 2126 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Move malloc() / free() out of the loop, and plug a leak. Ideally, we shouldn't need to malloc() / free() at all, but I don't have time to figure out how to avoid it right now. Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 09:05:10 UTC (rev 2125) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 09:09:17 UTC (rev 2126) @@ -298,18 +298,19 @@ if (http_GetHdr(sp->http, H_Content_Length, &ptr)) { content_length = strtoul(ptr, &endp, 10); /* XXX should check result of conversion */ + p = malloc(content_length); while (content_length) { - p = malloc(content_length); read = HTC_Read(sp->htc, p, content_length); WRK_Write(w, p, read); if (WRK_Flush(w)) { VBE_UpdateHealth(sp, vc, -1); VBE_ClosedFd(sp->wrk, vc); + free(p); return (__LINE__); } content_length -= read; - free(p); } + free(p); } if (WRK_Flush(w)) { From des at projects.linpro.no Fri Oct 19 09:09:43 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 11:09:43 +0200 (CEST) Subject: r2127 - trunk/varnish-tools/regress/lib/Varnish/Test/Case Message-ID: <20071019090943.0DA801EC030@projects.linpro.no> Author: des Date: 2007-10-19 11:09:42 +0200 (Fri, 19 Oct 2007) New Revision: 2127 Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm Log: Also test pipelining of POST requests (in pass mode) Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm 2007-10-19 09:09:17 UTC (rev 2126) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm 2007-10-19 09:09:42 UTC (rev 2127) @@ -41,7 +41,15 @@ 'Williams' => "I have always depended upon the kindness of strangers.", ); -sub testPipeline($) { +our $VCL = <new_client; @@ -58,11 +66,31 @@ return 'OK' } -sub server_get($$$) { +sub testPipelinePost($) { + my ($self) = @_; + + my $client = $self->new_client; + foreach my $author (sort keys %CONTENT) { + $self->post($client, "/$author", [], $CONTENT{$author}); + } + foreach my $author (sort keys %CONTENT) { + $self->wait(); + $self->assert_ok(); + $self->assert_xid(); + $self->assert_body(qr/\Q$CONTENT{$author}\E/); + } + + return 'OK' +} + +sub server($$$) { my ($self, $request, $response) = @_; my ($author) = ($request->uri =~ m/(\w+)$/); if ($CONTENT{$author}) { + if ($request->method eq 'POST') { + die unless $request->content =~ qr/\Q$CONTENT{$author}\E/; + } $response->content($CONTENT{$author}); } else { $response->code(404); From des at projects.linpro.no Fri Oct 19 09:35:09 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 11:35:09 +0200 (CEST) Subject: r2128 - trunk/varnish-tools/regress/lib/Varnish/Test/Case Message-ID: <20071019093509.708401EC21C@projects.linpro.no> Author: des Date: 2007-10-19 11:35:09 +0200 (Fri, 19 Oct 2007) New Revision: 2128 Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm Log: The framework bugs which used to affect this test case have long since been fixed, so remove the workarounds. Also stop testing things which are not intended to work. Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-19 09:09:42 UTC (rev 2127) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/POST.pm 2007-10-19 09:35:09 UTC (rev 2128) @@ -36,15 +36,6 @@ our $DESCR = "Tests Varnish's ability to correctly pass POST requests" . " to the backend, and their replies back to the client."; -# testCachePOST and testPassPOST are known to fail, and it is not -# clear at this point whether that is a bug or a feature. -# -# More interestingly, if you run testPassPOST before testPipePOST, the -# latter receives the Varnish Guru Meditation intended for the former. -# This seems to be a bug in either IO::Multiplex or Varnish::Test. -# -our @TESTS = qw(testPipePOST testCachePOST testPassPOST); - our $VCL = <uri =~ m/cache_me/); die "Got GET request instead of POST\n"; } From des at projects.linpro.no Fri Oct 19 09:46:58 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 11:46:58 +0200 (CEST) Subject: r2129 - trunk/varnish-tools/regress/lib/Varnish/Test/Case Message-ID: <20071019094658.6A9941EC21D@projects.linpro.no> Author: des Date: 2007-10-19 11:46:58 +0200 (Fri, 19 Oct 2007) New Revision: 2129 Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm Log: When testing pipelined POST requests, send enough data to actually exercise request copying loop. Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm 2007-10-19 09:35:09 UTC (rev 2128) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm 2007-10-19 09:46:58 UTC (rev 2129) @@ -41,6 +41,8 @@ 'Williams' => "I have always depended upon the kindness of strangers.", ); +our $REPS = 4096; + our $VCL = <new_client; foreach my $author (sort keys %CONTENT) { - $self->post($client, "/$author", [], $CONTENT{$author}); + $self->post($client, "/$author", [], $CONTENT{$author} x $REPS); } foreach my $author (sort keys %CONTENT) { $self->wait(); @@ -89,7 +91,7 @@ my ($author) = ($request->uri =~ m/(\w+)$/); if ($CONTENT{$author}) { if ($request->method eq 'POST') { - die unless $request->content =~ qr/\Q$CONTENT{$author}\E/; + die unless $request->content eq $CONTENT{$author} x $REPS; } $response->content($CONTENT{$author}); } else { From des at projects.linpro.no Fri Oct 19 09:47:53 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 11:47:53 +0200 (CEST) Subject: r2130 - trunk/varnish-cache/bin/varnishd Message-ID: <20071019094753.35EF91EC21C@projects.linpro.no> Author: des Date: 2007-10-19 11:47:53 +0200 (Fri, 19 Oct 2007) New Revision: 2130 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Use an 8 kB stack buffer instead of a heap buffer. Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 09:46:58 UTC (rev 2129) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-19 09:47:53 UTC (rev 2130) @@ -260,10 +260,8 @@ struct bereq *bereq; int mklen, is_head; struct http_conn htc[1]; - unsigned long content_length; - int i, read; + int i; char *ptr, *endp; - char *p = NULL; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); @@ -296,21 +294,26 @@ * pipelined bytes to the backend as well */ if (http_GetHdr(sp->http, H_Content_Length, &ptr)) { + unsigned long content_length; + char buf[8192]; + int read; + content_length = strtoul(ptr, &endp, 10); /* XXX should check result of conversion */ - p = malloc(content_length); while (content_length) { - read = HTC_Read(sp->htc, p, content_length); - WRK_Write(w, p, read); + if (content_length > sizeof buf) + read = sizeof buf; + else + read = content_length; + read = HTC_Read(sp->htc, buf, read); + WRK_Write(w, buf, read); if (WRK_Flush(w)) { VBE_UpdateHealth(sp, vc, -1); VBE_ClosedFd(sp->wrk, vc); - free(p); return (__LINE__); } content_length -= read; } - free(p); } if (WRK_Flush(w)) { From des at projects.linpro.no Fri Oct 19 09:48:35 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 11:48:35 +0200 (CEST) Subject: r2131 - trunk/varnish-tools/regress/lib/Varnish/Test/Case Message-ID: <20071019094835.646221EC21C@projects.linpro.no> Author: des Date: 2007-10-19 11:48:35 +0200 (Fri, 19 Oct 2007) New Revision: 2131 Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm Log: Add error message. Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm 2007-10-19 09:47:53 UTC (rev 2130) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/Pipeline.pm 2007-10-19 09:48:35 UTC (rev 2131) @@ -91,7 +91,8 @@ my ($author) = ($request->uri =~ m/(\w+)$/); if ($CONTENT{$author}) { if ($request->method eq 'POST') { - die unless $request->content eq $CONTENT{$author} x $REPS; + die "Not the content I expected\n" + unless $request->content eq $CONTENT{$author} x $REPS; } $response->content($CONTENT{$author}); } else { From des at projects.linpro.no Fri Oct 19 10:00:20 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 12:00:20 +0200 (CEST) Subject: r2132 - in branches/1.2: . bin/varnishd Message-ID: <20071019100020.8494F1EC030@projects.linpro.no> Author: des Date: 2007-10-19 12:00:20 +0200 (Fri, 19 Oct 2007) New Revision: 2132 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache.h branches/1.2/bin/varnishd/cache_center.c branches/1.2/bin/varnishd/cache_fetch.c branches/1.2/bin/varnishd/cache_httpconn.c Log: Merged revisions 2115,2117-2120,2122-2130 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2115 | cecilihf | 2007-10-18 15:38:45 +0200 (Thu, 18 Oct 2007) | 3 lines Make pass mode work for POST requests. Solves ticket #47. ........ r2122 | phk | 2007-10-19 10:50:50 +0200 (Fri, 19 Oct 2007) | 3 lines Fix pipelining: don't expect the fd to become readable before we look for complete requests. ........ r2123 | cecilihf | 2007-10-19 10:51:40 +0200 (Fri, 19 Oct 2007) | 2 lines Improved handling of pass for POST requests. ........ r2124 | des | 2007-10-19 10:55:46 +0200 (Fri, 19 Oct 2007) | 2 lines Style & whitespace ........ r2125 | des | 2007-10-19 11:05:10 +0200 (Fri, 19 Oct 2007) | 2 lines Simplify ........ r2126 | des | 2007-10-19 11:09:17 +0200 (Fri, 19 Oct 2007) | 4 lines Move malloc() / free() out of the loop, and plug a leak. Ideally, we shouldn't need to malloc() / free() at all, but I don't have time to figure out how to avoid it right now. ........ r2130 | des | 2007-10-19 11:47:53 +0200 (Fri, 19 Oct 2007) | 2 lines Use an 8 kB stack buffer instead of a heap buffer. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2116 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130 Modified: branches/1.2/bin/varnishd/cache.h =================================================================== --- branches/1.2/bin/varnishd/cache.h 2007-10-19 09:48:35 UTC (rev 2131) +++ branches/1.2/bin/varnishd/cache.h 2007-10-19 10:00:20 UTC (rev 2132) @@ -488,6 +488,7 @@ int HTC_Reinit(struct http_conn *htc); int HTC_Rx(struct http_conn *htc); int HTC_Read(struct http_conn *htc, void *d, unsigned len); +int HTC_Complete(struct http_conn *htc); #define HTTPH(a, b, c, d, e, f, g) extern char b[]; #include "http_headers.h" Modified: branches/1.2/bin/varnishd/cache_center.c =================================================================== --- branches/1.2/bin/varnishd/cache_center.c 2007-10-19 09:48:35 UTC (rev 2131) +++ branches/1.2/bin/varnishd/cache_center.c 2007-10-19 10:00:20 UTC (rev 2132) @@ -89,9 +89,9 @@ assert(sp->xid == 0); - do + i = HTC_Complete(sp->htc); + while (i == 0) i = HTC_Rx(sp->htc); - while (i == 0); if (i == 1) { sp->step = STP_RECV; } else { Modified: branches/1.2/bin/varnishd/cache_fetch.c =================================================================== --- branches/1.2/bin/varnishd/cache_fetch.c 2007-10-19 09:48:35 UTC (rev 2131) +++ branches/1.2/bin/varnishd/cache_fetch.c 2007-10-19 10:00:20 UTC (rev 2132) @@ -261,6 +261,7 @@ int mklen, is_head; struct http_conn htc[1]; int i; + char *ptr, *endp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); @@ -287,6 +288,34 @@ return (__LINE__); WRK_Reset(w, &vc->fd); http_Write(w, hp, 0); + + /* + * If a POST request was passed to fetch, we must send any + * pipelined bytes to the backend as well + */ + if (http_GetHdr(sp->http, H_Content_Length, &ptr)) { + unsigned long content_length; + char buf[8192]; + int read; + + content_length = strtoul(ptr, &endp, 10); + /* XXX should check result of conversion */ + while (content_length) { + if (content_length > sizeof buf) + read = sizeof buf; + else + read = content_length; + read = HTC_Read(sp->htc, buf, read); + WRK_Write(w, buf, read); + if (WRK_Flush(w)) { + VBE_UpdateHealth(sp, vc, -1); + VBE_ClosedFd(sp->wrk, vc); + return (__LINE__); + } + content_length -= read; + } + } + if (WRK_Flush(w)) { VBE_UpdateHealth(sp, vc, -1); VBE_ClosedFd(sp->wrk, vc); Modified: branches/1.2/bin/varnishd/cache_httpconn.c =================================================================== --- branches/1.2/bin/varnishd/cache_httpconn.c 2007-10-19 09:48:35 UTC (rev 2131) +++ branches/1.2/bin/varnishd/cache_httpconn.c 2007-10-19 10:00:20 UTC (rev 2132) @@ -124,6 +124,30 @@ } /*-------------------------------------------------------------------- + * + */ + +int +HTC_Complete(struct http_conn *htc) +{ + int i; + + CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); + i = htc_header_complete(&htc->rxbuf); + if (i < 0) + htc->rxbuf.e = htc->rxbuf.b; + if (i <= 0) + return (0); + WS_ReleaseP(htc->ws, htc->rxbuf.e); + if (htc->rxbuf.b + i < htc->rxbuf.e) { + htc->pipeline.b = htc->rxbuf.b + i; + htc->pipeline.e = htc->rxbuf.e; + htc->rxbuf.e = htc->pipeline.b; + } + return (1); +} + +/*-------------------------------------------------------------------- * Receive more HTTP protocol bytes * Returns: * -2 overflow @@ -151,18 +175,7 @@ } htc->rxbuf.e += i; *htc->rxbuf.e = '\0'; - i = htc_header_complete(&htc->rxbuf); - if (i < 0) - htc->rxbuf.e = htc->rxbuf.b; - if (i <= 0) - return (0); - WS_ReleaseP(htc->ws, htc->rxbuf.e); - if (htc->rxbuf.b + i < htc->rxbuf.e) { - htc->pipeline.b = htc->rxbuf.b + i; - htc->pipeline.e = htc->rxbuf.e; - htc->rxbuf.e = htc->pipeline.b; - } - return (1); + return (HTC_Complete(htc)); } int From des at projects.linpro.no Fri Oct 19 11:18:49 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:18:49 +0200 (CEST) Subject: r2133 - in trunk/varnish-cache: . bin/varnishd Message-ID: <20071019111849.8FAD41EC033@projects.linpro.no> Author: des Date: 2007-10-19 13:18:49 +0200 (Fri, 19 Oct 2007) New Revision: 2133 Modified: trunk/varnish-cache/bin/varnishd/storage_file.c trunk/varnish-cache/configure.ac Log: Re-add Solaris support which was removed in r1465. Modified: trunk/varnish-cache/bin/varnishd/storage_file.c =================================================================== --- trunk/varnish-cache/bin/varnishd/storage_file.c 2007-10-19 10:00:20 UTC (rev 2132) +++ trunk/varnish-cache/bin/varnishd/storage_file.c 2007-10-19 11:18:49 UTC (rev 2133) @@ -41,6 +41,10 @@ #include #endif +#ifdef HAVE_SYS_STATVFS_H +#include +#endif + #ifdef HAVE_SYS_VFS_H #include #endif Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2007-10-19 10:00:20 UTC (rev 2132) +++ trunk/varnish-cache/configure.ac 2007-10-19 11:18:49 UTC (rev 2133) @@ -67,6 +67,7 @@ AC_HEADER_TIME AC_CHECK_HEADERS([sys/socket.h]) AC_CHECK_HEADERS([sys/mount.h]) +AC_CHECK_HEADERS([sys/statvfs.h]) AC_CHECK_HEADERS([sys/vfs.h]) AC_CHECK_HEADERS([netinet/in.h]) AC_CHECK_HEADERS([stddef.h]) From des at projects.linpro.no Fri Oct 19 11:19:12 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:19:12 +0200 (CEST) Subject: r2134 - in branches/1.2: . bin/varnishd Message-ID: <20071019111912.E52A91EC030@projects.linpro.no> Author: des Date: 2007-10-19 13:19:12 +0200 (Fri, 19 Oct 2007) New Revision: 2134 Modified: branches/1.2/ branches/1.2/bin/varnishd/storage_file.c branches/1.2/configure.ac Log: Merged revisions 2133 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2133 | des | 2007-10-19 13:18:49 +0200 (Fri, 19 Oct 2007) | 2 lines Re-add Solaris support which was removed in r1465. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133 Modified: branches/1.2/bin/varnishd/storage_file.c =================================================================== --- branches/1.2/bin/varnishd/storage_file.c 2007-10-19 11:18:49 UTC (rev 2133) +++ branches/1.2/bin/varnishd/storage_file.c 2007-10-19 11:19:12 UTC (rev 2134) @@ -41,6 +41,10 @@ #include #endif +#ifdef HAVE_SYS_STATVFS_H +#include +#endif + #ifdef HAVE_SYS_VFS_H #include #endif Modified: branches/1.2/configure.ac =================================================================== --- branches/1.2/configure.ac 2007-10-19 11:18:49 UTC (rev 2133) +++ branches/1.2/configure.ac 2007-10-19 11:19:12 UTC (rev 2134) @@ -67,6 +67,7 @@ AC_HEADER_TIME AC_CHECK_HEADERS([sys/socket.h]) AC_CHECK_HEADERS([sys/mount.h]) +AC_CHECK_HEADERS([sys/statvfs.h]) AC_CHECK_HEADERS([sys/vfs.h]) AC_CHECK_HEADERS([netinet/in.h]) AC_CHECK_HEADERS([stddef.h]) From des at projects.linpro.no Fri Oct 19 11:19:21 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:19:21 +0200 (CEST) Subject: r2135 - in branches/1.1: . bin/varnishd Message-ID: <20071019111921.BA8421EC033@projects.linpro.no> Author: des Date: 2007-10-19 13:19:21 +0200 (Fri, 19 Oct 2007) New Revision: 2135 Modified: branches/1.1/ branches/1.1/bin/varnishd/storage_file.c branches/1.1/configure.ac Log: Merged revisions 2133 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2133 | des | 2007-10-19 13:18:49 +0200 (Fri, 19 Oct 2007) | 2 lines Re-add Solaris support which was removed in r1465. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033 + /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033,2133 Modified: branches/1.1/bin/varnishd/storage_file.c =================================================================== --- branches/1.1/bin/varnishd/storage_file.c 2007-10-19 11:19:12 UTC (rev 2134) +++ branches/1.1/bin/varnishd/storage_file.c 2007-10-19 11:19:21 UTC (rev 2135) @@ -41,6 +41,10 @@ #include #endif +#ifdef HAVE_SYS_STATVFS_H +#include +#endif + #ifdef HAVE_SYS_VFS_H #include #endif Modified: branches/1.1/configure.ac =================================================================== --- branches/1.1/configure.ac 2007-10-19 11:19:12 UTC (rev 2134) +++ branches/1.1/configure.ac 2007-10-19 11:19:21 UTC (rev 2135) @@ -67,6 +67,7 @@ AC_HEADER_TIME AC_CHECK_HEADERS([sys/socket.h]) AC_CHECK_HEADERS([sys/mount.h]) +AC_CHECK_HEADERS([sys/statvfs.h]) AC_CHECK_HEADERS([sys/vfs.h]) AC_CHECK_HEADERS([netinet/in.h]) AC_CHECK_HEADERS([stddef.h]) From des at projects.linpro.no Fri Oct 19 11:20:15 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:20:15 +0200 (CEST) Subject: r2136 - in branches/1.1: . bin/varnishd Message-ID: <20071019112015.98D7F1EC030@projects.linpro.no> Author: des Date: 2007-10-19 13:20:15 +0200 (Fri, 19 Oct 2007) New Revision: 2136 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache.h Log: Merged revisions 1733 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r1733 | des | 2007-07-20 12:14:43 +0200 (Fri, 20 Jul 2007) | 2 lines Style nit. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033,2133 Modified: branches/1.1/bin/varnishd/cache.h =================================================================== --- branches/1.1/bin/varnishd/cache.h 2007-10-19 11:19:21 UTC (rev 2135) +++ branches/1.1/bin/varnishd/cache.h 2007-10-19 11:20:15 UTC (rev 2136) @@ -96,8 +96,6 @@ void WS_Reset(struct ws *ws); char *WS_Alloc(struct ws *ws, unsigned bytes); - - /*-------------------------------------------------------------------- * HTTP Request/Response/Header handling structure. */ From des at projects.linpro.no Fri Oct 19 11:21:06 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:21:06 +0200 (CEST) Subject: r2137 - in branches/1.1: . bin/varnishd Message-ID: <20071019112106.B6C1F1EC475@projects.linpro.no> Author: des Date: 2007-10-19 13:21:06 +0200 (Fri, 19 Oct 2007) New Revision: 2137 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache_backend.c Log: Merged revisions 1809 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r1809 | phk | 2007-08-07 12:27:34 +0200 (Tue, 07 Aug 2007) | 7 lines Minimize a race when looking up addresses for backends. The race is not closed however, proper locking needs to be thought out. An XXX comment documents this for now. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033,2133 Modified: branches/1.1/bin/varnishd/cache_backend.c =================================================================== --- branches/1.1/bin/varnishd/cache_backend.c 2007-10-19 11:20:15 UTC (rev 2136) +++ branches/1.1/bin/varnishd/cache_backend.c 2007-10-19 11:21:06 UTC (rev 2137) @@ -116,20 +116,20 @@ return (vbc); } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * XXX: There is a race here, we need to lock the replacement of the + * XXX: resolved addresses, or some other thread might try to access + * XXX: them while/during/after we changed them. + * XXX: preferably, we should make a copy to the vbe while we hold a + * XXX: lock anyway. + */ static void vbe_lookup(struct backend *bp) { - struct addrinfo *res, hint; + struct addrinfo *res, hint, *old; int error; - if (bp->addr != NULL) { - freeaddrinfo(bp->addr); - bp->addr = NULL; - bp->last_addr = NULL; - } - memset(&hint, 0, sizeof hint); hint.ai_family = PF_UNSPEC; hint.ai_socktype = SOCK_STREAM; @@ -144,8 +144,11 @@ printf("getaddrinfo: %s\n", gai_strerror(error)); /* XXX */ return; } + old = bp->addr; bp->last_addr = res; bp->addr = res; + if (old != NULL) + freeaddrinfo(old); } /*--------------------------------------------------------------------*/ From des at projects.linpro.no Fri Oct 19 11:23:50 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:23:50 +0200 (CEST) Subject: r2138 - in branches/1.1: . bin/varnishd Message-ID: <20071019112350.55BF81EC030@projects.linpro.no> Author: des Date: 2007-10-19 13:23:50 +0200 (Fri, 19 Oct 2007) New Revision: 2138 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache_http.c Log: Merged revisions 1888 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r1888 | phk | 2007-08-20 13:05:07 +0200 (Mon, 20 Aug 2007) | 8 lines Fix a long-standing bug in pipe-mode: We must pass the protocol version across unchanged, otherwise the semantics of the Connection: header cannot be interpreted correctly by the server. wget(1) could trigger this problem and would have to wait for the server to close the (seemingly idle) connection before continuing. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033,2133 Modified: branches/1.1/bin/varnishd/cache_http.c =================================================================== --- branches/1.1/bin/varnishd/cache_http.c 2007-10-19 11:21:06 UTC (rev 2137) +++ branches/1.1/bin/varnishd/cache_http.c 2007-10-19 11:23:50 UTC (rev 2138) @@ -715,17 +715,20 @@ } static void -http_copyreq(struct http *to, struct http *fm, int forceget) +http_copyreq(struct http *to, struct http *fm, int transparent) { CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); - if (forceget) + if (transparent) + http_copyh(to, fm, HTTP_HDR_REQ); + else http_SetH(to, HTTP_HDR_REQ, "GET"); + http_copyh(to, fm, HTTP_HDR_URL); + if (transparent) + http_copyh(to, fm, HTTP_HDR_PROTO); else - http_copyh(to, fm, HTTP_HDR_REQ); - http_copyh(to, fm, HTTP_HDR_URL); - http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1"); + http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1"); } void From des at projects.linpro.no Fri Oct 19 11:29:01 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:29:01 +0200 (CEST) Subject: r2139 - in branches/1.1: . bin/varnishd Message-ID: <20071019112901.892EB1EC033@projects.linpro.no> Author: des Date: 2007-10-19 13:29:01 +0200 (Fri, 19 Oct 2007) New Revision: 2139 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache_vrt.c Log: Merged revisions 2026 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2026 | phk | 2007-09-25 09:32:15 +0200 (Tue, 25 Sep 2007) | 2 lines Bail if we get unknown address families ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2032-2033,2133 Modified: branches/1.1/bin/varnishd/cache_vrt.c =================================================================== --- branches/1.1/bin/varnishd/cache_vrt.c 2007-10-19 11:23:50 UTC (rev 2138) +++ branches/1.1/bin/varnishd/cache_vrt.c 2007-10-19 11:29:01 UTC (rev 2139) @@ -513,6 +513,8 @@ case AF_INET6: len = sizeof(struct sockaddr_in6); break; + default: + INCOMPL(); } XXXAN(len); TCP_name(sa, len, h, sizeof h, p, sizeof p); From des at projects.linpro.no Fri Oct 19 11:29:31 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:29:31 +0200 (CEST) Subject: r2140 - branches/1.1 Message-ID: <20071019112931.383FF1EC030@projects.linpro.no> Author: des Date: 2007-10-19 13:29:31 +0200 (Fri, 19 Oct 2007) New Revision: 2140 Modified: branches/1.1/ branches/1.1/autogen.des Log: Merged revisions 2031 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2031 | des | 2007-09-25 10:19:50 +0200 (Tue, 25 Sep 2007) | 2 lines Use a config cache. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2032-2033,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2133 Modified: branches/1.1/autogen.des =================================================================== --- branches/1.1/autogen.des 2007-10-19 11:29:01 UTC (rev 2139) +++ branches/1.1/autogen.des 2007-10-19 11:29:31 UTC (rev 2140) @@ -11,6 +11,7 @@ export CONFIG_SHELL=/bin/sh ./configure \ + --config-cache \ --enable-developer-warnings \ --enable-debugging-symbols \ --enable-dependency-tracking \ From des at projects.linpro.no Fri Oct 19 11:32:49 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:32:49 +0200 (CEST) Subject: r2141 - in branches/1.1: . debian Message-ID: <20071019113249.DFCA31EC033@projects.linpro.no> Author: des Date: 2007-10-19 13:32:49 +0200 (Fri, 19 Oct 2007) New Revision: 2141 Modified: branches/1.1/ branches/1.1/debian/varnish.postinst Log: Merged revisions 2078 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2078 | ssm | 2007-10-05 11:15:09 +0200 (Fri, 05 Oct 2007) | 1 line Fix ticket #166, debian package issues ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078,2133 Modified: branches/1.1/debian/varnish.postinst =================================================================== --- branches/1.1/debian/varnish.postinst 2007-10-19 11:29:31 UTC (rev 2140) +++ branches/1.1/debian/varnish.postinst 2007-10-19 11:32:49 UTC (rev 2141) @@ -5,8 +5,12 @@ adduser --system --no-create-home --group varnish 2>&1 > /dev/null || exit 78 fi } +varnish_create_storagedir() { + install -o varnish -g varnish -d /var/lib/varnish/$(uname -n) || exit 78 +} varnish_setup_user +varnish_create_storagedir #DEBHELPER# # Automatically added by dh_installinit @@ -19,13 +23,3 @@ fi fi # End automatically added section -# Automatically added by dh_installinit -if [ -x "/etc/init.d/varnishlog" ]; then - update-rc.d varnishlog defaults >/dev/null - if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then - invoke-rc.d varnishlog start || exit $? - else - /etc/init.d/varnishlog start || exit $? - fi -fi -# End automatically added section From des at projects.linpro.no Fri Oct 19 11:33:23 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:33:23 +0200 (CEST) Subject: r2142 - in branches/1.1: . bin/varnishd Message-ID: <20071019113323.E1FCF1EC033@projects.linpro.no> Author: des Date: 2007-10-19 13:33:23 +0200 (Fri, 19 Oct 2007) New Revision: 2142 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache_synthetic.c Log: Merged revisions 2079 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2079 | phk | 2007-10-08 09:18:48 +0200 (Mon, 08 Oct 2007) | 4 lines Flush the threads shmlog before we try to make up a reponse, so that we know what transactions trigger problems in that code. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2133 Modified: branches/1.1/bin/varnishd/cache_synthetic.c =================================================================== --- branches/1.1/bin/varnishd/cache_synthetic.c 2007-10-19 11:32:49 UTC (rev 2141) +++ branches/1.1/bin/varnishd/cache_synthetic.c 2007-10-19 11:33:23 UTC (rev 2142) @@ -55,6 +55,7 @@ double now; int fd; + WSL_Flush(sp->wrk); assert(status >= 100 && status <= 999); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); From des at projects.linpro.no Fri Oct 19 11:35:48 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:35:48 +0200 (CEST) Subject: r2143 - in branches/1.1: . bin/varnishd Message-ID: <20071019113548.670F21EC030@projects.linpro.no> Author: des Date: 2007-10-19 13:35:48 +0200 (Fri, 19 Oct 2007) New Revision: 2143 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache_acceptor_kqueue.c Log: Merged revisions 2088 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2088 | phk | 2007-10-08 13:28:11 +0200 (Mon, 08 Oct 2007) | 2 lines Add an assert for spotting ticket #162 ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2133 Modified: branches/1.1/bin/varnishd/cache_acceptor_kqueue.c =================================================================== --- branches/1.1/bin/varnishd/cache_acceptor_kqueue.c 2007-10-19 11:33:23 UTC (rev 2142) +++ branches/1.1/bin/varnishd/cache_acceptor_kqueue.c 2007-10-19 11:35:48 UTC (rev 2143) @@ -88,6 +88,7 @@ while (i >= sizeof ss[0]) { CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC); assert(ss[j]->fd >= 0); + AZ(ss[j]->obj); VTAILQ_INSERT_TAIL(&sesshead, ss[j], list); vca_kq_sess(ss[j], EV_ADD); j++; From des at projects.linpro.no Fri Oct 19 11:35:55 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:35:55 +0200 (CEST) Subject: r2144 - branches/1.1 Message-ID: <20071019113555.140C63BC007@projects.linpro.no> Author: des Date: 2007-10-19 13:35:54 +0200 (Fri, 19 Oct 2007) New Revision: 2144 Modified: branches/1.1/ branches/1.1/configure.ac Log: Merged revisions 2097 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2097 | des | 2007-10-10 15:23:15 +0200 (Wed, 10 Oct 2007) | 2 lines Fix braino in Solaris compat bit. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2097,2133 Modified: branches/1.1/configure.ac =================================================================== --- branches/1.1/configure.ac 2007-10-19 11:35:48 UTC (rev 2143) +++ branches/1.1/configure.ac 2007-10-19 11:35:54 UTC (rev 2144) @@ -53,7 +53,7 @@ save_LIBS="${LIBS}" LIBS="" AC_CHECK_LIB(socket, socket) -AC_CHECK_LIB(getaddrinfo, ns) +AC_CHECK_LIB(nsl, getaddrinfo) NET_LIBS="${LIBS}" LIBS="${save_LIBS}" AC_SUBST(NET_LIBS) From des at projects.linpro.no Fri Oct 19 11:36:22 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:36:22 +0200 (CEST) Subject: r2145 - in branches/1.1: . include include/compat lib/libvarnishcompat Message-ID: <20071019113622.CEA631EC403@projects.linpro.no> Author: des Date: 2007-10-19 13:36:22 +0200 (Fri, 19 Oct 2007) New Revision: 2145 Added: branches/1.1/include/compat/daemon.h branches/1.1/lib/libvarnishcompat/daemon.c Modified: branches/1.1/ branches/1.1/include/Makefile.am branches/1.1/lib/libvarnishcompat/Makefile.am Log: Merged revisions 2106 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2106 | des | 2007-10-16 16:12:23 +0200 (Tue, 16 Oct 2007) | 2 lines Pull in FreeBSD's daemon(3) for platforms that lack it. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2097,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2097,2106,2133 Modified: branches/1.1/include/Makefile.am =================================================================== --- branches/1.1/include/Makefile.am 2007-10-19 11:35:54 UTC (rev 2144) +++ branches/1.1/include/Makefile.am 2007-10-19 11:36:22 UTC (rev 2145) @@ -7,12 +7,13 @@ stats.h \ varnishapi.h -noinst_HEADERS = \ +nobase_noinst_HEADERS = \ binary_heap.h \ cli.h \ cli_common.h \ cli_priv.h \ compat/asprintf.h \ + compat/daemon.h \ compat/setproctitle.h \ compat/srandomdev.h \ compat/strlcat.h \ Copied: branches/1.1/include/compat/daemon.h (from rev 2106, trunk/varnish-cache/include/compat/daemon.h) =================================================================== --- branches/1.1/include/compat/daemon.h (rev 0) +++ branches/1.1/include/compat/daemon.h 2007-10-19 11:36:22 UTC (rev 2145) @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2007 Linpro AS + * All rights reserved. + * + * Author: Dag-Erling Sm?rgrav + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#ifndef COMPAT_DAEMON_H_INCLUDED +#define COMPAT_DAEMON_H_INCLUDED + +#ifndef HAVE_DAEMON +int daemon(int nochdir, int noclose); +#endif + +#endif Modified: branches/1.1/lib/libvarnishcompat/Makefile.am =================================================================== --- branches/1.1/lib/libvarnishcompat/Makefile.am 2007-10-19 11:35:54 UTC (rev 2144) +++ branches/1.1/lib/libvarnishcompat/Makefile.am 2007-10-19 11:36:22 UTC (rev 2145) @@ -6,6 +6,7 @@ libvarnishcompat_la_SOURCES = \ asprintf.c \ + daemon.c \ vasprintf.c \ setproctitle.c \ srandomdev.c \ Copied: branches/1.1/lib/libvarnishcompat/daemon.c (from rev 2106, trunk/varnish-cache/lib/libvarnishcompat/daemon.c) =================================================================== --- branches/1.1/lib/libvarnishcompat/daemon.c (rev 0) +++ branches/1.1/lib/libvarnishcompat/daemon.c 2007-10-19 11:36:22 UTC (rev 2145) @@ -0,0 +1,92 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + * Derived from: + * $FreeBSD: src/lib/libc/gen/daemon.c,v 1.8 2007/01/09 00:27:53 imp Exp $ + */ + +#ifndef HAVE_DAEMON + +#include +#include +#include +#include +#include +#include + +#include "compat/daemon.h" + +int +daemon(int nochdir, int noclose) +{ + struct sigaction osa, sa; + int fd; + pid_t newgrp; + int oerrno; + int osa_ok; + + /* A SIGHUP may be thrown when the parent exits below. */ + sigemptyset(&sa.sa_mask); + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + osa_ok = sigaction(SIGHUP, &sa, &osa); + + switch (fork()) { + case -1: + return (-1); + case 0: + break; + default: + exit(0); + } + + newgrp = setsid(); + oerrno = errno; + if (osa_ok != -1) + sigaction(SIGHUP, &osa, NULL); + + if (newgrp == -1) { + errno = oerrno; + return (-1); + } + + if (!nochdir) + (void)chdir("/"); + + if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { + (void)dup2(fd, STDIN_FILENO); + (void)dup2(fd, STDOUT_FILENO); + (void)dup2(fd, STDERR_FILENO); + if (fd > 2) + (void)close(fd); + } + return (0); +} + +#endif From des at projects.linpro.no Fri Oct 19 11:36:36 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:36:36 +0200 (CEST) Subject: r2146 - in branches/1.1: . lib/libvarnish Message-ID: <20071019113636.29EAD3BC322@projects.linpro.no> Author: des Date: 2007-10-19 13:36:35 +0200 (Fri, 19 Oct 2007) New Revision: 2146 Modified: branches/1.1/ branches/1.1/lib/libvarnish/assert.c branches/1.1/lib/libvarnish/binary_heap.c branches/1.1/lib/libvarnish/crc32.c branches/1.1/lib/libvarnish/vss.c Log: Merged revisions 2107 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2107 | des | 2007-10-16 16:15:54 +0200 (Tue, 16 Oct 2007) | 2 lines Whitespace cleanup. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2097,2106,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2097,2106-2107,2133 Modified: branches/1.1/lib/libvarnish/assert.c =================================================================== --- branches/1.1/lib/libvarnish/assert.c 2007-10-19 11:36:22 UTC (rev 2145) +++ branches/1.1/lib/libvarnish/assert.c 2007-10-19 11:36:35 UTC (rev 2146) @@ -57,4 +57,3 @@ " errno = %d (%s)\n", func, file, line, cond, err, strerror(err)); abort(); } - Modified: branches/1.1/lib/libvarnish/binary_heap.c =================================================================== --- branches/1.1/lib/libvarnish/binary_heap.c 2007-10-19 11:36:22 UTC (rev 2145) +++ branches/1.1/lib/libvarnish/binary_heap.c 2007-10-19 11:36:35 UTC (rev 2146) @@ -298,7 +298,7 @@ #else struct foo { - unsigned idx; + unsigned idx; unsigned key; }; Modified: branches/1.1/lib/libvarnish/crc32.c =================================================================== --- branches/1.1/lib/libvarnish/crc32.c 2007-10-19 11:36:22 UTC (rev 2145) +++ branches/1.1/lib/libvarnish/crc32.c 2007-10-19 11:36:35 UTC (rev 2146) @@ -99,4 +99,3 @@ crc = crc32(~0U, p1, l); return (crc ^ ~0U); } - Modified: branches/1.1/lib/libvarnish/vss.c =================================================================== --- branches/1.1/lib/libvarnish/vss.c 2007-10-19 11:36:22 UTC (rev 2145) +++ branches/1.1/lib/libvarnish/vss.c 2007-10-19 11:36:35 UTC (rev 2146) @@ -127,14 +127,14 @@ struct vss_addr **va; int i, ret; - memset(&hints, 0, sizeof hints); - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; - ret = getaddrinfo(addr, port, &hints, &res0); - if (ret != 0) { - fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(ret)); - return (0); - } + memset(&hints, 0, sizeof hints); + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_PASSIVE; + ret = getaddrinfo(addr, port, &hints, &res0); + if (ret != 0) { + fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(ret)); + return (0); + } for (res = res0, i = 0; res != NULL; res = res->ai_next) ++i; va = calloc(i, sizeof *va); From des at projects.linpro.no Fri Oct 19 11:42:26 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:42:26 +0200 (CEST) Subject: r2147 - in branches/1.1: . bin/varnishd Message-ID: <20071019114226.D05F01EC5D8@projects.linpro.no> Author: des Date: 2007-10-19 13:42:26 +0200 (Fri, 19 Oct 2007) New Revision: 2147 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache.h branches/1.1/bin/varnishd/cache_backend.c branches/1.1/bin/varnishd/cache_fetch.c branches/1.1/bin/varnishd/cache_pipe.c Log: Merged revisions 1889 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r1889 | phk | 2007-08-20 13:05:48 +0200 (Mon, 20 Aug 2007) | 3 lines Remove the unnecessary third argument to VBE_ClosedFd() and remove a couple of now pointless debugging messages in pipe mode. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2097,2106-2107,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2097,2106-2107,2133 Modified: branches/1.1/bin/varnishd/cache.h =================================================================== --- branches/1.1/bin/varnishd/cache.h 2007-10-19 11:36:35 UTC (rev 2146) +++ branches/1.1/bin/varnishd/cache.h 2007-10-19 11:42:26 UTC (rev 2147) @@ -368,7 +368,7 @@ /* cache_backend.c */ void VBE_Init(void); struct vbe_conn *VBE_GetFd(struct sess *sp); -void VBE_ClosedFd(struct worker *w, struct vbe_conn *vc, int already); +void VBE_ClosedFd(struct worker *w, struct vbe_conn *vc); void VBE_RecycleFd(struct worker *w, struct vbe_conn *vc); struct bereq *vbe_new_bereq(void); void vbe_free_bereq(struct bereq *bereq); Modified: branches/1.1/bin/varnishd/cache_backend.c =================================================================== --- branches/1.1/bin/varnishd/cache_backend.c 2007-10-19 11:36:35 UTC (rev 2146) +++ branches/1.1/bin/varnishd/cache_backend.c 2007-10-19 11:42:26 UTC (rev 2147) @@ -284,7 +284,7 @@ reuse = 1; break; } - VBE_ClosedFd(sp->wrk, vc, 0); + VBE_ClosedFd(sp->wrk, vc); } if (vc == NULL) { @@ -346,15 +346,14 @@ /* Close a connection ------------------------------------------------*/ void -VBE_ClosedFd(struct worker *w, struct vbe_conn *vc, int already) +VBE_ClosedFd(struct worker *w, struct vbe_conn *vc) { CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); assert(vc->fd >= 0); AN(vc->backend); WSL(w, SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name); - if (!already) - AZ(close(vc->fd)); + AZ(close(vc->fd)); vc->fd = -1; vc->backend = NULL; LOCK(&vbemtx); Modified: branches/1.1/bin/varnishd/cache_fetch.c =================================================================== --- branches/1.1/bin/varnishd/cache_fetch.c 2007-10-19 11:36:35 UTC (rev 2146) +++ branches/1.1/bin/varnishd/cache_fetch.c 2007-10-19 11:42:26 UTC (rev 2147) @@ -341,7 +341,7 @@ } else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) { /* XXX: AUGH! */ VSL(SLT_Debug, vc->fd, "Invalid Transfer-Encoding"); - VBE_ClosedFd(sp->wrk, vc, 0); + VBE_ClosedFd(sp->wrk, vc); return (-1); } else if (strcmp(http_GetProto(hp), "HTTP/1.1")) { switch (http_GetStatus(hp)) { @@ -364,7 +364,7 @@ VTAILQ_REMOVE(&sp->obj->store, st, list); STV_free(st); } - VBE_ClosedFd(sp->wrk, vc, 0); + VBE_ClosedFd(sp->wrk, vc); return (-1); } @@ -382,7 +382,7 @@ cls = 1; if (cls) - VBE_ClosedFd(sp->wrk, vc, 0); + VBE_ClosedFd(sp->wrk, vc); else VBE_RecycleFd(sp->wrk, vc); Modified: branches/1.1/bin/varnishd/cache_pipe.c =================================================================== --- branches/1.1/bin/varnishd/cache_pipe.c 2007-10-19 11:36:35 UTC (rev 2146) +++ branches/1.1/bin/varnishd/cache_pipe.c 2007-10-19 11:42:26 UTC (rev 2147) @@ -50,8 +50,6 @@ i = read(fds[idx].fd, buf, sizeof buf); if (i <= 0 || fds[1-idx].events == 0) { - VSL(SLT_Debug, fds[idx].fd, "Pipe Shut read(read)"); - VSL(SLT_Debug, fds[1-idx].fd, "Pipe Shut write(read)"); shutdown(fds[idx].fd, SHUT_RD); shutdown(fds[1-idx].fd, SHUT_WR); fds[idx].events = 0; @@ -59,9 +57,7 @@ } for (p = buf; i > 0; i -= j, p += j) { j = write(fds[1-idx].fd, p, i); - if (j < 0) { - VSL(SLT_Debug, fds[idx].fd, "Pipe Shut write(write)"); - VSL(SLT_Debug, fds[1-idx].fd, "Pipe Shut read(write)"); + if (j != i) { shutdown(fds[idx].fd, SHUT_WR); shutdown(fds[1-idx].fd, SHUT_RD); fds[1-idx].events = 0; @@ -98,7 +94,7 @@ if (WRK_Flush(w)) { vca_close_session(sp, "pipe"); - VBE_ClosedFd(sp->wrk, vc, 0); + VBE_ClosedFd(sp->wrk, vc); return; } @@ -125,6 +121,5 @@ rdf(fds, 1); } vca_close_session(sp, "pipe"); - (void)close (vc->fd); - VBE_ClosedFd(sp->wrk, vc, 1); + VBE_ClosedFd(sp->wrk, vc); } From des at projects.linpro.no Fri Oct 19 11:42:50 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:42:50 +0200 (CEST) Subject: r2148 - branches/1.1/bin/varnishd Message-ID: <20071019114250.6DCFD1EC475@projects.linpro.no> Author: des Date: 2007-10-19 13:42:50 +0200 (Fri, 19 Oct 2007) New Revision: 2148 Modified: branches/1.1/bin/varnishd/cache_pipe.c Log: Partial merge of r2025: Assert return values of system{calls,functions} Modified: branches/1.1/bin/varnishd/cache_pipe.c =================================================================== --- branches/1.1/bin/varnishd/cache_pipe.c 2007-10-19 11:42:26 UTC (rev 2147) +++ branches/1.1/bin/varnishd/cache_pipe.c 2007-10-19 11:42:50 UTC (rev 2148) @@ -50,16 +50,16 @@ i = read(fds[idx].fd, buf, sizeof buf); if (i <= 0 || fds[1-idx].events == 0) { - shutdown(fds[idx].fd, SHUT_RD); - shutdown(fds[1-idx].fd, SHUT_WR); + AZ(shutdown(fds[idx].fd, SHUT_RD)); + AZ(shutdown(fds[1-idx].fd, SHUT_WR)); fds[idx].events = 0; return; } for (p = buf; i > 0; i -= j, p += j) { j = write(fds[1-idx].fd, p, i); if (j != i) { - shutdown(fds[idx].fd, SHUT_WR); - shutdown(fds[1-idx].fd, SHUT_RD); + AZ(shutdown(fds[idx].fd, SHUT_WR)); + AZ(shutdown(fds[1-idx].fd, SHUT_RD)); fds[1-idx].events = 0; return; } From des at projects.linpro.no Fri Oct 19 11:46:03 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 13:46:03 +0200 (CEST) Subject: r2149 - in branches/1.1: . bin/varnishd Message-ID: <20071019114603.7C0911EC5D8@projects.linpro.no> Author: des Date: 2007-10-19 13:46:03 +0200 (Fri, 19 Oct 2007) New Revision: 2149 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache_pipe.c Log: Merged revisions 2057,2077,2080,2086 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2057 | phk | 2007-09-30 21:42:08 +0200 (Sun, 30 Sep 2007) | 3 lines Set the poll'ed fd to -1 when we halfclose the fd to avoid an infinite loop on certain OS's. ........ r2077 | phk | 2007-10-01 14:44:19 +0200 (Mon, 01 Oct 2007) | 3 lines Go over pipe's polling code and try to do it right in one go by actually paying attention to what goes on. ........ r2080 | phk | 2007-10-08 09:19:52 +0200 (Mon, 08 Oct 2007) | 2 lines Try to make the pipe code even more robust ........ r2086 | phk | 2007-10-08 12:25:47 +0200 (Mon, 08 Oct 2007) | 3 lines Drop the asserts around shutdown(2), there are a number of legitimate error conditions. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2078-2079,2088,2097,2106-2107,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2133 Modified: branches/1.1/bin/varnishd/cache_pipe.c =================================================================== --- branches/1.1/bin/varnishd/cache_pipe.c 2007-10-19 11:42:50 UTC (rev 2148) +++ branches/1.1/bin/varnishd/cache_pipe.c 2007-10-19 11:46:03 UTC (rev 2149) @@ -42,28 +42,25 @@ #include "heritage.h" #include "cache.h" -static void -rdf(struct pollfd *fds, int idx) +static int +rdf(int fd0, int fd1) { int i, j; char buf[BUFSIZ], *p; - i = read(fds[idx].fd, buf, sizeof buf); - if (i <= 0 || fds[1-idx].events == 0) { - AZ(shutdown(fds[idx].fd, SHUT_RD)); - AZ(shutdown(fds[1-idx].fd, SHUT_WR)); - fds[idx].events = 0; - return; - } + i = read(fd0, buf, sizeof buf); + if (i <= 0) + return (1); for (p = buf; i > 0; i -= j, p += j) { - j = write(fds[1-idx].fd, p, i); - if (j != i) { - AZ(shutdown(fds[idx].fd, SHUT_WR)); - AZ(shutdown(fds[1-idx].fd, SHUT_RD)); - fds[1-idx].events = 0; - return; + j = write(fd1, p, i); + if (j <= 0) + return (1); + if (i != j) { + printf("flunk %d %d\n", i, j); + usleep(100000); /* XXX hack */ } } + return (0); } void @@ -109,17 +106,33 @@ fds[1].fd = sp->fd; fds[1].events = POLLIN | POLLERR; - while (fds[0].events || fds[1].events) { + while (fds[0].fd > -1 || fds[1].fd > -1) { fds[0].revents = 0; fds[1].revents = 0; i = poll(fds, 2, params->pipe_timeout * 1000); - if (i != 1) + if (i < 1) break; - if (fds[0].revents) - rdf(fds, 0); - if (fds[1].revents) - rdf(fds, 1); + if (fds[0].revents && rdf(vc->fd, sp->fd)) { + shutdown(vc->fd, SHUT_RD); + shutdown(sp->fd, SHUT_WR); + fds[0].events = 0; + fds[0].fd = -1; + } + if (fds[1].revents && rdf(sp->fd, vc->fd)) { + shutdown(sp->fd, SHUT_RD); + shutdown(vc->fd, SHUT_WR); + fds[1].events = 0; + fds[1].fd = -1; + } } + if (fds[0].fd >= 0) { + shutdown(vc->fd, SHUT_RD); + shutdown(sp->fd, SHUT_WR); + } + if (fds[1].fd >= 0) { + shutdown(sp->fd, SHUT_RD); + shutdown(vc->fd, SHUT_WR); + } vca_close_session(sp, "pipe"); VBE_ClosedFd(sp->wrk, vc); } From des at projects.linpro.no Fri Oct 19 12:01:19 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 14:01:19 +0200 (CEST) Subject: r2150 - in branches/1.1: . bin/varnishd lib/libvarnishapi Message-ID: <20071019120119.BEDFA1EC403@projects.linpro.no> Author: des Date: 2007-10-19 14:01:19 +0200 (Fri, 19 Oct 2007) New Revision: 2150 Modified: branches/1.1/ branches/1.1/bin/varnishd/Makefile.am branches/1.1/configure.ac branches/1.1/lib/libvarnishapi/Makefile.am Log: Merged revisions 2116 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2116 | des | 2007-10-18 17:18:42 +0200 (Thu, 18 Oct 2007) | 2 lines Make VARNISH_STATE_DIR work correctly when using the default prefix. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2116,2133 Modified: branches/1.1/bin/varnishd/Makefile.am =================================================================== --- branches/1.1/bin/varnishd/Makefile.am 2007-10-19 11:46:03 UTC (rev 2149) +++ branches/1.1/bin/varnishd/Makefile.am 2007-10-19 12:01:19 UTC (rev 2150) @@ -60,7 +60,8 @@ steps.h \ stevedore.h -varnishd_CFLAGS = -include config.h +varnishd_CFLAGS = -include config.h \ + -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' varnishd_LDFLAGS = -export-dynamic Modified: branches/1.1/configure.ac =================================================================== --- branches/1.1/configure.ac 2007-10-19 11:46:03 UTC (rev 2149) +++ branches/1.1/configure.ac 2007-10-19 12:01:19 UTC (rev 2150) @@ -115,9 +115,8 @@ AC_CHECK_FUNCS([poll]) # Run-time directory -VARNISH_STATE_DIR=`eval "echo $localstatedir/varnish"` -AC_DEFINE_UNQUOTED(VARNISH_STATE_DIR, "$VARNISH_STATE_DIR", - [Base directory for run-time state]) +VARNISH_STATE_DIR="${localstatedir}/varnish" +AC_SUBST(VARNISH_STATE_DIR) # Now that we're done using the compiler to look for functions and # libraries, set CFLAGS to what we want them to be for our own code Modified: branches/1.1/lib/libvarnishapi/Makefile.am =================================================================== --- branches/1.1/lib/libvarnishapi/Makefile.am 2007-10-19 11:46:03 UTC (rev 2149) +++ branches/1.1/lib/libvarnishapi/Makefile.am 2007-10-19 12:01:19 UTC (rev 2150) @@ -9,4 +9,5 @@ instance.c \ shmlog.c -libvarnishapi_la_CFLAGS = -include config.h +libvarnishapi_la_CFLAGS = -include config.h \ + -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' From des at projects.linpro.no Fri Oct 19 13:49:27 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 15:49:27 +0200 (CEST) Subject: r2151 - trunk/varnish-cache/bin/varnishd Message-ID: <20071019134927.4326C1EC030@projects.linpro.no> Author: des Date: 2007-10-19 15:49:27 +0200 (Fri, 19 Oct 2007) New Revision: 2151 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c Log: Don't try to interpret the status code when we know the response is invalid. Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-19 12:01:19 UTC (rev 2150) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-10-19 13:49:27 UTC (rev 2151) @@ -503,8 +503,9 @@ if (i != 0 || memcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.", 7)) WSLR(w, SLT_HttpGarbage, htc->fd, htc->rxbuf); - if (i != 0 && hp->status == 0) { - hp->status = i; + if (i != 0) { + if (hp->status == 0) + hp->status = i; } else { hp->status = strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10); From des at projects.linpro.no Fri Oct 19 13:49:43 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 15:49:43 +0200 (CEST) Subject: r2152 - in branches/1.2: . bin/varnishd Message-ID: <20071019134943.598171EC403@projects.linpro.no> Author: des Date: 2007-10-19 15:49:43 +0200 (Fri, 19 Oct 2007) New Revision: 2152 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_http.c Log: Merged revisions 2151 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2151 | des | 2007-10-19 15:49:27 +0200 (Fri, 19 Oct 2007) | 2 lines Don't try to interpret the status code when we know the response is invalid. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151 Modified: branches/1.2/bin/varnishd/cache_http.c =================================================================== --- branches/1.2/bin/varnishd/cache_http.c 2007-10-19 13:49:27 UTC (rev 2151) +++ branches/1.2/bin/varnishd/cache_http.c 2007-10-19 13:49:43 UTC (rev 2152) @@ -503,8 +503,9 @@ if (i != 0 || memcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.", 7)) WSLR(w, SLT_HttpGarbage, htc->fd, htc->rxbuf); - if (i != 0 && hp->status == 0) { - hp->status = i; + if (i != 0) { + if (hp->status == 0) + hp->status = i; } else { hp->status = strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10); From des at projects.linpro.no Fri Oct 19 13:58:12 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Fri, 19 Oct 2007 15:58:12 +0200 (CEST) Subject: r2153 - trunk/varnish-cache/bin/varnishd Message-ID: <20071019135812.CE9BB1EC030@projects.linpro.no> Author: des Date: 2007-10-19 15:58:12 +0200 (Fri, 19 Oct 2007) New Revision: 2153 Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c Log: Don't assert that close() returns 0, it won't when the remote end closes the connection first. This fixes #168. Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-10-19 13:49:43 UTC (rev 2152) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-10-19 13:58:12 UTC (rev 2153) @@ -346,10 +346,10 @@ cli_close: vsb_delete(cp->cli->sb); free(cp->buf); - AZ(close(cp->fdi)); + (void)close(cp->fdi); if (cp->fdi == 0) assert(open("/dev/null", O_RDONLY) == 0); - AZ(close(cp->fdo)); + (void)close(cp->fdo); if (cp->fdo == 1) { assert(open("/dev/null", O_WRONLY) == 1); close(2); From des at projects.linpro.no Mon Oct 22 14:37:19 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 22 Oct 2007 16:37:19 +0200 (CEST) Subject: r2154 - trunk/varnish-cache Message-ID: <20071022143719.EF00D1EC033@projects.linpro.no> Author: des Date: 2007-10-22 16:37:19 +0200 (Mon, 22 Oct 2007) New Revision: 2154 Modified: trunk/varnish-cache/configure.ac Log: Evaluate ${localstatedir} later. Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2007-10-19 13:58:12 UTC (rev 2153) +++ trunk/varnish-cache/configure.ac 2007-10-22 14:37:19 UTC (rev 2154) @@ -116,7 +116,7 @@ AC_CHECK_FUNCS([poll]) # Run-time directory -VARNISH_STATE_DIR="${localstatedir}/varnish" +VARNISH_STATE_DIR='${localstatedir}/varnish' AC_SUBST(VARNISH_STATE_DIR) # Now that we're done using the compiler to look for functions and From des at projects.linpro.no Mon Oct 22 14:37:47 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 22 Oct 2007 16:37:47 +0200 (CEST) Subject: r2155 - branches/1.2 Message-ID: <20071022143747.0AA931EC223@projects.linpro.no> Author: des Date: 2007-10-22 16:37:46 +0200 (Mon, 22 Oct 2007) New Revision: 2155 Modified: branches/1.2/ branches/1.2/configure.ac Log: Merged revisions 2154 via svnmerge from file:///var/lib/svn/varnish/trunk/varnish-cache ........ r2154 | des | 2007-10-22 16:37:19 +0200 (Mon, 22 Oct 2007) | 2 lines Evaluate ${localstatedir} later. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2154 Modified: branches/1.2/configure.ac =================================================================== --- branches/1.2/configure.ac 2007-10-22 14:37:19 UTC (rev 2154) +++ branches/1.2/configure.ac 2007-10-22 14:37:46 UTC (rev 2155) @@ -116,7 +116,7 @@ AC_CHECK_FUNCS([poll]) # Run-time directory -VARNISH_STATE_DIR="${localstatedir}/varnish" +VARNISH_STATE_DIR='${localstatedir}/varnish' AC_SUBST(VARNISH_STATE_DIR) # Now that we're done using the compiler to look for functions and From des at projects.linpro.no Mon Oct 22 14:38:03 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 22 Oct 2007 16:38:03 +0200 (CEST) Subject: r2156 - branches/1.1 Message-ID: <20071022143803.C1B601EC6DB@projects.linpro.no> Author: des Date: 2007-10-22 16:38:03 +0200 (Mon, 22 Oct 2007) New Revision: 2156 Modified: branches/1.1/ branches/1.1/configure.ac Log: Merged revisions 2154 via svnmerge from file:///var/lib/svn/varnish/trunk/varnish-cache ........ r2154 | des | 2007-10-22 16:37:19 +0200 (Mon, 22 Oct 2007) | 2 lines Evaluate ${localstatedir} later. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2116,2133 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2116,2133,2154 Modified: branches/1.1/configure.ac =================================================================== --- branches/1.1/configure.ac 2007-10-22 14:37:46 UTC (rev 2155) +++ branches/1.1/configure.ac 2007-10-22 14:38:03 UTC (rev 2156) @@ -115,7 +115,7 @@ AC_CHECK_FUNCS([poll]) # Run-time directory -VARNISH_STATE_DIR="${localstatedir}/varnish" +VARNISH_STATE_DIR='${localstatedir}/varnish' AC_SUBST(VARNISH_STATE_DIR) # Now that we're done using the compiler to look for functions and From phk at projects.linpro.no Tue Oct 23 09:23:04 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 23 Oct 2007 11:23:04 +0200 (CEST) Subject: r2157 - trunk/varnish-cache/bin/varnishd Message-ID: <20071023092304.EB5DC1EC223@projects.linpro.no> Author: phk Date: 2007-10-23 11:23:04 +0200 (Tue, 23 Oct 2007) New Revision: 2157 Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c Log: Quench a pointless sigchild warning Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2007-10-22 14:38:03 UTC (rev 2156) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2007-10-23 09:23:04 UTC (rev 2157) @@ -304,14 +304,10 @@ } ev_poker = NULL; - r = wait4(-1, &status, WNOHANG, NULL); - if (r == 0) + r = wait4(child_pid, &status, WNOHANG, NULL); + if (r == 0 || (r == -1 && errno == ECHILD)) return (0); - if (r != child_pid || r == -1) { - fprintf(stderr, "Unknown child died pid=%d status=0x%x\n", - r, status); - return (0); - } + assert(r == child_pid); fprintf(stderr, "Cache child died pid=%d status=0x%x\n", r, status); child_pid = -1; From des at projects.linpro.no Tue Oct 23 09:34:02 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 23 Oct 2007 11:34:02 +0200 (CEST) Subject: r2158 - branches/1.2/bin/varnishd Message-ID: <20071023093402.2E4701EC223@projects.linpro.no> Author: des Date: 2007-10-23 11:34:01 +0200 (Tue, 23 Oct 2007) New Revision: 2158 Modified: branches/1.2/bin/varnishd/cache_main.c Log: Remove debugging stuff. Modified: branches/1.2/bin/varnishd/cache_main.c =================================================================== --- branches/1.2/bin/varnishd/cache_main.c 2007-10-23 09:23:04 UTC (rev 2157) +++ branches/1.2/bin/varnishd/cache_main.c 2007-10-23 09:34:01 UTC (rev 2158) @@ -51,22 +51,6 @@ setbuf(stderr, NULL); printf("Child starts\n"); -#define SZOF(foo) printf("sizeof(%s) = %zd\n", #foo, sizeof(foo)); - SZOF(struct ws); - SZOF(struct http); - SZOF(struct http_conn); - SZOF(struct acct); - SZOF(struct worker); - SZOF(struct workreq); - SZOF(struct bereq); - SZOF(struct storage); - SZOF(struct object); - SZOF(struct objhead); - SZOF(struct sess); - SZOF(struct vbe_conn); - SZOF(struct backend); - - CNT_Init(); VCL_Init(); From des at projects.linpro.no Tue Oct 23 11:56:56 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 23 Oct 2007 13:56:56 +0200 (CEST) Subject: r2159 - trunk/varnish-tools/regress/lib/Varnish/Test/Case Message-ID: <20071023115656.789481EC030@projects.linpro.no> Author: des Date: 2007-10-23 13:56:56 +0200 (Tue, 23 Oct 2007) New Revision: 2159 Added: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket164.pm Log: Add a test case for the root cause of #164, which is that the backend sends a garbled response (or no response at all). Added: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket164.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket164.pm (rev 0) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket164.pm 2007-10-23 11:56:56 UTC (rev 2159) @@ -0,0 +1,89 @@ +#!/usr/bin/perl -w +#- +# Copyright (c) 2007 Linpro AS +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer +# in this position and unchanged. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $Id$ +# + +package Varnish::Test::Case::Ticket164; + +use strict; +use base 'Varnish::Test::Case'; + +our $DESCR = "Exercises a bug in the backend HTTP path."; + +sub testGarbledResponse($) { + my ($self) = @_; + + my $client = $self->new_client; + + $self->get($client, '/garbled'); + $self->wait(); + $self->assert_code(503); + $client->shutdown(); + + return 'OK'; +} + +sub testPartialResponse($) { + my ($self) = @_; + + my $client = $self->new_client; + + $self->get($client, '/partial'); + $self->wait(); + $self->assert_code(503); + $client->shutdown(); + + return 'OK'; +} + +sub testNoResponse($) { + my ($self) = @_; + + my $client = $self->new_client; + + $self->get($client, '/none'); + $self->wait(); + $self->assert_code(503); + $client->shutdown(); + + return 'OK'; +} + +sub ev_server_request($$$$) { + my ($self, $server, $connection, $request) = @_; + + if ($request->uri =~ m/garbled/) { + $connection->write("Garbled response\r\n"); + } elsif ($request->uri =~ m/partial/) { + $connection->write("HTTP/1.1 200 OK\r\n"); + $connection->write("Oops: incomplete response\r\n"); + } + $connection->shutdown(); +} + +1; Property changes on: trunk/varnish-tools/regress/lib/Varnish/Test/Case/Ticket164.pm ___________________________________________________________________ Name: svn:keywords + Id From des at projects.linpro.no Tue Oct 23 11:57:17 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 23 Oct 2007 13:57:17 +0200 (CEST) Subject: r2160 - trunk/varnish-tools/regress/lib/Varnish/Test/Server Message-ID: <20071023115717.17D261EC223@projects.linpro.no> Author: des Date: 2007-10-23 13:57:16 +0200 (Tue, 23 Oct 2007) New Revision: 2160 Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm Log: Add a test case for the root cause of #164, which is that the backend sends a garbled response (or no response at all). Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm 2007-10-23 11:56:56 UTC (rev 2159) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm 2007-10-23 11:57:16 UTC (rev 2160) @@ -67,6 +67,20 @@ return $self; } +=head2 write + +Write data to the connection + +=cut + +sub write($@) { + my ($self, @data) = @_; + + foreach my $data (@data) { + $self->{'mux'}->write($self->{'fh'}, $data); + } +} + =head2 send_response Called by test-cases to send a given HTTP::Response object out on the From des at projects.linpro.no Tue Oct 23 12:35:29 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 23 Oct 2007 14:35:29 +0200 (CEST) Subject: r2161 - trunk/varnish-cache/bin/varnishd Message-ID: <20071023123529.DC6EB1EC030@projects.linpro.no> Author: des Date: 2007-10-23 14:35:29 +0200 (Tue, 23 Oct 2007) New Revision: 2161 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c Log: Supply reasonable defaults for error code / reason. Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-10-23 11:57:16 UTC (rev 2160) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-10-23 12:35:29 UTC (rev 2161) @@ -56,8 +56,8 @@ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason); - sp->err_code = code; - sp->err_reason = reason; + sp->err_code = code ? code : 503; + sp->err_reason = reason ? reason : http_StatusMessage(sp->err_code); } /*--------------------------------------------------------------------*/ From des at projects.linpro.no Tue Oct 23 12:36:35 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 23 Oct 2007 14:36:35 +0200 (CEST) Subject: r2162 - trunk/varnish-cache/bin/varnishd Message-ID: <20071023123635.336691EC475@projects.linpro.no> Author: des Date: 2007-10-23 14:36:34 +0200 (Tue, 23 Oct 2007) New Revision: 2162 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Check for a negative return from HTC_Rx(). Probably needs revisiting. Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-23 12:35:29 UTC (rev 2161) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-23 12:36:34 UTC (rev 2162) @@ -331,6 +331,13 @@ i = HTC_Rx(htc); while (i == 0); + if (i < 0) { + VBE_UpdateHealth(sp, vc, -1); + VBE_ClosedFd(sp->wrk, vc); + /* XXX: other cleanup ? */ + return (__LINE__); + } + if (http_DissectResponse(sp->wrk, htc, hp)) { VBE_UpdateHealth(sp, vc, -2); VBE_ClosedFd(sp->wrk, vc); From des at projects.linpro.no Tue Oct 23 12:38:20 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 23 Oct 2007 14:38:20 +0200 (CEST) Subject: r2163 - in branches/1.2: . bin/varnishd Message-ID: <20071023123820.153D11EC030@projects.linpro.no> Author: des Date: 2007-10-23 14:38:19 +0200 (Tue, 23 Oct 2007) New Revision: 2163 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_fetch.c branches/1.2/bin/varnishd/cache_vrt.c Log: Merged revisions 2161-2162 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2161 | des | 2007-10-23 14:35:29 +0200 (Tue, 23 Oct 2007) | 2 lines Supply reasonable defaults for error code / reason. ........ r2162 | des | 2007-10-23 14:36:34 +0200 (Tue, 23 Oct 2007) | 2 lines Check for a negative return from HTC_Rx(). Probably needs revisiting. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2154 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2154,2161-2162 Modified: branches/1.2/bin/varnishd/cache_fetch.c =================================================================== --- branches/1.2/bin/varnishd/cache_fetch.c 2007-10-23 12:36:34 UTC (rev 2162) +++ branches/1.2/bin/varnishd/cache_fetch.c 2007-10-23 12:38:19 UTC (rev 2163) @@ -331,6 +331,13 @@ i = HTC_Rx(htc); while (i == 0); + if (i < 0) { + VBE_UpdateHealth(sp, vc, -1); + VBE_ClosedFd(sp->wrk, vc); + /* XXX: other cleanup ? */ + return (__LINE__); + } + if (http_DissectResponse(sp->wrk, htc, hp)) { VBE_UpdateHealth(sp, vc, -2); VBE_ClosedFd(sp->wrk, vc); Modified: branches/1.2/bin/varnishd/cache_vrt.c =================================================================== --- branches/1.2/bin/varnishd/cache_vrt.c 2007-10-23 12:36:34 UTC (rev 2162) +++ branches/1.2/bin/varnishd/cache_vrt.c 2007-10-23 12:38:19 UTC (rev 2163) @@ -56,8 +56,8 @@ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason); - sp->err_code = code; - sp->err_reason = reason; + sp->err_code = code ? code : 503; + sp->err_reason = reason ? reason : http_StatusMessage(sp->err_code); } /*--------------------------------------------------------------------*/ From des at projects.linpro.no Tue Oct 23 12:41:23 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 23 Oct 2007 14:41:23 +0200 (CEST) Subject: r2164 - in branches/1.2: . bin/varnishd Message-ID: <20071023124123.7678C1EC033@projects.linpro.no> Author: des Date: 2007-10-23 14:41:23 +0200 (Tue, 23 Oct 2007) New Revision: 2164 Modified: branches/1.2/ branches/1.2/bin/varnishd/mgt_child.c Log: Merged revisions 2157 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2157 | phk | 2007-10-23 11:23:04 +0200 (Tue, 23 Oct 2007) | 2 lines Quench a pointless sigchild warning ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2154,2161-2162 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2154,2157,2161-2162 Modified: branches/1.2/bin/varnishd/mgt_child.c =================================================================== --- branches/1.2/bin/varnishd/mgt_child.c 2007-10-23 12:38:19 UTC (rev 2163) +++ branches/1.2/bin/varnishd/mgt_child.c 2007-10-23 12:41:23 UTC (rev 2164) @@ -304,14 +304,10 @@ } ev_poker = NULL; - r = wait4(-1, &status, WNOHANG, NULL); - if (r == 0) + r = wait4(child_pid, &status, WNOHANG, NULL); + if (r == 0 || (r == -1 && errno == ECHILD)) return (0); - if (r != child_pid || r == -1) { - fprintf(stderr, "Unknown child died pid=%d status=0x%x\n", - r, status); - return (0); - } + assert(r == child_pid); fprintf(stderr, "Cache child died pid=%d status=0x%x\n", r, status); child_pid = -1; From des at projects.linpro.no Tue Oct 23 12:42:11 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 23 Oct 2007 14:42:11 +0200 (CEST) Subject: r2165 - in branches/1.2: . bin/varnishd Message-ID: <20071023124211.047781ECE86@projects.linpro.no> Author: des Date: 2007-10-23 14:42:10 +0200 (Tue, 23 Oct 2007) New Revision: 2165 Modified: branches/1.2/ branches/1.2/bin/varnishd/mgt_cli.c Log: Merged revisions 2153 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2153 | des | 2007-10-19 15:58:12 +0200 (Fri, 19 Oct 2007) | 3 lines Don't assert that close() returns 0, it won't when the remote end closes the connection first. This fixes #168. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2154,2157,2161-2162 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162 Modified: branches/1.2/bin/varnishd/mgt_cli.c =================================================================== --- branches/1.2/bin/varnishd/mgt_cli.c 2007-10-23 12:41:23 UTC (rev 2164) +++ branches/1.2/bin/varnishd/mgt_cli.c 2007-10-23 12:42:10 UTC (rev 2165) @@ -346,10 +346,10 @@ cli_close: vsb_delete(cp->cli->sb); free(cp->buf); - AZ(close(cp->fdi)); + (void)close(cp->fdi); if (cp->fdi == 0) assert(open("/dev/null", O_RDONLY) == 0); - AZ(close(cp->fdo)); + (void)close(cp->fdo); if (cp->fdo == 1) { assert(open("/dev/null", O_WRONLY) == 1); close(2); From phk at projects.linpro.no Wed Oct 24 10:24:09 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 24 Oct 2007 12:24:09 +0200 (CEST) Subject: r2166 - trunk/varnish-cache/bin/varnishd Message-ID: <20071024102409.0E6951EC033@projects.linpro.no> Author: phk Date: 2007-10-24 12:24:08 +0200 (Wed, 24 Oct 2007) New Revision: 2166 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_ws.c Log: Add a WS_Dup() function Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-23 12:42:10 UTC (rev 2165) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-24 10:24:08 UTC (rev 2166) @@ -585,6 +585,7 @@ void WS_Assert(const struct ws *ws); void WS_Reset(struct ws *ws); char *WS_Alloc(struct ws *ws, unsigned bytes); +char *WS_Dup(struct ws *ws, const char *); /* rfc2616.c */ int RFC2616_cache_policy(const struct sess *sp, const struct http *hp); Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-23 12:42:10 UTC (rev 2165) +++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-24 10:24:08 UTC (rev 2166) @@ -96,6 +96,19 @@ return (r); } +char * +WS_Dup(struct ws *ws, const char *s) +{ + unsigned l; + char *p; + + l = strlen(s) + 1; + p = WS_Alloc(ws, l); + if (p != NULL) + memcpy(p, s, l); + return (p); +} + unsigned WS_Reserve(struct ws *ws, unsigned bytes) { From phk at projects.linpro.no Wed Oct 24 14:32:12 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 24 Oct 2007 16:32:12 +0200 (CEST) Subject: r2167 - in trunk/varnish-cache: bin/varnishd include lib/libvcl Message-ID: <20071024143212.8728A1EC030@projects.linpro.no> Author: phk Date: 2007-10-24 16:32:12 +0200 (Wed, 24 Oct 2007) New Revision: 2167 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_httpconn.c trunk/varnish-cache/bin/varnishd/cache_session.c trunk/varnish-cache/bin/varnishd/cache_vrt.c trunk/varnish-cache/bin/varnishd/cache_ws.c trunk/varnish-cache/include/vrt.h trunk/varnish-cache/lib/libvcl/vcc_action.c trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c Log: Gently shuffle closer to being able to restart a esi:include on the next element: Add two checkpoints for the sessions workspace. The first checkpoint is after the session fixed data, and move the client address and port to workspace to see that this works. The second checkpoint is after the, as received unadultered by VCL http request. Grab a copy of the http request matching this. Implement rollback as an optional feature of restart in VCL. Move various workspace initialization and resetting operations to more suitable locations in the program flow. I don't know if this is really usable, but now it's possible to do: backend b1 { set backend.host = "backend1"; set backend.port = "80"; } backend b2 { set backend.host = "backend2"; set backend.port = "80"; } sub vcl_recv { set req.backend = b1; remove req.http.cookie; if (req.restarts == 0) { set req.url = "foobar.html"; } else { set req.backend = b2; } } sub vcl_fetch { if (obj.status != 200) { restart rollback; } } And have it first look for "foobar.html" on one backend, and failing that, try to give the user what they asked for from the other backend. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-24 14:32:12 UTC (rev 2167) @@ -288,14 +288,18 @@ struct sockaddr *mysockaddr; /* formatted ascii client address */ - char addr[TCP_ADDRBUFSIZE]; - char port[TCP_PORTBUFSIZE]; + char *addr; + char *port; struct srcaddr *srcaddr; /* HTTP request */ const char *doclose; struct http *http; + struct http *http0; + struct ws ws[1]; + char *ws_ses; /* WS above session data */ + char *ws_req; /* WS above request data */ struct http_conn htc[1]; @@ -583,9 +587,10 @@ void WS_Release(struct ws *ws, unsigned bytes); void WS_ReleaseP(struct ws *ws, char *ptr); void WS_Assert(const struct ws *ws); -void WS_Reset(struct ws *ws); +void WS_Reset(struct ws *ws, char *p); char *WS_Alloc(struct ws *ws, unsigned bytes); char *WS_Dup(struct ws *ws, const char *); +char *WS_Snapshot(struct ws *ws); /* rfc2616.c */ int RFC2616_cache_policy(const struct sess *sp, const struct http *hp); Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-24 14:32:12 UTC (rev 2167) @@ -107,9 +107,14 @@ void VCA_Prep(struct sess *sp) { + char addr[TCP_ADDRBUFSIZE]; + char port[TCP_PORTBUFSIZE]; + TCP_name(sp->sockaddr, sp->sockaddrlen, - sp->addr, sizeof sp->addr, sp->port, sizeof sp->port); + addr, sizeof addr, port, sizeof port); + sp->addr = WS_Dup(sp->ws, addr); + sp->port = WS_Dup(sp->ws, port); VSL(SLT_SessionOpen, sp->fd, "%s %s", sp->addr, sp->port); sp->acct.first = sp->t_open; if (need_test) @@ -195,7 +200,6 @@ sp->id = i; sp->t_open = now; - HTC_Init(sp->htc, sp->ws, sp->fd); sp->step = STP_FIRST; WRK_QueueSession(sp); } Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-24 14:32:12 UTC (rev 2167) @@ -221,6 +221,9 @@ return (1); } + /* Reset the workspace to the session-watermark */ + WS_Reset(sp->ws, sp->ws_ses); + i = HTC_Reinit(sp->htc); if (i == 1) { VSL_stats->sess_pipeline++; @@ -368,12 +371,19 @@ assert(sp->xid == 0); VCA_Prep(sp); + + /* Record the session watermark */ + sp->ws_ses = WS_Snapshot(sp->ws); + + /* Receive a HTTP protocol request */ + HTC_Init(sp->htc, sp->ws, sp->fd); sp->wrk->used = sp->t_open; sp->wrk->acct.sess++; SES_RefSrcAddr(sp); do i = HTC_Rx(sp->htc); while (i == 0); + switch (i) { case 1: sp->step = STP_RECV; @@ -734,7 +744,15 @@ sp->vcl = sp->wrk->vcl; sp->wrk->vcl = NULL; + http_Setup(sp->http, sp->ws); done = http_DissectRequest(sp); + + /* Catch request snapshot */ + sp->ws_req = WS_Snapshot(sp->ws); + + /* Catch original request, before modification */ + *sp->http0 = *sp->http; + if (done != 0) { RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */ sp->step = STP_DONE; Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-10-24 14:32:12 UTC (rev 2167) @@ -86,7 +86,6 @@ htc->magic = HTTP_CONN_MAGIC; htc->ws = ws; htc->fd = fd; - WS_Reset(htc->ws); WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2); htc->rxbuf.b = ws->f; htc->rxbuf.e = ws->f; @@ -107,7 +106,6 @@ int i; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); - WS_Reset(htc->ws); WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2); htc->rxbuf.b = htc->ws->f; htc->rxbuf.e = htc->ws->f; Modified: trunk/varnish-cache/bin/varnishd/cache_session.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_session.c 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/bin/varnishd/cache_session.c 2007-10-24 14:32:12 UTC (rev 2167) @@ -65,7 +65,7 @@ #define SESSMEM_MAGIC 0x555859c5 struct sess sess; - struct http http; + struct http http[2]; unsigned workspace; VTAILQ_ENTRY(sessmem) list; struct sockaddr_storage sockaddr[2]; @@ -319,8 +319,8 @@ } WS_Init(sp->ws, (void *)(sm + 1), sm->workspace); - sp->http = &sm->http; - http_Setup(sp->http, sp->ws); + sp->http = &sm->http[0]; + sp->http0 = &sm->http[1]; return (sp); } Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-10-24 14:32:12 UTC (rev 2167) @@ -510,6 +510,16 @@ /*--------------------------------------------------------------------*/ void +VRT_Rollback(struct sess *sp) +{ + + *sp->http = *sp->http0; + WS_Reset(sp->ws, sp->ws_req); +} + +/*--------------------------------------------------------------------*/ + +void VRT_purge(const char *regexp, int hash) { Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-24 14:32:12 UTC (rev 2167) @@ -74,12 +74,18 @@ } void -WS_Reset(struct ws *ws) +WS_Reset(struct ws *ws, char *p) { WS_Assert(ws); assert(ws->r == NULL); - ws->f = ws->s; + if (p == NULL) + ws->f = ws->s; + else { + assert(p >= ws->s); + assert(p < ws->e); + ws->f = p; + } } char * @@ -109,6 +115,14 @@ return (p); } +char * +WS_Snapshot(struct ws *ws) +{ + + assert(ws->r == NULL); + return (ws->f); +} + unsigned WS_Reserve(struct ws *ws, unsigned bytes) { Modified: trunk/varnish-cache/include/vrt.h =================================================================== --- trunk/varnish-cache/include/vrt.h 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/include/vrt.h 2007-10-24 14:32:12 UTC (rev 2167) @@ -114,8 +114,8 @@ int VRT_strcmp(const char *s1, const char *s2); void VRT_ESI(struct sess *sp); +void VRT_Rollback(struct sess *sp); - /* Backend related */ void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *); void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *); Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-10-24 14:32:12 UTC (rev 2167) @@ -55,6 +55,25 @@ /*--------------------------------------------------------------------*/ static void +parse_restart_real(struct tokenlist *tl) +{ + struct token *t1; + + t1 = VTAILQ_NEXT(tl->t, list); + if (t1->tok == ID && vcc_IdIs(t1, "rollback")) { + Fb(tl, 1, "VRT_Rollback(sp);\n"); + vcc_NextToken(tl); + } else if (t1->tok != ';') { + vsb_printf(tl->sb, "Expected \"rollback\" or semicolon.\n"); + vcc_ErrWhere(tl, t1); + ERRCHK(tl); + } + parse_restart(tl); +} + +/*--------------------------------------------------------------------*/ + +static void parse_call(struct tokenlist *tl) { @@ -333,6 +352,7 @@ const char *name; action_f *func; } action_table[] = { + { "restart", parse_restart_real }, #define VCL_RET_MAC(l, u, b, i) { #l, parse_##l }, #define VCL_RET_MAC_E(l, u, b, i) VCL_RET_MAC(l, u, b, i) #include "vcl_returns.h" Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-10-24 10:24:08 UTC (rev 2166) +++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-10-24 14:32:12 UTC (rev 2167) @@ -493,8 +493,8 @@ vsb_cat(sb, "int VRT_strcmp(const char *s1, const char *s2);\n"); vsb_cat(sb, "\n"); vsb_cat(sb, "void VRT_ESI(struct sess *sp);\n"); + vsb_cat(sb, "void VRT_Rollback(struct sess *sp);\n"); vsb_cat(sb, "\n"); - vsb_cat(sb, "\n"); vsb_cat(sb, "/* Backend related */\n"); vsb_cat(sb, "void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *);\n"); vsb_cat(sb, "void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *);\n"); From phk at projects.linpro.no Wed Oct 24 18:38:18 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 24 Oct 2007 20:38:18 +0200 (CEST) Subject: r2168 - trunk/varnish-cache/bin/varnishd Message-ID: <20071024183818.07C871EC035@projects.linpro.no> Author: phk Date: 2007-10-24 20:38:17 +0200 (Wed, 24 Oct 2007) New Revision: 2168 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/steps.h Log: Split STP_RECV in two: STP_START is the initial setup of a viable workerthread: Dissecting HTTP, getting vcl reference etc. STP_RECV is invoking vcl_recv() and following orders. Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-24 14:32:12 UTC (rev 2167) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-10-24 18:38:17 UTC (rev 2168) @@ -222,7 +222,7 @@ SES_Delete(sp); break; case 1: - sp->step = STP_RECV; + sp->step = STP_START; WRK_QueueSession(sp); break; default: Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-24 14:32:12 UTC (rev 2167) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-24 18:38:17 UTC (rev 2168) @@ -48,12 +48,12 @@ DOT size="7.2,10.5" DOT margin="0.5" DOT center="1" -DOT start [ +DOT acceptor [ DOT shape=hexagon DOT label="Request received" DOT ] DOT ERROR [shape=plaintext] -DOT start -> recv [style=bold,color=green,weight=4] +DOT acceptor -> start [style=bold,color=green,weight=4] */ #include @@ -93,7 +93,7 @@ while (i == 0) i = HTC_Rx(sp->htc); if (i == 1) { - sp->step = STP_RECV; + sp->step = STP_START; } else { vca_close_session(sp, "overflow"); sp->step = STP_DONE; @@ -227,7 +227,7 @@ i = HTC_Reinit(sp->htc); if (i == 1) { VSL_stats->sess_pipeline++; - sp->step = STP_RECV; + sp->step = STP_START; return (0); } if (Tlen(sp->htc->rxbuf)) { @@ -290,6 +290,7 @@ DOT } DOT fetch_pass -> deliver DOT vcl_fetch -> deliver [label="insert",style=bold,color=blue,weight=2] +DOT vcl_fetch -> recv [label="restart"] DOT vcl_fetch -> errfetch [label="error"] DOT errfetch [label="ERROR",shape=plaintext] */ @@ -386,7 +387,7 @@ switch (i) { case 1: - sp->step = STP_RECV; + sp->step = STP_START; break; case -1: vca_close_session(sp, "error"); @@ -700,8 +701,7 @@ /*-------------------------------------------------------------------- * RECV - * We have a complete request, get a VCL reference and dispatch it - * as instructed by vcl_recv{} + * We have a complete request, set everything up and start it. * DOT subgraph xcluster_recv { DOT recv [ @@ -719,56 +719,10 @@ static int cnt_recv(struct sess *sp) { - int done; AZ(sp->obj); + AN(sp->vcl); - if (sp->restarts > params->max_restarts) { - sp->step = STP_ERROR; - return (0); - } - if (sp->restarts == 0) { - AZ(sp->vcl); - /* Update stats of various sorts */ - VSL_stats->client_req++; /* XXX not locked */ - sp->t_req = TIM_real(); - sp->wrk->used = sp->t_req; - sp->wrk->acct.req++; - - /* Assign XID and log */ - sp->xid = ++xids; /* XXX not locked */ - WSP(sp, SLT_ReqStart, "%s %s %u", sp->addr, sp->port, sp->xid); - - /* Borrow VCL reference from worker thread */ - VCL_Refresh(&sp->wrk->vcl); - sp->vcl = sp->wrk->vcl; - sp->wrk->vcl = NULL; - - http_Setup(sp->http, sp->ws); - done = http_DissectRequest(sp); - - /* Catch request snapshot */ - sp->ws_req = WS_Snapshot(sp->ws); - - /* Catch original request, before modification */ - *sp->http0 = *sp->http; - - if (done != 0) { - RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */ - sp->step = STP_DONE; - return (0); - } - - sp->doclose = http_DoConnection(sp->http); - - /* By default we use the first backend */ - AZ(sp->backend); - sp->backend = sp->vcl->backend[0]; - CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); - - /* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */ - } - VCL_recv_method(sp); sp->wantbody = (strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD") != 0); @@ -792,7 +746,66 @@ } } +/*-------------------------------------------------------------------- + * START + * Handle a request, wherever it came from recv/restart. + * +DOT start [shape=box,label="Dissect request"] +DOT start -> recv + */ +static int +cnt_start(struct sess *sp) +{ + int done; + + AZ(sp->restarts); + AZ(sp->obj); + AZ(sp->vcl); + + /* Update stats of various sorts */ + VSL_stats->client_req++; /* XXX not locked */ + sp->t_req = TIM_real(); + sp->wrk->used = sp->t_req; + sp->wrk->acct.req++; + + /* Assign XID and log */ + sp->xid = ++xids; /* XXX not locked */ + WSP(sp, SLT_ReqStart, "%s %s %u", sp->addr, sp->port, sp->xid); + + /* Borrow VCL reference from worker thread */ + VCL_Refresh(&sp->wrk->vcl); + sp->vcl = sp->wrk->vcl; + sp->wrk->vcl = NULL; + + http_Setup(sp->http, sp->ws); + done = http_DissectRequest(sp); + + /* Catch request snapshot */ + sp->ws_req = WS_Snapshot(sp->ws); + + /* Catch original request, before modification */ + *sp->http0 = *sp->http; + + if (done != 0) { + RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */ + sp->step = STP_DONE; + return (0); + } + + sp->doclose = http_DoConnection(sp->http); + + /* By default we use the first backend */ + AZ(sp->backend); + sp->backend = sp->vcl->backend[0]; + CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); + + /* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */ + + sp->step = STP_RECV; + return (0); +} + /*-------------------------------------------------------------------- * Central state engine dispatcher. * Modified: trunk/varnish-cache/bin/varnishd/steps.h =================================================================== --- trunk/varnish-cache/bin/varnishd/steps.h 2007-10-24 14:32:12 UTC (rev 2167) +++ trunk/varnish-cache/bin/varnishd/steps.h 2007-10-24 18:38:17 UTC (rev 2168) @@ -32,6 +32,7 @@ STEP(again, AGAIN) STEP(first, FIRST) STEP(recv, RECV) +STEP(start, START) STEP(pipe, PIPE) STEP(pass, PASS) STEP(lookup, LOOKUP) From phk at projects.linpro.no Wed Oct 24 19:38:43 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 24 Oct 2007 21:38:43 +0200 (CEST) Subject: r2169 - trunk/varnish-cache/bin/varnishd Message-ID: <20071024193843.9A92D1EC033@projects.linpro.no> Author: phk Date: 2007-10-24 21:38:43 +0200 (Wed, 24 Oct 2007) New Revision: 2169 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Add attribute parsing Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-24 18:38:17 UTC (rev 2168) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-24 19:38:43 UTC (rev 2169) @@ -41,6 +41,7 @@ */ #include +#include #include #include #include @@ -75,10 +76,63 @@ }; /*-------------------------------------------------------------------- + * Report a parsing error + */ + +static void +esi_error(const struct esi_work *ew, const char *p, int i, const char *err) +{ + int ellipsis = 0; + char buf[256], *q; + txt t; + + if (i == 0) + i = p - ((char *)ew->st->ptr + ew->st->len); + if (i > 20) { + i = 20; + ellipsis = 1; + } + q = buf; + q += sprintf(buf, "at %zd: %s \"", + ew->off + (p - (char*)ew->st->ptr), err); + while (i > 0) { + if (*p >= ' ' && *p <= '~') { + *q++ = *p; + } else if (*p == '\n') { + *q++ = '\\'; + *q++ = 'n'; + } else if (*p == '\r') { + *q++ = '\\'; + *q++ = 'r'; + } else if (*p == '\t') { + *q++ = '\\'; + *q++ = 't'; + } else { + /* XXX: use %%%02x instead ? */ + q += sprintf(q, "\\x%02x", *p); + } + p++; + i--; + } + if (ellipsis) { + *q++ = '['; + *q++ = '.'; + *q++ = '.'; + *q++ = '.'; + *q++ = ']'; + } + *q++ = '"'; + *q++ = '\0'; + t.b = buf; + t.e = q; + WSPR(ew->sp, SLT_ESI_xmlerror, t); +} + +/*-------------------------------------------------------------------- * Add ESI bit to object */ -static void +static struct esi_bit * esi_addbit(struct esi_work *ew) { @@ -99,6 +153,7 @@ ew->eb->verbatim = ew->dst; sprintf(ew->eb->chunk_length, "%x\r\n", Tlen(ew->dst)); VSL(SLT_Debug, ew->sp->fd, "AddBit: %.*s", Tlen(ew->dst), ew->dst.b); + return(ew->eb); } @@ -116,69 +171,101 @@ } /*-------------------------------------------------------------------- - * Add one piece to the output, either verbatim or include + * Tease the next attribute and value out of an XML element. + * + * XXX: is the syntax correct ? */ -static void -esi_addinclude(struct esi_work *ew, txt t) +static int +esi_attrib(const struct esi_work *ew, txt *in, txt *attrib, txt *val) { - VSL(SLT_Debug, 0, "Incl \"%.*s\"", t.e - t.b, t.b); - esi_addbit(ew); - ew->eb->include = t; + /* Skip leading blanks */ + while(in->b < in->e && isspace(*in->b)) + in->b++; + + /* Nothing found */ + if (in->b >= in->e) + return (0); + + if (!isalpha(*in->b)) { + /* XXX error */ + esi_error(ew, in->b, 1, "XML 1.0 Illegal attribute character"); + return (-1); + } + + /* Attribute name until '=' or space */ + *attrib = *in; + while(in->b < in->e && *in->b != '=' && !isspace(*in->b)) { + if (!isalnum(*in->b)) { + esi_error(ew, attrib->b, 1 + (in->b - attrib->b), + "XML 1.0 Illegal attribute character"); + return (-1); + } + in->b++; + } + attrib->e = in->b; + + if (in->b >= in->e || isspace(*in->b)) { + /* Attribute without value */ + val->b = val->e = in->b; + return (1); + } + + /* skip '=' */ + in->b++; + + /* Value, if any ? */ + *val = *in; + if (in->b >= in->e) + return (1); + + if (*in->b == '"') { + /* Skip quote */ + in->b++; + val->b++; + + /* Anything goes, until next quote */ + while(in->b < in->e && *in->b != '"') + in->b++; + val->e = in->b; + + if (in->b >= in->e) { + esi_error(ew, val->b, in->e - val->b, + "XML 1.0 missing ending quote"); + return (-1); + } + + /* Skip quote */ + in->b++; + } else { + /* Anything until whitespace */ + while(in->b < in->e && !isspace(*in->b)) + in->b++; + val->e = in->b; + } + return (1); } /*-------------------------------------------------------------------- - * Report a parsing error + * Add one piece to the output, either verbatim or include */ static void -esi_error(const struct esi_work *ew, const char *p, int i, const char *err) +esi_addinclude(struct esi_work *ew, txt t) { - int ellipsis = 0; - char buf[256], *q; - txt t; + struct esi_bit *eb; + txt tag; + txt cont; - if (i == 0) - i = p - ((char *)ew->st->ptr + ew->st->len); - if (i > 20) { - i = 20; - ellipsis = 1; + eb = esi_addbit(ew); + while (esi_attrib(ew, &t, &tag, &cont) == 1) { + VSL(SLT_Debug, 0, "<%.*s> -> <%.*s>", + tag.e - tag.b, tag.b, + cont.e - cont.b, cont.b); } - q = buf; - q += sprintf(buf, "at %zd: %s \"", - ew->off + (p - (char*)ew->st->ptr), err); - while (i > 0) { - if (*p >= ' ' && *p <= '~') { - *q++ = *p; - } else if (*p == '\n') { - *q++ = '\\'; - *q++ = 'n'; - } else if (*p == '\r') { - *q++ = '\\'; - *q++ = 'r'; - } else if (*p == '\t') { - *q++ = '\\'; - *q++ = 't'; - } else { - /* XXX: use %%%02x instead ? */ - q += sprintf(q, "\\x%02x", *p); - } - p++; - i--; - } - if (ellipsis) { - *q++ = '['; - *q++ = '.'; - *q++ = '.'; - *q++ = '.'; - *q++ = ']'; - } - *q++ = '"'; - *q++ = '\0'; - t.b = buf; - t.e = q; - WSPR(ew->sp, SLT_ESI_xmlerror, t); + eb->include = t; + VSL(SLT_Debug, 0, "Incl \"%.*s\"", t.e - t.b, t.b); } /*-------------------------------------------------------------------- @@ -366,12 +453,14 @@ if (celem == 0) { o.b = r + 11; - o.e = q; - esi_addinclude(ew, o); if (q[-1] != '/') { esi_error(ew, p, 1 + q - p, "ESI 1.0 wants emtpy esi:include"); + o.e = q; + } else { + o.e = q - 1; } + esi_addinclude(ew, o); ew->dst.b = q + 1; ew->dst.e = q + 1; } else { From phk at projects.linpro.no Wed Oct 24 20:34:24 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 24 Oct 2007 22:34:24 +0200 (CEST) Subject: r2170 - trunk/varnish-cache/bin/varnishd Message-ID: <20071024203424.82CDF1EC035@projects.linpro.no> Author: phk Date: 2007-10-24 22:34:24 +0200 (Wed, 24 Oct 2007) New Revision: 2170 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_response.c trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Push hole through the esi:include path, making a very trivial example work fully, leaving a trail of XXX and other devastation: Add an esi nesting counter to the session. Teach RES_WriteObj() to send an object as a chunk in chunked encoding. Bail cnt_done() early for nested ESI transactions. Catch the src="" attribute in esi:include and store it in the esibit. In ESI_Deliver(), recurse into CNT_Session(STP_RECV) in order to handle the include element of an esibit. Recursion is probably not the ideal solution here, but it might quite conceiveably be the best one, since it is quite cheap and very trivial. Outstanding issues: too many to list still. The following example worked for me:
	
	
Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-24 19:38:43 UTC (rev 2169) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-24 20:34:24 UTC (rev 2170) @@ -279,6 +279,7 @@ unsigned xid; int restarts; + int esis; struct worker *wrk; Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-24 19:38:43 UTC (rev 2169) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-24 20:34:24 UTC (rev 2170) @@ -211,6 +211,11 @@ sp->t_req = NAN; sp->t_resp = NAN; WSL_Flush(sp->wrk); + + /* If we did an ESI include, don't mess up our state */ + if (sp->esis > 0) + return (1); + if (sp->fd >= 0 && sp->doclose != NULL) vca_close_session(sp, sp->doclose); if (sp->fd < 0) { Modified: trunk/varnish-cache/bin/varnishd/cache_response.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-10-24 19:38:43 UTC (rev 2169) +++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-10-24 20:34:24 UTC (rev 2170) @@ -150,11 +150,17 @@ { struct storage *st; unsigned u = 0; + char lenbuf[20]; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); WRK_Reset(sp->wrk, &sp->fd); - sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); + if (sp->esis == 0) { + sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); + } else { + sprintf(lenbuf, "%x\r\n", sp->obj->len); + sp->wrk->acct.hdrbytes += WRK_Write(sp->wrk, lenbuf, -1); + } CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (sp->wantbody && !VTAILQ_EMPTY(&sp->obj->esibits)) { @@ -186,6 +192,8 @@ } assert(u == sp->obj->len); } + if (sp->esis > 0) + WRK_Write(sp->wrk, "\r\n", -1); if (WRK_Flush(sp->wrk)) vca_close_session(sp, "remote closed"); } Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-24 19:38:43 UTC (rev 2169) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-24 20:34:24 UTC (rev 2170) @@ -256,16 +256,18 @@ { struct esi_bit *eb; txt tag; - txt cont; + txt val; + VSL(SLT_Debug, 0, "Incl \"%.*s\"", t.e - t.b, t.b); eb = esi_addbit(ew); - while (esi_attrib(ew, &t, &tag, &cont) == 1) { + while (esi_attrib(ew, &t, &tag, &val) == 1) { VSL(SLT_Debug, 0, "<%.*s> -> <%.*s>", tag.e - tag.b, tag.b, - cont.e - cont.b, cont.b); + val.e - val.b, val.b); + if (Tlen(tag) != 3 && memcmp(tag.b, "src", 3)) + continue; + eb->include = val; } - eb->include = t; - VSL(SLT_Debug, 0, "Incl \"%.*s\"", t.e - t.b, t.b); } /*-------------------------------------------------------------------- @@ -543,14 +545,38 @@ { struct esi_bit *eb; + struct object *obj; VTAILQ_FOREACH(eb, &sp->obj->esibits, list) { WRK_Write(sp->wrk, eb->chunk_length, -1); WRK_Write(sp->wrk, eb->verbatim.b, Tlen(eb->verbatim)); - if (VTAILQ_NEXT(eb, list)) - WRK_Write(sp->wrk, "\r\n", -1); - else - WRK_Write(sp->wrk, "\r\n0\r\n", -1); + WRK_Write(sp->wrk, "\r\n", -1); + if (eb->include.b != NULL) { + /* + * We flush here, because the next transaction is + * quite likely to take some time, so we should get + * as many bits to the client as we can already + */ + WRK_Flush(sp->wrk); + /* + * XXX: Must edit url relative to the one we have + * XXX: at this point, and not the http0 url. + */ + printf("INCL: %.*s\n", + Tlen(eb->include), eb->include.b); + *eb->include.e = '\0'; /* XXX ! */ + sp->esis++; + obj = sp->obj; + sp->obj = NULL; + *sp->http = *sp->http0; + http_SetH(sp->http, HTTP_HDR_URL, eb->include.b); + sp->step = STP_RECV; + CNT_Session(sp); + sp->esis--; + sp->obj = obj; + } + if (!VTAILQ_NEXT(eb, list)) + WRK_Write(sp->wrk, "0\r\n", -1); } } From phk at projects.linpro.no Fri Oct 26 11:00:26 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Oct 2007 13:00:26 +0200 (CEST) Subject: r2171 - trunk/varnish-cache/bin/varnishd Message-ID: <20071026110026.1A2271EC033@projects.linpro.no> Author: phk Date: 2007-10-26 13:00:25 +0200 (Fri, 26 Oct 2007) New Revision: 2171 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_param.c Log: More ESI work, now full URL srcs (http://...) work in addition to absolute src ("/..."). Relative src's coming up next, once I find out where to store the edited string. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-24 20:34:24 UTC (rev 2170) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-26 11:00:25 UTC (rev 2171) @@ -737,6 +737,12 @@ sp->step = STP_LOOKUP; return (0); case VCL_RET_PIPE: + if (sp->esis > 0) { + /* XXX: VSL something */ + INCOMPL(); + sp->step = STP_DONE; + return (1); + } sp->step = STP_PIPE; return (0); case VCL_RET_PASS: Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-24 20:34:24 UTC (rev 2170) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-26 11:00:25 UTC (rev 2171) @@ -41,12 +41,14 @@ */ #include +#include #include #include #include #include #include "shmlog.h" +#include "heritage.h" #include "vrt.h" #include "vcl.h" #include "cache.h" @@ -59,6 +61,7 @@ VTAILQ_ENTRY(esi_bit) list; char chunk_length[20]; txt verbatim; + txt host; txt include; int free_this; }; @@ -146,8 +149,6 @@ ew->ebl++; ew->neb--; -printf("FIRST: %p\n", VTAILQ_FIRST(&ew->sp->obj->esibits)); -printf("ADD %p->%p\n", ew->sp->obj, ew->eb); VTAILQ_INSERT_TAIL(&ew->sp->obj->esibits, ew->eb, list); ew->eb->verbatim = ew->dst; @@ -244,6 +245,7 @@ in->b++; val->e = in->b; } + *val->e = '\0'; return (1); } @@ -255,6 +257,7 @@ esi_addinclude(struct esi_work *ew, txt t) { struct esi_bit *eb; + char *p, *q; txt tag; txt val; @@ -266,7 +269,32 @@ val.e - val.b, val.b); if (Tlen(tag) != 3 && memcmp(tag.b, "src", 3)) continue; - eb->include = val; + + assert(Tlen(val) > 0); /* XXX */ + + if (Tlen(val) > 7 && !memcmp(val.b, "http://", 7)) { + /* Rewrite to Host: header inplace */ + eb->host.b = val.b; + memcpy(eb->host.b, "Host: ", 6); + q = eb->host.b + 6; + for (p = eb->host.b + 7; p < val.e && *p != '/'; p++) + *q++ = *p; + *q++ = '\0'; + eb->host.e = q; + assert(*p == '/'); /* XXX */ + /* The rest is the URL */ + eb->include.b = p; + eb->include.e = val.e; + } else if (Tlen(val) > 0 && *val.b == '/') { + /* Absolute on this host */ + eb->include = val; + } else { + /* Relative to current URL */ + /* XXX: search forward to '?' use previous / */ + /* XXX: where to store edited result ? */ + eb->include = val; + INCOMPL(); + } } } @@ -506,6 +534,8 @@ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); + + /* XXX: only if GET ? */ ew = eww; memset(eww, 0, sizeof eww); ew->sp = sp; @@ -515,14 +545,11 @@ ew->st = st; i = esi_parse(ew); ew->off += st->len; - printf("VXML(%p+%d) = %d", st->ptr, st->len, i); if (i < st->len) { /* XXX: Handle complications */ - printf(" \"%.*s\"", st->len - i, st->ptr + i); if (VTAILQ_NEXT(st, list)) INCOMPL(); } - printf("\n"); i = Tlen(ew->dst); } if (Tlen(ew->dst)) @@ -551,33 +578,34 @@ WRK_Write(sp->wrk, eb->chunk_length, -1); WRK_Write(sp->wrk, eb->verbatim.b, Tlen(eb->verbatim)); WRK_Write(sp->wrk, "\r\n", -1); - if (eb->include.b != NULL) { - /* - * We flush here, because the next transaction is - * quite likely to take some time, so we should get - * as many bits to the client as we can already - */ - WRK_Flush(sp->wrk); - /* - * XXX: Must edit url relative to the one we have - * XXX: at this point, and not the http0 url. - */ - printf("INCL: %.*s\n", - Tlen(eb->include), eb->include.b); - *eb->include.e = '\0'; /* XXX ! */ - sp->esis++; - obj = sp->obj; - sp->obj = NULL; - *sp->http = *sp->http0; - http_SetH(sp->http, HTTP_HDR_URL, eb->include.b); - sp->step = STP_RECV; - CNT_Session(sp); - sp->esis--; - sp->obj = obj; + if (eb->include.b == NULL || + sp->esis >= params->max_esi_includes) + continue; + + /* + * We flush here, because the next transaction is + * quite likely to take some time, so we should get + * as many bits to the client as we can already + */ + WRK_Flush(sp->wrk); + + sp->esis++; + obj = sp->obj; + sp->obj = NULL; + *sp->http = *sp->http0; + /* XXX: reset sp->ws */ + http_SetH(sp->http, HTTP_HDR_URL, eb->include.b); + if (eb->host.b != NULL) { + http_Unset(sp->http, H_Host); + http_SetHeader(sp->wrk, sp->fd, sp->http, eb->host.b); } - if (!VTAILQ_NEXT(eb, list)) - WRK_Write(sp->wrk, "0\r\n", -1); + sp->step = STP_RECV; + CNT_Session(sp); + sp->esis--; + sp->obj = obj; + } + WRK_Write(sp->wrk, "0\r\n", -1); } /*--------------------------------------------------------------------*/ Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2007-10-24 20:34:24 UTC (rev 2170) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2007-10-26 11:00:25 UTC (rev 2171) @@ -128,6 +128,9 @@ /* Maximum restarts allowed */ unsigned max_restarts; + /* Maximum esi:include depth allowed */ + unsigned max_esi_includes; + }; extern volatile struct params *params; Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-10-24 20:34:24 UTC (rev 2170) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-10-26 11:00:25 UTC (rev 2171) @@ -563,6 +563,14 @@ tweak_generic_uint(cli, &master.max_restarts, arg, 0, UINT_MAX); } +static void +tweak_max_esi_includes(struct cli *cli, struct parspec *par, const char *arg) +{ + + (void)par; + tweak_generic_uint(cli, &master.max_esi_includes, arg, 0, UINT_MAX); +} + /*--------------------------------------------------------------------*/ /* @@ -770,12 +778,14 @@ , NULL }, { "max_restarts", tweak_max_restarts, "Upper limit on how many times a request can restart." -#ifdef NOT_YET - " ESI:include counts as a restart in this context." -#endif "\nBe aware that restarts are likely to cause a hit against " "the backend, so don't increase thoughtlessly.\n", "4", "restarts" }, + { "max_esi_includes", tweak_max_esi_includes, + "Maximum depth of esi:include processing." + "\nBe aware that restarts are likely to cause a hit against " + "the backend, so don't increase thoughtlessly.\n", + "5", "restarts" }, { NULL, NULL, NULL } }; From phk at projects.linpro.no Fri Oct 26 11:13:32 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Oct 2007 13:13:32 +0200 (CEST) Subject: r2172 - trunk/varnish-cache/bin/varnishd Message-ID: <20071026111332.9BE561EC033@projects.linpro.no> Author: phk Date: 2007-10-26 13:13:32 +0200 (Fri, 26 Oct 2007) New Revision: 2172 Modified: trunk/varnish-cache/bin/varnishd/cache_response.c trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Don't mess up the chunked encoding for nested esi:include Modified: trunk/varnish-cache/bin/varnishd/cache_response.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-10-26 11:00:25 UTC (rev 2171) +++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-10-26 11:13:32 UTC (rev 2172) @@ -153,19 +153,20 @@ char lenbuf[20]; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); WRK_Reset(sp->wrk, &sp->fd); - if (sp->esis == 0) { + if (sp->esis == 0) sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); - } else { - sprintf(lenbuf, "%x\r\n", sp->obj->len); - sp->wrk->acct.hdrbytes += WRK_Write(sp->wrk, lenbuf, -1); - } - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (sp->wantbody && !VTAILQ_EMPTY(&sp->obj->esibits)) { ESI_Deliver(sp); } else if (sp->wantbody) { + if (sp->esis > 0) { + sprintf(lenbuf, "%x\r\n", sp->obj->len); + sp->wrk->acct.hdrbytes += + WRK_Write(sp->wrk, lenbuf, -1); + } VTAILQ_FOREACH(st, &sp->obj->store, list) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -191,9 +192,9 @@ WRK_Write(sp->wrk, st->ptr, st->len); } assert(u == sp->obj->len); + if (sp->esis > 0) + WRK_Write(sp->wrk, "\r\n", -1); } - if (sp->esis > 0) - WRK_Write(sp->wrk, "\r\n", -1); if (WRK_Flush(sp->wrk)) vca_close_session(sp, "remote closed"); } Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-26 11:00:25 UTC (rev 2171) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-26 11:13:32 UTC (rev 2172) @@ -605,7 +605,8 @@ sp->obj = obj; } - WRK_Write(sp->wrk, "0\r\n", -1); + if (sp->esis == 0) + WRK_Write(sp->wrk, "0\r\n", -1); } /*--------------------------------------------------------------------*/ From des at projects.linpro.no Sun Oct 28 18:43:25 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Sun, 28 Oct 2007 19:43:25 +0100 (CET) Subject: r2173 - trunk/varnish-cache/debian Message-ID: <20071028184325.7E3151EC030@projects.linpro.no> Author: des Date: 2007-10-28 19:43:24 +0100 (Sun, 28 Oct 2007) New Revision: 2173 Modified: trunk/varnish-cache/debian/Makefile.am Log: Fix file list. Modified: trunk/varnish-cache/debian/Makefile.am =================================================================== --- trunk/varnish-cache/debian/Makefile.am 2007-10-26 11:13:32 UTC (rev 2172) +++ trunk/varnish-cache/debian/Makefile.am 2007-10-28 18:43:24 UTC (rev 2173) @@ -9,10 +9,10 @@ copyright \ dirs \ docs \ - libvarnish-dev.dirs \ - libvarnish-dev.install \ - libvarnish.dirs \ - libvarnish.install \ + libvarnish0-dev.dirs \ + libvarnish0-dev.install \ + libvarnish0.dirs \ + libvarnish0.install \ lintian-override \ rules \ varnish.default \ From des at projects.linpro.no Sun Oct 28 18:43:42 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Sun, 28 Oct 2007 19:43:42 +0100 (CET) Subject: r2174 - in branches/1.1: . debian Message-ID: <20071028184342.69C0D1EC033@projects.linpro.no> Author: des Date: 2007-10-28 19:43:42 +0100 (Sun, 28 Oct 2007) New Revision: 2174 Modified: branches/1.1/ branches/1.1/debian/Makefile.am Log: Merged revisions 2173 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2173 | des | 2007-10-28 19:43:24 +0100 (Sun, 28 Oct 2007) | 2 lines Fix file list. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2116,2133,2154 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2116,2133,2154,2173 Modified: branches/1.1/debian/Makefile.am =================================================================== --- branches/1.1/debian/Makefile.am 2007-10-28 18:43:24 UTC (rev 2173) +++ branches/1.1/debian/Makefile.am 2007-10-28 18:43:42 UTC (rev 2174) @@ -9,10 +9,10 @@ copyright \ dirs \ docs \ - libvarnish-dev.dirs \ - libvarnish-dev.install \ - libvarnish.dirs \ - libvarnish.install \ + libvarnish0-dev.dirs \ + libvarnish0-dev.install \ + libvarnish0.dirs \ + libvarnish0.install \ lintian-override \ rules \ varnish.default \ From phk at projects.linpro.no Mon Oct 29 07:46:12 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 08:46:12 +0100 (CET) Subject: r2175 - trunk/varnish-cache/include Message-ID: <20071029074612.725771EC2AE@projects.linpro.no> Author: phk Date: 2007-10-29 08:46:12 +0100 (Mon, 29 Oct 2007) New Revision: 2175 Modified: trunk/varnish-cache/include/shmlog_tags.h Log: Add a VCL_error shmtag Modified: trunk/varnish-cache/include/shmlog_tags.h =================================================================== --- trunk/varnish-cache/include/shmlog_tags.h 2007-10-28 18:43:42 UTC (rev 2174) +++ trunk/varnish-cache/include/shmlog_tags.h 2007-10-29 07:46:12 UTC (rev 2175) @@ -84,6 +84,7 @@ SLTM(VCL_call) SLTM(VCL_trace) SLTM(VCL_return) +SLTM(VCL_error) SLTM(ReqStart) SLTM(Hit) SLTM(HitPass) From phk at projects.linpro.no Mon Oct 29 07:53:01 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 08:53:01 +0100 (CET) Subject: r2176 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029075301.3A3451EC6F1@projects.linpro.no> Author: phk Date: 2007-10-29 08:53:01 +0100 (Mon, 29 Oct 2007) New Revision: 2176 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_vcl.c Log: Give VRT code a chance to see which method we are in. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-29 07:46:12 UTC (rev 2175) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-29 07:53:01 UTC (rev 2176) @@ -311,6 +311,7 @@ double t_end; enum step step; + unsigned cur_method; unsigned handling; unsigned char wantbody; int err_code; Modified: trunk/varnish-cache/bin/varnishd/cache_vcl.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vcl.c 2007-10-29 07:46:12 UTC (rev 2175) +++ trunk/varnish-cache/bin/varnishd/cache_vcl.c 2007-10-29 07:53:01 UTC (rev 2176) @@ -298,15 +298,17 @@ #define VCL_RET_MAC(l,u,b,n) -#define VCL_MET_MAC(func, xxx, bitmap) \ +#define VCL_MET_MAC(func, upper, bitmap) \ void \ VCL_##func##_method(struct sess *sp) \ { \ \ sp->handling = 0; \ + sp->cur_method = VCL_MET_ ## upper; \ WSP(sp, SLT_VCL_call, "%s", #func); \ sp->vcl->func##_func(sp); \ WSP(sp, SLT_VCL_return, "%s", vcl_handlingname(sp->handling)); \ + sp->cur_method = 0; \ assert(sp->handling & bitmap); \ assert(!(sp->handling & ~bitmap)); \ } From phk at projects.linpro.no Mon Oct 29 07:53:28 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 08:53:28 +0100 (CET) Subject: r2177 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029075328.19FB51EC2AE@projects.linpro.no> Author: phk Date: 2007-10-29 08:53:27 +0100 (Mon, 29 Oct 2007) New Revision: 2177 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Issue an VCL_error if 'esi' is not used from vcl_fetch. Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 07:53:01 UTC (rev 2176) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 07:53:27 UTC (rev 2177) @@ -533,6 +533,13 @@ int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + if (sp->cur_method != VCL_MET_FETCH) { + /* XXX: we should catch this at compile time */ + WSP(sp, SLT_VCL_error, + "esi can only be called from vcl_fetch", ""); + return; + } + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX: only if GET ? */ From phk at projects.linpro.no Mon Oct 29 08:09:28 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 09:09:28 +0100 (CET) Subject: r2178 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029080928.5BCA31EC030@projects.linpro.no> Author: phk Date: 2007-10-29 09:09:28 +0100 (Mon, 29 Oct 2007) New Revision: 2178 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Don't complain about unrecognized Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 07:53:27 UTC (rev 2177) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 08:09:28 UTC (rev 2178) @@ -405,16 +405,6 @@ continue; } - if (p[1] == '!') { - /* - * Unrecognized '; q++) continue; From phk at projects.linpro.no Mon Oct 29 08:16:22 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 09:16:22 +0100 (CET) Subject: r2179 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029081622.8C9DA1EC033@projects.linpro.no> Author: phk Date: 2007-10-29 09:16:22 +0100 (Mon, 29 Oct 2007) New Revision: 2179 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: If we find no ESI elements of an object, don't penalize it with ESI's chunked delivery. Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 08:09:28 UTC (rev 2178) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 08:16:22 UTC (rev 2179) @@ -76,6 +76,7 @@ struct esi_bit *eb; struct esi_bit *ebl; /* list of */ int neb; + int is_esi; }; /*-------------------------------------------------------------------- @@ -361,6 +362,7 @@ * first seven because the tail is handled * by the incmt flag. */ + ew->is_esi++; if (i < 7) return (p - t.b); @@ -426,6 +428,8 @@ if (r + 9 < q && !memcmp(r, "esi:remove", 10)) { + ew->is_esi++; + if (celem != remflg) { /* * ESI 1.0 violation, ignore element @@ -468,6 +472,8 @@ if (r + 10 < q && !memcmp(r, "esi:include", 11)) { + ew->is_esi++; + o.e = p; esi_addverbatim(ew, o); @@ -547,11 +553,15 @@ if (VTAILQ_NEXT(st, list)) INCOMPL(); } - i = Tlen(ew->dst); } if (Tlen(ew->dst)) esi_addbit(ew); + if (!ew->is_esi) { + ESI_Destroy(sp->obj); + return; + } + /* * Our ESI implementation needs chunked encoding * XXX: We should only do this if we find any ESI directives From phk at projects.linpro.no Mon Oct 29 08:24:04 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 09:24:04 +0100 (CET) Subject: r2180 - trunk/varnish-cache/lib/libvarnishapi Message-ID: <20071029082404.D47E81EC528@projects.linpro.no> Author: phk Date: 2007-10-29 09:24:04 +0100 (Mon, 29 Oct 2007) New Revision: 2180 Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c Log: Mask negative characters to 8 bit before formatting. Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c =================================================================== --- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2007-10-29 08:16:22 UTC (rev 2179) +++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2007-10-29 08:24:04 UTC (rev 2180) @@ -353,7 +353,7 @@ if (*ptr >= ' ' && *ptr <= '~') fprintf(fo, "%c", *ptr); else - fprintf(fo, "%%%02x", *ptr); + fprintf(fo, "%%%02x", (*ptr) & 0xff); ptr++; } fprintf(fo, "\"\n"); From phk at projects.linpro.no Mon Oct 29 09:16:13 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 10:16:13 +0100 (CET) Subject: r2181 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029091613.56BEF1ECF53@projects.linpro.no> Author: phk Date: 2007-10-29 10:16:13 +0100 (Mon, 29 Oct 2007) New Revision: 2181 Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c Log: Remember to reset te bereq's workspace after use. NB: This should be merged back to 1.1 Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-10-29 08:24:04 UTC (rev 2180) +++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-10-29 09:16:13 UTC (rev 2181) @@ -161,6 +161,7 @@ { CHECK_OBJ_NOTNULL(bereq, BEREQ_MAGIC); + WS_Reset(bereq->ws, NULL); LOCK(&VBE_mtx); VTAILQ_INSERT_HEAD(&bereq_head, bereq, list); UNLOCK(&VBE_mtx); From phk at projects.linpro.no Mon Oct 29 09:24:16 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 10:24:16 +0100 (CET) Subject: r2182 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029092416.A5D6C1ECF2B@projects.linpro.no> Author: phk Date: 2007-10-29 10:24:16 +0100 (Mon, 29 Oct 2007) New Revision: 2182 Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c Log: Add compile-time selectable SHMlogging of WS-activity Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-29 09:16:13 UTC (rev 2181) +++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-29 09:24:16 UTC (rev 2182) @@ -45,11 +45,22 @@ #include "cli_priv.h" #include "cache.h" +/* Enable this to get detailed logging of WS usage */ +#if 0 +# define WS_DEBUG(foo) VSL foo +#else +# define WS_DEBUG(foo) /* nothing */ +#endif + void WS_Assert(const struct ws *ws) { assert(ws != NULL); + WS_DEBUG((SLT_Debug, 0, "WS(%p = (%p %u %u %u)", + ws, ws->s, pdiff(ws->s, ws->f), + ws->r == NULL ? 0 : pdiff(ws->f, ws->r), + pdiff(ws->s, ws->e))); assert(ws->s != NULL); assert(ws->e != NULL); assert(ws->s < ws->e); @@ -65,6 +76,7 @@ WS_Init(struct ws *ws, void *space, unsigned len) { + WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, %p, %u)", ws, space, len)); assert(space != NULL); memset(ws, 0, sizeof *ws); ws->s = space; @@ -78,6 +90,7 @@ { WS_Assert(ws); + WS_DEBUG((SLT_Debug, 0, "WS_Reset(%p, %p)", ws, p)); assert(ws->r == NULL); if (p == NULL) ws->f = ws->s; @@ -99,6 +112,7 @@ return(NULL); r = ws->f; ws->f += bytes; + WS_DEBUG((SLT_Debug, 0, "WS_Alloc(%p, %u) = %p", ws, bytes, r)); return (r); } @@ -112,6 +126,7 @@ p = WS_Alloc(ws, l); if (p != NULL) memcpy(p, s, l); + WS_DEBUG((SLT_Debug, 0, "WS_Dup(%p, \"%s\") = %p", ws, s, p)); return (p); } @@ -119,26 +134,33 @@ WS_Snapshot(struct ws *ws) { + WS_Assert(ws); assert(ws->r == NULL); + WS_DEBUG((SLT_Debug, 0, "WS_Snapshot(%p) = %p", ws, ws->f)); return (ws->f); } unsigned WS_Reserve(struct ws *ws, unsigned bytes) { + unsigned b2 = bytes; + WS_Assert(ws); assert(ws->r == NULL); if (bytes == 0) - bytes = ws->e - ws->f; - xxxassert(ws->f + bytes <= ws->e); - ws->r = ws->f + bytes; - return (ws->r - ws->f); + b2 = ws->e - ws->f; + xxxassert(ws->f + b2 <= ws->e); + ws->r = ws->f + b2; + WS_DEBUG((SLT_Debug, 0, "WS_Reserve(%p, %u/%u) = %u", + ws, b2, bytes, pdiff(ws->f, ws->r))); + return (pdiff(ws->f, ws->r)); } void WS_Release(struct ws *ws, unsigned bytes) { WS_Assert(ws); + WS_DEBUG((SLT_Debug, 0, "WS_Release(%p, %u)", ws, bytes)); assert(ws->r != NULL); assert(ws->f + bytes <= ws->r); ws->f += bytes; @@ -149,6 +171,7 @@ WS_ReleaseP(struct ws *ws, char *ptr) { WS_Assert(ws); + WS_DEBUG((SLT_Debug, 0, "WS_ReleaseP(%p, %p)", ws, ptr)); assert(ws->r != NULL); assert(ptr >= ws->f); assert(ptr <= ws->r); From phk at projects.linpro.no Mon Oct 29 09:28:21 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 10:28:21 +0100 (CET) Subject: r2183 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029092821.DD3C81EC6F1@projects.linpro.no> Author: phk Date: 2007-10-29 10:28:21 +0100 (Mon, 29 Oct 2007) New Revision: 2183 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_backend.c trunk/varnish-cache/bin/varnishd/cache_fetch.c trunk/varnish-cache/bin/varnishd/cache_session.c trunk/varnish-cache/bin/varnishd/cache_synthetic.c trunk/varnish-cache/bin/varnishd/cache_ws.c Log: Give workspaces an identifying string to aid debugging. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-29 09:24:16 UTC (rev 2182) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-29 09:28:21 UTC (rev 2183) @@ -90,6 +90,7 @@ */ struct ws { + const char *id; /* identity */ char *s; /* (S)tart of buffer */ char *f; /* (F)ree pointer */ char *r; /* (R)eserved length */ @@ -584,7 +585,7 @@ /* cache_ws.c */ -void WS_Init(struct ws *ws, void *space, unsigned len); +void WS_Init(struct ws *ws, const char *id, void *space, unsigned len); unsigned WS_Reserve(struct ws *ws, unsigned bytes); void WS_Release(struct ws *ws, unsigned bytes); void WS_ReleaseP(struct ws *ws, char *ptr); Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-10-29 09:24:16 UTC (rev 2182) +++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-10-29 09:28:21 UTC (rev 2183) @@ -147,7 +147,7 @@ if (bereq == NULL) return (NULL); bereq->magic = BEREQ_MAGIC; - WS_Init(bereq->ws, bereq + 1, len); + WS_Init(bereq->ws, "bereq", bereq + 1, len); } http_Setup(bereq->http, bereq->ws); return (bereq); Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-29 09:24:16 UTC (rev 2182) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-10-29 09:28:21 UTC (rev 2183) @@ -278,7 +278,7 @@ /* Set up obj's workspace */ st = sp->obj->objstore; - WS_Init(sp->obj->ws_o, st->ptr + st->len, st->space - st->len); + WS_Init(sp->obj->ws_o, "obj", st->ptr + st->len, st->space - st->len); st->len = st->space; WS_Assert(sp->obj->ws_o); http_Setup(sp->obj->http, sp->obj->ws_o); Modified: trunk/varnish-cache/bin/varnishd/cache_session.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_session.c 2007-10-29 09:24:16 UTC (rev 2182) +++ trunk/varnish-cache/bin/varnishd/cache_session.c 2007-10-29 09:28:21 UTC (rev 2183) @@ -318,7 +318,7 @@ sp->sockaddrlen = len; } - WS_Init(sp->ws, (void *)(sm + 1), sm->workspace); + WS_Init(sp->ws, "sess", (void *)(sm + 1), sm->workspace); sp->http = &sm->http[0]; sp->http0 = &sm->http[1]; Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-29 09:24:16 UTC (rev 2182) +++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-10-29 09:28:21 UTC (rev 2183) @@ -73,7 +73,7 @@ /* Set up obj's workspace */ st = o->objstore; - WS_Init(o->ws_o, st->ptr + st->len, st->space - st->len); + WS_Init(o->ws_o, "obj", st->ptr + st->len, st->space - st->len); st->len = st->space; WS_Assert(o->ws_o); http_Setup(o->http, o->ws_o); @@ -126,7 +126,7 @@ /* allocate space for header */ - WS_Init(h->ws, malloc(1024), 1024); + WS_Init(h->ws, "error", malloc(1024), 1024); /* generate header */ http_ClrHeader(h); Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-29 09:24:16 UTC (rev 2182) +++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-29 09:28:21 UTC (rev 2183) @@ -57,8 +57,8 @@ { assert(ws != NULL); - WS_DEBUG((SLT_Debug, 0, "WS(%p = (%p %u %u %u)", - ws, ws->s, pdiff(ws->s, ws->f), + WS_DEBUG((SLT_Debug, 0, "WS(%p = (%s, %p %u %u %u)", + ws, ws->id, ws->s, pdiff(ws->s, ws->f), ws->r == NULL ? 0 : pdiff(ws->f, ws->r), pdiff(ws->s, ws->e))); assert(ws->s != NULL); @@ -73,15 +73,16 @@ } void -WS_Init(struct ws *ws, void *space, unsigned len) +WS_Init(struct ws *ws, const char *id, void *space, unsigned len) { - WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, %p, %u)", ws, space, len)); + WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len)); assert(space != NULL); memset(ws, 0, sizeof *ws); ws->s = space; ws->e = ws->s + len; ws->f = ws->s; + ws->id = id; WS_Assert(ws); } From phk at projects.linpro.no Mon Oct 29 10:18:35 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 11:18:35 +0100 (CET) Subject: r2184 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029101835.D58C81ECF2B@projects.linpro.no> Author: phk Date: 2007-10-29 11:17:58 +0100 (Mon, 29 Oct 2007) New Revision: 2184 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Postpone freeing the bereq until after VCL_fetch() has been called Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-29 09:28:21 UTC (rev 2183) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-29 10:17:58 UTC (rev 2184) @@ -310,9 +310,6 @@ i = Fetch(sp); CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); - VBE_free_bereq(sp->bereq); - sp->bereq = NULL; - if (!i) RFC2616_cache_policy(sp, sp->obj->http); /* XXX -> VCL */ else { @@ -325,6 +322,9 @@ sp->err_code = http_GetStatus(sp->obj->http); VCL_fetch_method(sp); + VBE_free_bereq(sp->bereq); + sp->bereq = NULL; + switch (sp->handling) { case VCL_RET_ERROR: case VCL_RET_RESTART: From phk at projects.linpro.no Mon Oct 29 10:20:43 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 11:20:43 +0100 (CET) Subject: r2185 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029102043.B03711ECF87@projects.linpro.no> Author: phk Date: 2007-10-29 11:20:36 +0100 (Mon, 29 Oct 2007) New Revision: 2185 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Implement relative URL for esi:include. Use the bereq.url as starting point, since req.url may have been rewritten underway. Store result in objects workspace. Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 10:17:58 UTC (rev 2184) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-29 10:20:36 UTC (rev 2185) @@ -261,6 +261,8 @@ char *p, *q; txt tag; txt val; + unsigned u, v; + struct ws *ws; VSL(SLT_Debug, 0, "Incl \"%.*s\"", t.e - t.b, t.b); eb = esi_addbit(ew); @@ -290,11 +292,40 @@ /* Absolute on this host */ eb->include = val; } else { - /* Relative to current URL */ - /* XXX: search forward to '?' use previous / */ - /* XXX: where to store edited result ? */ - eb->include = val; - INCOMPL(); + + /* + * Decision: We interpret the relative URL against + * the actual URL we asked the backend for. + * The client's request URL may be entirely + * different and have been rewritten underway. + */ + CHECK_OBJ_NOTNULL(ew->sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(ew->sp->bereq, BEREQ_MAGIC); + CHECK_OBJ_NOTNULL(ew->sp->bereq->http, HTTP_MAGIC); + tag = ew->sp->bereq->http->hd[HTTP_HDR_URL]; + + /* Use the objects WS to store the result */ + CHECK_OBJ_NOTNULL(ew->sp->obj, OBJECT_MAGIC); + ws = ew->sp->obj->ws_o; + WS_Assert(ws); + + /* Look for the last '/' before a '?' */ + q = NULL; + for (p = tag.b; p < tag.e && *p != '?'; p++) + if (*p == '/') + q = p; + if (q != NULL) + tag.e = q + 1; + + u = WS_Reserve(ws, 0); + v = snprintf(ws->f, u - 1, "%.*s%.*s", + tag.e - tag.b, tag.b, + val.e - val.b, val.b); + v++; + xxxassert(v < u); + eb->include.b = ws->f; + eb->include.e = ws->f + v; + WS_Release(ws, v); } } } From phk at projects.linpro.no Mon Oct 29 10:22:22 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 11:22:22 +0100 (CET) Subject: r2186 - in trunk/varnish-cache: bin/varnishd lib/libvcl Message-ID: <20071029102222.D101E1ECF59@projects.linpro.no> Author: phk Date: 2007-10-29 11:22:22 +0100 (Mon, 29 Oct 2007) New Revision: 2186 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl trunk/varnish-cache/lib/libvcl/vcc_obj.c Log: Make bereq. available from vcl_fetch() Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-29 10:20:36 UTC (rev 2185) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-29 10:22:22 UTC (rev 2186) @@ -284,7 +284,7 @@ DOT ] DOT vcl_fetch [ DOT shape=record -DOT label="vcl_fetch()|req.\nobj." +DOT label="vcl_fetch()|req.\nobj.\nbereq." DOT ] DOT fetch -> vcl_fetch [style=bold,color=blue,weight=2] DOT fetch_pass [ Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2007-10-29 10:20:36 UTC (rev 2185) +++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2007-10-29 10:22:22 UTC (rev 2186) @@ -101,22 +101,22 @@ # Request sent to backend { bereq.request RW STRING - { pipe pass miss } + { pipe pass miss fetch } "const struct sess *" } { bereq.url RW STRING - { pipe pass miss } + { pipe pass miss fetch } "const struct sess *" } { bereq.proto RW STRING - { pipe pass miss } + { pipe pass miss fetch } "const struct sess *" } { bereq.http. RW HDR_BEREQ - { pipe pass miss } + { pipe pass miss fetch } "const struct sess *" } Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_obj.c 2007-10-29 10:20:36 UTC (rev 2185) +++ trunk/varnish-cache/lib/libvcl/vcc_obj.c 2007-10-29 10:22:22 UTC (rev 2186) @@ -110,28 +110,28 @@ "VRT_l_bereq_request(sp, ", V_RW, 0, - VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS + VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH }, { "bereq.url", STRING, 9, "VRT_r_bereq_url(sp)", "VRT_l_bereq_url(sp, ", V_RW, 0, - VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS + VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH }, { "bereq.proto", STRING, 11, "VRT_r_bereq_proto(sp)", "VRT_l_bereq_proto(sp, ", V_RW, 0, - VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS + VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH }, { "bereq.http.", HEADER, 11, "VRT_r_bereq_http_(sp)", "VRT_l_bereq_http_(sp, ", V_RW, "HDR_BEREQ", - VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS + VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH }, { "obj.proto", STRING, 9, "VRT_r_obj_proto(sp)", From phk at projects.linpro.no Mon Oct 29 12:06:34 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 13:06:34 +0100 (CET) Subject: r2187 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029120634.7E7A81ECF2B@projects.linpro.no> Author: phk Date: 2007-10-29 13:06:34 +0100 (Mon, 29 Oct 2007) New Revision: 2187 Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/hash_classic.c Log: More checks, trying to find pointer tango Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-29 10:22:22 UTC (rev 2186) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-29 12:06:34 UTC (rev 2187) @@ -73,6 +73,7 @@ struct storage *st; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); w = sp->wrk; if (w->nobjhead == NULL) { @@ -87,7 +88,8 @@ if (w->nobj == NULL) { st = STV_alloc(sp, params->mem_workspace); XXXAN(st); - w->nobj = (void *)st->ptr; + assert(st->size > sizeof *w->nobj); + w->nobj = (void *)st->ptr; /* XXX: align ? */ st->len = sizeof *w->nobj; memset(w->nobj, 0, sizeof *w->nobj); w->nobj->objstore = st; @@ -122,6 +124,9 @@ unsigned u, v; const char *b; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(obj, OBJHEAD_MAGIC); i = sp->lhashptr - obj->hashlen; if (i) return (i); Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-10-29 10:22:22 UTC (rev 2186) +++ trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-10-29 12:06:34 UTC (rev 2187) @@ -128,6 +128,9 @@ unsigned u, v; int i; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); CHECK_OBJ_ORNULL(noh, OBJHEAD_MAGIC); digest = ~0U; From phk at projects.linpro.no Mon Oct 29 12:09:54 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 13:09:54 +0100 (CET) Subject: r2188 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029120954.5EB1F1ECF27@projects.linpro.no> Author: phk Date: 2007-10-29 13:09:54 +0100 (Mon, 29 Oct 2007) New Revision: 2188 Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c Log: Typo in previous commit. Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-29 12:06:34 UTC (rev 2187) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-10-29 12:09:54 UTC (rev 2188) @@ -88,7 +88,7 @@ if (w->nobj == NULL) { st = STV_alloc(sp, params->mem_workspace); XXXAN(st); - assert(st->size > sizeof *w->nobj); + assert(st->space > sizeof *w->nobj); w->nobj = (void *)st->ptr; /* XXX: align ? */ st->len = sizeof *w->nobj; memset(w->nobj, 0, sizeof *w->nobj); From phk at projects.linpro.no Mon Oct 29 12:10:16 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 13:10:16 +0100 (CET) Subject: r2189 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029121016.651CA1ECF12@projects.linpro.no> Author: phk Date: 2007-10-29 13:10:16 +0100 (Mon, 29 Oct 2007) New Revision: 2189 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_ws.c Log: Give struct ws the mini_obj treatment, not sure why I didn't before. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2007-10-29 12:09:54 UTC (rev 2188) +++ trunk/varnish-cache/bin/varnishd/cache.h 2007-10-29 12:10:16 UTC (rev 2189) @@ -90,6 +90,8 @@ */ struct ws { + unsigned magic; +#define WS_MAGIC 0x35fac554 const char *id; /* identity */ char *s; /* (S)tart of buffer */ char *f; /* (F)ree pointer */ Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-29 12:09:54 UTC (rev 2188) +++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-29 12:10:16 UTC (rev 2189) @@ -56,7 +56,7 @@ WS_Assert(const struct ws *ws) { - assert(ws != NULL); + CHECK_OBJ_NOTNULL(ws, WS_MAGIC); WS_DEBUG((SLT_Debug, 0, "WS(%p = (%s, %p %u %u %u)", ws, ws->id, ws->s, pdiff(ws->s, ws->f), ws->r == NULL ? 0 : pdiff(ws->f, ws->r), @@ -79,6 +79,7 @@ WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len)); assert(space != NULL); memset(ws, 0, sizeof *ws); + ws->magic = WS_MAGIC; ws->s = space; ws->e = ws->s + len; ws->f = ws->s; From phk at projects.linpro.no Mon Oct 29 12:22:38 2007 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 29 Oct 2007 13:22:38 +0100 (CET) Subject: r2190 - trunk/varnish-cache/bin/varnishd Message-ID: <20071029122238.B768F1ECF81@projects.linpro.no> Author: phk Date: 2007-10-29 13:22:38 +0100 (Mon, 29 Oct 2007) New Revision: 2190 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Add more paranoia Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-29 12:10:16 UTC (rev 2189) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-29 12:22:38 UTC (rev 2190) @@ -87,6 +87,9 @@ { int i; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + AZ(sp->obj); assert(sp->xid == 0); i = HTC_Complete(sp->htc); @@ -142,6 +145,10 @@ cnt_deliver(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + sp->t_resp = TIM_real(); if (sp->obj->objhead != NULL) EXP_Touch(sp->obj, sp->t_resp); @@ -183,6 +190,9 @@ double dh, dp, da; int i; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + AZ(sp->obj); AZ(sp->bereq); sp->backend = NULL; @@ -305,6 +315,9 @@ { int i; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + AN(sp->bereq); CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); i = Fetch(sp); @@ -428,6 +441,10 @@ cnt_hit(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + assert(!sp->obj->pass); VCL_hit_method(sp); @@ -492,6 +509,7 @@ uintptr_t u; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); if (sp->obj == NULL) { @@ -585,6 +603,10 @@ cnt_miss(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + http_FilterHeader(sp, HTTPH_R_FETCH); VCL_miss_method(sp); if (sp->handling == VCL_RET_ERROR) { @@ -644,6 +666,8 @@ cnt_pass(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); http_FilterHeader(sp, HTTPH_R_PASS); @@ -690,6 +714,9 @@ cnt_pipe(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + sp->wrk->acct.pipe++; http_FilterHeader(sp, HTTPH_R_PIPE); @@ -725,8 +752,9 @@ cnt_recv(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); - AN(sp->vcl); VCL_recv_method(sp); @@ -770,6 +798,7 @@ { int done; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); AZ(sp->restarts); AZ(sp->obj); AZ(sp->vcl); From des at linpro.no Mon Oct 29 14:43:04 2007 From: des at linpro.no (=?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?=) Date: Mon, 29 Oct 2007 15:43:04 +0100 Subject: r2180 - trunk/varnish-cache/lib/libvarnishapi In-Reply-To: <20071029082404.D47E81EC528@projects.linpro.no> (phk@projects.linpro.no's message of "Mon, 29 Oct 2007 09:24:04 +0100 (CET)") References: <20071029082404.D47E81EC528@projects.linpro.no> Message-ID: phk at projects.linpro.no writes: > Log: > Mask negative characters to 8 bit before formatting. A cast would be more appropriate... and we should probably use isprint() instead of hardcoding (*ptr >= ' ' && *ptr <= '~'). DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no From phk at phk.freebsd.dk Mon Oct 29 15:28:07 2007 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Mon, 29 Oct 2007 15:28:07 +0000 Subject: r2180 - trunk/varnish-cache/lib/libvarnishapi In-Reply-To: Your message of "Mon, 29 Oct 2007 15:43:04 +0100." Message-ID: <32518.1193671687@critter.freebsd.dk> In message , =?iso-8859-1?Q?Dag-Erling_Sm?rg rav?= writes: >phk at projects.linpro.no writes: >> Log: >> Mask negative characters to 8 bit before formatting. > >A cast would be more appropriate... and we should probably use >isprint() instead of hardcoding (*ptr >= ' ' && *ptr <= '~'). A cast we can discuss, but isprint() would be wrong because it would take the locale into consideration and HTTP is specifically specified in ASCII with no extension. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From des at linpro.no Mon Oct 29 15:44:47 2007 From: des at linpro.no (=?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?=) Date: Mon, 29 Oct 2007 16:44:47 +0100 Subject: r2180 - trunk/varnish-cache/lib/libvarnishapi In-Reply-To: <32518.1193671687@critter.freebsd.dk> (Poul-Henning Kamp's message of "Mon, 29 Oct 2007 15:28:07 +0000") References: <32518.1193671687@critter.freebsd.dk> Message-ID: "Poul-Henning Kamp" writes: > "Dag-Erling Sm?rgrav" writes: > > A cast would be more appropriate... and we should probably use > > isprint() instead of hardcoding (*ptr >= ' ' && *ptr <= '~'). > A cast we can discuss, but isprint() would be wrong because it would > take the locale into consideration and HTTP is specifically specified > in ASCII with no extension. We already force the time zone to UTC, there is no reason not to force the locale to "C". Alternatively, we can provide our own ASCII-only implementation - I really don't like (*ptr >= ' ' && *ptr <= '~'). DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no From des at projects.linpro.no Tue Oct 30 10:43:32 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 11:43:32 +0100 (CET) Subject: r2191 - in branches/1.1: . bin/varnishd Message-ID: <20071030104332.C92651EC528@projects.linpro.no> Author: des Date: 2007-10-30 11:43:32 +0100 (Tue, 30 Oct 2007) New Revision: 2191 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache_backend.c Log: Merged revisions 2181 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2181 | phk | 2007-10-29 10:16:13 +0100 (Mon, 29 Oct 2007) | 5 lines Remember to reset te bereq's workspace after use. NB: This should be merged back to 1.1 ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2116,2133,2154,2173 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2116,2133,2154,2173,2181 Modified: branches/1.1/bin/varnishd/cache_backend.c =================================================================== --- branches/1.1/bin/varnishd/cache_backend.c 2007-10-29 12:22:38 UTC (rev 2190) +++ branches/1.1/bin/varnishd/cache_backend.c 2007-10-30 10:43:32 UTC (rev 2191) @@ -95,6 +95,7 @@ { CHECK_OBJ_NOTNULL(bereq, BEREQ_MAGIC); + WS_Reset(bereq->ws, NULL); LOCK(&vbemtx); VTAILQ_INSERT_HEAD(&bereq_head, bereq, list); UNLOCK(&vbemtx); From des at projects.linpro.no Tue Oct 30 10:45:29 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 11:45:29 +0100 (CET) Subject: r2192 - in branches/1.2: . bin/varnishd include Message-ID: <20071030104529.2C3ED1EC030@projects.linpro.no> Author: des Date: 2007-10-30 11:45:28 +0100 (Tue, 30 Oct 2007) New Revision: 2192 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache.h branches/1.2/bin/varnishd/cache_vcl.c branches/1.2/include/shmlog_tags.h Log: Merged revisions 2175-2176 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2175 | phk | 2007-10-29 08:46:12 +0100 (Mon, 29 Oct 2007) | 2 lines Add a VCL_error shmtag ........ r2176 | phk | 2007-10-29 08:53:01 +0100 (Mon, 29 Oct 2007) | 2 lines Give VRT code a chance to see which method we are in. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2175-2176 Modified: branches/1.2/bin/varnishd/cache.h =================================================================== --- branches/1.2/bin/varnishd/cache.h 2007-10-30 10:43:32 UTC (rev 2191) +++ branches/1.2/bin/varnishd/cache.h 2007-10-30 10:45:28 UTC (rev 2192) @@ -303,6 +303,7 @@ double t_end; enum step step; + unsigned cur_method; unsigned handling; unsigned char wantbody; int err_code; Modified: branches/1.2/bin/varnishd/cache_vcl.c =================================================================== --- branches/1.2/bin/varnishd/cache_vcl.c 2007-10-30 10:43:32 UTC (rev 2191) +++ branches/1.2/bin/varnishd/cache_vcl.c 2007-10-30 10:45:28 UTC (rev 2192) @@ -298,15 +298,17 @@ #define VCL_RET_MAC(l,u,b,n) -#define VCL_MET_MAC(func, xxx, bitmap) \ +#define VCL_MET_MAC(func, upper, bitmap) \ void \ VCL_##func##_method(struct sess *sp) \ { \ \ sp->handling = 0; \ + sp->cur_method = VCL_MET_ ## upper; \ WSP(sp, SLT_VCL_call, "%s", #func); \ sp->vcl->func##_func(sp); \ WSP(sp, SLT_VCL_return, "%s", vcl_handlingname(sp->handling)); \ + sp->cur_method = 0; \ assert(sp->handling & bitmap); \ assert(!(sp->handling & ~bitmap)); \ } Modified: branches/1.2/include/shmlog_tags.h =================================================================== --- branches/1.2/include/shmlog_tags.h 2007-10-30 10:43:32 UTC (rev 2191) +++ branches/1.2/include/shmlog_tags.h 2007-10-30 10:45:28 UTC (rev 2192) @@ -84,6 +84,7 @@ SLTM(VCL_call) SLTM(VCL_trace) SLTM(VCL_return) +SLTM(VCL_error) SLTM(ReqStart) SLTM(Hit) SLTM(HitPass) From des at projects.linpro.no Tue Oct 30 10:48:31 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 11:48:31 +0100 (CET) Subject: r2193 - trunk/varnish-cache/lib/libvarnishapi Message-ID: <20071030104831.319361EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 11:48:30 +0100 (Tue, 30 Oct 2007) New Revision: 2193 Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c Log: Use a cast to prevent sign extension instead of masking it off after the fact. Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c =================================================================== --- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2007-10-30 10:45:28 UTC (rev 2192) +++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2007-10-30 10:48:30 UTC (rev 2193) @@ -353,7 +353,7 @@ if (*ptr >= ' ' && *ptr <= '~') fprintf(fo, "%c", *ptr); else - fprintf(fo, "%%%02x", (*ptr) & 0xff); + fprintf(fo, "%%%02x", (unsigned char)*ptr); ptr++; } fprintf(fo, "\"\n"); From des at projects.linpro.no Tue Oct 30 10:48:51 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 11:48:51 +0100 (CET) Subject: r2194 - in branches/1.2: . lib/libvarnishapi Message-ID: <20071030104851.EEA1B1EC030@projects.linpro.no> Author: des Date: 2007-10-30 11:48:51 +0100 (Tue, 30 Oct 2007) New Revision: 2194 Modified: branches/1.2/ branches/1.2/lib/libvarnishapi/shmlog.c Log: Merged revisions 2180,2191-2192 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2180 | phk | 2007-10-29 09:24:04 +0100 (Mon, 29 Oct 2007) | 2 lines Mask negative characters to 8 bit before formatting. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2175-2176 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2175-2176,2180,2191-2192 Modified: branches/1.2/lib/libvarnishapi/shmlog.c =================================================================== --- branches/1.2/lib/libvarnishapi/shmlog.c 2007-10-30 10:48:30 UTC (rev 2193) +++ branches/1.2/lib/libvarnishapi/shmlog.c 2007-10-30 10:48:51 UTC (rev 2194) @@ -353,7 +353,7 @@ if (*ptr >= ' ' && *ptr <= '~') fprintf(fo, "%c", *ptr); else - fprintf(fo, "%%%02x", *ptr); + fprintf(fo, "%%%02x", (*ptr) & 0xff); ptr++; } fprintf(fo, "\"\n"); From des at projects.linpro.no Tue Oct 30 10:57:41 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 11:57:41 +0100 (CET) Subject: r2195 - in branches/1.2: . bin/varnishd Message-ID: <20071030105741.B9FE11EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 11:57:41 +0100 (Tue, 30 Oct 2007) New Revision: 2195 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache.h branches/1.2/bin/varnishd/cache_ws.c Log: Merged revisions 2166 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2166 | phk | 2007-10-24 12:24:08 +0200 (Wed, 24 Oct 2007) | 2 lines Add a WS_Dup() function ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2175-2176,2180,2191-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166,2175-2176,2180,2191-2192 Modified: branches/1.2/bin/varnishd/cache.h =================================================================== --- branches/1.2/bin/varnishd/cache.h 2007-10-30 10:48:51 UTC (rev 2194) +++ branches/1.2/bin/varnishd/cache.h 2007-10-30 10:57:41 UTC (rev 2195) @@ -578,6 +578,7 @@ void WS_Assert(const struct ws *ws); void WS_Reset(struct ws *ws); char *WS_Alloc(struct ws *ws, unsigned bytes); +char *WS_Dup(struct ws *ws, const char *); /* rfc2616.c */ int RFC2616_cache_policy(const struct sess *sp, const struct http *hp); Modified: branches/1.2/bin/varnishd/cache_ws.c =================================================================== --- branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 10:48:51 UTC (rev 2194) +++ branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 10:57:41 UTC (rev 2195) @@ -96,6 +96,19 @@ return (r); } +char * +WS_Dup(struct ws *ws, const char *s) +{ + unsigned l; + char *p; + + l = strlen(s) + 1; + p = WS_Alloc(ws, l); + if (p != NULL) + memcpy(p, s, l); + return (p); +} + unsigned WS_Reserve(struct ws *ws, unsigned bytes) { From des at projects.linpro.no Tue Oct 30 10:59:36 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 11:59:36 +0100 (CET) Subject: r2196 - in branches/1.2: . bin/varnishd Message-ID: <20071030105936.BAE401EC528@projects.linpro.no> Author: des Date: 2007-10-30 11:59:36 +0100 (Tue, 30 Oct 2007) New Revision: 2196 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_backend.c Log: Merged revisions 2181 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2181 | phk | 2007-10-29 10:16:13 +0100 (Mon, 29 Oct 2007) | 5 lines Remember to reset te bereq's workspace after use. NB: This should be merged back to 1.1 ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166,2175-2176,2180,2191-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166,2175-2176,2180-2181,2191-2192 Modified: branches/1.2/bin/varnishd/cache_backend.c =================================================================== --- branches/1.2/bin/varnishd/cache_backend.c 2007-10-30 10:57:41 UTC (rev 2195) +++ branches/1.2/bin/varnishd/cache_backend.c 2007-10-30 10:59:36 UTC (rev 2196) @@ -161,6 +161,7 @@ { CHECK_OBJ_NOTNULL(bereq, BEREQ_MAGIC); + WS_Reset(bereq->ws, NULL); LOCK(&VBE_mtx); VTAILQ_INSERT_HEAD(&bereq_head, bereq, list); UNLOCK(&VBE_mtx); From des at projects.linpro.no Tue Oct 30 11:02:51 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 12:02:51 +0100 (CET) Subject: r2197 - in branches/1.2: . bin/varnishd include lib/libvcl Message-ID: <20071030110251.4C8111EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 12:02:51 +0100 (Tue, 30 Oct 2007) New Revision: 2197 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache.h branches/1.2/bin/varnishd/cache_acceptor.c branches/1.2/bin/varnishd/cache_center.c branches/1.2/bin/varnishd/cache_httpconn.c branches/1.2/bin/varnishd/cache_session.c branches/1.2/bin/varnishd/cache_vrt.c branches/1.2/bin/varnishd/cache_ws.c branches/1.2/include/vrt.h branches/1.2/lib/libvcl/vcc_action.c branches/1.2/lib/libvcl/vcc_fixed_token.c Log: Merged revisions 2167 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2167 | phk | 2007-10-24 16:32:12 +0200 (Wed, 24 Oct 2007) | 48 lines Gently shuffle closer to being able to restart a esi:include on the next element: Add two checkpoints for the sessions workspace. The first checkpoint is after the session fixed data, and move the client address and port to workspace to see that this works. The second checkpoint is after the, as received unadultered by VCL http request. Grab a copy of the http request matching this. Implement rollback as an optional feature of restart in VCL. Move various workspace initialization and resetting operations to more suitable locations in the program flow. I don't know if this is really usable, but now it's possible to do: backend b1 { set backend.host = "backend1"; set backend.port = "80"; } backend b2 { set backend.host = "backend2"; set backend.port = "80"; } sub vcl_recv { set req.backend = b1; remove req.http.cookie; if (req.restarts == 0) { set req.url = "foobar.html"; } else { set req.backend = b2; } } sub vcl_fetch { if (obj.status != 200) { restart rollback; } } And have it first look for "foobar.html" on one backend, and failing that, try to give the user what they asked for from the other backend. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166,2175-2176,2180-2181,2191-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2167,2175-2176,2180-2181,2191-2192 Modified: branches/1.2/bin/varnishd/cache.h =================================================================== --- branches/1.2/bin/varnishd/cache.h 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/bin/varnishd/cache.h 2007-10-30 11:02:51 UTC (rev 2197) @@ -285,14 +285,18 @@ struct sockaddr *mysockaddr; /* formatted ascii client address */ - char addr[TCP_ADDRBUFSIZE]; - char port[TCP_PORTBUFSIZE]; + char *addr; + char *port; struct srcaddr *srcaddr; /* HTTP request */ const char *doclose; struct http *http; + struct http *http0; + struct ws ws[1]; + char *ws_ses; /* WS above session data */ + char *ws_req; /* WS above request data */ struct http_conn htc[1]; @@ -576,9 +580,10 @@ void WS_Release(struct ws *ws, unsigned bytes); void WS_ReleaseP(struct ws *ws, char *ptr); void WS_Assert(const struct ws *ws); -void WS_Reset(struct ws *ws); +void WS_Reset(struct ws *ws, char *p); char *WS_Alloc(struct ws *ws, unsigned bytes); char *WS_Dup(struct ws *ws, const char *); +char *WS_Snapshot(struct ws *ws); /* rfc2616.c */ int RFC2616_cache_policy(const struct sess *sp, const struct http *hp); Modified: branches/1.2/bin/varnishd/cache_acceptor.c =================================================================== --- branches/1.2/bin/varnishd/cache_acceptor.c 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/bin/varnishd/cache_acceptor.c 2007-10-30 11:02:51 UTC (rev 2197) @@ -107,9 +107,14 @@ void VCA_Prep(struct sess *sp) { + char addr[TCP_ADDRBUFSIZE]; + char port[TCP_PORTBUFSIZE]; + TCP_name(sp->sockaddr, sp->sockaddrlen, - sp->addr, sizeof sp->addr, sp->port, sizeof sp->port); + addr, sizeof addr, port, sizeof port); + sp->addr = WS_Dup(sp->ws, addr); + sp->port = WS_Dup(sp->ws, port); VSL(SLT_SessionOpen, sp->fd, "%s %s", sp->addr, sp->port); sp->acct.first = sp->t_open; if (need_test) @@ -195,7 +200,6 @@ sp->id = i; sp->t_open = now; - HTC_Init(sp->htc, sp->ws, sp->fd); sp->step = STP_FIRST; WRK_QueueSession(sp); } Modified: branches/1.2/bin/varnishd/cache_center.c =================================================================== --- branches/1.2/bin/varnishd/cache_center.c 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/bin/varnishd/cache_center.c 2007-10-30 11:02:51 UTC (rev 2197) @@ -221,6 +221,9 @@ return (1); } + /* Reset the workspace to the session-watermark */ + WS_Reset(sp->ws, sp->ws_ses); + i = HTC_Reinit(sp->htc); if (i == 1) { VSL_stats->sess_pipeline++; @@ -368,12 +371,19 @@ assert(sp->xid == 0); VCA_Prep(sp); + + /* Record the session watermark */ + sp->ws_ses = WS_Snapshot(sp->ws); + + /* Receive a HTTP protocol request */ + HTC_Init(sp->htc, sp->ws, sp->fd); sp->wrk->used = sp->t_open; sp->wrk->acct.sess++; SES_RefSrcAddr(sp); do i = HTC_Rx(sp->htc); while (i == 0); + switch (i) { case 1: sp->step = STP_RECV; @@ -734,7 +744,15 @@ sp->vcl = sp->wrk->vcl; sp->wrk->vcl = NULL; + http_Setup(sp->http, sp->ws); done = http_DissectRequest(sp); + + /* Catch request snapshot */ + sp->ws_req = WS_Snapshot(sp->ws); + + /* Catch original request, before modification */ + *sp->http0 = *sp->http; + if (done != 0) { RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */ sp->step = STP_DONE; Modified: branches/1.2/bin/varnishd/cache_httpconn.c =================================================================== --- branches/1.2/bin/varnishd/cache_httpconn.c 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/bin/varnishd/cache_httpconn.c 2007-10-30 11:02:51 UTC (rev 2197) @@ -86,7 +86,6 @@ htc->magic = HTTP_CONN_MAGIC; htc->ws = ws; htc->fd = fd; - WS_Reset(htc->ws); WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2); htc->rxbuf.b = ws->f; htc->rxbuf.e = ws->f; @@ -107,7 +106,6 @@ int i; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); - WS_Reset(htc->ws); WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2); htc->rxbuf.b = htc->ws->f; htc->rxbuf.e = htc->ws->f; Modified: branches/1.2/bin/varnishd/cache_session.c =================================================================== --- branches/1.2/bin/varnishd/cache_session.c 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/bin/varnishd/cache_session.c 2007-10-30 11:02:51 UTC (rev 2197) @@ -65,7 +65,7 @@ #define SESSMEM_MAGIC 0x555859c5 struct sess sess; - struct http http; + struct http http[2]; unsigned workspace; VTAILQ_ENTRY(sessmem) list; struct sockaddr_storage sockaddr[2]; @@ -319,8 +319,8 @@ } WS_Init(sp->ws, (void *)(sm + 1), sm->workspace); - sp->http = &sm->http; - http_Setup(sp->http, sp->ws); + sp->http = &sm->http[0]; + sp->http0 = &sm->http[1]; return (sp); } Modified: branches/1.2/bin/varnishd/cache_vrt.c =================================================================== --- branches/1.2/bin/varnishd/cache_vrt.c 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/bin/varnishd/cache_vrt.c 2007-10-30 11:02:51 UTC (rev 2197) @@ -510,6 +510,16 @@ /*--------------------------------------------------------------------*/ void +VRT_Rollback(struct sess *sp) +{ + + *sp->http = *sp->http0; + WS_Reset(sp->ws, sp->ws_req); +} + +/*--------------------------------------------------------------------*/ + +void VRT_purge(const char *regexp, int hash) { Modified: branches/1.2/bin/varnishd/cache_ws.c =================================================================== --- branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 11:02:51 UTC (rev 2197) @@ -74,12 +74,18 @@ } void -WS_Reset(struct ws *ws) +WS_Reset(struct ws *ws, char *p) { WS_Assert(ws); assert(ws->r == NULL); - ws->f = ws->s; + if (p == NULL) + ws->f = ws->s; + else { + assert(p >= ws->s); + assert(p < ws->e); + ws->f = p; + } } char * @@ -109,6 +115,14 @@ return (p); } +char * +WS_Snapshot(struct ws *ws) +{ + + assert(ws->r == NULL); + return (ws->f); +} + unsigned WS_Reserve(struct ws *ws, unsigned bytes) { Modified: branches/1.2/include/vrt.h =================================================================== --- branches/1.2/include/vrt.h 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/include/vrt.h 2007-10-30 11:02:51 UTC (rev 2197) @@ -114,8 +114,8 @@ int VRT_strcmp(const char *s1, const char *s2); void VRT_ESI(struct sess *sp); +void VRT_Rollback(struct sess *sp); - /* Backend related */ void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *); void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *); Modified: branches/1.2/lib/libvcl/vcc_action.c =================================================================== --- branches/1.2/lib/libvcl/vcc_action.c 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/lib/libvcl/vcc_action.c 2007-10-30 11:02:51 UTC (rev 2197) @@ -55,6 +55,25 @@ /*--------------------------------------------------------------------*/ static void +parse_restart_real(struct tokenlist *tl) +{ + struct token *t1; + + t1 = VTAILQ_NEXT(tl->t, list); + if (t1->tok == ID && vcc_IdIs(t1, "rollback")) { + Fb(tl, 1, "VRT_Rollback(sp);\n"); + vcc_NextToken(tl); + } else if (t1->tok != ';') { + vsb_printf(tl->sb, "Expected \"rollback\" or semicolon.\n"); + vcc_ErrWhere(tl, t1); + ERRCHK(tl); + } + parse_restart(tl); +} + +/*--------------------------------------------------------------------*/ + +static void parse_call(struct tokenlist *tl) { @@ -335,6 +354,7 @@ const char *name; action_f *func; } action_table[] = { + { "restart", parse_restart_real }, #define VCL_RET_MAC(l, u, b, i) { #l, parse_##l }, #define VCL_RET_MAC_E(l, u, b, i) VCL_RET_MAC(l, u, b, i) #include "vcl_returns.h" Modified: branches/1.2/lib/libvcl/vcc_fixed_token.c =================================================================== --- branches/1.2/lib/libvcl/vcc_fixed_token.c 2007-10-30 10:59:36 UTC (rev 2196) +++ branches/1.2/lib/libvcl/vcc_fixed_token.c 2007-10-30 11:02:51 UTC (rev 2197) @@ -493,8 +493,8 @@ vsb_cat(sb, "int VRT_strcmp(const char *s1, const char *s2);\n"); vsb_cat(sb, "\n"); vsb_cat(sb, "void VRT_ESI(struct sess *sp);\n"); + vsb_cat(sb, "void VRT_Rollback(struct sess *sp);\n"); vsb_cat(sb, "\n"); - vsb_cat(sb, "\n"); vsb_cat(sb, "/* Backend related */\n"); vsb_cat(sb, "void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *);\n"); vsb_cat(sb, "void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *);\n"); From des at projects.linpro.no Tue Oct 30 11:03:05 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 12:03:05 +0100 (CET) Subject: r2198 - in branches/1.2: . bin/varnishd Message-ID: <20071030110305.514B11EC51C@projects.linpro.no> Author: des Date: 2007-10-30 12:03:05 +0100 (Tue, 30 Oct 2007) New Revision: 2198 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_acceptor.c branches/1.2/bin/varnishd/cache_center.c branches/1.2/bin/varnishd/steps.h Log: Merged revisions 2168 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2168 | phk | 2007-10-24 20:38:17 +0200 (Wed, 24 Oct 2007) | 8 lines Split STP_RECV in two: STP_START is the initial setup of a viable workerthread: Dissecting HTTP, getting vcl reference etc. STP_RECV is invoking vcl_recv() and following orders. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2167,2175-2176,2180-2181,2191-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2181,2191-2192 Modified: branches/1.2/bin/varnishd/cache_acceptor.c =================================================================== --- branches/1.2/bin/varnishd/cache_acceptor.c 2007-10-30 11:02:51 UTC (rev 2197) +++ branches/1.2/bin/varnishd/cache_acceptor.c 2007-10-30 11:03:05 UTC (rev 2198) @@ -222,7 +222,7 @@ SES_Delete(sp); break; case 1: - sp->step = STP_RECV; + sp->step = STP_START; WRK_QueueSession(sp); break; default: Modified: branches/1.2/bin/varnishd/cache_center.c =================================================================== --- branches/1.2/bin/varnishd/cache_center.c 2007-10-30 11:02:51 UTC (rev 2197) +++ branches/1.2/bin/varnishd/cache_center.c 2007-10-30 11:03:05 UTC (rev 2198) @@ -48,12 +48,12 @@ DOT size="7.2,10.5" DOT margin="0.5" DOT center="1" -DOT start [ +DOT acceptor [ DOT shape=hexagon DOT label="Request received" DOT ] DOT ERROR [shape=plaintext] -DOT start -> recv [style=bold,color=green,weight=4] +DOT acceptor -> start [style=bold,color=green,weight=4] */ #include @@ -93,7 +93,7 @@ while (i == 0) i = HTC_Rx(sp->htc); if (i == 1) { - sp->step = STP_RECV; + sp->step = STP_START; } else { vca_close_session(sp, "overflow"); sp->step = STP_DONE; @@ -227,7 +227,7 @@ i = HTC_Reinit(sp->htc); if (i == 1) { VSL_stats->sess_pipeline++; - sp->step = STP_RECV; + sp->step = STP_START; return (0); } if (Tlen(sp->htc->rxbuf)) { @@ -290,6 +290,7 @@ DOT } DOT fetch_pass -> deliver DOT vcl_fetch -> deliver [label="insert",style=bold,color=blue,weight=2] +DOT vcl_fetch -> recv [label="restart"] DOT vcl_fetch -> errfetch [label="error"] DOT errfetch [label="ERROR",shape=plaintext] */ @@ -386,7 +387,7 @@ switch (i) { case 1: - sp->step = STP_RECV; + sp->step = STP_START; break; case -1: vca_close_session(sp, "error"); @@ -700,8 +701,7 @@ /*-------------------------------------------------------------------- * RECV - * We have a complete request, get a VCL reference and dispatch it - * as instructed by vcl_recv{} + * We have a complete request, set everything up and start it. * DOT subgraph xcluster_recv { DOT recv [ @@ -719,56 +719,10 @@ static int cnt_recv(struct sess *sp) { - int done; AZ(sp->obj); + AN(sp->vcl); - if (sp->restarts > params->max_restarts) { - sp->step = STP_ERROR; - return (0); - } - if (sp->restarts == 0) { - AZ(sp->vcl); - /* Update stats of various sorts */ - VSL_stats->client_req++; /* XXX not locked */ - sp->t_req = TIM_real(); - sp->wrk->used = sp->t_req; - sp->wrk->acct.req++; - - /* Assign XID and log */ - sp->xid = ++xids; /* XXX not locked */ - WSP(sp, SLT_ReqStart, "%s %s %u", sp->addr, sp->port, sp->xid); - - /* Borrow VCL reference from worker thread */ - VCL_Refresh(&sp->wrk->vcl); - sp->vcl = sp->wrk->vcl; - sp->wrk->vcl = NULL; - - http_Setup(sp->http, sp->ws); - done = http_DissectRequest(sp); - - /* Catch request snapshot */ - sp->ws_req = WS_Snapshot(sp->ws); - - /* Catch original request, before modification */ - *sp->http0 = *sp->http; - - if (done != 0) { - RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */ - sp->step = STP_DONE; - return (0); - } - - sp->doclose = http_DoConnection(sp->http); - - /* By default we use the first backend */ - AZ(sp->backend); - sp->backend = sp->vcl->backend[0]; - CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); - - /* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */ - } - VCL_recv_method(sp); sp->wantbody = (strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD") != 0); @@ -792,7 +746,66 @@ } } +/*-------------------------------------------------------------------- + * START + * Handle a request, wherever it came from recv/restart. + * +DOT start [shape=box,label="Dissect request"] +DOT start -> recv + */ +static int +cnt_start(struct sess *sp) +{ + int done; + + AZ(sp->restarts); + AZ(sp->obj); + AZ(sp->vcl); + + /* Update stats of various sorts */ + VSL_stats->client_req++; /* XXX not locked */ + sp->t_req = TIM_real(); + sp->wrk->used = sp->t_req; + sp->wrk->acct.req++; + + /* Assign XID and log */ + sp->xid = ++xids; /* XXX not locked */ + WSP(sp, SLT_ReqStart, "%s %s %u", sp->addr, sp->port, sp->xid); + + /* Borrow VCL reference from worker thread */ + VCL_Refresh(&sp->wrk->vcl); + sp->vcl = sp->wrk->vcl; + sp->wrk->vcl = NULL; + + http_Setup(sp->http, sp->ws); + done = http_DissectRequest(sp); + + /* Catch request snapshot */ + sp->ws_req = WS_Snapshot(sp->ws); + + /* Catch original request, before modification */ + *sp->http0 = *sp->http; + + if (done != 0) { + RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */ + sp->step = STP_DONE; + return (0); + } + + sp->doclose = http_DoConnection(sp->http); + + /* By default we use the first backend */ + AZ(sp->backend); + sp->backend = sp->vcl->backend[0]; + CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); + + /* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */ + + sp->step = STP_RECV; + return (0); +} + /*-------------------------------------------------------------------- * Central state engine dispatcher. * Modified: branches/1.2/bin/varnishd/steps.h =================================================================== --- branches/1.2/bin/varnishd/steps.h 2007-10-30 11:02:51 UTC (rev 2197) +++ branches/1.2/bin/varnishd/steps.h 2007-10-30 11:03:05 UTC (rev 2198) @@ -32,6 +32,7 @@ STEP(again, AGAIN) STEP(first, FIRST) STEP(recv, RECV) +STEP(start, START) STEP(pipe, PIPE) STEP(pass, PASS) STEP(lookup, LOOKUP) From des at projects.linpro.no Tue Oct 30 11:03:23 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 12:03:23 +0100 (CET) Subject: r2199 - in branches/1.2: . bin/varnishd Message-ID: <20071030110323.27D841EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 12:03:22 +0100 (Tue, 30 Oct 2007) New Revision: 2199 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache.h branches/1.2/bin/varnishd/cache_backend.c branches/1.2/bin/varnishd/cache_fetch.c branches/1.2/bin/varnishd/cache_session.c branches/1.2/bin/varnishd/cache_synthetic.c branches/1.2/bin/varnishd/cache_ws.c Log: Merged revisions 2182-2183 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2182 | phk | 2007-10-29 10:24:16 +0100 (Mon, 29 Oct 2007) | 2 lines Add compile-time selectable SHMlogging of WS-activity ........ r2183 | phk | 2007-10-29 10:28:21 +0100 (Mon, 29 Oct 2007) | 2 lines Give workspaces an identifying string to aid debugging. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2181,2191-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2183,2191-2192 Modified: branches/1.2/bin/varnishd/cache.h =================================================================== --- branches/1.2/bin/varnishd/cache.h 2007-10-30 11:03:05 UTC (rev 2198) +++ branches/1.2/bin/varnishd/cache.h 2007-10-30 11:03:22 UTC (rev 2199) @@ -89,6 +89,7 @@ */ struct ws { + const char *id; /* identity */ char *s; /* (S)tart of buffer */ char *f; /* (F)ree pointer */ char *r; /* (R)eserved length */ @@ -575,7 +576,7 @@ /* cache_ws.c */ -void WS_Init(struct ws *ws, void *space, unsigned len); +void WS_Init(struct ws *ws, const char *id, void *space, unsigned len); unsigned WS_Reserve(struct ws *ws, unsigned bytes); void WS_Release(struct ws *ws, unsigned bytes); void WS_ReleaseP(struct ws *ws, char *ptr); Modified: branches/1.2/bin/varnishd/cache_backend.c =================================================================== --- branches/1.2/bin/varnishd/cache_backend.c 2007-10-30 11:03:05 UTC (rev 2198) +++ branches/1.2/bin/varnishd/cache_backend.c 2007-10-30 11:03:22 UTC (rev 2199) @@ -147,7 +147,7 @@ if (bereq == NULL) return (NULL); bereq->magic = BEREQ_MAGIC; - WS_Init(bereq->ws, bereq + 1, len); + WS_Init(bereq->ws, "bereq", bereq + 1, len); } http_Setup(bereq->http, bereq->ws); return (bereq); Modified: branches/1.2/bin/varnishd/cache_fetch.c =================================================================== --- branches/1.2/bin/varnishd/cache_fetch.c 2007-10-30 11:03:05 UTC (rev 2198) +++ branches/1.2/bin/varnishd/cache_fetch.c 2007-10-30 11:03:22 UTC (rev 2199) @@ -278,7 +278,7 @@ /* Set up obj's workspace */ st = sp->obj->objstore; - WS_Init(sp->obj->ws_o, st->ptr + st->len, st->space - st->len); + WS_Init(sp->obj->ws_o, "obj", st->ptr + st->len, st->space - st->len); st->len = st->space; WS_Assert(sp->obj->ws_o); http_Setup(sp->obj->http, sp->obj->ws_o); Modified: branches/1.2/bin/varnishd/cache_session.c =================================================================== --- branches/1.2/bin/varnishd/cache_session.c 2007-10-30 11:03:05 UTC (rev 2198) +++ branches/1.2/bin/varnishd/cache_session.c 2007-10-30 11:03:22 UTC (rev 2199) @@ -318,7 +318,7 @@ sp->sockaddrlen = len; } - WS_Init(sp->ws, (void *)(sm + 1), sm->workspace); + WS_Init(sp->ws, "sess", (void *)(sm + 1), sm->workspace); sp->http = &sm->http[0]; sp->http0 = &sm->http[1]; Modified: branches/1.2/bin/varnishd/cache_synthetic.c =================================================================== --- branches/1.2/bin/varnishd/cache_synthetic.c 2007-10-30 11:03:05 UTC (rev 2198) +++ branches/1.2/bin/varnishd/cache_synthetic.c 2007-10-30 11:03:22 UTC (rev 2199) @@ -73,7 +73,7 @@ /* Set up obj's workspace */ st = o->objstore; - WS_Init(o->ws_o, st->ptr + st->len, st->space - st->len); + WS_Init(o->ws_o, "obj", st->ptr + st->len, st->space - st->len); st->len = st->space; WS_Assert(o->ws_o); http_Setup(o->http, o->ws_o); @@ -126,7 +126,7 @@ /* allocate space for header */ - WS_Init(h->ws, malloc(1024), 1024); + WS_Init(h->ws, "error", malloc(1024), 1024); /* generate header */ http_ClrHeader(h); Modified: branches/1.2/bin/varnishd/cache_ws.c =================================================================== --- branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 11:03:05 UTC (rev 2198) +++ branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 11:03:22 UTC (rev 2199) @@ -45,11 +45,22 @@ #include "cli_priv.h" #include "cache.h" +/* Enable this to get detailed logging of WS usage */ +#if 0 +# define WS_DEBUG(foo) VSL foo +#else +# define WS_DEBUG(foo) /* nothing */ +#endif + void WS_Assert(const struct ws *ws) { assert(ws != NULL); + WS_DEBUG((SLT_Debug, 0, "WS(%p = (%s, %p %u %u %u)", + ws, ws->id, ws->s, pdiff(ws->s, ws->f), + ws->r == NULL ? 0 : pdiff(ws->f, ws->r), + pdiff(ws->s, ws->e))); assert(ws->s != NULL); assert(ws->e != NULL); assert(ws->s < ws->e); @@ -62,14 +73,16 @@ } void -WS_Init(struct ws *ws, void *space, unsigned len) +WS_Init(struct ws *ws, const char *id, void *space, unsigned len) { + WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len)); assert(space != NULL); memset(ws, 0, sizeof *ws); ws->s = space; ws->e = ws->s + len; ws->f = ws->s; + ws->id = id; WS_Assert(ws); } @@ -78,6 +91,7 @@ { WS_Assert(ws); + WS_DEBUG((SLT_Debug, 0, "WS_Reset(%p, %p)", ws, p)); assert(ws->r == NULL); if (p == NULL) ws->f = ws->s; @@ -99,6 +113,7 @@ return(NULL); r = ws->f; ws->f += bytes; + WS_DEBUG((SLT_Debug, 0, "WS_Alloc(%p, %u) = %p", ws, bytes, r)); return (r); } @@ -112,6 +127,7 @@ p = WS_Alloc(ws, l); if (p != NULL) memcpy(p, s, l); + WS_DEBUG((SLT_Debug, 0, "WS_Dup(%p, \"%s\") = %p", ws, s, p)); return (p); } @@ -119,26 +135,33 @@ WS_Snapshot(struct ws *ws) { + WS_Assert(ws); assert(ws->r == NULL); + WS_DEBUG((SLT_Debug, 0, "WS_Snapshot(%p) = %p", ws, ws->f)); return (ws->f); } unsigned WS_Reserve(struct ws *ws, unsigned bytes) { + unsigned b2 = bytes; + WS_Assert(ws); assert(ws->r == NULL); if (bytes == 0) - bytes = ws->e - ws->f; - xxxassert(ws->f + bytes <= ws->e); - ws->r = ws->f + bytes; - return (ws->r - ws->f); + b2 = ws->e - ws->f; + xxxassert(ws->f + b2 <= ws->e); + ws->r = ws->f + b2; + WS_DEBUG((SLT_Debug, 0, "WS_Reserve(%p, %u/%u) = %u", + ws, b2, bytes, pdiff(ws->f, ws->r))); + return (pdiff(ws->f, ws->r)); } void WS_Release(struct ws *ws, unsigned bytes) { WS_Assert(ws); + WS_DEBUG((SLT_Debug, 0, "WS_Release(%p, %u)", ws, bytes)); assert(ws->r != NULL); assert(ws->f + bytes <= ws->r); ws->f += bytes; @@ -149,6 +172,7 @@ WS_ReleaseP(struct ws *ws, char *ptr) { WS_Assert(ws); + WS_DEBUG((SLT_Debug, 0, "WS_ReleaseP(%p, %p)", ws, ptr)); assert(ws->r != NULL); assert(ptr >= ws->f); assert(ptr <= ws->r); From des at projects.linpro.no Tue Oct 30 11:03:50 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 12:03:50 +0100 (CET) Subject: r2200 - in branches/1.2: . bin/varnishd lib/libvcl Message-ID: <20071030110350.BDBE51EC033@projects.linpro.no> Author: des Date: 2007-10-30 12:03:50 +0100 (Tue, 30 Oct 2007) New Revision: 2200 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_center.c branches/1.2/lib/libvcl/vcc_gen_obj.tcl branches/1.2/lib/libvcl/vcc_obj.c Log: Merged revisions 2184,2186 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2184 | phk | 2007-10-29 11:17:58 +0100 (Mon, 29 Oct 2007) | 2 lines Postpone freeing the bereq until after VCL_fetch() has been called ........ r2186 | phk | 2007-10-29 11:22:22 +0100 (Mon, 29 Oct 2007) | 2 lines Make bereq. available from vcl_fetch() ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2183,2191-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186,2191-2192 Modified: branches/1.2/bin/varnishd/cache_center.c =================================================================== --- branches/1.2/bin/varnishd/cache_center.c 2007-10-30 11:03:22 UTC (rev 2199) +++ branches/1.2/bin/varnishd/cache_center.c 2007-10-30 11:03:50 UTC (rev 2200) @@ -279,7 +279,7 @@ DOT ] DOT vcl_fetch [ DOT shape=record -DOT label="vcl_fetch()|req.\nobj." +DOT label="vcl_fetch()|req.\nobj.\nbereq." DOT ] DOT fetch -> vcl_fetch [style=bold,color=blue,weight=2] DOT fetch_pass [ @@ -305,9 +305,6 @@ i = Fetch(sp); CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); - VBE_free_bereq(sp->bereq); - sp->bereq = NULL; - if (!i) RFC2616_cache_policy(sp, sp->obj->http); /* XXX -> VCL */ else { @@ -320,6 +317,9 @@ sp->err_code = http_GetStatus(sp->obj->http); VCL_fetch_method(sp); + VBE_free_bereq(sp->bereq); + sp->bereq = NULL; + switch (sp->handling) { case VCL_RET_ERROR: case VCL_RET_RESTART: Modified: branches/1.2/lib/libvcl/vcc_gen_obj.tcl =================================================================== --- branches/1.2/lib/libvcl/vcc_gen_obj.tcl 2007-10-30 11:03:22 UTC (rev 2199) +++ branches/1.2/lib/libvcl/vcc_gen_obj.tcl 2007-10-30 11:03:50 UTC (rev 2200) @@ -101,22 +101,22 @@ # Request sent to backend { bereq.request RW STRING - { pipe pass miss } + { pipe pass miss fetch } "const struct sess *" } { bereq.url RW STRING - { pipe pass miss } + { pipe pass miss fetch } "const struct sess *" } { bereq.proto RW STRING - { pipe pass miss } + { pipe pass miss fetch } "const struct sess *" } { bereq.http. RW HDR_BEREQ - { pipe pass miss } + { pipe pass miss fetch } "const struct sess *" } Modified: branches/1.2/lib/libvcl/vcc_obj.c =================================================================== --- branches/1.2/lib/libvcl/vcc_obj.c 2007-10-30 11:03:22 UTC (rev 2199) +++ branches/1.2/lib/libvcl/vcc_obj.c 2007-10-30 11:03:50 UTC (rev 2200) @@ -110,28 +110,28 @@ "VRT_l_bereq_request(sp, ", V_RW, 0, - VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS + VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH }, { "bereq.url", STRING, 9, "VRT_r_bereq_url(sp)", "VRT_l_bereq_url(sp, ", V_RW, 0, - VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS + VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH }, { "bereq.proto", STRING, 11, "VRT_r_bereq_proto(sp)", "VRT_l_bereq_proto(sp, ", V_RW, 0, - VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS + VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH }, { "bereq.http.", HEADER, 11, "VRT_r_bereq_http_(sp)", "VRT_l_bereq_http_(sp, ", V_RW, "HDR_BEREQ", - VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS + VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH }, { "obj.proto", STRING, 9, "VRT_r_obj_proto(sp)", From des at projects.linpro.no Tue Oct 30 11:04:12 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 12:04:12 +0100 (CET) Subject: r2201 - in branches/1.2: . bin/varnishd Message-ID: <20071030110412.96D861EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 12:04:12 +0100 (Tue, 30 Oct 2007) New Revision: 2201 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_hash.c branches/1.2/bin/varnishd/hash_classic.c Log: Merged revisions 2187-2188 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2187 | phk | 2007-10-29 13:06:34 +0100 (Mon, 29 Oct 2007) | 2 lines More checks, trying to find pointer tango ........ r2188 | phk | 2007-10-29 13:09:54 +0100 (Mon, 29 Oct 2007) | 2 lines Typo in previous commit. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186,2191-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186-2188,2191-2192 Modified: branches/1.2/bin/varnishd/cache_hash.c =================================================================== --- branches/1.2/bin/varnishd/cache_hash.c 2007-10-30 11:03:50 UTC (rev 2200) +++ branches/1.2/bin/varnishd/cache_hash.c 2007-10-30 11:04:12 UTC (rev 2201) @@ -73,6 +73,7 @@ struct storage *st; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); w = sp->wrk; if (w->nobjhead == NULL) { @@ -87,7 +88,8 @@ if (w->nobj == NULL) { st = STV_alloc(sp, params->mem_workspace); XXXAN(st); - w->nobj = (void *)st->ptr; + assert(st->space > sizeof *w->nobj); + w->nobj = (void *)st->ptr; /* XXX: align ? */ st->len = sizeof *w->nobj; memset(w->nobj, 0, sizeof *w->nobj); w->nobj->objstore = st; @@ -121,6 +123,9 @@ unsigned u, v; const char *b; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(obj, OBJHEAD_MAGIC); i = sp->lhashptr - obj->hashlen; if (i) return (i); Modified: branches/1.2/bin/varnishd/hash_classic.c =================================================================== --- branches/1.2/bin/varnishd/hash_classic.c 2007-10-30 11:03:50 UTC (rev 2200) +++ branches/1.2/bin/varnishd/hash_classic.c 2007-10-30 11:04:12 UTC (rev 2201) @@ -128,6 +128,9 @@ unsigned u, v; int i; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); CHECK_OBJ_ORNULL(noh, OBJHEAD_MAGIC); digest = ~0U; From des at projects.linpro.no Tue Oct 30 11:04:31 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 12:04:31 +0100 (CET) Subject: r2202 - in branches/1.2: . bin/varnishd Message-ID: <20071030110431.8346D1EC033@projects.linpro.no> Author: des Date: 2007-10-30 12:04:31 +0100 (Tue, 30 Oct 2007) New Revision: 2202 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache.h branches/1.2/bin/varnishd/cache_ws.c Log: Merged revisions 2189 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2189 | phk | 2007-10-29 13:10:16 +0100 (Mon, 29 Oct 2007) | 2 lines Give struct ws the mini_obj treatment, not sure why I didn't before. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186-2188,2191-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186-2189,2191-2192 Modified: branches/1.2/bin/varnishd/cache.h =================================================================== --- branches/1.2/bin/varnishd/cache.h 2007-10-30 11:04:12 UTC (rev 2201) +++ branches/1.2/bin/varnishd/cache.h 2007-10-30 11:04:31 UTC (rev 2202) @@ -89,6 +89,8 @@ */ struct ws { + unsigned magic; +#define WS_MAGIC 0x35fac554 const char *id; /* identity */ char *s; /* (S)tart of buffer */ char *f; /* (F)ree pointer */ Modified: branches/1.2/bin/varnishd/cache_ws.c =================================================================== --- branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 11:04:12 UTC (rev 2201) +++ branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 11:04:31 UTC (rev 2202) @@ -56,7 +56,7 @@ WS_Assert(const struct ws *ws) { - assert(ws != NULL); + CHECK_OBJ_NOTNULL(ws, WS_MAGIC); WS_DEBUG((SLT_Debug, 0, "WS(%p = (%s, %p %u %u %u)", ws, ws->id, ws->s, pdiff(ws->s, ws->f), ws->r == NULL ? 0 : pdiff(ws->f, ws->r), @@ -79,6 +79,7 @@ WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len)); assert(space != NULL); memset(ws, 0, sizeof *ws); + ws->magic = WS_MAGIC; ws->s = space; ws->e = ws->s + len; ws->f = ws->s; From des at projects.linpro.no Tue Oct 30 11:04:40 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 12:04:40 +0100 (CET) Subject: r2203 - in branches/1.2: . bin/varnishd Message-ID: <20071030110440.2FB311EC51C@projects.linpro.no> Author: des Date: 2007-10-30 12:04:39 +0100 (Tue, 30 Oct 2007) New Revision: 2203 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_center.c Log: Merged revisions 2190 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2190 | phk | 2007-10-29 13:22:38 +0100 (Mon, 29 Oct 2007) | 2 lines Add more paranoia ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186-2189,2191-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186-2192 Modified: branches/1.2/bin/varnishd/cache_center.c =================================================================== --- branches/1.2/bin/varnishd/cache_center.c 2007-10-30 11:04:31 UTC (rev 2202) +++ branches/1.2/bin/varnishd/cache_center.c 2007-10-30 11:04:39 UTC (rev 2203) @@ -87,6 +87,9 @@ { int i; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + AZ(sp->obj); assert(sp->xid == 0); i = HTC_Complete(sp->htc); @@ -142,6 +145,10 @@ cnt_deliver(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + sp->t_resp = TIM_real(); if (sp->obj->objhead != NULL) EXP_Touch(sp->obj, sp->t_resp); @@ -183,6 +190,9 @@ double dh, dp, da; int i; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + AZ(sp->obj); AZ(sp->bereq); sp->backend = NULL; @@ -300,6 +310,9 @@ { int i; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + AN(sp->bereq); CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); i = Fetch(sp); @@ -423,6 +436,10 @@ cnt_hit(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + assert(!sp->obj->pass); VCL_hit_method(sp); @@ -487,6 +504,7 @@ uintptr_t u; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); if (sp->obj == NULL) { @@ -580,6 +598,10 @@ cnt_miss(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + http_FilterHeader(sp, HTTPH_R_FETCH); VCL_miss_method(sp); if (sp->handling == VCL_RET_ERROR) { @@ -639,6 +661,8 @@ cnt_pass(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); http_FilterHeader(sp, HTTPH_R_PASS); @@ -685,6 +709,9 @@ cnt_pipe(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + sp->wrk->acct.pipe++; http_FilterHeader(sp, HTTPH_R_PIPE); @@ -720,8 +747,9 @@ cnt_recv(struct sess *sp) { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); - AN(sp->vcl); VCL_recv_method(sp); @@ -759,6 +787,7 @@ { int done; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); AZ(sp->restarts); AZ(sp->obj); AZ(sp->vcl); From des at projects.linpro.no Tue Oct 30 11:05:33 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 12:05:33 +0100 (CET) Subject: r2204 - in branches/1.2: . lib/libvarnishapi Message-ID: <20071030110533.025221ECE86@projects.linpro.no> Author: des Date: 2007-10-30 12:05:32 +0100 (Tue, 30 Oct 2007) New Revision: 2204 Modified: branches/1.2/ branches/1.2/lib/libvarnishapi/shmlog.c Log: Merged revisions 2193 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2193 | des | 2007-10-30 11:48:30 +0100 (Tue, 30 Oct 2007) | 2 lines Use a cast to prevent sign extension instead of masking it off after the fact. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186-2192 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186-2193 Modified: branches/1.2/lib/libvarnishapi/shmlog.c =================================================================== --- branches/1.2/lib/libvarnishapi/shmlog.c 2007-10-30 11:04:39 UTC (rev 2203) +++ branches/1.2/lib/libvarnishapi/shmlog.c 2007-10-30 11:05:32 UTC (rev 2204) @@ -353,7 +353,7 @@ if (*ptr >= ' ' && *ptr <= '~') fprintf(fo, "%c", *ptr); else - fprintf(fo, "%%%02x", (*ptr) & 0xff); + fprintf(fo, "%%%02x", (unsigned char)*ptr); ptr++; } fprintf(fo, "\"\n"); From des at projects.linpro.no Tue Oct 30 12:11:49 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 13:11:49 +0100 (CET) Subject: r2205 - in branches/1.2: . debian Message-ID: <20071030121149.D081F1EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 13:11:49 +0100 (Tue, 30 Oct 2007) New Revision: 2205 Modified: branches/1.2/ branches/1.2/debian/Makefile.am Log: Merged revisions 2173 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2173 | des | 2007-10-28 19:43:24 +0100 (Sun, 28 Oct 2007) | 2 lines Fix file list. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2175-2176,2180-2184,2186-2193 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193 Modified: branches/1.2/debian/Makefile.am =================================================================== --- branches/1.2/debian/Makefile.am 2007-10-30 11:05:32 UTC (rev 2204) +++ branches/1.2/debian/Makefile.am 2007-10-30 12:11:49 UTC (rev 2205) @@ -9,10 +9,10 @@ copyright \ dirs \ docs \ - libvarnish-dev.dirs \ - libvarnish-dev.install \ - libvarnish.dirs \ - libvarnish.install \ + libvarnish0-dev.dirs \ + libvarnish0-dev.install \ + libvarnish0.dirs \ + libvarnish0.install \ lintian-override \ rules \ varnish.default \ From des at linpro.no Tue Oct 30 12:15:24 2007 From: des at linpro.no (=?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?=) Date: Tue, 30 Oct 2007 13:15:24 +0100 Subject: r2181 - trunk/varnish-cache/bin/varnishd In-Reply-To: <20071029091613.56BEF1ECF53@projects.linpro.no> (phk@projects.linpro.no's message of "Mon, 29 Oct 2007 10:16:13 +0100 (CET)") References: <20071029091613.56BEF1ECF53@projects.linpro.no> Message-ID: phk at projects.linpro.no writes: > Log: > Remember to reset te bereq's workspace after use. Do you have a ticket number for this? DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no From des at projects.linpro.no Tue Oct 30 12:35:40 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 13:35:40 +0100 (CET) Subject: r2206 - trunk/varnish-cache/bin/varnishd Message-ID: <20071030123540.62E5C1EC033@projects.linpro.no> Author: des Date: 2007-10-30 13:35:40 +0100 (Tue, 30 Oct 2007) New Revision: 2206 Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c Log: Comment tweak Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c =================================================================== --- trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-10-30 12:11:49 UTC (rev 2205) +++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-10-30 12:35:40 UTC (rev 2206) @@ -177,7 +177,7 @@ case 203: /* Non-Authoritative Information */ case 300: /* Multiple Choices */ case 301: /* Moved Permanently */ - case 302: /* XXX */ + case 302: /* Moved Temporarily */ case 410: /* Gone */ case 404: /* Not Found */ sp->obj->cacheable = 1; From des at projects.linpro.no Tue Oct 30 12:36:09 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 13:36:09 +0100 (CET) Subject: r2207 - trunk/varnish-cache/doc Message-ID: <20071030123609.33B761EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 13:36:09 +0100 (Tue, 30 Oct 2007) New Revision: 2207 Added: trunk/varnish-cache/doc/changes-1.1.1-1.1.2.xml trunk/varnish-cache/doc/changes-1.1.2.xml Log: Incomplete change log for 1.1.2 Added: trunk/varnish-cache/doc/changes-1.1.1-1.1.2.xml =================================================================== --- trunk/varnish-cache/doc/changes-1.1.1-1.1.2.xml (rev 0) +++ trunk/varnish-cache/doc/changes-1.1.1-1.1.2.xml 2007-10-30 12:36:09 UTC (rev 2207) @@ -0,0 +1,53 @@ + + +]> + + + + varnishd + + + When switching to a new VCL configuration, a race + condition exists which may cause Varnish to reference a backend + which no longer exists (see ). This race + condition has not been entirely eliminated, but it should occur + less frequently. + + + + When dropping a TCP session before any requests were + processed, an assertion would be triggered due to an + uninitialized timestamp (see ). The + timestamp is now correctly initialized. + + + + Varnish will now correctly generate a Date: + header for every response instead of copying the one it got from + the backend (see ). + + + + Comparisons in VCL which involve a non-existent string + (usually a header which is not present in the request or object + being processed) would cause a NULL pointer dereference; now the + comparison will simply fail. + + + + A bug in the VCL compiler which would cause a double-free + when processing include directives has been + fixed. + + + + + + + + + Build system + + + Property changes on: trunk/varnish-cache/doc/changes-1.1.1-1.1.2.xml ___________________________________________________________________ Name: svn:keywords + Id Added: trunk/varnish-cache/doc/changes-1.1.2.xml =================================================================== --- trunk/varnish-cache/doc/changes-1.1.2.xml (rev 0) +++ trunk/varnish-cache/doc/changes-1.1.2.xml 2007-10-30 12:36:09 UTC (rev 2207) @@ -0,0 +1,12 @@ + + + +]> + + + Varnish + 1.1.2 + + + Property changes on: trunk/varnish-cache/doc/changes-1.1.2.xml ___________________________________________________________________ Name: svn:keywords + Id From des at projects.linpro.no Tue Oct 30 12:38:35 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 13:38:35 +0100 (CET) Subject: r2208 - trunk/varnish-cache/bin/varnishd Message-ID: <20071030123835.25D981EC033@projects.linpro.no> Author: des Date: 2007-10-30 13:38:34 +0100 (Tue, 30 Oct 2007) New Revision: 2208 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: AFAICT, it is perfectly valid for sp->vcl to be NULL here. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 12:36:09 UTC (rev 2207) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 12:38:34 UTC (rev 2208) @@ -191,7 +191,7 @@ int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + CHECK_OBJ_ORNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); AZ(sp->bereq); From des at projects.linpro.no Tue Oct 30 12:54:11 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 13:54:11 +0100 (CET) Subject: r2209 - trunk/varnish-cache/bin/varnishd Message-ID: <20071030125411.26C581EC030@projects.linpro.no> Author: des Date: 2007-10-30 13:54:10 +0100 (Tue, 30 Oct 2007) New Revision: 2209 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Use pdiff() Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-30 12:38:34 UTC (rev 2208) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-10-30 12:54:10 UTC (rev 2209) @@ -319,8 +319,8 @@ u = WS_Reserve(ws, 0); v = snprintf(ws->f, u - 1, "%.*s%.*s", - tag.e - tag.b, tag.b, - val.e - val.b, val.b); + pdiff(tag.b, tag.e), tag.b, + pdiff(val.b, val.e), val.b); v++; xxxassert(v < u); eb->include.b = ws->f; From des at projects.linpro.no Tue Oct 30 12:57:03 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 13:57:03 +0100 (CET) Subject: r2210 - trunk/varnish-cache/bin/varnishd Message-ID: <20071030125703.DA0E71EC033@projects.linpro.no> Author: des Date: 2007-10-30 13:57:03 +0100 (Tue, 30 Oct 2007) New Revision: 2210 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Revert r2208, I believe the assert is correct. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 12:54:10 UTC (rev 2209) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 12:57:03 UTC (rev 2210) @@ -191,7 +191,7 @@ int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_ORNULL(sp->vcl, VCL_CONF_MAGIC); + CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); AZ(sp->bereq); From des at projects.linpro.no Tue Oct 30 13:39:21 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 14:39:21 +0100 (CET) Subject: r2211 - trunk/varnish-cache Message-ID: <20071030133921.DB2051EC033@projects.linpro.no> Author: des Date: 2007-10-30 14:39:21 +0100 (Tue, 30 Oct 2007) New Revision: 2211 Modified: trunk/varnish-cache/configure.ac Log: Add an --enable-diagnostics option which causes DIAGNOSTICS to be defined. Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2007-10-30 12:57:03 UTC (rev 2210) +++ trunk/varnish-cache/configure.ac 2007-10-30 13:39:21 UTC (rev 2211) @@ -134,6 +134,9 @@ AC_ARG_ENABLE(debugging-symbols, AS_HELP_STRING([--enable-debugging-symbols],[enable debugging symbols (default is NO)]), CFLAGS="${CFLAGS} -O0 -g -fno-inline") +AC_ARG_ENABLE(diagnostics, + AS_HELP_STRING([--enable-diagnostics],[enable run-time diagnostics (default is NO)]), + CFLAGS="${CFLAGS} -DDIAGNOSTICS") AC_ARG_ENABLE(extra-developer-warnings, AS_HELP_STRING([--enable-extra-developer-warnings],[enable even stricter warnings (default is NO)]), CFLAGS="${CFLAGS} ${EXTRA_DEVELOPER_CFLAGS}") From des at projects.linpro.no Tue Oct 30 13:41:56 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 14:41:56 +0100 (CET) Subject: r2212 - trunk/varnish-cache Message-ID: <20071030134156.E2B081EC030@projects.linpro.no> Author: des Date: 2007-10-30 14:41:56 +0100 (Tue, 30 Oct 2007) New Revision: 2212 Modified: trunk/varnish-cache/autogen.des Log: Enable diagnostics Modified: trunk/varnish-cache/autogen.des =================================================================== --- trunk/varnish-cache/autogen.des 2007-10-30 13:39:21 UTC (rev 2211) +++ trunk/varnish-cache/autogen.des 2007-10-30 13:41:56 UTC (rev 2212) @@ -15,6 +15,7 @@ --enable-developer-warnings \ --enable-debugging-symbols \ --enable-dependency-tracking \ + --enable-diagnostics \ --enable-extra-developer-warnings \ --enable-stack-protector \ --enable-werror \ From des at projects.linpro.no Tue Oct 30 13:42:52 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 14:42:52 +0100 (CET) Subject: r2213 - trunk/varnish-cache/bin/varnishd Message-ID: <20071030134252.8428D1EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 14:42:52 +0100 (Tue, 30 Oct 2007) New Revision: 2213 Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c Log: Simplify WS_DEBUG(), and make it conditional on DIAGNOSTICS. Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-30 13:41:56 UTC (rev 2212) +++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-10-30 13:42:52 UTC (rev 2213) @@ -46,10 +46,10 @@ #include "cache.h" /* Enable this to get detailed logging of WS usage */ -#if 0 -# define WS_DEBUG(foo) VSL foo +#ifdef DIAGNOSTICS +# define WS_DEBUG(fmt, ...) VSL(SLT_Debug, 0, fmt, __VA_ARGS__) #else -# define WS_DEBUG(foo) /* nothing */ +# define WS_DEBUG(fmt, ...) /* nothing */ #endif void @@ -57,10 +57,10 @@ { CHECK_OBJ_NOTNULL(ws, WS_MAGIC); - WS_DEBUG((SLT_Debug, 0, "WS(%p = (%s, %p %u %u %u)", + WS_DEBUG("WS(%p = (%s, %p %u %u %u)", ws, ws->id, ws->s, pdiff(ws->s, ws->f), ws->r == NULL ? 0 : pdiff(ws->f, ws->r), - pdiff(ws->s, ws->e))); + pdiff(ws->s, ws->e)); assert(ws->s != NULL); assert(ws->e != NULL); assert(ws->s < ws->e); @@ -76,7 +76,7 @@ WS_Init(struct ws *ws, const char *id, void *space, unsigned len) { - WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len)); + WS_DEBUG("WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len); assert(space != NULL); memset(ws, 0, sizeof *ws); ws->magic = WS_MAGIC; @@ -92,7 +92,7 @@ { WS_Assert(ws); - WS_DEBUG((SLT_Debug, 0, "WS_Reset(%p, %p)", ws, p)); + WS_DEBUG("WS_Reset(%p, %p)", ws, p); assert(ws->r == NULL); if (p == NULL) ws->f = ws->s; @@ -114,7 +114,7 @@ return(NULL); r = ws->f; ws->f += bytes; - WS_DEBUG((SLT_Debug, 0, "WS_Alloc(%p, %u) = %p", ws, bytes, r)); + WS_DEBUG("WS_Alloc(%p, %u) = %p", ws, bytes, r); return (r); } @@ -128,7 +128,7 @@ p = WS_Alloc(ws, l); if (p != NULL) memcpy(p, s, l); - WS_DEBUG((SLT_Debug, 0, "WS_Dup(%p, \"%s\") = %p", ws, s, p)); + WS_DEBUG("WS_Dup(%p, \"%s\") = %p", ws, s, p); return (p); } @@ -138,7 +138,7 @@ WS_Assert(ws); assert(ws->r == NULL); - WS_DEBUG((SLT_Debug, 0, "WS_Snapshot(%p) = %p", ws, ws->f)); + WS_DEBUG("WS_Snapshot(%p) = %p", ws, ws->f); return (ws->f); } @@ -153,8 +153,8 @@ b2 = ws->e - ws->f; xxxassert(ws->f + b2 <= ws->e); ws->r = ws->f + b2; - WS_DEBUG((SLT_Debug, 0, "WS_Reserve(%p, %u/%u) = %u", - ws, b2, bytes, pdiff(ws->f, ws->r))); + WS_DEBUG("WS_Reserve(%p, %u/%u) = %u", + ws, b2, bytes, pdiff(ws->f, ws->r)); return (pdiff(ws->f, ws->r)); } @@ -162,7 +162,7 @@ WS_Release(struct ws *ws, unsigned bytes) { WS_Assert(ws); - WS_DEBUG((SLT_Debug, 0, "WS_Release(%p, %u)", ws, bytes)); + WS_DEBUG("WS_Release(%p, %u)", ws, bytes); assert(ws->r != NULL); assert(ws->f + bytes <= ws->r); ws->f += bytes; @@ -173,7 +173,7 @@ WS_ReleaseP(struct ws *ws, char *ptr) { WS_Assert(ws); - WS_DEBUG((SLT_Debug, 0, "WS_ReleaseP(%p, %p)", ws, ptr)); + WS_DEBUG("WS_ReleaseP(%p, %p)", ws, ptr); assert(ws->r != NULL); assert(ptr >= ws->f); assert(ptr <= ws->r); From des at projects.linpro.no Tue Oct 30 14:02:58 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 15:02:58 +0100 (CET) Subject: r2214 - trunk/varnish-cache/bin/varnishd Message-ID: <20071030140258.AB6061EC030@projects.linpro.no> Author: des Date: 2007-10-30 15:02:58 +0100 (Tue, 30 Oct 2007) New Revision: 2214 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: r2208 was correct but incomplete. It is possible for a session to reach cnt_done() without a VCL reference, if we never got a request on that connection. However, a session that reaches cnt_again() will never have a VCL reference, so the assertion there is incorrect. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 13:42:52 UTC (rev 2213) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 14:02:58 UTC (rev 2214) @@ -88,7 +88,7 @@ int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + AZ(sp->vcl); AZ(sp->obj); assert(sp->xid == 0); @@ -191,7 +191,7 @@ int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + CHECK_OBJ_ORNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); AZ(sp->bereq); From des at projects.linpro.no Tue Oct 30 14:06:38 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 15:06:38 +0100 (CET) Subject: r2215 - trunk/varnish-cache/bin/varnishd Message-ID: <20071030140638.108491EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 15:06:37 +0100 (Tue, 30 Oct 2007) New Revision: 2215 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: When DIAGNOSTICS is defined, log every step that each session goes through, along with some vital statistics, and flush the log regularly. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 14:02:58 UTC (rev 2214) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 14:06:37 UTC (rev 2215) @@ -877,7 +877,21 @@ CHECK_OBJ_ORNULL(sp->backend, BACKEND_MAGIC); switch (sp->step) { -#define STEP(l,u) case STP_##u: done = cnt_##l(sp); break; +#ifdef DIAGNOSTICS +#define STEP(l,u) \ + case STP_##u: \ + WSL(sp->wrk, SLT_Debug, sp->id, \ + "cnt_%s(%p) xid %x obj %p vcl %p", \ + #l, sp, sp->xid, sp->obj, sp->vcl); \ + WSL_Flush(sp->wrk); \ + done = cnt_##l(sp); \ + break; +#else +#define STEP(l,u) \ + case STP_##u: \ + done = cnt_##l(sp); \ + break; +#endif #include "steps.h" #undef STEP default: INCOMPL(); From des at projects.linpro.no Tue Oct 30 14:07:40 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 15:07:40 +0100 (CET) Subject: r2216 - in branches/1.2: . bin/varnishd Message-ID: <20071030140740.CF79C1EC033@projects.linpro.no> Author: des Date: 2007-10-30 15:07:40 +0100 (Tue, 30 Oct 2007) New Revision: 2216 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_center.c Log: Merged revisions 2208,2210,2214 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2208 | des | 2007-10-30 13:38:34 +0100 (Tue, 30 Oct 2007) | 2 lines AFAICT, it is perfectly valid for sp->vcl to be NULL here. ........ r2210 | des | 2007-10-30 13:57:03 +0100 (Tue, 30 Oct 2007) | 2 lines Revert r2208, I believe the assert is correct. ........ r2214 | des | 2007-10-30 15:02:58 +0100 (Tue, 30 Oct 2007) | 5 lines r2208 was correct but incomplete. It is possible for a session to reach cnt_done() without a VCL reference, if we never got a request on that connection. However, a session that reaches cnt_again() will never have a VCL reference, so the assertion there is incorrect. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193,2208,2210,2214 Modified: branches/1.2/bin/varnishd/cache_center.c =================================================================== --- branches/1.2/bin/varnishd/cache_center.c 2007-10-30 14:06:37 UTC (rev 2215) +++ branches/1.2/bin/varnishd/cache_center.c 2007-10-30 14:07:40 UTC (rev 2216) @@ -88,7 +88,7 @@ int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + AZ(sp->vcl); AZ(sp->obj); assert(sp->xid == 0); @@ -191,7 +191,7 @@ int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); + CHECK_OBJ_ORNULL(sp->vcl, VCL_CONF_MAGIC); AZ(sp->obj); AZ(sp->bereq); From des at projects.linpro.no Tue Oct 30 14:08:28 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 15:08:28 +0100 (CET) Subject: r2217 - in branches/1.2: . bin/varnishd Message-ID: <20071030140828.7E8621EC033@projects.linpro.no> Author: des Date: 2007-10-30 15:08:28 +0100 (Tue, 30 Oct 2007) New Revision: 2217 Modified: branches/1.2/ branches/1.2/bin/varnishd/rfc2616.c Log: Merged revisions 2206 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2206 | des | 2007-10-30 13:35:40 +0100 (Tue, 30 Oct 2007) | 2 lines Comment tweak ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193,2208,2210,2214 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193,2206,2208,2210,2214 Modified: branches/1.2/bin/varnishd/rfc2616.c =================================================================== --- branches/1.2/bin/varnishd/rfc2616.c 2007-10-30 14:07:40 UTC (rev 2216) +++ branches/1.2/bin/varnishd/rfc2616.c 2007-10-30 14:08:28 UTC (rev 2217) @@ -177,7 +177,7 @@ case 203: /* Non-Authoritative Information */ case 300: /* Multiple Choices */ case 301: /* Moved Permanently */ - case 302: /* XXX */ + case 302: /* Moved Temporarily */ case 410: /* Gone */ case 404: /* Not Found */ sp->obj->cacheable = 1; From des at projects.linpro.no Tue Oct 30 14:08:41 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 15:08:41 +0100 (CET) Subject: r2218 - in branches/1.2: . bin/varnishd Message-ID: <20071030140841.424E41EC030@projects.linpro.no> Author: des Date: 2007-10-30 15:08:40 +0100 (Tue, 30 Oct 2007) New Revision: 2218 Modified: branches/1.2/ branches/1.2/autogen.des branches/1.2/bin/varnishd/cache_center.c branches/1.2/bin/varnishd/cache_ws.c branches/1.2/configure.ac Log: Merged revisions 2211-2213,2215 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2211 | des | 2007-10-30 14:39:21 +0100 (Tue, 30 Oct 2007) | 2 lines Add an --enable-diagnostics option which causes DIAGNOSTICS to be defined. ........ r2212 | des | 2007-10-30 14:41:56 +0100 (Tue, 30 Oct 2007) | 2 lines Enable diagnostics ........ r2213 | des | 2007-10-30 14:42:52 +0100 (Tue, 30 Oct 2007) | 2 lines Simplify WS_DEBUG(), and make it conditional on DIAGNOSTICS. ........ r2215 | des | 2007-10-30 15:06:37 +0100 (Tue, 30 Oct 2007) | 3 lines When DIAGNOSTICS is defined, log every step that each session goes through, along with some vital statistics, and flush the log regularly. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193,2206,2208,2210,2214 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193,2206,2208,2210-2215 Modified: branches/1.2/autogen.des =================================================================== --- branches/1.2/autogen.des 2007-10-30 14:08:28 UTC (rev 2217) +++ branches/1.2/autogen.des 2007-10-30 14:08:40 UTC (rev 2218) @@ -15,6 +15,7 @@ --enable-developer-warnings \ --enable-debugging-symbols \ --enable-dependency-tracking \ + --enable-diagnostics \ --enable-extra-developer-warnings \ --enable-stack-protector \ --enable-werror \ Modified: branches/1.2/bin/varnishd/cache_center.c =================================================================== --- branches/1.2/bin/varnishd/cache_center.c 2007-10-30 14:08:28 UTC (rev 2217) +++ branches/1.2/bin/varnishd/cache_center.c 2007-10-30 14:08:40 UTC (rev 2218) @@ -866,7 +866,21 @@ CHECK_OBJ_ORNULL(sp->backend, BACKEND_MAGIC); switch (sp->step) { -#define STEP(l,u) case STP_##u: done = cnt_##l(sp); break; +#ifdef DIAGNOSTICS +#define STEP(l,u) \ + case STP_##u: \ + WSL(sp->wrk, SLT_Debug, sp->id, \ + "cnt_%s(%p) xid %x obj %p vcl %p", \ + #l, sp, sp->xid, sp->obj, sp->vcl); \ + WSL_Flush(sp->wrk); \ + done = cnt_##l(sp); \ + break; +#else +#define STEP(l,u) \ + case STP_##u: \ + done = cnt_##l(sp); \ + break; +#endif #include "steps.h" #undef STEP default: INCOMPL(); Modified: branches/1.2/bin/varnishd/cache_ws.c =================================================================== --- branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 14:08:28 UTC (rev 2217) +++ branches/1.2/bin/varnishd/cache_ws.c 2007-10-30 14:08:40 UTC (rev 2218) @@ -46,10 +46,10 @@ #include "cache.h" /* Enable this to get detailed logging of WS usage */ -#if 0 -# define WS_DEBUG(foo) VSL foo +#ifdef DIAGNOSTICS +# define WS_DEBUG(fmt, ...) VSL(SLT_Debug, 0, fmt, __VA_ARGS__) #else -# define WS_DEBUG(foo) /* nothing */ +# define WS_DEBUG(fmt, ...) /* nothing */ #endif void @@ -57,10 +57,10 @@ { CHECK_OBJ_NOTNULL(ws, WS_MAGIC); - WS_DEBUG((SLT_Debug, 0, "WS(%p = (%s, %p %u %u %u)", + WS_DEBUG("WS(%p = (%s, %p %u %u %u)", ws, ws->id, ws->s, pdiff(ws->s, ws->f), ws->r == NULL ? 0 : pdiff(ws->f, ws->r), - pdiff(ws->s, ws->e))); + pdiff(ws->s, ws->e)); assert(ws->s != NULL); assert(ws->e != NULL); assert(ws->s < ws->e); @@ -76,7 +76,7 @@ WS_Init(struct ws *ws, const char *id, void *space, unsigned len) { - WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len)); + WS_DEBUG("WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len); assert(space != NULL); memset(ws, 0, sizeof *ws); ws->magic = WS_MAGIC; @@ -92,7 +92,7 @@ { WS_Assert(ws); - WS_DEBUG((SLT_Debug, 0, "WS_Reset(%p, %p)", ws, p)); + WS_DEBUG("WS_Reset(%p, %p)", ws, p); assert(ws->r == NULL); if (p == NULL) ws->f = ws->s; @@ -114,7 +114,7 @@ return(NULL); r = ws->f; ws->f += bytes; - WS_DEBUG((SLT_Debug, 0, "WS_Alloc(%p, %u) = %p", ws, bytes, r)); + WS_DEBUG("WS_Alloc(%p, %u) = %p", ws, bytes, r); return (r); } @@ -128,7 +128,7 @@ p = WS_Alloc(ws, l); if (p != NULL) memcpy(p, s, l); - WS_DEBUG((SLT_Debug, 0, "WS_Dup(%p, \"%s\") = %p", ws, s, p)); + WS_DEBUG("WS_Dup(%p, \"%s\") = %p", ws, s, p); return (p); } @@ -138,7 +138,7 @@ WS_Assert(ws); assert(ws->r == NULL); - WS_DEBUG((SLT_Debug, 0, "WS_Snapshot(%p) = %p", ws, ws->f)); + WS_DEBUG("WS_Snapshot(%p) = %p", ws, ws->f); return (ws->f); } @@ -153,8 +153,8 @@ b2 = ws->e - ws->f; xxxassert(ws->f + b2 <= ws->e); ws->r = ws->f + b2; - WS_DEBUG((SLT_Debug, 0, "WS_Reserve(%p, %u/%u) = %u", - ws, b2, bytes, pdiff(ws->f, ws->r))); + WS_DEBUG("WS_Reserve(%p, %u/%u) = %u", + ws, b2, bytes, pdiff(ws->f, ws->r)); return (pdiff(ws->f, ws->r)); } @@ -162,7 +162,7 @@ WS_Release(struct ws *ws, unsigned bytes) { WS_Assert(ws); - WS_DEBUG((SLT_Debug, 0, "WS_Release(%p, %u)", ws, bytes)); + WS_DEBUG("WS_Release(%p, %u)", ws, bytes); assert(ws->r != NULL); assert(ws->f + bytes <= ws->r); ws->f += bytes; @@ -173,7 +173,7 @@ WS_ReleaseP(struct ws *ws, char *ptr) { WS_Assert(ws); - WS_DEBUG((SLT_Debug, 0, "WS_ReleaseP(%p, %p)", ws, ptr)); + WS_DEBUG("WS_ReleaseP(%p, %p)", ws, ptr); assert(ws->r != NULL); assert(ptr >= ws->f); assert(ptr <= ws->r); Modified: branches/1.2/configure.ac =================================================================== --- branches/1.2/configure.ac 2007-10-30 14:08:28 UTC (rev 2217) +++ branches/1.2/configure.ac 2007-10-30 14:08:40 UTC (rev 2218) @@ -134,6 +134,9 @@ AC_ARG_ENABLE(debugging-symbols, AS_HELP_STRING([--enable-debugging-symbols],[enable debugging symbols (default is NO)]), CFLAGS="${CFLAGS} -O0 -g -fno-inline") +AC_ARG_ENABLE(diagnostics, + AS_HELP_STRING([--enable-diagnostics],[enable run-time diagnostics (default is NO)]), + CFLAGS="${CFLAGS} -DDIAGNOSTICS") AC_ARG_ENABLE(extra-developer-warnings, AS_HELP_STRING([--enable-extra-developer-warnings],[enable even stricter warnings (default is NO)]), CFLAGS="${CFLAGS} ${EXTRA_DEVELOPER_CFLAGS}") From des at projects.linpro.no Tue Oct 30 14:09:49 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 15:09:49 +0100 (CET) Subject: r2219 - in branches/1.1: . bin/varnishd Message-ID: <20071030140949.546F91EC033@projects.linpro.no> Author: des Date: 2007-10-30 15:09:49 +0100 (Tue, 30 Oct 2007) New Revision: 2219 Modified: branches/1.1/ branches/1.1/bin/varnishd/rfc2616.c Log: Merged revisions 2206 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2206 | des | 2007-10-30 13:35:40 +0100 (Tue, 30 Oct 2007) | 2 lines Comment tweak ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2116,2133,2154,2173,2181 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2097,2106-2107,2116,2133,2154,2173,2181,2206 Modified: branches/1.1/bin/varnishd/rfc2616.c =================================================================== --- branches/1.1/bin/varnishd/rfc2616.c 2007-10-30 14:08:40 UTC (rev 2218) +++ branches/1.1/bin/varnishd/rfc2616.c 2007-10-30 14:09:49 UTC (rev 2219) @@ -177,7 +177,7 @@ case 203: /* Non-Authoritative Information */ case 300: /* Multiple Choices */ case 301: /* Moved Permanently */ - case 302: /* XXX */ + case 302: /* Moved Temporarily */ case 410: /* Gone */ case 404: /* Not Found */ sp->obj->cacheable = 1; From des at projects.linpro.no Tue Oct 30 14:40:55 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 15:40:55 +0100 (CET) Subject: r2220 - trunk/varnish-cache/bin/varnishd Message-ID: <20071030144055.5281D1EC030@projects.linpro.no> Author: des Date: 2007-10-30 15:40:55 +0100 (Tue, 30 Oct 2007) New Revision: 2220 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Refine the debugging string: we don't really need the XID, but we do need the thread ID in order to locate the correct thread in gdb. Furthermore, we must use VSL rather than WSL since the session might actually not have a worker at that point; but if it does, make sure to flush the log first. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 14:09:49 UTC (rev 2219) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-10-30 14:40:55 UTC (rev 2220) @@ -880,10 +880,11 @@ #ifdef DIAGNOSTICS #define STEP(l,u) \ case STP_##u: \ - WSL(sp->wrk, SLT_Debug, sp->id, \ - "cnt_%s(%p) xid %x obj %p vcl %p", \ - #l, sp, sp->xid, sp->obj, sp->vcl); \ - WSL_Flush(sp->wrk); \ + if (sp->wrk) \ + WSL_Flush(sp->wrk); \ + VSL(SLT_Debug, sp->id, \ + "thr %p STP_%s sp %p obj %p vcl %p", \ + pthread_self(), #u, sp, sp->obj, sp->vcl); \ done = cnt_##l(sp); \ break; #else From des at projects.linpro.no Tue Oct 30 14:41:11 2007 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 30 Oct 2007 15:41:11 +0100 (CET) Subject: r2221 - in branches/1.2: . bin/varnishd Message-ID: <20071030144111.347491EC2ED@projects.linpro.no> Author: des Date: 2007-10-30 15:41:11 +0100 (Tue, 30 Oct 2007) New Revision: 2221 Modified: branches/1.2/ branches/1.2/bin/varnishd/cache_center.c Log: Merged revisions 2220 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2220 | des | 2007-10-30 15:40:55 +0100 (Tue, 30 Oct 2007) | 5 lines Refine the debugging string: we don't really need the XID, but we do need the thread ID in order to locate the correct thread in gdb. Furthermore, we must use VSL rather than WSL since the session might actually not have a worker at that point; but if it does, make sure to flush the log first. ........ Property changes on: branches/1.2 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193,2206,2208,2210-2215 + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193,2206,2208,2210-2215,2220 Modified: branches/1.2/bin/varnishd/cache_center.c =================================================================== --- branches/1.2/bin/varnishd/cache_center.c 2007-10-30 14:40:55 UTC (rev 2220) +++ branches/1.2/bin/varnishd/cache_center.c 2007-10-30 14:41:11 UTC (rev 2221) @@ -869,10 +869,11 @@ #ifdef DIAGNOSTICS #define STEP(l,u) \ case STP_##u: \ - WSL(sp->wrk, SLT_Debug, sp->id, \ - "cnt_%s(%p) xid %x obj %p vcl %p", \ - #l, sp, sp->xid, sp->obj, sp->vcl); \ - WSL_Flush(sp->wrk); \ + if (sp->wrk) \ + WSL_Flush(sp->wrk); \ + VSL(SLT_Debug, sp->id, \ + "thr %p STP_%s sp %p obj %p vcl %p", \ + pthread_self(), #u, sp, sp->obj, sp->vcl); \ done = cnt_##l(sp); \ break; #else From phk at phk.freebsd.dk Tue Oct 30 15:39:34 2007 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Tue, 30 Oct 2007 15:39:34 +0000 Subject: r2181 - trunk/varnish-cache/bin/varnishd In-Reply-To: Your message of "Tue, 30 Oct 2007 13:15:24 +0100." Message-ID: <1327.1193758774@critter.freebsd.dk> In message , =?iso-8859-1?Q?Dag-Erling_Sm=F8rg rav?= writes: >phk at projects.linpro.no writes: >> Log: >> Remember to reset te bereq's workspace after use. > >Do you have a ticket number for this? No. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.