From phk at projects.linpro.no Mon Feb 1 06:48:16 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 07:48:16 +0100 (CET) Subject: r4513 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201064816.B51841F7C3E@projects.linpro.no> Author: phk Date: 2010-02-01 07:48:16 +0100 (Mon, 01 Feb 2010) New Revision: 4513 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_expire.c trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/cache_panic.c trunk/varnish-cache/bin/varnishd/stevedore.c trunk/varnish-cache/bin/varnishd/storage_persistent.c Log: Lift the object refcount up to the objcore structure. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2010-01-29 12:16:31 UTC (rev 4512) +++ trunk/varnish-cache/bin/varnishd/cache.h 2010-02-01 06:48:16 UTC (rev 4513) @@ -284,6 +284,7 @@ struct objcore { unsigned magic; #define OBJCORE_MAGIC 0x4d301302 + unsigned refcnt; struct object *obj; struct objhead *objhead; double timer_when; @@ -315,7 +316,6 @@ struct object { unsigned magic; #define OBJECT_MAGIC 0x32851d42 - unsigned refcnt; unsigned xid; struct storage *objstore; struct objcore *objcore; Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_expire.c 2010-01-29 12:16:31 UTC (rev 4512) +++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2010-02-01 06:48:16 UTC (rev 4513) @@ -345,7 +345,7 @@ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); if (oc->timer_idx == BINHEAP_NOIDX) /* exp_timer has it */ continue; - if (oc->obj->refcnt == 1) + if (oc->refcnt == 1) break; } if (oc != NULL) { Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-01-29 12:16:31 UTC (rev 4512) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-01 06:48:16 UTC (rev 4513) @@ -294,6 +294,7 @@ /* Insert (precreated) objcore in objecthead */ oc = w->nobjcore; w->nobjcore = NULL; + oc->refcnt = 1; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->flags & OC_F_BUSY); @@ -409,7 +410,7 @@ assert(oc->objhead == oh); /* We found an object we like */ - o->refcnt++; + oc->refcnt++; if (o->hits < INT_MAX) o->hits++; assert(oh->refcnt > 1); @@ -437,6 +438,7 @@ oc = w->nobjcore; w->nobjcore = NULL; AN(oc->flags & OC_F_BUSY); + oc->refcnt = 1; /* XXX: Should this not be ..._HEAD now ? */ VTAILQ_INSERT_TAIL(&oh->objcs, oc, list); @@ -474,6 +476,12 @@ } } +/********************************************************************** + * Kill a busy object we don't need anyway. + * There may be sessions on the waiting list, so we cannot just blow + * it out of the water. + */ + void HSH_Drop(struct sess *sp) { @@ -482,8 +490,8 @@ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); o = sp->obj; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - assert(o->refcnt > 0); if (o->objcore != NULL) { /* Pass has no objcore */ + assert(o->objcore->refcnt > 0); AN(ObjIsBusy(o)); o->ttl = 0; } @@ -509,7 +517,7 @@ AN(ObjIsBusy(o)); AN(o->ban); assert(o->objcore->obj == o); - assert(o->refcnt > 0); + assert(o->objcore->refcnt > 0); assert(oh->refcnt > 0); if (o->ws_o->overflow) sp->wrk->stats.n_objoverflow++; @@ -534,8 +542,8 @@ oh = o->objcore->objhead; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); Lck_Lock(&oh->mtx); - assert(o->refcnt > 0); - o->refcnt++; + assert(o->objcore->refcnt > 0); + o->objcore->refcnt++; Lck_Unlock(&oh->mtx); } @@ -593,7 +601,7 @@ if (oc2 != NULL && oc2->flags & OC_F_PERSISTENT) SMP_Fixup(sp, oh, oc2); if (oc2 != NULL) - oc2->obj->refcnt++; + oc2->refcnt++; Lck_Unlock(&oh->mtx); *oc = oc2; } @@ -612,8 +620,7 @@ CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); oc = o->objcore; if (oc == NULL) { - assert(o->refcnt > 0); - r = --o->refcnt; + r = 0; oh = NULL; } else { CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); @@ -622,8 +629,8 @@ Lck_Lock(&oh->mtx); assert(oh->refcnt > 0); - assert(o->refcnt > 0); - r = --o->refcnt; + assert(oc->refcnt > 0); + r = --oc->refcnt; if (!r) VTAILQ_REMOVE(&oh->objcs, oc, list); hsh_rush(oh); Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_panic.c 2010-01-29 12:16:31 UTC (rev 4512) +++ trunk/varnish-cache/bin/varnishd/cache_panic.c 2010-02-01 06:48:16 UTC (rev 4513) @@ -163,7 +163,7 @@ const struct storage *st; vsb_printf(vsp, " obj = %p {\n", o); - vsb_printf(vsp, " refcnt = %u, xid = %u,\n", o->refcnt, o->xid); + vsb_printf(vsp, " xid = %u,\n", o->xid); pan_ws(o->ws_o, 4); pan_http("obj", o->http, 4); vsb_printf(vsp, " len = %u,\n", o->len); Modified: trunk/varnish-cache/bin/varnishd/stevedore.c =================================================================== --- trunk/varnish-cache/bin/varnishd/stevedore.c 2010-01-29 12:16:31 UTC (rev 4512) +++ trunk/varnish-cache/bin/varnishd/stevedore.c 2010-02-01 06:48:16 UTC (rev 4513) @@ -101,7 +101,6 @@ http_Setup(o->http, o->ws_o); o->http->magic = HTTP_MAGIC; - o->refcnt = 1; o->grace = NAN; o->entered = NAN; VTAILQ_INIT(&o->store); Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c =================================================================== --- trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-01-29 12:16:31 UTC (rev 4512) +++ trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-02-01 06:48:16 UTC (rev 4513) @@ -672,7 +672,6 @@ oc->flags &= ~OC_F_PERSISTENT; /* refcnt is one because the object is in the hash */ - oc->obj->refcnt = 1; oc->obj->objcore = oc; oc->obj->ban = oc->ban; From phk at projects.linpro.no Mon Feb 1 08:29:16 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 09:29:16 +0100 (CET) Subject: r4514 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201082916.9111E1F7BAD@projects.linpro.no> Author: phk Date: 2010-02-01 09:29:16 +0100 (Mon, 01 Feb 2010) New Revision: 4514 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_backend.c trunk/varnish-cache/bin/varnishd/cache_backend.h trunk/varnish-cache/bin/varnishd/cache_dir_random.c trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/cache_vrt.c Log: Make the trouble-list hold a uintptr_t of the objhead, instead of the actual objhead, to make it painfully obvious, that no dereference is allowed. Various strokes with the polishing cloth along the way. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2010-02-01 06:48:16 UTC (rev 4513) +++ trunk/varnish-cache/bin/varnishd/cache.h 2010-02-01 08:29:16 UTC (rev 4514) @@ -456,7 +456,8 @@ /* cache_backend.c */ struct vbe_conn *VBE_GetFd(const struct director *, struct sess *sp); -int VBE_Healthy(const struct director *, const struct sess *sp); +int VBE_Healthy(double now, const struct director *, uintptr_t target); +int VBE_Healthy_sp(const struct sess *sp, const struct director *); void VBE_ClosedFd(struct sess *sp); void VBE_RecycleFd(struct sess *sp); void VBE_AddHostHeader(const struct sess *sp); Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.c 2010-02-01 06:48:16 UTC (rev 4513) +++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2010-02-01 08:29:16 UTC (rev 4514) @@ -243,18 +243,18 @@ */ static unsigned int -vbe_Healthy(const struct sess *sp, struct backend *backend) +vbe_Healthy(double now, uintptr_t target, struct backend *backend) { struct trouble *tr; struct trouble *tr2; - struct trouble *old = NULL; - unsigned i = 0; + struct trouble *old; + unsigned i = 0, retval; unsigned int threshold; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(backend, BACKEND_MAGIC); if (!backend->healthy) - return 0; + return (0); /* VRT/VCC sets threshold to UINT_MAX to mark that it's not * specified by VCL (thus use param). @@ -266,43 +266,47 @@ /* Saintmode is disabled */ if (threshold == 0) - return 1; + return (1); /* No need to test if we don't have an object head to test against. * FIXME: Should check the magic too, but probably not assert? */ - if (!sp->objhead) - return 1; + if (target == 0) + return (1); + old = NULL; + retval = 1; Lck_Lock(&backend->mtx); VTAILQ_FOREACH_SAFE(tr, &backend->troublelist, list, tr2) { CHECK_OBJ_NOTNULL(tr, TROUBLE_MAGIC); - if (tr->timeout < sp->t_req) { + + if (tr->timeout < now) { VTAILQ_REMOVE(&backend->troublelist, tr, list); old = tr; + retval = 1; break; } - if (tr->objhead == sp->objhead) { - Lck_Unlock(&backend->mtx); - return 0; + if (tr->target == target) { + retval = 0; + break; } /* If the threshold is at 1, a single entry on the list * will disable the backend. Since 0 is disable, ++i * instead of i++ to allow this behavior. */ - if (++i >=threshold) { - Lck_Unlock(&backend->mtx); - return 0; + if (++i >= threshold) { + retval = 0; + break; } } Lck_Unlock(&backend->mtx); - if (old) + if (old != NULL) FREE_OBJ(old); - return 1; + return (retval); } /*-------------------------------------------------------------------- @@ -342,7 +346,7 @@ VBE_ClosedFd(sp); } - if (!vbe_Healthy(sp, bp)) { + if (!vbe_Healthy(sp->t_req, (uintptr_t)sp->objhead, bp)) { VSL_stats->backend_unhealthy++; return (NULL); } @@ -423,19 +427,30 @@ return (d->getfd(d, sp)); } -/* Check health ------------------------------------------------------*/ +/* Check health ------------------------------------------------------ + * + * The target is really an objhead pointer, but since it can not be + * dereferenced during health-checks, we pass it as uintptr_t, which + * hopefully will make people investigate, before mucking about with it. + */ int -VBE_Healthy(const struct director *d, const struct sess *sp) +VBE_Healthy_sp(const struct sess *sp, const struct director *d) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - if (d == NULL) - d = sp->director; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - return (d->healthy(d, sp)); + return (d->healthy(sp->t_req, d, (uintptr_t)sp->objhead)); } +int +VBE_Healthy(double now, const struct director *d, uintptr_t target) +{ + + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + return (d->healthy(now, d, target)); +} + /*-------------------------------------------------------------------- * The "simple" director really isn't, since thats where all the actual * connections happen. Nontheless, pretend it is simple by sequestering @@ -469,14 +484,13 @@ } static unsigned -vdi_simple_healthy(const struct director *d, const struct sess *sp) +vdi_simple_healthy(double now, const struct director *d, uintptr_t target) { struct vdi_simple *vs; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - return (vbe_Healthy(sp, vs->backend)); + return (vbe_Healthy(now, target, vs->backend)); } /*lint -e{818} not const-able */ Modified: trunk/varnish-cache/bin/varnishd/cache_backend.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.h 2010-02-01 06:48:16 UTC (rev 4513) +++ trunk/varnish-cache/bin/varnishd/cache_backend.h 2010-02-01 08:29:16 UTC (rev 4514) @@ -79,7 +79,8 @@ typedef struct vbe_conn *vdi_getfd_f(const struct director *, struct sess *sp); typedef void vdi_fini_f(struct director *); -typedef unsigned vdi_healthy(const struct director *, const struct sess *sp); +typedef unsigned vdi_healthy(double now, const struct director *, + uintptr_t target); struct director { unsigned magic; @@ -99,7 +100,7 @@ struct trouble { unsigned magic; #define TROUBLE_MAGIC 0x4211ab21 - void *objhead; /* NB: only comparison */ + uintptr_t target; double timeout; VTAILQ_ENTRY(trouble) list; }; Modified: trunk/varnish-cache/bin/varnishd/cache_dir_random.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2010-02-01 06:48:16 UTC (rev 4513) +++ trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2010-02-01 08:29:16 UTC (rev 4514) @@ -137,7 +137,7 @@ if (r >= s1) continue; d2 = vs->hosts[i].backend; - if (!VBE_Healthy(d2, sp)) + if (!VBE_Healthy_sp(sp, d2)) break; vbe = VBE_GetFd(d2, sp); if (vbe != NULL) @@ -152,7 +152,7 @@ for (i = 0; i < vs->nhosts; i++) { d2 = vs->hosts[i].backend; /* XXX: cache result of healty to avoid double work */ - if (VBE_Healthy(d2, sp)) + if (VBE_Healthy_sp(sp, d2)) s1 += vs->hosts[i].weight; } @@ -171,7 +171,7 @@ s1 = 0.0; for (i = 0; i < vs->nhosts; i++) { d2 = vs->hosts[i].backend; - if (!VBE_Healthy(d2, sp)) + if (!VBE_Healthy_sp(sp, d2)) continue; s1 += vs->hosts[i].weight; if (r >= s1) @@ -187,17 +187,16 @@ } static unsigned -vdi_random_healthy(const struct director *d, const struct sess *sp) +vdi_random_healthy(double now, const struct director *d, uintptr_t target) { struct vdi_random *vs; int i; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC); for (i = 0; i < vs->nhosts; i++) { - if (VBE_Healthy(vs->hosts[i].backend, sp)) + if (VBE_Healthy(now, vs->hosts[i].backend, target)) return 1; } return 0; Modified: trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c 2010-02-01 06:48:16 UTC (rev 4513) +++ trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c 2010-02-01 08:29:16 UTC (rev 4514) @@ -75,7 +75,7 @@ for (i = 0; i < vs->nhosts; i++) { backend = vs->hosts[vs->next_host].backend; vs->next_host = (vs->next_host + 1) % vs->nhosts; - if (!VBE_Healthy(backend, sp)) + if (!VBE_Healthy_sp(sp, backend)) continue; vbe = VBE_GetFd(backend, sp); if (vbe != NULL) @@ -86,19 +86,18 @@ } static unsigned -vdi_round_robin_healthy(const struct director *d, const struct sess *sp) +vdi_round_robin_healthy(double now, const struct director *d, uintptr_t target) { struct vdi_round_robin *vs; struct director *backend; int i; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_ROUND_ROBIN_MAGIC); for (i = 0; i < vs->nhosts; i++) { backend = vs->hosts[i].backend; - if (VBE_Healthy(backend, sp)) + if (VBE_Healthy(now, backend, target)) return 1; } return 0; Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-01 06:48:16 UTC (rev 4513) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-01 08:29:16 UTC (rev 4514) @@ -187,7 +187,7 @@ WSP(sp, SLT_Hash, "%s", str); } -/********************************************************************** +/*--------------------------------------------------------------------- * This is a debugging hack to enable testing of boundary conditions * in the hash algorithm. * We trap the first 9 different digests and translate them to different @@ -394,15 +394,16 @@ * mode'. Is this entirely wrong, or just ugly? Why isn't objhead * set here? FIXME:Grace. */ - sp->objhead = oh; - if (oc == NULL && grace_oc != NULL && - (busy_oc != NULL || !VBE_Healthy(NULL, sp))) { + if (oc == NULL /* We found no live object */ + && grace_oc != NULL /* There is a grace candidate */ + && (busy_oc != NULL /* Somebody else is already busy */ + || !VBE_Healthy(sp->t_req, sp->director, (uintptr_t)oh))) { + /* Or it is impossible to fetch: */ o = grace_oc->obj; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); if (o->ttl + HSH_Grace(sp->grace) >= sp->t_req) oc = grace_oc; } - sp->objhead = NULL; if (oc != NULL) { o = oc->obj; Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-02-01 06:48:16 UTC (rev 4513) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-02-01 08:29:16 UTC (rev 4514) @@ -308,7 +308,7 @@ ALLOC_OBJ(new, TROUBLE_MAGIC); AN(new); - new->objhead = sp->objhead; + new->target = (uintptr_t)sp->objhead; new->timeout = sp->t_req + a; /* Insert the new item on the list before the first item with a @@ -782,7 +782,7 @@ { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - return (VBE_Healthy(NULL, sp)); + return (VBE_Healthy_sp(sp, sp->director)); } /*--------------------------------------------------------------------*/ From phk at projects.linpro.no Mon Feb 1 08:58:18 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 09:58:18 +0100 (CET) Subject: r4515 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201085818.7320E1F7BAD@projects.linpro.no> Author: phk Date: 2010-02-01 09:58:17 +0100 (Mon, 01 Feb 2010) New Revision: 4515 Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c Log: Explain the oh->refcnt that is lent to sess on waiting list. Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-01 08:29:16 UTC (rev 4514) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-01 08:58:17 UTC (rev 4515) @@ -330,6 +330,10 @@ hsh_testmagic(sp->wrk->nobjhead->digest); if (sp->objhead != NULL) { + /* + * This sess came off the waiting list, and brings a + * oh refcnt with it. + */ CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC); oh = sp->objhead; sp->objhead = NULL; @@ -390,10 +394,6 @@ * XXX: this until the object is unbusy'ed, so in practice we * XXX: serialize fetch of all Vary's if grace is possible. */ - /* Grace-stuff: sp->objhead is evaluated in healthy() for 'saint - * mode'. Is this entirely wrong, or just ugly? Why isn't objhead - * set here? FIXME:Grace. - */ if (oc == NULL /* We found no live object */ && grace_oc != NULL /* There is a grace candidate */ && (busy_oc != NULL /* Somebody else is already busy */ @@ -429,6 +429,11 @@ WSP(sp, SLT_Debug, "on waiting list <%p>", oh); SES_Charge(sp); + /* + * The objhead reference transfers to the sess, we get it + * back when the sess comes off the waiting list and + * calls us again + */ sp->objhead = oh; sp->wrk = NULL; Lck_Unlock(&oh->mtx); From phk at projects.linpro.no Mon Feb 1 09:00:13 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 10:00:13 +0100 (CET) Subject: r4516 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201090013.D54481F7BAD@projects.linpro.no> Author: phk Date: 2010-02-01 10:00:13 +0100 (Mon, 01 Feb 2010) New Revision: 4516 Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c Log: Don't nuke the objcore object pointer when we deref the last object on the LRU list, we may not be holding the last reference. Fixes: #634 Tip of hat to: Matt Page for execellent diagnosis & patch. Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_expire.c 2010-02-01 08:58:17 UTC (rev 4515) +++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2010-02-01 09:00:13 UTC (rev 4516) @@ -324,6 +324,7 @@ EXP_NukeOne(const struct sess *sp, const struct lru *lru) { struct objcore *oc; + struct object *o; /* * Find the first currently unused object on the LRU. @@ -361,7 +362,8 @@ return (-1); WSL(sp->wrk, SLT_ExpKill, 0, "%u LRU", oc->obj->xid); - HSH_Deref(sp->wrk, &(oc->obj)); + o = oc->obj; + HSH_Deref(sp->wrk, &o); return (1); } From phk at projects.linpro.no Mon Feb 1 10:36:52 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 11:36:52 +0100 (CET) Subject: r4517 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201103652.D847A1F7C46@projects.linpro.no> Author: phk Date: 2010-02-01 11:36:52 +0100 (Mon, 01 Feb 2010) New Revision: 4517 Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c Log: Don't assert on write errors to the child process CLI-pipe, it might simply be dying on us. Instead return the designed error code for this: CLIS_COMM Fixes #639 Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-01 09:00:13 UTC (rev 4516) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-01 10:36:52 UTC (rev 4517) @@ -175,9 +175,19 @@ } AN(cli->cmd); i = write(cli_o, cli->cmd, strlen(cli->cmd)); - xxxassert(i == strlen(cli->cmd)); + if (i != strlen(cli->cmd)) { + cli_result(cli, CLIS_COMMS); + cli_out(cli, "CLI communication error"); + return; + } i = write(cli_o, "\n", 1); - xxxassert(i == 1); + if (i != 1) { + cli_result(cli, CLIS_COMMS); + cli_out(cli, "CLI communication error"); + return; + } + + assert(i == 1 || errno == EPIPE); (void)cli_readres(cli_i, &u, &q, params->cli_timeout); cli_result(cli, u); From phk at projects.linpro.no Mon Feb 1 12:40:44 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 13:40:44 +0100 (CET) Subject: r4518 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20100201124044.93DD41F7C4E@projects.linpro.no> Author: phk Date: 2010-02-01 13:40:44 +0100 (Mon, 01 Feb 2010) New Revision: 4518 Modified: trunk/varnish-cache/bin/varnishtest/tests/c00029.vtc Log: Add an explanation I spent too long figuring out on my own. Modified: trunk/varnish-cache/bin/varnishtest/tests/c00029.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00029.vtc 2010-02-01 10:36:52 UTC (rev 4517) +++ trunk/varnish-cache/bin/varnishtest/tests/c00029.vtc 2010-02-01 12:40:44 UTC (rev 4518) @@ -85,6 +85,9 @@ expect resp.http.X-Saint != "yes" expect resp.http.X-Restarts == "1" + # The saintmode_threshold should kick in now + # so expect no more restarts + txreq -url "/three" rxresp expect resp.status == 200 From phk at projects.linpro.no Mon Feb 1 12:44:08 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 13:44:08 +0100 (CET) Subject: r4519 - in trunk/varnish-cache: bin/varnishd include Message-ID: <20100201124408.1C2461F7C57@projects.linpro.no> Author: phk Date: 2010-02-01 13:44:07 +0100 (Mon, 01 Feb 2010) New Revision: 4519 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/include/stat_field.h Log: Add a varnish "uptime" counter, which counts seconds of uptime for the worker thread. Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-01 12:40:44 UTC (rev 4518) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-01 12:44:07 UTC (rev 4519) @@ -187,7 +187,7 @@ struct pollfd *pfd; struct listen_sock *ls; unsigned u; - double now, pace; + double t0, now, pace; THR_SetName("cache-acceptor"); (void)arg; @@ -208,6 +208,7 @@ need_test = 1; pace = 0; + t0 = TIM_real(); while (1) { #ifdef SO_SNDTIMEO_WORKS if (params->send_timeout != tv_sndtimeo.tv_sec) { @@ -244,6 +245,7 @@ TIM_sleep(pace); i = poll(pfd, heritage.nsocks, 1000); now = TIM_real(); + VSL_stats->uptime = (uint64_t)(now - t0); u = 0; VTAILQ_FOREACH(ls, &heritage.socks, list) { if (ls->sock < 0) Modified: trunk/varnish-cache/include/stat_field.h =================================================================== --- trunk/varnish-cache/include/stat_field.h 2010-02-01 12:40:44 UTC (rev 4518) +++ trunk/varnish-cache/include/stat_field.h 2010-02-01 12:44:07 UTC (rev 4519) @@ -151,3 +151,4 @@ MAC_STAT(esi_errors, uint64_t, 0, 'a', "ESI parse errors (unlock)") MAC_STAT(accept_fail, uint64_t, 0, 'a', "Accept failures") MAC_STAT(client_drop_late, uint64_t, 0, 'a', "Connection dropped late") +MAC_STAT(uptime, uint64_t, 0, 'a', "Client uptime") From phk at projects.linpro.no Mon Feb 1 13:06:32 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 14:06:32 +0100 (CET) Subject: r4520 - in trunk/varnish-cache: bin/varnishd include Message-ID: <20100201130632.0C2811F7BAD@projects.linpro.no> Author: phk Date: 2010-02-01 14:06:31 +0100 (Mon, 01 Feb 2010) New Revision: 4520 Modified: trunk/varnish-cache/bin/varnishd/shmlog.c trunk/varnish-cache/include/shmlog.h Log: Add the master and child pid's to the SHMFILE. If the master pid is active when we start, we issue a message about this, (with a hint about -n) and exit. If the master pid is not active, but the child pid is, we issue a message about it presumably being busy dying, dump the SHMFILE and create a new one. (This only saves our bacon, if the dying process manages to close the listening sockets before we need them). This should end any confusion that might arise from accidentally running multiple varnishes at the same time. Fixes #620 Modified: trunk/varnish-cache/bin/varnishd/shmlog.c =================================================================== --- trunk/varnish-cache/bin/varnishd/shmlog.c 2010-02-01 12:44:07 UTC (rev 4519) +++ trunk/varnish-cache/bin/varnishd/shmlog.c 2010-02-01 13:06:31 UTC (rev 4520) @@ -32,6 +32,7 @@ #include "svnid.h" SVNID("$Id$") +#include #include #include #include @@ -313,6 +314,7 @@ loghead->starttime = TIM_real(); loghead->panicstr[0] = '\0'; memset(VSL_stats, 0, sizeof *VSL_stats); + loghead->child_pid = getpid(); } /*--------------------------------------------------------------------*/ @@ -333,6 +335,25 @@ return (0); if (slh.start != sizeof slh + sizeof *params) return (0); + + if (!kill(slh.master_pid, 0)) { + fprintf(stderr, + "SHMFILE owned by running varnishd master (pid=%jd)\n", + (intmax_t)slh.master_pid); + fprintf(stderr, + "(Use unique -n arguments if you want multiple " + "instances.)\n"); + exit(2); + } + + if (slh.child_pid != 0 && !kill(slh.child_pid, 0)) { + fprintf(stderr, + "SHMFILE used by orphan varnishd child process (pid=%jd)\n", + (intmax_t)slh.child_pid); + fprintf(stderr, "(We assume that process is busy dying.)\n"); + return (0); + } + /* XXX more checks */ heritage.vsl_size = slh.size + slh.start; return (1); @@ -345,7 +366,7 @@ int i; (void)unlink(fn); - heritage.vsl_fd = open(fn, O_RDWR | O_CREAT, 0644); + heritage.vsl_fd = open(fn, O_RDWR | O_CREAT | O_EXCL, 0644); if (heritage.vsl_fd < 0) { fprintf(stderr, "Could not open %s: %s\n", fn, strerror(errno)); @@ -384,6 +405,7 @@ PROT_READ|PROT_WRITE, MAP_HASSEMAPHORE | MAP_NOSYNC | MAP_SHARED, heritage.vsl_fd, 0); + loghead->master_pid = getpid(); xxxassert(loghead != MAP_FAILED); (void)mlock(loghead, heritage.vsl_size); VSL_stats = &loghead->stats; Modified: trunk/varnish-cache/include/shmlog.h =================================================================== --- trunk/varnish-cache/include/shmlog.h 2010-02-01 12:44:07 UTC (rev 4519) +++ trunk/varnish-cache/include/shmlog.h 2010-02-01 13:06:31 UTC (rev 4520) @@ -39,6 +39,7 @@ #define SHMLOG_FILENAME "_.vsl" #include +#include #include "stats.h" @@ -49,6 +50,8 @@ unsigned hdrsize; time_t starttime; + pid_t master_pid; + pid_t child_pid; /* * Byte offset into the file where the fifolog starts From phk at projects.linpro.no Mon Feb 1 13:25:03 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 14:25:03 +0100 (CET) Subject: r4521 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201132503.60FEE1F7BAD@projects.linpro.no> Author: phk Date: 2010-02-01 14:25:01 +0100 (Mon, 01 Feb 2010) New Revision: 4521 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/cache_cli.c Log: When we detect the parent absconding the CLI pipes, close the acceptor sockets as fast as we can, so that a new copy of varnishd can get at them. Fixes #622 Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2010-02-01 13:06:31 UTC (rev 4520) +++ trunk/varnish-cache/bin/varnishd/cache.h 2010-02-01 13:25:01 UTC (rev 4521) @@ -450,6 +450,7 @@ void vca_close_session(struct sess *sp, const char *why); void VCA_Prep(struct sess *sp); void VCA_Init(void); +void VCA_Shutdown(void); const char *VCA_waiter_name(void); extern pthread_t VCA_thread; Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-01 13:06:31 UTC (rev 4520) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-01 13:25:01 UTC (rev 4521) @@ -425,6 +425,21 @@ } void +VCA_Shutdown(void) +{ + struct listen_sock *ls; + int i; + + VTAILQ_FOREACH(ls, &heritage.socks, list) { + if (ls->sock < 0) + continue; + i = ls->sock; + ls->sock = -1; + (void)close(i); + } +} + +void VCA_tweak_waiter(struct cli *cli, const char *arg) { int i; Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_cli.c 2010-02-01 13:06:31 UTC (rev 4520) +++ trunk/varnish-cache/bin/varnishd/cache_cli.c 2010-02-01 13:25:01 UTC (rev 4521) @@ -112,6 +112,7 @@ i = CLS_Poll(cls, -1); } while(i > 0); VSL(SLT_CLI, 0, "EOF on CLI connection, worker stops"); + VCA_Shutdown(); } /*--------------------------------------------------------------------*/ From phk at projects.linpro.no Mon Feb 1 18:48:08 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 19:48:08 +0100 (CET) Subject: r4522 - trunk/varnish-cache/lib/libvarnish Message-ID: <20100201184808.87A731F7C3E@projects.linpro.no> Author: phk Date: 2010-02-01 19:48:08 +0100 (Mon, 01 Feb 2010) New Revision: 4522 Modified: trunk/varnish-cache/lib/libvarnish/vsb.c Log: Merger a bunch of (mostly) stylistic changes from FreeBSD. Modified: trunk/varnish-cache/lib/libvarnish/vsb.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vsb.c 2010-02-01 13:25:01 UTC (rev 4521) +++ trunk/varnish-cache/lib/libvarnish/vsb.c 2010-02-01 18:48:08 UTC (rev 4522) @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2000 Poul-Henning Kamp and Dag-Erling Sm?rgrav + * Copyright (c) 2000-2008 Poul-Henning Kamp + * Copyright (c) 2000-2008 Dag-Erling Co?dan Sm?rgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -12,17 +13,18 @@ * 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 ``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 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. - * $FreeBSD: src/sys/kern/subr_sbuf.c,v 1.30 2005/12/23 11:49:53 phk Exp $ + * 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. +__FBSDID("$FreeBSD: head/sys/kern/subr_sbuf.c 181462 2008-08-09 10:26:21Z des $"); */ #include "config.h" @@ -73,6 +75,7 @@ static void _vsb_assert_integrity(const char *fun, struct vsb *s) { + (void)fun; (void)s; KASSERT(s != NULL, @@ -88,6 +91,7 @@ static void _vsb_assert_state(const char *fun, struct vsb *s, int state) { + (void)fun; (void)s; (void)state; @@ -114,7 +118,6 @@ else newsize += VSB_MAXEXTENDINCR; } - return (newsize); } @@ -130,9 +133,8 @@ if (!VSB_CANEXTEND(s)) return (-1); - newsize = vsb_extendsize(s->s_size + addlen); - newbuf = (char *)SBMALLOC(newsize); + newbuf = SBMALLOC(newsize); if (newbuf == NULL) return (-1); memcpy(newbuf, s->s_buf, s->s_size); @@ -153,6 +155,7 @@ struct vsb * vsb_new(struct vsb *s, char *buf, int length, int flags) { + KASSERT(length >= 0, ("attempt to create an vsb of negative length (%d)", length)); KASSERT((flags & ~VSB_USRFLAGMSK) == 0, @@ -160,17 +163,11 @@ flags &= VSB_USRFLAGMSK; if (s == NULL) { - s = (struct vsb *)SBMALLOC(sizeof *s); + s = SBMALLOC(sizeof(*s)); if (s == NULL) return (NULL); - if (vsb_new(s, buf, length, flags) == NULL) { - free(s); - return (NULL); - } - VSB_SETFLAG(s, VSB_DYNSTRUCT); - return (s); + flags |= VSB_DYNSTRUCT; } - memset(s, 0, sizeof *s); s->s_flags = flags; s->s_magic = VSB_MAGIC; @@ -181,9 +178,12 @@ } if (flags & VSB_AUTOEXTEND) s->s_size = vsb_extendsize(s->s_size); - s->s_buf = (char *)SBMALLOC(s->s_size); - if (s->s_buf == NULL) + s->s_buf = SBMALLOC(s->s_size); + if (s->s_buf == NULL) { + if (VSB_ISDYNSTRUCT(s)) + SBFREE(s); return (NULL); + } VSB_SETFLAG(s, VSB_DYNAMIC); return (s); } @@ -194,6 +194,7 @@ void vsb_clear(struct vsb *s) { + vsb_assert_integrity(s); /* don't care if it's finished or not */ @@ -209,6 +210,7 @@ int vsb_setpos(struct vsb *s, int pos) { + vsb_assert_integrity(s); vsb_assert_state(s, 0); @@ -236,7 +238,6 @@ if (VSB_HASOVERFLOWED(s)) return (-1); - for (; len; len--) { if (!VSB_HASROOM(s) && vsb_extend(s, len) < 0) break; @@ -255,6 +256,7 @@ int vsb_bcpy(struct vsb *s, const void *buf, size_t len) { + vsb_assert_integrity(s); vsb_assert_state(s, 0); @@ -268,6 +270,7 @@ int vsb_cat(struct vsb *s, const char *str) { + vsb_assert_integrity(s); vsb_assert_state(s, 0); @@ -292,6 +295,7 @@ int vsb_cpy(struct vsb *s, const char *str) { + vsb_assert_integrity(s); vsb_assert_state(s, 0); @@ -367,18 +371,18 @@ int vsb_putc(struct vsb *s, int c) { + vsb_assert_integrity(s); vsb_assert_state(s, 0); if (VSB_HASOVERFLOWED(s)) return (-1); - if (!VSB_HASROOM(s) && vsb_extend(s, 1) < 0) { VSB_SETFLAG(s, VSB_OVERFLOWED); return (-1); } if (c != '\0') - s->s_buf[s->s_len++] = (char)c; + s->s_buf[s->s_len++] = (char)c; return (0); } @@ -388,6 +392,7 @@ int vsb_trim(struct vsb *s) { + vsb_assert_integrity(s); vsb_assert_state(s, 0); @@ -406,7 +411,8 @@ int vsb_overflowed(const struct vsb *s) { - return VSB_HASOVERFLOWED(s); + + return (VSB_HASOVERFLOWED(s)); } /* @@ -415,6 +421,7 @@ void vsb_finish(struct vsb *s) { + vsb_assert_integrity(s); vsb_assert_state(s, 0); @@ -429,10 +436,11 @@ char * vsb_data(struct vsb *s) { + vsb_assert_integrity(s); vsb_assert_state(s, VSB_FINISHED); - return s->s_buf; + return (s->s_buf); } /* @@ -441,12 +449,13 @@ int vsb_len(struct vsb *s) { + vsb_assert_integrity(s); /* don't care if it's finished or not */ if (VSB_HASOVERFLOWED(s)) return (-1); - return s->s_len; + return (s->s_len); } /* From phk at projects.linpro.no Mon Feb 1 19:44:50 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 20:44:50 +0100 (CET) Subject: r4523 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201194450.DF4A31F7BAD@projects.linpro.no> Author: phk Date: 2010-02-01 20:44:50 +0100 (Mon, 01 Feb 2010) New Revision: 4523 Modified: trunk/varnish-cache/bin/varnishd/cache_esi.c Log: Fix an unwarranted assert, st->len can of course use the entire storage space. Fixes 590 Modified: trunk/varnish-cache/bin/varnishd/cache_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_esi.c 2010-02-01 18:48:08 UTC (rev 4522) +++ trunk/varnish-cache/bin/varnishd/cache_esi.c 2010-02-01 19:44:50 UTC (rev 4523) @@ -845,7 +845,7 @@ VTAILQ_INSERT_TAIL(&ed->esibits, eb, list); } - assert(st->len < st->space); + assert(st->len <= st->space); assert(st->len == ew->space); sp->obj->esidata = ed; From phk at projects.linpro.no Mon Feb 1 19:45:28 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 20:45:28 +0100 (CET) Subject: r4524 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20100201194528.210131F7BAD@projects.linpro.no> Author: phk Date: 2010-02-01 20:45:27 +0100 (Mon, 01 Feb 2010) New Revision: 4524 Added: trunk/varnish-cache/bin/varnishtest/tests/r00590.vtc Log: Add a regression test for ticket 590, now that I finally figured it out. Added: trunk/varnish-cache/bin/varnishtest/tests/r00590.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00590.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/r00590.vtc 2010-02-01 19:45:27 UTC (rev 4524) @@ -0,0 +1,75 @@ +# $Id$ + +test "Regression test for 590" + +server s1 { + rxreq + expect req.url == "/" + txresp -body { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } + + rxreq + txresp -body "foo" + +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + return (pass); + } + sub vcl_fetch { + esi; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.bodylen == 184 +} -run From phk at projects.linpro.no Mon Feb 1 20:08:18 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 21:08:18 +0100 (CET) Subject: r4525 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201200818.65D831F7C46@projects.linpro.no> Author: phk Date: 2010-02-01 21:08:18 +0100 (Mon, 01 Feb 2010) New Revision: 4525 Modified: trunk/varnish-cache/bin/varnishd/varnishd.1 Log: Mdoc manual page adjustments. Fixes #592 Modified: trunk/varnish-cache/bin/varnishd/varnishd.1 =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-01 19:45:27 UTC (rev 4524) +++ trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-01 20:08:18 UTC (rev 4525) @@ -36,24 +36,37 @@ .Nd HTTP accelerator daemon .Sh SYNOPSIS .Nm -.Op Fl a Ar address Ns Op : Ns Ar port -.Op Fl b Ar host Ns Op : Ns Ar port +.Oo Fl a Ar address Ns +.Op : Ns Ar port +.Oc +.Oo Fl b Ar host Ns +.Op : Ns Ar port +.Oc .Op Fl d .Op Fl F .Op Fl f Ar config .Op Fl g Ar group -.Op Fl h Ar type Ns Op , Ns Ar options +.Oo Fl h Ar type Ns +.Op , Ns Ar options +.Oc .Op Fl i Ar identity .Op Fl l Ar shmlogsize .Op Fl n Ar name .Op Fl P Ar file .Op Fl p Ar param Ns = Ns Ar value -.Op Fl s Ar type Ns Op , Ns Ar options -.Op Fl T Ar address Ns Op : Ns Ar port +.Oo Fl s Ar type Ns +.Op , Ns Ar options +.Oc +.Oo Fl T Ar address Ns +.Op : Ns Ar port +.Oc .Op Fl t Ar ttl .Op Fl u Ar user .Op Fl V -.Op Fl w Ar min Ns Op , Ns Ar max Ns Op , Ns Ar timeout +.Oo Fl w Ar min Ns +.Oo , Ns Ar max Ns +.Op , Ns Ar timeout +.Oc Oc .Sh DESCRIPTION The .Nm @@ -63,9 +76,11 @@ .Pp The following options are available: .Bl -tag -width Fl -.It Xo -.Fl a Ar address Ns Op : Ns Ar port Ns -.Op , Ns Ar address Ns Op : Ns Ar port Ns +.It Fl a Ar address Ns Xo +.Op : Ns Ar port Ns +.Oo , Ns Ar address Ns +.Op : Ns Ar port Ns +.Oc .Op ... .Xc Listen for client requests on the specified @@ -92,7 +107,9 @@ is used. Multiple listening addresses and ports can be specified as a whitespace- or comma-separated list. -.It Fl b Ar host Ns Op : Ns Ar port +.It Fl b Ar host Ns Xo +.Op : Ns Ar port +.Xc Use the specified .Ar host as backend server. @@ -134,7 +151,9 @@ This is a shortcut for specifying the .Va group run-time parameter. -.It Fl h Ar type Ns Op , Ns Ar options +.It Fl h Ar type Ns Xo +.Op , Ns Ar options +.Xc Specifies the hash algorithm. See .Sx Hash Algorithms @@ -149,7 +168,7 @@ Scaling suffixes like 'k', 'm' can be used up to (e)tabytes. Default is 80 Megabytes. Specifying less than 8 Megabytes is unwise. -.It Fl n +.It Fl n Ar name Specify a name for this instance. Amonst other things, this name is used to construct the name of the directory in which @@ -169,14 +188,18 @@ See .Sx Run-Time Parameters for a list of parameters. -.It Fl s Ar type Ns Op , Ns Ar options +.It Fl s Ar type Ns Xo +.Op , Ns Ar options +.Xc Use the specified storage backend. See .Sx Storage Types for a list of supported storage types. This option can be used multiple times to specify multiple storage files. -.It Fl T Ar address Ns Op : Ns Ar port +.It Fl T Ar address Ns Xo +.Op : Ns Ar port +.Xc Offer a management interface on the specified .Ar address and @@ -200,7 +223,11 @@ first. .It Fl V Display the version number and exit. -.It Fl w Ar min Ns Op , Ns Ar max Ns Op , Ns Ar timeout +.It Fl w Ar min Ns Xo +.Oo , Ns Ar max Ns +.Op , Ns Ar timeout +.Oc +.Xc Start at least .Ar min but no more than @@ -227,7 +254,9 @@ .It Cm simple_list A simple doubly-linked list. Not recommended for production use. -.It Cm classic Ns Op Ns , Ns Ar buckets +.It Cm classic Ns Xo +.Op Ns , Ns Ar buckets +.Xc A standard hash table. This is the default. .Pp @@ -244,7 +273,9 @@ .Ss Storage Types The following storage types are available: .Bl -tag -width 4n -.It Cm malloc Ns Op Ns , Ns Ar size Ns +.It Cm malloc Ns Xo +.Op Ns , Ns Ar size Ns +.Xc Storage for each object is allocated with .Xr malloc 3 . .Pp @@ -265,7 +296,12 @@ .El .Pp The default size is unlimited. -.It Cm file Ns Op Ns , Ns Ar path Ns Op Ns , Ns Ar size Ns Op Ns , Ns Ar granularity +.It Cm file Ns Xo +.Oo Ns , Ns Ar path Ns +.Oo Ns , Ns Ar size Ns +.Op Ns , Ns Ar granularity +.Oc Oc +.Xc Storage for each object is allocated from an arena backed by a file. This is the default. .Pp @@ -364,7 +400,10 @@ parameter. .It Cm ping Op Ns Ar timestamp Ping the Varnish cache process, keeping the connection alive. -.It Cm purge Ar field Ar operator Ar argument Op && Ar field Ar operator Ar argument Op ... +.It Cm purge Ar field Ar operator Ar argument Xo +.Oo && Ar field Ar operator Ar argument Oo ... +.Oc Oc +.Xc Immediately invalidate all documents matching the purge expression. See .Va Purge expressions From phk at projects.linpro.no Mon Feb 1 21:06:31 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 22:06:31 +0100 (CET) Subject: r4526 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201210631.372931F7BAD@projects.linpro.no> Author: phk Date: 2010-02-01 22:06:30 +0100 (Mon, 01 Feb 2010) New Revision: 4526 Modified: trunk/varnish-cache/bin/varnishd/mgt.h trunk/varnish-cache/bin/varnishd/mgt_param.c trunk/varnish-cache/bin/varnishd/varnishd.c Log: Add a secret, and decisively undocumented -x option to varnishd, which only does something if -DDIAGNOSTIC was configured. First secret superpower is "-x dumpmdoc" which emits a -mdoc suitable table of all run-time parameters, which can be absorbed into the varnishd.1 manual page, so we do not have to maintain the text in two different places. Modified: trunk/varnish-cache/bin/varnishd/mgt.h =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt.h 2010-02-01 20:08:18 UTC (rev 4525) +++ trunk/varnish-cache/bin/varnishd/mgt.h 2010-02-01 21:06:30 UTC (rev 4526) @@ -63,6 +63,7 @@ void MCF_ParamSync(void); void MCF_ParamInit(struct cli *); void MCF_ParamSet(struct cli *, const char *param, const char *val); +void MCF_DumpMdoc(void); /* mgt_vcc.c */ void mgt_vcc_init(void); Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-01 20:08:18 UTC (rev 4525) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-01 21:06:30 UTC (rev 4526) @@ -1022,3 +1022,66 @@ params = &master; } + +/*--------------------------------------------------------------------*/ + +#ifdef DIAGNOSTICS + +void +MCF_DumpMdoc(void) +{ + const struct parspec *pp; + const char *p, *q; + int i; + + printf(".Bl -tag -width 4n\n"); + for (i = 0; i < nparspec; i++) { + pp = parspec[i]; + printf(".It Va %s\n", pp->name); + if (pp->units != NULL && *pp->units != '\0') + printf("Units:\n.Dv %s\n.br\n", pp->units); + printf("Default:\n.Dv %s\n.br\n", pp->def); + /* + * XXX: we should mark the params with one/two flags + * XXX: that say if ->min/->max are valid, so we + * XXX: can emit those also in help texts. + */ + if (pp->flags) { + printf("Flags:\n.Dv \""); + q = ""; + if (pp->flags & DELAYED_EFFECT) { + printf("%sdelayed", q); + q = ", "; + } + if (pp->flags & MUST_RESTART) { + printf("%smust_restart", q); + q = ", "; + } + if (pp->flags & MUST_RELOAD) { + printf("%smust_reload", q); + q = ", "; + } + if (pp->flags & EXPERIMENTAL) { + printf("%sexperimental", q); + q = ", "; + } + printf("\"\n.br\n"); + } + printf(".Pp\n"); + for (p = pp->descr; *p; p++) { + if (*p == '\n' && p[1] =='\0') + break; + if (*p == '\n' && p[1] =='\n') { + printf("\n.Pp\n"); + p++; + } else if (*p == '\n') { + printf("\n.br\n"); + } else { + printf("%c", *p); + } + } + printf("\n.Pp\n"); + } + printf(".El\n"); +} +#endif /* DIAGNOSTICS */ Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-01 20:08:18 UTC (rev 4525) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-01 21:06:30 UTC (rev 4526) @@ -582,7 +582,7 @@ cli_check(cli); while ((o = getopt(argc, argv, - "a:b:Cdf:Fg:h:i:l:M:n:P:p:S:s:T:t:u:Vw:")) != -1) + "a:b:Cdf:Fg:h:i:l:M:n:P:p:S:s:T:t:u:Vx:w:")) != -1) switch (o) { case 'a': MCF_ParamSet(cli, "listen_address", optarg); @@ -652,6 +652,15 @@ case 'V': varnish_version("varnishd"); exit(0); + case 'x': +#ifdef DIAGNOSTICS + if (!strcmp(optarg, "dumpmdoc")) { + MCF_DumpMdoc(); + exit (0); + } +#endif /* DIAGNOSTICS */ + usage(); + break; case 'w': tackle_warg(optarg); break; From phk at projects.linpro.no Mon Feb 1 21:08:37 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 1 Feb 2010 22:08:37 +0100 (CET) Subject: r4527 - trunk/varnish-cache/bin/varnishd Message-ID: <20100201210837.A69EF1F7C46@projects.linpro.no> Author: phk Date: 2010-02-01 22:08:37 +0100 (Mon, 01 Feb 2010) New Revision: 4527 Modified: trunk/varnish-cache/bin/varnishd/varnishd.1 Log: Evict the entire section about run-time parameters and replace with a table produced from the CLI parameter tables. In the future all updates to these descriptions SHALL happen in the CLI tables in the C source code. Fixes #419 Modified: trunk/varnish-cache/bin/varnishd/varnishd.1 =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-01 21:06:30 UTC (rev 4526) +++ trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-01 21:08:37 UTC (rev 4527) @@ -485,296 +485,846 @@ use when they arrived. .El .Ss Run-Time Parameters -.\" Keep in synch with parspec[] in mgt_param.c and WRK_parspec[] in - \" mgt_pool.c .Pp -Note that if an run-time parameter is marked -.Bq experimental , -we do not know yet if it is a good idea to change this parameter, or -if the default value is even sensible. Caution is advised, and -feedback is most welcome. +Runtime parameters are marked with shorthand flags to avoid repeating +the same text over and over in the table below. +The meaning of the flags are: .Bl -tag -width 4n +.It Va experimental +We have no solid information about good/bad/optimal values for this +parameter. +Feedback with experience and observations are most welcome. +.It Va delayed +This parameter can be changed on the fly, but will not take effect +immediately. +.It Va restart +The worker process must be stopped and restarted, before this parameter +takes effect. +.It Va reload +The VCL programs must be reloaded for this parameter to take effect. +.El +.Pp +Here is a list of all parameters, current as of last time we remembered +to update the manual page. +This text is produced from the same text you will find in the CLI +if you use the +.Cm param.show +command, so should there be a new parameter which is not listed here, +you can find the description using the CLI commands. +.Pp +.\" ---------------------------------------------------------------- +.\" This table is generated by running a -DDIAGNOSTIC version of +.\" varnishd with the secret "-x dumpmdoc" argument +.\" XXX: Much smarter if we could use .so params.mdoc... +.\" ---------------------------------------------------------------- +.Bl -tag -width 4n +.It Va acceptor_sleep_decay +Default: +.Dv 0.900 +.br +Flags: +.Dv "experimental" +.br +.Pp +If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. +.br +This parameter (multiplicatively) reduce the sleep duration for each succesfull accept. (ie: 0.9 = reduce by 10%) +.Pp +.It Va acceptor_sleep_incr +Units: +.Dv s +.br +Default: +.Dv 0.001 +.br +Flags: +.Dv "experimental" +.br +.Pp +If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. +.br +This parameter control how much longer we sleep, each time we fail to accept a new connection. +.Pp +.It Va acceptor_sleep_max +Units: +.Dv s +.br +Default: +.Dv 0.050 +.br +Flags: +.Dv "experimental" +.br +.Pp +If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. +.br +This parameter limits how long it can sleep between attempts to accept new connections. +.Pp .It Va auto_restart -Whether to automatically restart the child process if it dies. +Units: +.Dv bool +.br +Default: +.Dv on +.br .Pp -The default is -.Dv on . -.It Va backend_http11 -Whether to force the use of HTTP/1.1 when requesting documents from -the server, or just use the same protocol version as the client which -triggered the retrieval. +Restart child process automatically if it dies. .Pp -The default is -.Dv off . +.It Va ban_lurker_sleep +Units: +.Dv s +.br +Default: +.Dv 0.0 +.br +.Pp +How long time does the ban lurker thread sleeps between successfull attempts to push the last item up the purge list. It always sleeps a second when nothing can be done. +.br +A value of zero disables the ban lurker. +.Pp .It Va between_bytes_timeout -Default timeout between bytes when receiving data from backend. -We only wait for this many seconds between bytes before giving up. -A value of 0 means it will never time out. -VCL can override this default value for each backend and backend request. -This parameter does not apply to pipe. +Units: +.Dv s +.br +Default: +.Dv 60 +.br .Pp -The default is -.Dv 60 seconds -.It Va cli_banner -Whether to print a banner whenever a client connects to the CLI interface. +Default timeout between bytes when receiving data from backend. We only wait for this many seconds between bytes before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend request and backend request. This parameter does not apply to pipe. .Pp -The default is -.Dv on . +.It Va cache_vbe_conns +Units: +.Dv bool +.br +Default: +.Dv off +.br +Flags: +.Dv "experimental" +.br +.Pp +Cache vbe_conn's or rely on malloc, that's the question. +.Pp +.It Va cc_command +Default: +.Dv exec cc -fpic -shared -Wl,-x -o %o %s +.br +Flags: +.Dv "must_reload" +.br +.Pp +Command used for compiling the C source code to a dlopen(3) loadable object. Any occurrence of %s in the string will be replaced with the source file name, and %o will be replaced with the output file name. +.Pp +.It Va cli_buffer +Units: +.Dv bytes +.br +Default: +.Dv 8192 +.br +.Pp +Size of buffer for CLI input. +.br +You may need to increase this if you have big VCL files and use the vcl.inline CLI command. +.br +NB: Must be specified with -p to have effect. +.Pp +.It Va cli_timeout +Units: +.Dv seconds +.br +Default: +.Dv 10 +.br +.Pp +Timeout for the childs replies to CLI requests from the master. +.Pp .It Va client_http11 -Whether to force the use of HTTP/1.1 when responding to client -requests, or just use the same protocol version as that used by the -backend server which delivered the requested document. +Units: +.Dv bool +.br +Default: +.Dv off +.br +Flags: +.Dv "experimental" +.br .Pp -The default is -.Dv off . +Force all client responses to be HTTP/1.1. +.br +By default we copy the protocol version from the backend response. +.Pp +.It Va clock_skew +Units: +.Dv s +.br +Default: +.Dv 10 +.br +.Pp +How much clockskew we are willing to accept between the backend and our own clock. +.Pp .It Va connect_timeout -Default connection timeout for backend connections. -We only try to connect to the backend for this many seconds before giving up. -VCL can override this default value for each backend and backend request. +Units: +.Dv s +.br +Default: +.Dv 0.4 +.br .Pp -The default is -.Dv 0.4 seconds +Default connection timeout for backend connections. We only try to connect to the backend for this many seconds before giving up. VCL can override this default value for each backend and backend request. +.Pp +.It Va default_grace +Default: +.Dv 10seconds +.br +Flags: +.Dv "delayed" +.br +.Pp +Default grace period. We will deliver an object this long after it has expired, provided another thread is attempting to get a new copy. +.Pp .It Va default_ttl -The default time-to-live assigned to objects if neither the backend -nor the configuration assign one. -Note that changes to this parameter are not applied retroactively. +Units: +.Dv seconds +.br +Default: +.Dv 120 +.br .Pp -The default is 120 seconds. +The TTL assigned to objects if neither the backend nor the VCL code assigns one. +.br +Objects already cached will not be affected by changes made until they are fetched from the backend again. +.br +To force an immediate effect at the expense of a total flush of the cache use "purge.url ." +.Pp +.It Va diag_bitmap +Units: +.Dv bitmap +.br +Default: +.Dv 0 +.br +.Pp +Bitmap controlling diagnostics code: +.br + 0x00000001 - CNT_Session states. +.br + 0x00000002 - workspace debugging. +.br + 0x00000004 - kqueue debugging. +.br + 0x00000008 - mutex logging. +.br + 0x00000010 - mutex contests. +.br + 0x00000020 - waiting list. +.br + 0x00000040 - object workspace. +.br + 0x00001000 - do not core-dump child process. +.br + 0x00002000 - only short panic message. +.br + 0x00004000 - panic to stderr. +.br + 0x00008000 - panic to abort2(). +.br + 0x00010000 - synchronize shmlog. +.br + 0x00020000 - synchronous start of persistence. +.br + 0x80000000 - do edge-detection on digest. +.br +Use 0x notation and do the bitor in your head :-) +.Pp .It Va err_ttl -The default time-to-live assigned to the synthesized error pages. +Units: +.Dv seconds +.br +Default: +.Dv 0 +.br .Pp -The default is 0 seconds. +The TTL assigned to the synthesized error pages +.Pp +.It Va esi_syntax +Units: +.Dv bitmap +.br +Default: +.Dv 0 +.br +.Pp +Bitmap controlling ESI parsing code: +.br + 0x00000001 - Don't check if it looks like XML +.br + 0x00000002 - Ignore non-esi elements +.br + 0x00000004 - Emit parsing debug records +.br +Use 0x notation and do the bitor in your head :-) +.Pp .It Va fetch_chunksize -The default chunk size used when retrieving documents for which the -backend server does not specify a content length. +Units: +.Dv kilobytes +.br +Default: +.Dv 128 +.br +Flags: +.Dv "experimental" +.br .Pp -The default is 128 kilobytes. +The default chunksize used by fetcher. This should be bigger than the majority of objects with short TTLs. +.br +Internal limits in the storage_file module makes increases above 128kb a dubious idea. +.Pp .It Va first_byte_timeout -Default timeout for receiving first byte from backend. -We only wait for this many seconds for the first byte before giving up. -A value of 0 means it will never time out. -VCL can override this default value for each backend and backend request. -This parameter does not apply to pipe. +Units: +.Dv s +.br +Default: +.Dv 60 +.br .Pp -The default is -.Dv 60 seconds +Default timeout for receiving first byte from backend. We only wait for this many seconds for the first byte before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend and backend request. This parameter does not apply to pipe. +.Pp .It Va group -The name of an unprivileged group to which the child process should -switch before it starts accepting connections. -Note that setting -.Va user -will automatically set -.Va group -to the primary group of the specified user, so if both -.Va user -and -.Va group -are specified, the latter should be specified last. +Default: +.Dv  +.br +Flags: +.Dv "must_restart" +.br .Pp -The default is "nogroup". -.It Va sess_workspace -The size of the per-session workspace for HTTP protocol data. -For performance reasons, this space is preallocated, so any change to -this parameter will only apply to new client sessions. +The unprivileged group to run as. .Pp -The default is 8192 bytes. +.It Va http_headers +Units: +.Dv header lines +.br +Default: +.Dv 64 +.br +.Pp +Maximum number of HTTP headers we will deal with. +.br +This space is preallocated in sessions and workthreads only objects allocate only space for the headers they store. +.Pp .It Va listen_address -The address at which to listen for client connections. -Changes to this parameter will only take effect when the child process -is restarted. +Default: +.Dv :80 +.br +Flags: +.Dv "must_restart" +.br .Pp -The default is 0.0.0.0:80. +Whitespace separated list of network endpoints where Varnish will accept requests. +.br +Possible formats: host, host:port, :port +.Pp .It Va listen_depth -The depth of the TCP listen queue. +Units: +.Dv connections +.br +Default: +.Dv 1024 +.br +Flags: +.Dv "must_restart" +.br .Pp -The default is 512. +Listen queue depth. +.Pp +.It Va log_hashstring +Units: +.Dv bool +.br +Default: +.Dv off +.br +.Pp +Log the hash string to shared memory log. +.Pp +.It Va log_local_address +Units: +.Dv bool +.br +Default: +.Dv off +.br +.Pp +Log the local address on the TCP connection in the SessionOpen shared memory record. +.Pp +.It Va lru_interval +Units: +.Dv seconds +.br +Default: +.Dv 2 +.br +Flags: +.Dv "experimental" +.br +.Pp +Grace period before object moves on LRU list. +.br +Objects are only moved to the front of the LRU list if they have not been moved there already inside this timeout period. This reduces the amount of lock operations necessary for LRU list access. +.Pp +.It Va max_esi_includes +Units: +.Dv includes +.br +Default: +.Dv 5 +.br +.Pp +Maximum depth of esi:include processing. +.Pp +.It Va max_restarts +Units: +.Dv restarts +.br +Default: +.Dv 4 +.br +.Pp +Upper limit on how many times a request can restart. +.br +Be aware that restarts are likely to cause a hit against the backend, so don't increase thoughtlessly. +.Pp +.It Va obj_workspace +Units: +.Dv bytes +.br +Default: +.Dv 0 +.br +Flags: +.Dv "delayed" +.br +.Pp +Bytes of HTTP protocol workspace allocated for objects. This space must be big enough for the entire HTTP protocol header and any edits done to it in the VCL code while it is cached. +.br +Minimum is 1024 bytes. +.Pp .It Va overflow_max -The maximum depth of the overflow queue as a percentage of -.Va thread_pool_max . -The overflow queue holds requests waiting for a worker thread to -become available. -If the overflow queue fills up, -.Nm -will start dropping new connections. +Units: +.Dv % +.br +Default: +.Dv 100 +.br +Flags: +.Dv "experimental" +.br .Pp -The default is 100%. +Percentage permitted overflow queue length. +.Pp +This sets the ratio of queued requests to worker threads, above which sessions will be dropped instead of queued. +.Pp .It Va ping_interval -The interval at which the parent process will ping the child process -to ascertain that it is still present and functioning. +Units: +.Dv seconds +.br +Default: +.Dv 3 +.br +Flags: +.Dv "must_restart" +.br .Pp -The default is 3 seconds. +Interval between pings from parent to child. +.br +Zero will disable pinging entirely, which makes it possible to attach a debugger to the child. +.Pp .It Va pipe_timeout -The time to wait before dropping an idle pipe mode connection. +Units: +.Dv seconds +.br +Default: +.Dv 60 +.br .Pp -The default is 60 seconds. +Idle timeout for PIPE sessions. If nothing have been received in either direction for this many seconds, the session is closed. +.Pp +.It Va prefer_ipv6 +Units: +.Dv bool +.br +Default: +.Dv off +.br +.Pp +Prefer IPv6 address when connecting to backends which have both IPv4 and IPv6 addresses. +.Pp +.It Va purge_dups +Units: +.Dv bool +.br +Default: +.Dv on +.br +.Pp +Detect and eliminate duplicate purges. +.Pp .It Va rush_exponent -.Bq experimental +Units: +.Dv requests per request +.br +Default: +.Dv 3 +.br +Flags: +.Dv "experimental" +.br .Pp How many parked request we start for each completed request on the object. +.br +NB: Even with the implict delay of delivery, this parameter controls an exponential increase in number of worker threads. .Pp -NB: Even with the implict delay of delivery, this parameter controls -an exponential increase in number of worker threads. -.Pp -The default is 3 requests per request. .It Va saintmode_threshold -The number of items allowed on the saintmode list for a backend before it -is considered sick. A value of 0 disables saintmode and any associated -overhead. +Units: +.Dv objects +.br +Default: +.Dv 10 +.br +Flags: +.Dv "experimental" +.br .Pp -The default is 10 objects +The maximum number of objects held off by saint mode before no further will be made to the backend until one times out. A value of 0 disables saintmode. +.Pp +.It Va send_timeout +Units: +.Dv seconds +.br +Default: +.Dv 600 +.br +Flags: +.Dv "delayed" +.br +.Pp +Send timeout for client connections. If no data has been sent to the client in this many seconds, the session is closed. +.br +See setsockopt(2) under SO_SNDTIMEO for more information. +.Pp .It Va sendfile_threshold -The size threshold beyond which documents are sent to the client using -.Xr sendfile 2 -instead of -.Xr writev 2 . -This is not likely to have any effect unless the working set is too -large to fit in physical memory. +Units: +.Dv bytes +.br +Default: +.Dv -1 +.br +Flags: +.Dv "experimental" +.br .Pp -Note that several operating systems have known bugs which make it -inadvisable to use this. +The minimum size of objects transmitted with sendfile. .Pp -The default is \-1, which disables the use of sendfile altogether. -.It Va send_timeout -The time to wait before dropping the connection to a client which is -not accepting data sent to it. -.Pp -The default is 600 seconds. .It Va sess_timeout -The time to wait before dropping an idle client session. +Units: +.Dv seconds +.br +Default: +.Dv 5 +.br .Pp -The default is 5 seconds. -.It Va srcaddr_hash -The size of the hash table used to store per-client accounting data. -This should preferably be a prime number. +Idle timeout for persistent sessions. If a HTTP request has not been received in this many seconds, the session is closed. .Pp -The default is 1049. -.It Va srcaddr_ttl -The length of time to keep per-client accounting records. -Setting this to 0 will disable per-client accounting. +.It Va sess_workspace +Units: +.Dv bytes +.br +Default: +.Dv 16384 +.br +Flags: +.Dv "delayed" +.br +.Pp +Bytes of HTTP protocol workspace allocated for sessions. This space must be big enough for the entire HTTP protocol header and any edits done to it in the VCL code. +.br +Minimum is 1024 bytes. +.Pp +.It Va session_linger +Units: +.Dv ms +.br +Default: +.Dv 50 +.br +Flags: +.Dv "experimental" +.br +.Pp +How long time the workerthread lingers on the session to see if a new request appears right away. +.br +If sessions are reused, as much as half of all reuses happen within the first 100 msec of the previous request completing. +.br +Setting this too high results in worker threads not doing anything for their keep, setting it too low just means that more sessions take a detour around the waiter. +.Pp +.It Va session_max +Units: +.Dv sessions +.br +Default: +.Dv 100000 +.br +.Pp +Maximum number of sessions we will allocate before just dropping connections. +.br +This is mostly an anti-DoS measure, and setting it plenty high should not hurt, as long as you have the memory for it. +.Pp +.It Va shm_reclen +Units: +.Dv bytes +.br +Default: +.Dv 255 +.br +.Pp +Maximum number of bytes in SHM log record. +.br +Maximum is 65535 bytes. +.Pp +.It Va shm_workspace +Units: +.Dv bytes +.br +Default: +.Dv 8192 +.br +Flags: +.Dv "delayed" +.br +.Pp +Bytes of shmlog workspace allocated for worker threads. If too big, it wastes some ram, if too small it causes needless flushes of the SHM workspace. +.br +These flushes show up in stats as "SHM flushes due to overflow". +.br +Minimum is 4096 bytes. +.Pp +.It Va syslog_cli_traffic +Units: +.Dv bool +.br +Default: +.Dv on +.br +.Pp +Log all CLI traffic to syslog(LOG_INFO). +.Pp .It Va thread_pool_add_delay -.Bq experimental +Units: +.Dv milliseconds +.br +Default: +.Dv 20 +.br +Flags: +.Dv "experimental" +.br .Pp -Wait at least many miliseconds between creating threads. +Wait at least this long between creating threads. .Pp Setting this too long results in insuffient worker threads. .Pp -Settings this too high increase the risk for worker thread pile-up. +Setting this too short increases the risk of worker thread pile-up. .Pp -The default is 20 miliseconds. .It Va thread_pool_add_threshold -.Bq experimental +Units: +.Dv requests +.br +Default: +.Dv 2 +.br +Flags: +.Dv "experimental" +.br .Pp -Overflow threshold in number of requests for worker thread creation. +Overflow threshold for worker thread creation. .Pp -Setting this too low, will result in excess worker threads, which is -generally a bad idea. +Setting this too low, will result in excess worker threads, which is generally a bad idea. .Pp Setting it too high results in insuffient worker threads. .Pp -The default is 2 requests .It Va thread_pool_fail_delay -.Bq experimental +Units: +.Dv milliseconds +.br +Default: +.Dv 200 +.br +Flags: +.Dv "experimental" +.br .Pp -Wait at least this many miliseconds after a failed thread creation -before trying to create another thread. +Wait at least this long after a failed thread creation before trying to create another thread. .Pp -Failure to create a worker thread is often a sign that the end is -near, because the process is running out of RAM resources for thread -stacks. This delay tries to not rush it on needlessly. +Failure to create a worker thread is often a sign that the end is near, because the process is running out of RAM resources for thread stacks. +.br +This delay tries to not rush it on needlessly. .Pp -If thread creation failures are a problem, check that -.Va thread_pool_max -is not too high. +If thread creation failures are a problem, check that thread_pool_max is not too high. .Pp -It may also help to increase -.Va thread_pool_timeout -and -.Va thread_pool_min , -to reduce the rate at which treads are destroyed and later recreated. +It may also help to increase thread_pool_timeout and thread_pool_min, to reduce the rate at which treads are destroyed and later recreated. .Pp -The default is 200 miliseconds .It Va thread_pool_max -.Bq experimental +Units: +.Dv threads +.br +Default: +.Dv 500 +.br +Flags: +.Dv "delayed, experimental" +.br .Pp -The maximum total number of worker threads. -If the number of concurrent requests rises beyond this number, -requests will start queueing up waiting for a worker thread to pick -them up. -Higher values may improve response time but will increase pressure on -the scheduler. +The maximum number of worker threads in all pools combined. .Pp -The default is 1000. +Do not set this higher than you have to, since excess worker threads soak up RAM and CPU and generally just get in the way of getting work done. +.Pp .It Va thread_pool_min -.Bq experimental +Units: +.Dv threads +.br +Default: +.Dv 5 +.br +Flags: +.Dv "delayed, experimental" +.br .Pp -The minimum total number of worker threads. -Higher values may allow -.Nm -to respond faster to a sudden increase in traffic. +The minimum number of threads in each worker pool. .Pp -The default is 5. +Increasing this may help ramp up faster from low load situations where threads have expired. +.Pp +Minimum is 2 threads. +.Pp .It Va thread_pool_purge_delay -.Bq experimental +Units: +.Dv milliseconds +.br +Default: +.Dv 1000 +.br +Flags: +.Dv "delayed, experimental" +.br .Pp -Wait this many miliseconds between purging threads. +Wait this long between purging threads. .Pp -This controls the decay of thread pool when idle(-ish). +This controls the decay of thread pools when idle(-ish). .Pp -The minimum is 100 miliseconds, the default is 1000 miliseconds. +Minimum is 100 milliseconds. +.Pp .It Va thread_pool_stack -.Bq experimental +Units: +.Dv bytes +.br +Default: +.Dv -1 +.br +Flags: +.Dv "experimental" +.br .Pp -Worker thread stack size. The number used is the amount of bytes used -as thread stack size. +Worker thread stack size. In particular on 32bit systems you may need to tweak this down to fit many threads into the limited address space. .Pp -On 32bit systems in particular you may need to tweak this down to fit -many threads into the limited address space. .It Va thread_pool_timeout -.Bq experimental +Units: +.Dv seconds +.br +Default: +.Dv 300 +.br +Flags: +.Dv "delayed, experimental" +.br .Pp -The amount of time a worker thread can be idle before it is killed, -when the number of worker threads exceeds -.Va thread_pool_min . +Thread idle threshold. .Pp -The default is 120 seconds. +Threads in excess of thread_pool_min, which have been idle for at least this long are candidates for purging. +.Pp +Minimum is 1 second. +.Pp .It Va thread_pools -The number of worker thread pools. -Higher values reduce lock contention but increase pressure on the -scheduler. -Note that a decrease of this parameter will only take effect after a -restart. +Units: +.Dv pools +.br +Default: +.Dv 2 +.br +Flags: +.Dv "delayed, experimental" +.br .Pp -The default is 2. +Number of worker thread pools. +.Pp +Increasing number of worker pools decreases lock contention. +.Pp +Too many pools waste CPU and RAM resources, and more than one pool for each CPU is probably detrimal to performance. +.Pp +Can be increased on the fly, but decreases require a restart to take effect. +.Pp .It Va thread_stats_rate -.Bq experimental +Units: +.Dv requests +.br +Default: +.Dv 10 +.br +Flags: +.Dv "experimental" +.br .Pp -Worker threads accumulate statistics, and dump these into the global -stats counters if the lock is free when they finish a request. +Worker threads accumulate statistics, and dump these into the global stats counters if the lock is free when they finish a request. +.br +This parameters defines the maximum number of requests a worker thread may handle, before it is forced to dump its accumulated stats into the global counters. .Pp -This parameters defines the maximum number of requests a worker thread -may handle, before it is forced to dump its accumulated stats into the -global counters. .It Va user -The name of an unprivileged user to which the child process should -switch before it starts accepting connections. -Note that setting -.Va user -will automatically set -.Va group -to the primary group of the specified user, so if both -.Va user -and -.Va group -are specified, the latter should be specified last. +Default: +.Dv  +.br +Flags: +.Dv "must_restart" +.br .Pp -The default is "nobody". +The unprivileged user to run as. Setting this will also set "group" to the specified user's primary group. +.Pp .It Va vcl_trace -Whether to issue log entries for calls to VCL code and their results. -Note that this will generate large amounts of log data. +Units: +.Dv bool +.br +Default: +.Dv off +.br .Pp -The default is -.Dv off . +Trace VCL execution in the shmlog. +.br +Enabling this will allow you to see the path each request has taken through the VCL program. +.br +This generates a lot of logrecords so it is off by default. +.Pp +.It Va waiter +Default: +.Dv default +.br +Flags: +.Dv "must_restart, experimental" +.br +.Pp +Select the waiter kernel interface. +.Pp .El +.\" ---------------------------------------------------------------- +.\" End of machine generated table +.\" ---------------------------------------------------------------- .Ss Purge expressions A purge expression consists of one or more conditions. A condition consists of a field, an operator, and an argument. From ingvar at projects.linpro.no Tue Feb 2 07:09:48 2010 From: ingvar at projects.linpro.no (ingvar at projects.linpro.no) Date: Tue, 2 Feb 2010 08:09:48 +0100 (CET) Subject: r4528 - trunk/varnish-cache/redhat Message-ID: <20100202070948.597291F7C00@projects.linpro.no> Author: ingvar Date: 2010-02-02 08:09:48 +0100 (Tue, 02 Feb 2010) New Revision: 4528 Modified: trunk/varnish-cache/redhat/varnish.spec Log: small rpm specfile fixes Modified: trunk/varnish-cache/redhat/varnish.spec =================================================================== --- trunk/varnish-cache/redhat/varnish.spec 2010-02-01 21:08:37 UTC (rev 4527) +++ trunk/varnish-cache/redhat/varnish.spec 2010-02-02 07:09:48 UTC (rev 4528) @@ -1,7 +1,7 @@ Summary: High-performance HTTP accelerator Name: varnish -Version: 2.0.6 -Release: 1%{?dist} +Version: 2.0.7 +Release: 0.1svn20100201r4527%{?dist} License: BSD Group: System Environment/Daemons URL: http://www.varnish-cache.org/ @@ -11,7 +11,7 @@ # The svn sources needs autoconf, automake and libtool to generate a suitable # configure script. Release tarballs would not need this #BuildRequires: automake autoconf libtool -BuildRequires: ncurses-devel libxslt groff +BuildRequires: ncurses-devel libxslt groff pcre-devel pkgconfig Requires: varnish-libs = %{version}-%{release} Requires: logrotate Requires: ncurses @@ -68,7 +68,7 @@ # Release tarballs would not need this #./autogen.sh -#%patch0 -p0 +#%patch0 # Hack to get 32- and 64-bits tests run concurrently on the same build machine case `uname -m` in @@ -93,9 +93,12 @@ # Remove "--disable static" if you want to build static libraries # jemalloc is not compatible with Red Hat's ppc* RHEL5 kernel koji server :-( %ifarch ppc64 ppc -%configure --disable-static --localstatedir=/var/lib --disable-jemalloc + if [[ `uname -r` =~ "2.6.18-.*" ]] + then %configure --disable-static --localstatedir=/var/lib --disable-jemalloc + else %configure --disable-static --localstatedir=/var/lib + fi %else -%configure --disable-static --localstatedir=/var/lib + %configure --disable-static --localstatedir=/var/lib %endif # We have to remove rpath - not allowed in Fedora @@ -132,6 +135,18 @@ %endif %endif +# The redhat ppc builders seem to have some ulimit problems? +# These tests work on a rhel4 ppc/ppc64 instance outside the builders +%ifarch ppc64 ppc + %if 0%{?rhel} == 4 + rm bin/varnishtest/tests/c00031.vtc + rm bin/varnishtest/tests/r00387.vtc + %endif +%endif + +# p class checks are still unstable +rm bin/varnishtest/tests/p*.vtc + LD_LIBRARY_PATH="lib/libvarnish/.libs:lib/libvarnishcompat/.libs:lib/libvarnishapi/.libs:lib/libvcl/.libs" bin/varnishd/varnishd -b 127.0.0.1:80 -C -n /tmp/foo %{__make} check LD_LIBRARY_PATH="../../lib/libvarnish/.libs:../../lib/libvarnishcompat/.libs:../../lib/libvarnishapi/.libs:../../lib/libvcl/.libs" @@ -235,8 +250,20 @@ %postun libs -p /sbin/ldconfig %changelog +* Mon Jan 25 2010 Ingvar Hagelund - 2.0.7-0.1 +- changes-2.0.6.html works now, so remove fix +- Added pcre-devel and pkgconfig to the build requirements + +* Wed Dec 23 2009 Ingvar Hagelund - 2.0.6-2 +- Added a test that enables jemalloc on ppc if the kernel is + not a rhel5 kernel (as on redhat builders) +- Removed tests c00031.vtc and r00387on rhel4/ppc as they fail + on the Red Hat ppc builders (but works on my rhel4 ppc instance) +- Added a patch that fixes broken changes-2.0.6.html in doc + * Mon Dec 14 2009 Ingvar Hagelund - 2.0.6-1 - New upstream release +- Removed patches for libjemalloc, as they are added upstream * Mon Nov 09 2009 Ingvar Hagelund - 2.0.5-1 - New upstream release From phk at projects.linpro.no Tue Feb 2 23:37:43 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 3 Feb 2010 00:37:43 +0100 (CET) Subject: r4529 - in trunk/varnish-cache/bin: varnishd varnishtest/tests Message-ID: <20100202233743.CFE1F1F7C39@projects.linpro.no> Author: phk Date: 2010-02-03 00:37:43 +0100 (Wed, 03 Feb 2010) New Revision: 4529 Added: trunk/varnish-cache/bin/varnishtest/tests/r00524.vtc Modified: trunk/varnish-cache/bin/varnishd/cache_response.c Log: When serving ESI to HTTP/1.0 clients, we use EOF mode. Remeber to properly close the connection when doing so. Fixes 524 Modified: trunk/varnish-cache/bin/varnishd/cache_response.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_response.c 2010-02-02 07:09:48 UTC (rev 4528) +++ trunk/varnish-cache/bin/varnishd/cache_response.c 2010-02-02 23:37:43 UTC (rev 4529) @@ -151,6 +151,8 @@ if(sp->http->protover >= 1.1) http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Transfer-Encoding: chunked"); + else + sp->doclose = "ESI EOF"; } TIM_format(TIM_real(), time_str); Added: trunk/varnish-cache/bin/varnishtest/tests/r00524.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00524.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/r00524.vtc 2010-02-02 23:37:43 UTC (rev 4529) @@ -0,0 +1,33 @@ +# $Id$ + +test "Regression test for 524: HTTP/1.0 and ESI" + +server s1 { + rxreq + expect req.url == "/" + txresp -body { + + + + } + + rxreq + txresp -body "" + +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + // return (pass); + } + sub vcl_fetch { + esi; + } +} -cliok "param.set sess_timeout 60" -start + +client c1 { + txreq -proto HTTP/1.0 -hdr "Connection: kEep-alive" + rxresp + expect resp.status == 200 + expect resp.bodylen == 18 +} -run From tfheen at projects.linpro.no Wed Feb 3 08:40:23 2010 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 3 Feb 2010 09:40:23 +0100 (CET) Subject: r4530 - trunk/varnish-cache/bin/varnishtop Message-ID: <20100203084023.A98601F72B1@projects.linpro.no> Author: tfheen Date: 2010-02-03 09:40:23 +0100 (Wed, 03 Feb 2010) New Revision: 4530 Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.c Log: Print the whole tag in once mode Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.c =================================================================== --- trunk/varnish-cache/bin/varnishtop/varnishtop.c 2010-02-02 23:37:43 UTC (rev 4529) +++ trunk/varnish-cache/bin/varnishtop/varnishtop.c 2010-02-03 08:40:23 UTC (rev 4530) @@ -276,7 +276,7 @@ len = SHMLOG_LEN(tp->rec); printf("%9.2f %s %*.*s\n", tp->count, VSL_tags[tp->rec[SHMLOG_TAG]], - len, len, tp->rec + SHMLOG_DATA); + len, len, tp->rec_data); } } From tfheen at projects.linpro.no Wed Feb 3 08:54:09 2010 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 3 Feb 2010 09:54:09 +0100 (CET) Subject: r4531 - branches/2.0/varnish-cache/bin/varnishtop Message-ID: <20100203085409.7BF9B1F72B1@projects.linpro.no> Author: tfheen Date: 2010-02-03 09:54:09 +0100 (Wed, 03 Feb 2010) New Revision: 4531 Modified: branches/2.0/varnish-cache/bin/varnishtop/varnishtop.c Log: Merge r4530: Print the whole tag in once mode Modified: branches/2.0/varnish-cache/bin/varnishtop/varnishtop.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishtop/varnishtop.c 2010-02-03 08:40:23 UTC (rev 4530) +++ branches/2.0/varnish-cache/bin/varnishtop/varnishtop.c 2010-02-03 08:54:09 UTC (rev 4531) @@ -273,7 +273,9 @@ if (tp->count <= 1.0) break; len = SHMLOG_LEN(tp->rec); - printf("%9.2f %s %*.*s\n", tp->count, VSL_tags[tp->rec[SHMLOG_TAG]], len, len, tp->rec + SHMLOG_DATA); + printf("%9.2f %s %*.*s\n", + tp->count, VSL_tags[tp->rec[SHMLOG_TAG]], + len, len, tp->rec_data); } } From phk at projects.linpro.no Thu Feb 4 09:09:19 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 4 Feb 2010 10:09:19 +0100 (CET) Subject: r4532 - trunk/varnish-cache/bin/varnishtest Message-ID: <20100204090919.075BE28135@projects.linpro.no> Author: phk Date: 2010-02-04 10:09:18 +0100 (Thu, 04 Feb 2010) New Revision: 4532 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Use TIM_real() or the benefit of OS/X. Fixes #640 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-03 08:54:09 UTC (rev 4531) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-04 09:09:18 UTC (rev 4532) @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -491,7 +492,7 @@ static double exec_file(const char *fn, unsigned dur) { - double t0; + double t0, t; struct priv_exec pe; pthread_t pt; struct timespec ts; @@ -509,8 +510,9 @@ fn, strerror(errno)); pe.fn = fn; - AZ(clock_gettime(CLOCK_REALTIME, &ts)); - ts.tv_sec += dur; + t = TIM_real() + dur; + ts.tv_sec = floor(t); + ts.tv_nsec = (t - ts.tv_sec) * 1e9; AZ(pthread_mutex_lock(&vtc_mtx)); AZ(pthread_create(&pt, NULL, exec_file_thread, &pe)); From phk at projects.linpro.no Thu Feb 4 09:27:38 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 4 Feb 2010 10:27:38 +0100 (CET) Subject: r4533 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20100204092738.0FE9A38758@projects.linpro.no> Author: phk Date: 2010-02-04 10:27:37 +0100 (Thu, 04 Feb 2010) New Revision: 4533 Added: trunk/varnish-cache/bin/varnishtest/tests/r00641.vtc Log: Add a testcase which demonstrates bug #641, but does not fail it, yet. Added: trunk/varnish-cache/bin/varnishtest/tests/r00641.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00641.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/r00641.vtc 2010-02-04 09:27:37 UTC (rev 4533) @@ -0,0 +1,31 @@ +# $Id$ + +test "Regression test for 524: HTTP/1.0 and ESI" + +server s1 { + rxreq + expect req.url == "/" + txresp -proto HTTP/1.0 -body { + + <_esi:include src="/foo"/> + + } + +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + // return (pass); + } + sub vcl_fetch { + esi; + } +} -cliok "param.set sess_timeout 60" -start + +client c1 { + txreq -proto HTTP/1.1 + rxresp + # XXX this is the problem: expect resp.proto == HTTP/1.1 + expect resp.status == 200 + expect resp.bodylen == 39 +} -run From phk at projects.linpro.no Fri Feb 5 08:58:30 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 5 Feb 2010 09:58:30 +0100 (CET) Subject: r4534 - trunk/varnish-cache/bin/varnishd Message-ID: <20100205085830.0496B1F7C3E@projects.linpro.no> Author: phk Date: 2010-02-05 09:58:29 +0100 (Fri, 05 Feb 2010) New Revision: 4534 Modified: trunk/varnish-cache/bin/varnishd/cache_backend_poll.c Log: Stylistic nit. Modified: trunk/varnish-cache/bin/varnishd/cache_backend_poll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend_poll.c 2010-02-04 09:27:37 UTC (rev 4533) +++ trunk/varnish-cache/bin/varnishd/cache_backend_poll.c 2010-02-05 08:58:29 UTC (rev 4534) @@ -436,9 +436,10 @@ vt->backend = b; vt->probe = *p; + p = &vt->probe; + if(p->request != NULL) { - vt->req = strdup(p->request); - XXXAN(vt->req); + REPLACE(vt->req, p->request); } else { vsb = vsb_newauto(); XXXAN(vsb); From phk at projects.linpro.no Fri Feb 5 09:20:21 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 5 Feb 2010 10:20:21 +0100 (CET) Subject: r4535 - trunk/varnish-cache/bin/varnishd Message-ID: <20100205092021.3A9451F7C3E@projects.linpro.no> Author: phk Date: 2010-02-05 10:20:20 +0100 (Fri, 05 Feb 2010) New Revision: 4535 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Always send HTTP/1.1 back to the client. Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2010-02-05 08:58:29 UTC (rev 4534) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2010-02-05 09:20:20 UTC (rev 4535) @@ -503,9 +503,9 @@ http_ProtoVer(struct http *hp) { - if (!strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.0")) + if (!strcasecmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.0")) hp->protover = 1.0; - else if (!strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1")) + else if (!strcasecmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1")) hp->protover = 1.1; else hp->protover = 0.9; @@ -621,10 +621,7 @@ CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); - if (params->client_http11) - http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1"); - else - http_copyh(to, fm, HTTP_HDR_PROTO); + http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1"); http_copyh(to, fm, HTTP_HDR_STATUS); http_copyh(to, fm, HTTP_HDR_RESPONSE); } Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-05 08:58:29 UTC (rev 4534) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-05 09:20:20 UTC (rev 4535) @@ -615,12 +615,6 @@ "Listen queue depth.", MUST_RESTART, "1024", "connections" }, - { "client_http11", tweak_bool, &master.client_http11, 0, 0, - "Force all client responses to be HTTP/1.1.\n" - "By default we copy the protocol version from the " - "backend response.", - EXPERIMENTAL, - "off", "bool" }, { "cli_timeout", tweak_timeout, &master.cli_timeout, 0, 0, "Timeout for the childs replies to CLI requests from " "the master.", From phk at projects.linpro.no Mon Feb 8 11:14:06 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Feb 2010 12:14:06 +0100 (CET) Subject: r4536 - trunk/varnish-cache/bin/varnishd Message-ID: <20100208111406.6BD701F7BAE@projects.linpro.no> Author: phk Date: 2010-02-08 12:14:05 +0100 (Mon, 08 Feb 2010) New Revision: 4536 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Increase session_workspace to 64k on non-32bit systems. Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-05 09:20:20 UTC (rev 4535) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-08 11:14:05 UTC (rev 4536) @@ -523,7 +523,12 @@ "header and any edits done to it in the VCL code.\n" "Minimum is 1024 bytes.", DELAYED_EFFECT, - "16384", "bytes" }, +#if SIZE_MAX <= UINT32_MAX + "16384", +#else + "65536", +#endif + "bytes" }, { "http_headers", tweak_uint, &master.http_headers, 32, UINT_MAX, "Maximum number of HTTP headers we will deal with.\n" "This space is preallocated in sessions and workthreads only " From phk at projects.linpro.no Mon Feb 8 11:53:52 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Feb 2010 12:53:52 +0100 (CET) Subject: r4537 - trunk/varnish-cache/bin/varnishd Message-ID: <20100208115352.309A91F7E2F@projects.linpro.no> Author: phk Date: 2010-02-08 12:53:51 +0100 (Mon, 08 Feb 2010) New Revision: 4537 Modified: trunk/varnish-cache/bin/varnishd/stevedore_utils.c Log: Remove an uninitialized variable and print the right one. Modified: trunk/varnish-cache/bin/varnishd/stevedore_utils.c =================================================================== --- trunk/varnish-cache/bin/varnishd/stevedore_utils.c 2010-02-08 11:14:05 UTC (rev 4536) +++ trunk/varnish-cache/bin/varnishd/stevedore_utils.c 2010-02-08 11:53:51 UTC (rev 4537) @@ -83,7 +83,6 @@ { int fd; struct stat st; - char *q; int retval = 1; char buf[FILENAME_MAX]; @@ -111,7 +110,7 @@ fd = mkstemp(buf); if (fd < 0) ARGV_ERR("(%s) \"%s\" mkstemp(%s) failed (%s)\n", - ctx, fn, q, strerror(errno)); + ctx, fn, buf, strerror(errno)); *fnp = strdup(buf); AN(*fnp); retval = 2; From phk at projects.linpro.no Mon Feb 8 18:09:50 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Feb 2010 19:09:50 +0100 (CET) Subject: r4538 - trunk/varnish-cache/bin/varnishd Message-ID: <20100208180950.26F121F7E32@projects.linpro.no> Author: phk Date: 2010-02-08 19:09:49 +0100 (Mon, 08 Feb 2010) New Revision: 4538 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c Log: Fix an edge-case in vrt_assemble_string(). You will still run out of workspace, but the message will make more sense... Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-02-08 11:53:51 UTC (rev 4537) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-02-08 18:09:49 UTC (rev 4538) @@ -156,10 +156,11 @@ if (b + x < e) memcpy(b, h, x); b += x; - if (b + 1 < e) - *b++ = ' '; + if (b < e) + *b = ' '; + b++; } - while (p != vrt_magic_string_end) { + while (p != vrt_magic_string_end && b < e) { if (p == NULL) p = "(null)"; x = strlen(p); @@ -168,8 +169,9 @@ b += x; p = va_arg(ap, const char *); } - if (b + 1 < e) - *b++ = '\0'; + if (b < e) + *b = '\0'; + b++; if (b > e) { WS_Release(hp->ws, 0); return (NULL); From phk at projects.linpro.no Mon Feb 8 20:20:00 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Feb 2010 21:20:00 +0100 (CET) Subject: r4539 - trunk/varnish-cache/bin/varnishd Message-ID: <20100208202000.4752B1F7E31@projects.linpro.no> Author: phk Date: 2010-02-08 21:20:00 +0100 (Mon, 08 Feb 2010) New Revision: 4539 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_param.c trunk/varnish-cache/bin/varnishd/stevedore.c trunk/varnish-cache/bin/varnishd/varnishd.1 Log: Remove obj_workspace parameter. We autosize it for just what is needed. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-08 18:09:49 UTC (rev 4538) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-08 20:20:00 UTC (rev 4539) @@ -336,7 +336,8 @@ if (sp->obj == NULL) { HSH_Prealloc(sp); sp->wrk->cacheable = 0; - sp->obj = STV_NewObject(sp, 0, 0, params->http_headers); + /* XXX: 1024 is a pure guess */ + sp->obj = STV_NewObject(sp, 1024, 0, params->http_headers); sp->obj->xid = sp->xid; sp->obj->entered = sp->t_req; } else { Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2010-02-08 18:09:49 UTC (rev 4538) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2010-02-08 20:20:00 UTC (rev 4539) @@ -99,7 +99,6 @@ /* Memory allocation hints */ unsigned sess_workspace; - unsigned obj_workspace; unsigned shm_workspace; unsigned http_headers; Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-08 18:09:49 UTC (rev 4538) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-08 20:20:00 UTC (rev 4539) @@ -535,14 +535,6 @@ "objects allocate only space for the headers they store.\n", 0, "64", "header lines" }, - { "obj_workspace", tweak_uint, &master.obj_workspace, 0, UINT_MAX, - "Bytes of HTTP protocol workspace allocated for objects. " - "This space must be big enough for the entire HTTP protocol " - "header and any edits done to it in the VCL code while it " - "is cached.\n" - "Minimum is 1024 bytes.", - DELAYED_EFFECT, - "0", "bytes" }, { "shm_workspace", tweak_uint, &master.shm_workspace, 4096, UINT_MAX, "Bytes of shmlog workspace allocated for worker threads. " "If too big, it wastes some ram, if too small it causes " Modified: trunk/varnish-cache/bin/varnishd/stevedore.c =================================================================== --- trunk/varnish-cache/bin/varnishd/stevedore.c 2010-02-08 18:09:49 UTC (rev 4538) +++ trunk/varnish-cache/bin/varnishd/stevedore.c 2010-02-08 20:20:00 UTC (rev 4539) @@ -117,10 +117,7 @@ unsigned lh; (void)ttl; - if (l == 0) - l = 1024; - if (params->obj_workspace > 0 && params->obj_workspace > l) - l = params->obj_workspace; + assert(l > 0); lh = HTTP_estimate(nhttp); Modified: trunk/varnish-cache/bin/varnishd/varnishd.1 =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-08 18:09:49 UTC (rev 4538) +++ trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-08 20:20:00 UTC (rev 4539) @@ -895,21 +895,6 @@ .br Be aware that restarts are likely to cause a hit against the backend, so don't increase thoughtlessly. .Pp -.It Va obj_workspace -Units: -.Dv bytes -.br -Default: -.Dv 0 -.br -Flags: -.Dv "delayed" -.br -.Pp -Bytes of HTTP protocol workspace allocated for objects. This space must be big enough for the entire HTTP protocol header and any edits done to it in the VCL code while it is cached. -.br -Minimum is 1024 bytes. -.Pp .It Va overflow_max Units: .Dv % From phk at projects.linpro.no Mon Feb 8 20:52:09 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 8 Feb 2010 21:52:09 +0100 (CET) Subject: r4540 - trunk/varnish-cache/bin/varnishd Message-ID: <20100208205209.B8C2238D4F@projects.linpro.no> Author: phk Date: 2010-02-08 21:52:09 +0100 (Mon, 08 Feb 2010) New Revision: 4540 Modified: trunk/varnish-cache/bin/varnishd/varnishd.c Log: Make critbit the default hasher. Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-08 20:20:00 UTC (rev 4539) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-08 20:52:09 UTC (rev 4540) @@ -529,7 +529,7 @@ const char *l_arg = "80m"; uintmax_t l_size; const char *q; - const char *h_arg = "classic"; + const char *h_arg = "critbit"; const char *M_arg = NULL; const char *n_arg = NULL; const char *P_arg = NULL; From phk at projects.linpro.no Wed Feb 10 10:15:38 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 11:15:38 +0100 (CET) Subject: r4541 - trunk/varnish-cache/bin/varnishtest Message-ID: <20100210101538.949D01F7E2F@projects.linpro.no> Author: phk Date: 2010-02-10 11:15:38 +0100 (Wed, 10 Feb 2010) New Revision: 4541 Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c Log: Off-by-one bug prevented the actual failure from being displayed if -v options given. Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_log.c 2010-02-08 20:52:09 UTC (rev 4540) +++ trunk/varnish-cache/bin/varnishtest/vtc_log.c 2010-02-10 10:15:38 UTC (rev 4541) @@ -127,7 +127,7 @@ vsb_cat(vtclog_full, vsb_data(vl->vsb)); AZ(pthread_mutex_unlock(&vtclog_mtx)); - if (lvl > 0 && lvl <= vtc_verbosity) + if (lvl <= vtc_verbosity) (void)fputs(vsb_data(vl->vsb), stdout); } From phk at projects.linpro.no Wed Feb 10 10:34:40 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 11:34:40 +0100 (CET) Subject: r4542 - trunk/varnish-cache/bin/varnishtest Message-ID: <20100210103440.9E5E61F7399@projects.linpro.no> Author: phk Date: 2010-02-10 11:34:39 +0100 (Wed, 10 Feb 2010) New Revision: 4542 Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Make it possible to check that varnish closes the backend socket. Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2010-02-10 10:15:38 UTC (rev 4541) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2010-02-10 10:34:39 UTC (rev 4542) @@ -758,10 +758,51 @@ } /********************************************************************** - * close and accept a new connection + * expect other end to close (server only) */ static void +cmd_http_expect_close(CMD_ARGS) +{ + struct http *hp; + struct pollfd fds[1]; + char c; + int i; + + (void)cmd; + (void)vl; + CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); + AZ(av[1]); + assert(hp->sfd >= 0); + + vtc_log(vl, 4, "Expecting close (fd = %d)", hp->fd); + while (1) { + fds[0].fd = hp->fd; + fds[0].events = POLLIN | POLLHUP | POLLERR; + fds[0].revents = 0; + i = poll(fds, 1, 1000); + if (i == 0) + vtc_log(vl, 0, "Expected close: timeout"); + if (i != 1 || !(fds[0].revents & POLLIN)) + vtc_log(vl, 0, + "Expected close: poll = %d, revents = 0x%x", + i, fds[0].revents); + i = read(hp->fd, &c, 1); + if (i == 0) + break; + if (i == 1 && vct_islws(c)) + continue; + vtc_log(vl, 0, + "Expecting close: read = %d, c = 0x%02x", i, c); + } + vtc_log(vl, 4, "fd=%d EOF, as expected", hp->fd); +} + +/********************************************************************** + * close and accept a new connection (server only) + */ + +static void cmd_http_accept(CMD_ARGS) { struct http *hp; @@ -772,7 +813,9 @@ AZ(av[1]); assert(hp->sfd >= 0); TCP_close(&hp->fd); + vtc_log(vl, 4, "Accepting"); hp->fd = accept(hp->sfd, NULL, NULL); + vtc_log(vl, 3, "Accepted socket fd is %d", hp->fd); } /********************************************************************** @@ -804,23 +847,24 @@ */ static const struct cmds http_cmds[] = { - { "timeout", cmd_http_timeout }, - { "txreq", cmd_http_txreq }, + { "timeout", cmd_http_timeout }, + { "txreq", cmd_http_txreq }, - { "rxreq", cmd_http_rxreq }, - { "rxhdrs", cmd_http_rxhdrs }, - { "rxbody", cmd_http_rxbody }, + { "rxreq", cmd_http_rxreq }, + { "rxhdrs", cmd_http_rxhdrs }, + { "rxbody", cmd_http_rxbody }, - { "txresp", cmd_http_txresp }, - { "rxresp", cmd_http_rxresp }, - { "expect", cmd_http_expect }, - { "send", cmd_http_send }, - { "chunked", cmd_http_chunked }, - { "delay", cmd_delay }, - { "sema", cmd_sema }, - { "accept", cmd_http_accept }, - { "loop", cmd_http_loop }, - { NULL, NULL } + { "txresp", cmd_http_txresp }, + { "rxresp", cmd_http_rxresp }, + { "expect", cmd_http_expect }, + { "send", cmd_http_send }, + { "chunked", cmd_http_chunked }, + { "delay", cmd_delay }, + { "sema", cmd_sema }, + { "expect_close", cmd_http_expect_close }, + { "accept", cmd_http_accept }, + { "loop", cmd_http_loop }, + { NULL, NULL } }; void From phk at projects.linpro.no Wed Feb 10 10:35:32 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 11:35:32 +0100 (CET) Subject: r4543 - trunk/varnish-cache/bin/varnishd Message-ID: <20100210103532.E446A1F7399@projects.linpro.no> Author: phk Date: 2010-02-10 11:35:32 +0100 (Wed, 10 Feb 2010) New Revision: 4543 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Make sure we always close backend socket if the backend sends "Connection: close" or if a HTTP/1.0 backend does not send "Connection: keep-alive". Fixes #495 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2010-02-10 10:34:39 UTC (rev 4542) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2010-02-10 10:35:32 UTC (rev 4543) @@ -497,6 +497,12 @@ mklen = 1; } + if (http_HdrIs(hp, H_Connection, "close")) + cls = 1; + + if (hp->protover < 1.1 && !http_HdrIs(hp, H_Connection, "keep-alive")) + cls = 1; + if (cls < 0) { sp->wrk->stats.fetch_failed++; /* XXX: Wouldn't this store automatically be released ? */ From phk at projects.linpro.no Wed Feb 10 10:35:50 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 11:35:50 +0100 (CET) Subject: r4544 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20100210103550.260371F7C47@projects.linpro.no> Author: phk Date: 2010-02-10 11:35:49 +0100 (Wed, 10 Feb 2010) New Revision: 4544 Added: trunk/varnish-cache/bin/varnishtest/tests/r00495.vtc Log: Add regression test for #495 Added: trunk/varnish-cache/bin/varnishtest/tests/r00495.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00495.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/r00495.vtc 2010-02-10 10:35:49 UTC (rev 4544) @@ -0,0 +1,44 @@ +# $Id$ + +test "HTTP 1.0 backend not getting reused" + + +server s1 { + rxreq + txresp -proto HTTP/1.0 -status 201 -hdr "Connection: keep-alive" -body foo + + rxreq + txresp -proto HTTP/1.0 -status 202 -hdr "Connection: close" -body foo + + expect_close + accept + + rxreq + txresp -proto HTTP/1.0 -status 203 -body foo + + expect_close + accept + + rxreq + txresp -proto HTTP/1.0 -status 204 -body bar + +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { return (pass); } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 201 + txreq + rxresp + expect resp.status == 202 + txreq + rxresp + expect resp.status == 203 + txreq + rxresp + expect resp.status == 204 +} -run From phk at projects.linpro.no Wed Feb 10 10:44:15 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 11:44:15 +0100 (CET) Subject: r4545 - trunk/varnish-cache/bin/varnishd Message-ID: <20100210104415.0A1201F7399@projects.linpro.no> Author: phk Date: 2010-02-10 11:44:14 +0100 (Wed, 10 Feb 2010) New Revision: 4545 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Oops, don't override fetch failure status. Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2010-02-10 10:35:49 UTC (rev 4544) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2010-02-10 10:44:14 UTC (rev 4545) @@ -497,10 +497,11 @@ mklen = 1; } - if (http_HdrIs(hp, H_Connection, "close")) + if (cls == 0 && http_HdrIs(hp, H_Connection, "close")) cls = 1; - if (hp->protover < 1.1 && !http_HdrIs(hp, H_Connection, "keep-alive")) + if (cls == 0 && hp->protover < 1.1 && + !http_HdrIs(hp, H_Connection, "keep-alive")) cls = 1; if (cls < 0) { From phk at projects.linpro.no Wed Feb 10 11:00:35 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 12:00:35 +0100 (CET) Subject: r4546 - trunk/varnish-cache/bin/varnishd Message-ID: <20100210110035.585B51F7E34@projects.linpro.no> Author: phk Date: 2010-02-10 12:00:35 +0100 (Wed, 10 Feb 2010) New Revision: 4546 Modified: trunk/varnish-cache/bin/varnishd/shmlog.c Log: Don't stumble over zero pid fields. Modified: trunk/varnish-cache/bin/varnishd/shmlog.c =================================================================== --- trunk/varnish-cache/bin/varnishd/shmlog.c 2010-02-10 10:44:14 UTC (rev 4545) +++ trunk/varnish-cache/bin/varnishd/shmlog.c 2010-02-10 11:00:35 UTC (rev 4546) @@ -336,7 +336,7 @@ if (slh.start != sizeof slh + sizeof *params) return (0); - if (!kill(slh.master_pid, 0)) { + if (slh.master_pid != 0 && !kill(slh.master_pid, 0)) { fprintf(stderr, "SHMFILE owned by running varnishd master (pid=%jd)\n", (intmax_t)slh.master_pid); From phk at projects.linpro.no Wed Feb 10 12:38:34 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 13:38:34 +0100 (CET) Subject: r4547 - trunk/varnish-cache/bin/varnishd Message-ID: <20100210123834.DDD0F1F7409@projects.linpro.no> Author: phk Date: 2010-02-10 13:38:34 +0100 (Wed, 10 Feb 2010) New Revision: 4547 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Comments with a warning I came close to forgetting Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-10 11:00:35 UTC (rev 4546) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-10 12:38:34 UTC (rev 4547) @@ -789,8 +789,8 @@ * We lost the session to a busy object, disembark the * worker thread. The hash code to restart the session, * still in STP_LOOKUP, later when the busy object isn't. + * NB: Do not access sp any more ! */ - AZ(sp->wrk); return (1); } @@ -1217,6 +1217,9 @@ if (sp->step == STP_FIRST || sp->step == STP_START) TCP_blocking(sp->fd); + /* + * NB: Once done is set, we can no longer touch sp! + */ for (done = 0; !done; ) { assert(sp->wrk == w); /* From phk at projects.linpro.no Wed Feb 10 12:44:43 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 13:44:43 +0100 (CET) Subject: r4548 - trunk/varnish-cache/bin/varnishd Message-ID: <20100210124443.3981B1F7409@projects.linpro.no> Author: phk Date: 2010-02-10 13:44:42 +0100 (Wed, 10 Feb 2010) New Revision: 4548 Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/hash_slinger.h Log: Be much more paranoid about objhead refcounts Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-10 12:38:34 UTC (rev 4547) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-10 12:44:42 UTC (rev 4548) @@ -290,6 +290,7 @@ if (oh == w->nobjhead) w->nobjhead = NULL; Lck_Lock(&oh->mtx); + assert(oh->refcnt > 0); /* Insert (precreated) objcore in objecthead */ oc = w->nobjcore; @@ -337,17 +338,16 @@ CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC); oh = sp->objhead; sp->objhead = NULL; - CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); - Lck_Lock(&oh->mtx); } else { AN(w->nobjhead); oh = hash->lookup(sp, w->nobjhead); - CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); if (oh == w->nobjhead) w->nobjhead = NULL; - Lck_Lock(&oh->mtx); } + CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + Lck_Lock(&oh->mtx); + assert(oh->refcnt > 0); busy_oc = NULL; grace_oc = NULL; VTAILQ_FOREACH(oc, &oh->objcs, list) { @@ -532,6 +532,7 @@ "Object %u workspace free %u", o->xid, WS_Free(o->ws_o)); Lck_Lock(&oh->mtx); + assert(oh->refcnt > 0); o->objcore->flags &= ~OC_F_BUSY; hsh_rush(oh); AN(o->ban); Modified: trunk/varnish-cache/bin/varnishd/hash_slinger.h =================================================================== --- trunk/varnish-cache/bin/varnishd/hash_slinger.h 2010-02-10 12:38:34 UTC (rev 4547) +++ trunk/varnish-cache/bin/varnishd/hash_slinger.h 2010-02-10 12:44:42 UTC (rev 4548) @@ -72,7 +72,7 @@ #define OBJHEAD_MAGIC 0x1b96615d struct lock mtx; - unsigned refcnt; + int refcnt; VTAILQ_HEAD(,objcore) objcs; unsigned char digest[DIGEST_LEN]; union { From phk at projects.linpro.no Wed Feb 10 12:48:18 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 13:48:18 +0100 (CET) Subject: r4549 - trunk/varnish-cache/bin/varnishd Message-ID: <20100210124818.5D27A1F7409@projects.linpro.no> Author: phk Date: 2010-02-10 13:48:17 +0100 (Wed, 10 Feb 2010) New Revision: 4549 Modified: trunk/varnish-cache/bin/varnishd/hash_critbit.c Log: Close what might be a race, and assert that it doesn't happen: When we do a lookup, we first try without the lock, if this gives us a refcnt==0 objhead, we try again, with the lock. When we deref an objhead, we would decrement the refcnt, holding oh->mtx, then lock the critbit-lock and remove it from the tree. It might be possible for a locked lookup to find an oh we just decremented the refcnt off, and we did not check for refcnt==0 in that case. Fix this, by removing the oh from the tree, holding the critbit-lock, before decrementing the refcnt. This way, a locked lookup can never find a refcnt==0 oh in the tree, and the unlocked lookup still catches this with the refcnt==0 check. Modified: trunk/varnish-cache/bin/varnishd/hash_critbit.c =================================================================== --- trunk/varnish-cache/bin/varnishd/hash_critbit.c 2010-02-10 12:44:42 UTC (rev 4548) +++ trunk/varnish-cache/bin/varnishd/hash_critbit.c 2010-02-10 12:48:17 UTC (rev 4549) @@ -216,6 +216,7 @@ /* We found a node, does it match ? */ oh2 = hcb_l_node(pp); + CHECK_OBJ_NOTNULL(oh2, OBJHEAD_MAGIC); if (!memcmp(oh2->digest, oh->digest, DIGEST_LEN)) return (oh2); @@ -357,6 +358,8 @@ (void)sleep(1); Lck_Lock(&hcb_mtx); VTAILQ_FOREACH_SAFE(oh, &laylow, coollist, oh2) { + CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + AZ(oh->refcnt); y = (void *)&oh->u; if (y->leaf[0] || y->leaf[1]) continue; @@ -365,7 +368,6 @@ #ifdef PHK fprintf(stderr, "OH %p is cold enough\n", oh); #endif - AZ(oh->refcnt); HSH_DeleteObjHead(&ww, oh); } } @@ -401,7 +403,8 @@ CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); Lck_Lock(&oh->mtx); assert(oh->refcnt > 0); - if (--oh->refcnt == 0) { + if (oh->refcnt == 1) { + /* Remove from tree before decrementing refcnt to zero */ Lck_Lock(&hcb_mtx); hcb_delete(&hcb_root, oh); assert(VTAILQ_EMPTY(&oh->objcs)); @@ -410,6 +413,7 @@ VTAILQ_INSERT_TAIL(&laylow, oh, coollist); Lck_Unlock(&hcb_mtx); } + oh->refcnt--; Lck_Unlock(&oh->mtx); #ifdef PHK fprintf(stderr, "hcb_defef %d %d <%s>\n", __LINE__, r, oh->hash); @@ -452,6 +456,7 @@ oh = hcb_insert(&hcb_root, noh, 1); if (oh == noh) { VSL_stats->hcb_insert++; + assert(oh->refcnt > 0); #ifdef PHK fprintf(stderr, "hcb_lookup %d\n", __LINE__); #endif @@ -462,6 +467,7 @@ fprintf(stderr, "hcb_lookup %d\n", __LINE__); #endif Lck_Lock(&oh->mtx); + assert(oh->refcnt > 0); oh->refcnt++; Lck_Unlock(&oh->mtx); } From phk at projects.linpro.no Wed Feb 10 13:46:44 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 10 Feb 2010 14:46:44 +0100 (CET) Subject: r4550 - trunk/varnish-cache/bin/varnishd Message-ID: <20100210134644.422C61F7C47@projects.linpro.no> Author: phk Date: 2010-02-10 14:46:44 +0100 (Wed, 10 Feb 2010) New Revision: 4550 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c trunk/varnish-cache/bin/varnishd/varnishd.1 trunk/varnish-cache/bin/varnishd/varnishd.c Log: Centralize default param changes for VM conservation on 32 bit systems. Mention this in man page. Update param list in man page. Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-10 12:48:17 UTC (rev 4549) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-10 13:46:44 UTC (rev 4550) @@ -523,11 +523,7 @@ "header and any edits done to it in the VCL code.\n" "Minimum is 1024 bytes.", DELAYED_EFFECT, -#if SIZE_MAX <= UINT32_MAX - "16384", -#else "65536", -#endif "bytes" }, { "http_headers", tweak_uint, &master.http_headers, 32, UINT_MAX, "Maximum number of HTTP headers we will deal with.\n" Modified: trunk/varnish-cache/bin/varnishd/varnishd.1 =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-10 12:48:17 UTC (rev 4549) +++ trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-10 13:46:44 UTC (rev 4550) @@ -512,6 +512,12 @@ command, so should there be a new parameter which is not listed here, you can find the description using the CLI commands. .Pp +Be aware that on 32 bit systems, certain default values, such as +.Va sess_workspace +(=16k) and +.Va thread_pool_stack +(=64k) are reduced relative to the values listed here, in order to conserve VM space. +.Pp .\" ---------------------------------------------------------------- .\" This table is generated by running a -DDIAGNOSTIC version of .\" varnishd with the secret "-x dumpmdoc" argument @@ -639,21 +645,6 @@ .Pp Timeout for the childs replies to CLI requests from the master. .Pp -.It Va client_http11 -Units: -.Dv bool -.br -Default: -.Dv off -.br -Flags: -.Dv "experimental" -.br -.Pp -Force all client responses to be HTTP/1.1. -.br -By default we copy the protocol version from the backend response. -.Pp .It Va clock_skew Units: .Dv s @@ -1026,7 +1017,7 @@ .Dv bytes .br Default: -.Dv 16384 +.Dv 65536 .br Flags: .Dv "delayed" Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-10 12:48:17 UTC (rev 4549) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-10 13:46:44 UTC (rev 4550) @@ -579,6 +579,18 @@ mgt_vcc_init(); MCF_ParamInit(cli); + + if (sizeof(void *) < 8) { + /* + * Adjust default parameters for 32 bit systems to conserve + * VM space. + */ + MCF_ParamSet(cli, "sess_workspace", "16384"); + cli_check(cli); + MCF_ParamSet(cli, "thread_pool_stack", "65536"); + cli_check(cli); + } + cli_check(cli); while ((o = getopt(argc, argv, From kristian at projects.linpro.no Wed Feb 10 15:23:34 2010 From: kristian at projects.linpro.no (kristian at projects.linpro.no) Date: Wed, 10 Feb 2010 16:23:34 +0100 (CET) Subject: r4551 - trunk/varnish-cache/man Message-ID: <20100210152334.C39341F7C47@projects.linpro.no> Author: kristian Date: 2010-02-10 16:23:34 +0100 (Wed, 10 Feb 2010) New Revision: 4551 Modified: trunk/varnish-cache/man/vcl.7so Log: Document .initial Modified: trunk/varnish-cache/man/vcl.7so =================================================================== --- trunk/varnish-cache/man/vcl.7so 2010-02-10 13:46:44 UTC (rev 4550) +++ trunk/varnish-cache/man/vcl.7so 2010-02-10 15:23:34 UTC (rev 4551) @@ -171,6 +171,9 @@ .Fa .threshold is how many of those must have succeeded for us to consider the backend healthy. +.Fa .initial +is how many of the probes are considered good when Varnish starts - +defaults to the same amount as the threshold. .Bd -literal -offset 4n backend www { .host = "www.example.com"; @@ -180,6 +183,7 @@ .timeout = 0.3 s; .window = 8; .threshold = 3; + .initial = 3; } } .Ed From kristian at projects.linpro.no Thu Feb 11 11:58:02 2010 From: kristian at projects.linpro.no (kristian at projects.linpro.no) Date: Thu, 11 Feb 2010 12:58:02 +0100 (CET) Subject: r4552 - trunk/varnish-cache/bin/varnishd Message-ID: <20100211115802.29C0A1F73A8@projects.linpro.no> Author: kristian Date: 2010-02-11 12:58:01 +0100 (Thu, 11 Feb 2010) New Revision: 4552 Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_epoll.c Log: Don't use edge-triggered mode in epoll Fixes #644 Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_epoll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_waiter_epoll.c 2010-02-10 15:23:34 UTC (rev 4551) +++ trunk/varnish-cache/bin/varnishd/cache_waiter_epoll.c 2010-02-11 11:58:01 UTC (rev 4552) @@ -68,10 +68,14 @@ vca_modadd(int fd, void *data, short arm) { + /* XXX: EPOLLET (edge triggered) can cause rather Bad Things to + * XXX: happen: If NEEV+1 threads get stuck in write(), all threads + * XXX: will hang. See #644. + */ assert(fd >= 0); if (data == vca_pipes || data == dotimer_pipe) { struct epoll_event ev = { - EPOLLIN | EPOLLPRI | EPOLLET, { data } + EPOLLIN | EPOLLPRI , { data } }; AZ(epoll_ctl(epfd, arm, fd, &ev)); } else { From kristian at projects.linpro.no Thu Feb 11 17:43:06 2010 From: kristian at projects.linpro.no (kristian at projects.linpro.no) Date: Thu, 11 Feb 2010 18:43:06 +0100 (CET) Subject: r4553 - in trunk/varnish-cache: bin/varnishd bin/varnishstat include Message-ID: <20100211174306.D10EA1F73C3@projects.linpro.no> Author: kristian Date: 2010-02-11 18:43:06 +0100 (Thu, 11 Feb 2010) New Revision: 4553 Modified: trunk/varnish-cache/bin/varnishd/cache_main.c trunk/varnish-cache/bin/varnishstat/varnishstat.c trunk/varnish-cache/include/stats.h Log: Remove old start_time code, replaced by VSL_stats->uptime Modified: trunk/varnish-cache/bin/varnishd/cache_main.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_main.c 2010-02-11 11:58:01 UTC (rev 4552) +++ trunk/varnish-cache/bin/varnishd/cache_main.c 2010-02-11 17:43:06 UTC (rev 4553) @@ -136,8 +136,6 @@ if (params->diag_bitmap & 0x00020000) SMP_Ready(); - VSL_stats->start_time = (time_t)TIM_real(); - CLI_Run(); STV_close(); Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.c =================================================================== --- trunk/varnish-cache/bin/varnishstat/varnishstat.c 2010-02-11 11:58:01 UTC (rev 4552) +++ trunk/varnish-cache/bin/varnishstat/varnishstat.c 2010-02-11 17:43:06 UTC (rev 4553) @@ -126,7 +126,7 @@ tt = tv.tv_usec * 1e-6 + tv.tv_sec; lt = tt - lt; - rt = tv.tv_sec - VSL_stats->start_time; + rt = VSL_stats->uptime; up = rt; mvprintw(0, 0, "%*s", COLS - 1, VSL_Name()); @@ -244,16 +244,8 @@ double up; gettimeofday(&tv, NULL); - up = tv.tv_sec - VSL_stats->start_time; + up = VSL_stats->uptime; - do { - if (fields != NULL && ! show_field("uptime", fields )) - break; - printf("%-16s %12ju %12s %s\n", "uptime", - (uintmax_t)(tv.tv_sec - VSL_stats->start_time), - ". ", "Child uptime"); - } while (0); - #define MAC_STAT(n, t, l, f, d) \ do { \ if (fields != NULL && ! show_field( #n, fields )) break; \ @@ -297,7 +289,6 @@ fprintf(stderr, "Varnishstat -f option fields:\n"); fprintf(stderr, "Field name Description\n"); fprintf(stderr, "---------- -----------\n"); - fprintf(stderr, "uptime Child uptime\n"); #define MAC_STAT(n, t, l, f, d) \ do { \ @@ -312,7 +303,6 @@ { int i, valid_field, field_length; const char *all_fields[] = { - "uptime", #define MAC_STAT(n, t, l, f, d) \ #n, #include "stat_field.h" Modified: trunk/varnish-cache/include/stats.h =================================================================== --- trunk/varnish-cache/include/stats.h 2010-02-11 11:58:01 UTC (rev 4552) +++ trunk/varnish-cache/include/stats.h 2010-02-11 17:43:06 UTC (rev 4553) @@ -32,7 +32,6 @@ #include struct varnish_stats { - time_t start_time; #define MAC_STAT(n, t, l, f, e) t n; #include "stat_field.h" #undef MAC_STAT From phk at projects.linpro.no Fri Feb 12 11:25:47 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 12 Feb 2010 12:25:47 +0100 (CET) Subject: r4554 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20100212112547.032431F7BAE@projects.linpro.no> Author: phk Date: 2010-02-12 12:25:46 +0100 (Fri, 12 Feb 2010) New Revision: 4554 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00020.vtc trunk/varnish-cache/bin/varnishtest/tests/b00021.vtc trunk/varnish-cache/bin/varnishtest/tests/b00022.vtc trunk/varnish-cache/bin/varnishtest/tests/b00023.vtc trunk/varnish-cache/bin/varnishtest/tests/b00024.vtc trunk/varnish-cache/bin/varnishtest/tests/b00025.vtc trunk/varnish-cache/bin/varnishtest/tests/b00026.vtc trunk/varnish-cache/bin/varnishtest/tests/b00027.vtc trunk/varnish-cache/bin/varnishtest/tests/b00028.vtc trunk/varnish-cache/bin/varnishtest/tests/b00029.vtc trunk/varnish-cache/bin/varnishtest/tests/b00030.vtc trunk/varnish-cache/bin/varnishtest/tests/b00031.vtc trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc trunk/varnish-cache/bin/varnishtest/tests/c00020.vtc trunk/varnish-cache/bin/varnishtest/tests/c00021.vtc trunk/varnish-cache/bin/varnishtest/tests/c00022.vtc trunk/varnish-cache/bin/varnishtest/tests/c00023.vtc trunk/varnish-cache/bin/varnishtest/tests/c00024.vtc trunk/varnish-cache/bin/varnishtest/tests/c00025.vtc trunk/varnish-cache/bin/varnishtest/tests/c00026.vtc trunk/varnish-cache/bin/varnishtest/tests/c00027.vtc trunk/varnish-cache/bin/varnishtest/tests/c00028.vtc trunk/varnish-cache/bin/varnishtest/tests/c00029.vtc trunk/varnish-cache/bin/varnishtest/tests/c00030.vtc trunk/varnish-cache/bin/varnishtest/tests/c00031.vtc trunk/varnish-cache/bin/varnishtest/tests/e00013.vtc trunk/varnish-cache/bin/varnishtest/tests/e00014.vtc trunk/varnish-cache/bin/varnishtest/tests/e00016.vtc trunk/varnish-cache/bin/varnishtest/tests/e00017.vtc trunk/varnish-cache/bin/varnishtest/tests/e00018.vtc trunk/varnish-cache/bin/varnishtest/tests/p00000.vtc trunk/varnish-cache/bin/varnishtest/tests/p00001.vtc trunk/varnish-cache/bin/varnishtest/tests/p00002.vtc trunk/varnish-cache/bin/varnishtest/tests/p00003.vtc trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc trunk/varnish-cache/bin/varnishtest/tests/p00006.vtc trunk/varnish-cache/bin/varnishtest/tests/r00345.vtc trunk/varnish-cache/bin/varnishtest/tests/r00365.vtc trunk/varnish-cache/bin/varnishtest/tests/r00386.vtc trunk/varnish-cache/bin/varnishtest/tests/r00387.vtc trunk/varnish-cache/bin/varnishtest/tests/r00400.vtc trunk/varnish-cache/bin/varnishtest/tests/r00409.vtc trunk/varnish-cache/bin/varnishtest/tests/r00412.vtc trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc trunk/varnish-cache/bin/varnishtest/tests/r00425.vtc trunk/varnish-cache/bin/varnishtest/tests/r00427.vtc trunk/varnish-cache/bin/varnishtest/tests/r00433.vtc trunk/varnish-cache/bin/varnishtest/tests/r00444.vtc trunk/varnish-cache/bin/varnishtest/tests/r00466.vtc trunk/varnish-cache/bin/varnishtest/tests/r00476.vtc trunk/varnish-cache/bin/varnishtest/tests/r00494.vtc trunk/varnish-cache/bin/varnishtest/tests/r00495.vtc trunk/varnish-cache/bin/varnishtest/tests/r00498.vtc trunk/varnish-cache/bin/varnishtest/tests/r00502.vtc trunk/varnish-cache/bin/varnishtest/tests/r00506.vtc trunk/varnish-cache/bin/varnishtest/tests/r00524.vtc trunk/varnish-cache/bin/varnishtest/tests/r00549.vtc trunk/varnish-cache/bin/varnishtest/tests/r00558.vtc trunk/varnish-cache/bin/varnishtest/tests/r00561.vtc trunk/varnish-cache/bin/varnishtest/tests/r00590.vtc trunk/varnish-cache/bin/varnishtest/tests/r00612.vtc trunk/varnish-cache/bin/varnishtest/tests/r00641.vtc trunk/varnish-cache/bin/varnishtest/tests/s00002.vtc trunk/varnish-cache/bin/varnishtest/tests/s00003.vtc trunk/varnish-cache/bin/varnishtest/tests/v00022.vtc trunk/varnish-cache/bin/varnishtest/tests/v00023.vtc trunk/varnish-cache/bin/varnishtest/tests/v00024.vtc trunk/varnish-cache/bin/varnishtest/tests/v00025.vtc trunk/varnish-cache/bin/varnishtest/tests/v00026.vtc Log: Set Id keyword expansion on these files. Modified: trunk/varnish-cache/bin/varnishtest/tests/b00020.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00020.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/b00020.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: b00019.vtc 3300 2008-10-15 09:52:15Z tfheen $ +# $Id$ test "Check the between_bytes_timeout behaves from parameters" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00020.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/b00021.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00021.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/b00021.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: b00019.vtc 3300 2008-10-15 09:52:15Z tfheen $ +# $Id$ test "Check the between_bytes_timeout behaves from vcl" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00021.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/b00022.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00022.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/b00022.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: b00019.vtc 3300 2008-10-15 09:52:15Z tfheen $ +# $Id$ test "Check the between_bytes_timeout behaves from backend definition" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00022.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/b00023.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00023.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/b00023.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: b00019.vtc 3300 2008-10-15 09:52:15Z tfheen $ +# $Id$ test "Check that the first_byte_timeout works from parameters" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00023.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/b00024.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00024.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/b00024.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: b00019.vtc 3300 2008-10-15 09:52:15Z tfheen $ +# $Id$ test "Check that the first_byte_timeout works from vcl" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00024.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/b00025.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00025.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/b00025.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: b00019.vtc 3300 2008-10-15 09:52:15Z tfheen $ +# $Id$ test "Check that the first_byte_timeout works from backend definition" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00025.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/b00026.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00026.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/b00026.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: b00019.vtc 3300 2008-10-15 09:52:15Z tfheen $ +# $Id$ test "Check the precedence for timeouts" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00026.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00027.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00028.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00029.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00030.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00031.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00020.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/c00021.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00021.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/c00021.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: c00006.vtc 2906 2008-07-08 10:29:07Z phk $ +# $Id$ test "Test banning a url with cli:purge" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00021.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00022.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00023.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00024.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00025.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00026.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00027.vtc ___________________________________________________________________ Name: svn:keywords - id + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00028.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00029.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00030.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/c00031.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00031.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/c00031.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,6 +1,6 @@ # Test that we get anything through at all # -# $Id: c00002.vtc 3053 2008-08-01 09:22:21Z phk $ +# $Id$ test "Worker thread stack size setting" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/c00031.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/e00013.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/e00014.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/e00016.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00016.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/e00016.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: e00015.vtc 4068 2009-05-11 08:50:45Z sky $ +# $Id$ test "ESI request can't be turned off midstream" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/e00016.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/e00017.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00017.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/e00017.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: e00003.vtc 3742 2009-02-11 07:53:47Z tfheen $ +# $Id$ test "Aggressive use of ESI include" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/e00017.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/e00018.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/p00000.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/p00001.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/p00002.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/p00003.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/p00006.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00345.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00365.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00386.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00387.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00400.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00409.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00412.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00425.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00427.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00433.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00444.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00466.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/r00476.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00476.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/r00476.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: r00445.vtc 3987 2009-03-23 11:54:19Z sky $ +# $Id$ test "zero length ESI include segmens with chunked encoding" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00476.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00494.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00495.vtc ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/varnish-cache/bin/varnishtest/tests/r00498.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00498.vtc 2010-02-11 17:43:06 UTC (rev 4553) +++ trunk/varnish-cache/bin/varnishtest/tests/r00498.vtc 2010-02-12 11:25:46 UTC (rev 4554) @@ -1,4 +1,4 @@ -# $Id: r00445.vtc 3987 2009-03-23 11:54:19Z sky $ +# $Id$ test "very very very long return header" Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00498.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00502.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00506.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00524.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00549.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00558.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00561.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00590.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00612.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/r00641.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/s00002.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/s00003.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/v00022.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/v00023.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/v00024.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/v00025.vtc ___________________________________________________________________ Name: svn:keywords + Id Property changes on: trunk/varnish-cache/bin/varnishtest/tests/v00026.vtc ___________________________________________________________________ Name: svn:keywords + Id From phk at projects.linpro.no Fri Feb 12 11:26:57 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 12 Feb 2010 12:26:57 +0100 (CET) Subject: r4555 - in trunk/varnish-cache: bin/varnishd bin/varnishtest include lib/libvarnish Message-ID: <20100212112657.028A51F7BAE@projects.linpro.no> Author: phk Date: 2010-02-12 12:26:56 +0100 (Fri, 12 Feb 2010) New Revision: 4555 Modified: trunk/varnish-cache/bin/varnishd/cache_lck.c trunk/varnish-cache/bin/varnishd/hash_critbit.c trunk/varnish-cache/bin/varnishd/storage_persistent.c trunk/varnish-cache/bin/varnishtest/varnishtest.1 trunk/varnish-cache/include/cli_serve.h trunk/varnish-cache/include/http_response.h trunk/varnish-cache/include/persistent.h trunk/varnish-cache/include/purge_vars.h trunk/varnish-cache/lib/libvarnish/subproc.c trunk/varnish-cache/lib/libvarnish/vsha256.c Log: Set Id keyword expansion Property changes on: trunk/varnish-cache/bin/varnishd/cache_lck.c ___________________________________________________________________ Name: svn:keyword + Id Property changes on: trunk/varnish-cache/bin/varnishd/hash_critbit.c ___________________________________________________________________ Name: svn:keyword + Id Property changes on: trunk/varnish-cache/bin/varnishd/storage_persistent.c ___________________________________________________________________ Name: svn:keyword + Id Property changes on: trunk/varnish-cache/bin/varnishtest/varnishtest.1 ___________________________________________________________________ Name: svn:keyword + Id Property changes on: trunk/varnish-cache/include/cli_serve.h ___________________________________________________________________ Name: svn:keyword + Id Property changes on: trunk/varnish-cache/include/http_response.h ___________________________________________________________________ Name: svn:keyword + Id Property changes on: trunk/varnish-cache/include/persistent.h ___________________________________________________________________ Name: svn:keyword + Id Property changes on: trunk/varnish-cache/include/purge_vars.h ___________________________________________________________________ Name: svn:keyword + Id Property changes on: trunk/varnish-cache/lib/libvarnish/subproc.c ___________________________________________________________________ Name: svn:keyword + Id Property changes on: trunk/varnish-cache/lib/libvarnish/vsha256.c ___________________________________________________________________ Name: svn:keyword + Id From phk at projects.linpro.no Fri Feb 12 11:42:03 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 12 Feb 2010 12:42:03 +0100 (CET) Subject: r4556 - in trunk/varnish-cache: bin/varnishd bin/varnishtest lib/libvarnish lib/libvarnishapi lib/libvcl Message-ID: <20100212114203.5D0EA1F7BAE@projects.linpro.no> Author: phk Date: 2010-02-12 12:42:03 +0100 (Fri, 12 Feb 2010) New Revision: 4556 Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_dir_random.c trunk/varnish-cache/bin/varnishd/cache_response.c trunk/varnish-cache/bin/varnishd/cache_session.c trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c trunk/varnish-cache/bin/varnishd/mgt_cli.c trunk/varnish-cache/bin/varnishd/mgt_param.c trunk/varnish-cache/bin/varnishd/stevedore.h trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c trunk/varnish-cache/lib/libvarnish/cli_serve.c trunk/varnish-cache/lib/libvarnish/time.c trunk/varnish-cache/lib/libvarnish/vss.c trunk/varnish-cache/lib/libvarnishapi/shmlog.c trunk/varnish-cache/lib/libvcl/vcc_backend.c Log: White-space cleanup Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -99,8 +99,8 @@ if (dst == 0.0) \ dst = params->tmx; \ } while (0) - + /*-------------------------------------------------------------------- * Attempt to connect to a given addrinfo entry. * Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -1218,7 +1218,7 @@ TCP_blocking(sp->fd); /* - * NB: Once done is set, we can no longer touch sp! + * NB: Once done is set, we can no longer touch sp! */ for (done = 0; !done; ) { assert(sp->wrk == w); Modified: trunk/varnish-cache/bin/varnishd/cache_dir_random.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -119,7 +119,7 @@ } /* - * If we are hashing, first try to hit our "canonical backend" + * If we are hashing, first try to hit our "canonical backend" * If that fails, we fall through, and select a weighted backend * amongst the healthy set. */ Modified: trunk/varnish-cache/bin/varnishd/cache_response.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_response.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishd/cache_response.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -151,7 +151,7 @@ if(sp->http->protover >= 1.1) http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, "Transfer-Encoding: chunked"); - else + else sp->doclose = "ESI EOF"; } Modified: trunk/varnish-cache/bin/varnishd/cache_session.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_session.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishd/cache_session.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -95,7 +95,7 @@ } /*-------------------------------------------------------------------- - * This function allocates a session + assorted peripheral data + * This function allocates a session + assorted peripheral data * structures in one single malloc operation. */ Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -130,7 +130,7 @@ v = poll(pollfd, hpoll + 1, 100); assert(v >= 0); if (v && pollfd[vca_pipes[0]].revents) { - + if (pollfd[vca_pipes[0]].revents != POLLIN) VSL(SLT_Debug, 0, "pipe.revents= 0x%x", pollfd[vca_pipes[0]].revents); Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -172,7 +172,7 @@ "(child not running).\n" "Type 'help' for more info."); return; - } + } AN(cli->cmd); i = write(cli_o, cli->cmd, strlen(cli->cmd)); if (i != strlen(cli->cmd)) { @@ -186,7 +186,7 @@ cli_out(cli, "CLI communication error"); return; } - + assert(i == 1 || errno == EPIPE); (void)cli_readres(cli_i, &u, &q, params->cli_timeout); @@ -418,7 +418,7 @@ (void)ident; (void)verbose; - if (cls == NULL) + if (cls == NULL) mgt_cli_init_cls(); cli = CLS_AddFd(cls, fdi, fdo, closefunc, priv); @@ -654,7 +654,7 @@ M_conn = vev_new(); AN(M_conn); M_conn->callback = Marg_poker; - M_conn->name = "-M connector"; + M_conn->name = "-M connector"; M_conn->fd_flags = EV_WR; M_conn->fd = s; M_fd = s; @@ -682,6 +682,6 @@ AN(M_poker); M_poker->timeout = M_poll; M_poker->callback = Marg_poker; - M_poker->name = "-M poker"; + M_poker->name = "-M poker"; AZ(vev_add(mgt_evb, M_poker)); } Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -1056,7 +1056,7 @@ } printf(".Pp\n"); for (p = pp->descr; *p; p++) { - if (*p == '\n' && p[1] =='\0') + if (*p == '\n' && p[1] =='\0') break; if (*p == '\n' && p[1] =='\n') { printf("\n.Pp\n"); Modified: trunk/varnish-cache/bin/varnishd/stevedore.h =================================================================== --- trunk/varnish-cache/bin/varnishd/stevedore.h 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishd/stevedore.h 2010-02-12 11:42:03 UTC (rev 4556) @@ -65,7 +65,7 @@ VTAILQ_ENTRY(stevedore) list; }; -struct object *STV_NewObject(struct sess *sp, unsigned len, double ttl, +struct object *STV_NewObject(struct sess *sp, unsigned len, double ttl, unsigned nhttp); struct storage *STV_alloc(struct sess *sp, size_t size, struct objcore *oc); void STV_trim(struct storage *st, size_t size); Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -278,10 +278,10 @@ continue; } /* - * We do an implict -wait if people muck about with a + * We do an implict -wait if people muck about with a * running server. */ - if (s->run) + if (s->run) server_wait(s); assert(s->run == 0); Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -309,10 +309,10 @@ vtc_log(v->vl, 0, "FAIL no CLI connection accepted"); return; } - + AZ(close(v->cli_fd)); v->cli_fd = nfd; - + vtc_log(v->vl, 3, "CLI connection fd = %d", v->cli_fd); assert(v->cli_fd >= 0); @@ -345,20 +345,20 @@ u = varnish_ask_cli(v, "start", &resp); if (vtc_error) return; - if (u != CLIS_OK) + if (u != CLIS_OK) vtc_log(v->vl, 0, "CLI start command failed: %u %s", u, resp); free(resp); u = varnish_ask_cli(v, "debug.xid 1000", &resp); if (vtc_error) return; - if (u != CLIS_OK) + if (u != CLIS_OK) vtc_log(v->vl, 0, "CLI debug.xid command failed: %u %s", u, resp); free(resp); u = varnish_ask_cli(v, "debug.listen_address", &resp); if (vtc_error) return; - if (u != CLIS_OK) + if (u != CLIS_OK) vtc_log(v->vl, 0, "CLI debug.listen_address command failed: %u %s", u, resp); h = resp; Modified: trunk/varnish-cache/lib/libvarnish/cli_serve.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/cli_serve.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/lib/libvarnish/cli_serve.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -50,7 +50,7 @@ #include #include #include - + struct cls_func { unsigned magic; #define CLS_FUNC_MAGIC 0x7d280c9b @@ -81,7 +81,7 @@ }; /*--------------------------------------------------------------------*/ - + void CLS_func_close(struct cli *cli, const char *const *av, void *priv) { @@ -262,7 +262,7 @@ av = ParseArgv(p, 0); AN(av); - cli->result = CLIS_UNKNOWN; + cli->result = CLIS_UNKNOWN; vsb_clear(cli->sb); cli_out(cli, "Unknown request.\nType 'help' for more info.\n"); @@ -355,7 +355,7 @@ static void cls_close_fd(struct cls *cs, struct cls_fd *cfd) { - + CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); CHECK_OBJ_NOTNULL(cfd, CLS_FD_MAGIC); @@ -482,7 +482,7 @@ cs = *csp; *csp = NULL; CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); - VTAILQ_FOREACH_SAFE(cfd, &cs->fds, list, cfd2) + VTAILQ_FOREACH_SAFE(cfd, &cs->fds, list, cfd2) cls_close_fd(cs, cfd); while (!VTAILQ_EMPTY(&cs->funcs)) { Modified: trunk/varnish-cache/lib/libvarnish/time.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/time.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/lib/libvarnish/time.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -250,7 +250,7 @@ exit (2); } } - + int main(int argc, char **argv) { Modified: trunk/varnish-cache/lib/libvarnish/vss.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vss.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/lib/libvarnish/vss.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -249,7 +249,7 @@ perror("socket()"); return (-1); } - if (nonblock) + if (nonblock) TCP_nonblocking(sd); i = connect(sd, &va->va_addr.sa, va->va_addrlen); if (i == 0 || (nonblock && errno == EINPROGRESS)) Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c =================================================================== --- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -81,8 +81,8 @@ * These two bitmaps mark fd's as belonging to client or backend * transactions respectively. */ - struct vbitmap *vbm_client; - struct vbitmap *vbm_backend; + struct vbitmap *vbm_client; + struct vbitmap *vbm_backend; /* * Bit map of programatically selected tags, that cannot be suppressed. Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2010-02-12 11:26:56 UTC (rev 4555) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2010-02-12 11:42:03 UTC (rev 4556) @@ -190,7 +190,7 @@ */ static void -vcc_EmitBeIdent(const struct tokenlist *tl, struct vsb *v, +vcc_EmitBeIdent(const struct tokenlist *tl, struct vsb *v, int serial, const struct token *first, const struct token *last) { @@ -833,7 +833,7 @@ Fi(tl, 0, "\t VGC_backend__%.*s, &vgc_dir_priv_%.*s);\n", PF(tl->t_dir), PF(tl->t_dir)); - + } if (tl->err) { vsb_printf(tl->sb, From phk at projects.linpro.no Fri Feb 12 11:58:43 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 12 Feb 2010 12:58:43 +0100 (CET) Subject: r4557 - in trunk/varnish-cache: bin/varnishd bin/varnishtest include lib/libvarnish lib/libvarnishapi Message-ID: <20100212115843.F236A1F7C32@projects.linpro.no> Author: phk Date: 2010-02-12 12:58:43 +0100 (Fri, 12 Feb 2010) New Revision: 4557 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/cache_backend.c trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_cli.c trunk/varnish-cache/bin/varnishd/cache_dir_random.c trunk/varnish-cache/bin/varnishd/cache_esi.c trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/cache_http.c trunk/varnish-cache/bin/varnishd/cache_session.c trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c trunk/varnish-cache/bin/varnishd/mgt_cli.c trunk/varnish-cache/bin/varnishd/mgt_param.c trunk/varnish-cache/bin/varnishd/shmlog.c trunk/varnish-cache/bin/varnishd/stevedore.c trunk/varnish-cache/bin/varnishd/varnishd.1 trunk/varnish-cache/bin/varnishd/varnishd.c trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_http.c trunk/varnish-cache/bin/varnishtest/vtc_log.c trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c trunk/varnish-cache/include/cli_serve.h trunk/varnish-cache/lib/libvarnish/cli_serve.c trunk/varnish-cache/lib/libvarnish/vct.c trunk/varnish-cache/lib/libvarnishapi/shmlog.c Log: Update copyright messages of files significantly changed in 2010 so far. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache.h 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_cli.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_cli.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_dir_random.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_esi.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_esi.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_esi.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_session.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_session.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_session.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/shmlog.c =================================================================== --- trunk/varnish-cache/bin/varnishd/shmlog.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/shmlog.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishd/stevedore.c =================================================================== --- trunk/varnish-cache/bin/varnishd/stevedore.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/stevedore.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2007-2009 Linpro AS + * Copyright (c) 2007-2010 Redpill Linpro AS * All rights reserved. * * Author: Dag-Erling Sm?rgav Modified: trunk/varnish-cache/bin/varnishd/varnishd.1 =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/varnishd.1 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ .\"- .\" Copyright (c) 2006 Verdens Gang AS -.\" Copyright (c) 2006-2009 Linpro AS +.\" Copyright (c) 2006-2010 Redpill Linpro AS .\" All rights reserved. .\" .\" Author: Dag-Erling Sm?rgrav Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2009 Linpro AS + * Copyright (c) 2008-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2009 Linpro AS + * Copyright (c) 2008-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2009 Linpro AS + * Copyright (c) 2008-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_log.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishtest/vtc_log.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2009 Linpro AS + * Copyright (c) 2008-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2009 Linpro AS + * Copyright (c) 2008-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2009 Linpro AS + * Copyright (c) 2008-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/include/cli_serve.h =================================================================== --- trunk/varnish-cache/include/cli_serve.h 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/include/cli_serve.h 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/lib/libvarnish/cli_serve.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/cli_serve.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/lib/libvarnish/cli_serve.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/lib/libvarnish/vct.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vct.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/lib/libvarnish/vct.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c =================================================================== --- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2010-02-12 11:42:03 UTC (rev 4556) +++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2010-02-12 11:58:43 UTC (rev 4557) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS + * Copyright (c) 2006-2010 Redpill Linpro AS * All rights reserved. * * Author: Poul-Henning Kamp From phk at projects.linpro.no Fri Feb 12 12:49:57 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 12 Feb 2010 13:49:57 +0100 (CET) Subject: r4558 - trunk/varnish-cache Message-ID: <20100212124957.7E8451F7BAE@projects.linpro.no> Author: phk Date: 2010-02-12 13:49:57 +0100 (Fri, 12 Feb 2010) New Revision: 4558 Modified: trunk/varnish-cache/configure.ac Log: Remove unused HTTP_HDR_MAX_VAL configuration, it is a regular parameter now. Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2010-02-12 11:58:43 UTC (rev 4557) +++ trunk/varnish-cache/configure.ac 2010-02-12 12:49:57 UTC (rev 4558) @@ -417,8 +417,6 @@ fi AC_DEFINE_UNQUOTED([VCC_CC],"$VCC_CC",[C compiler command line for VCL code]) -AC_DEFINE_UNQUOTED(HTTP_HDR_MAX_VAL, $with_max_header_fields, [Define maximum number of header fields supported by varnish ]) - # Use jemalloc on Linux JEMALLOC_SUBDIR= JEMALLOC_LDADD= From phk at projects.linpro.no Sat Feb 13 08:31:04 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 13 Feb 2010 09:31:04 +0100 (CET) Subject: r4559 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20100213083104.84F4D1F7C46@projects.linpro.no> Author: phk Date: 2010-02-13 09:31:04 +0100 (Sat, 13 Feb 2010) New Revision: 4559 Modified: trunk/varnish-cache/bin/varnishtest/tests/v00017.vtc Log: Change from a non-resolving to an illegal DNS name, to avoid spurious test-failures if peoples DNS servers lie to them. Fixes #356 Modified: trunk/varnish-cache/bin/varnishtest/tests/v00017.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/v00017.vtc 2010-02-12 12:49:57 UTC (rev 4558) +++ trunk/varnish-cache/bin/varnishtest/tests/v00017.vtc 2010-02-13 08:31:04 UTC (rev 4559) @@ -34,7 +34,7 @@ varnish v1 -badvcl { backend b { .host = "127.0.0.1"; } - acl a { "en.lille.nisse.rejste."; } + acl a { "...com"; } sub vcl_recv { if (client.ip ~ a) { pass; } } } @@ -60,8 +60,8 @@ backend b { .host = "127.0.0.1"; } acl a { ! "10.1.3"; - ("en.lille.nisse.rejste." / 22); - (!"en.lille.nisse.rejste."); + ("...com" / 22); + (!"...com"); } sub vcl_recv { if (client.ip ~ a) { pass; } } } From phk at projects.linpro.no Sat Feb 13 08:55:05 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 13 Feb 2010 09:55:05 +0100 (CET) Subject: r4560 - trunk/varnish-cache/bin/varnishd Message-ID: <20100213085505.F1FBC1F7C46@projects.linpro.no> Author: phk Date: 2010-02-13 09:55:05 +0100 (Sat, 13 Feb 2010) New Revision: 4560 Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c Log: Assert that we found all active fd's Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-13 08:31:04 UTC (rev 4559) +++ trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-13 08:55:05 UTC (rev 4560) @@ -156,6 +156,9 @@ if (pollfd[fd].revents) { v--; i = HTC_Rx(sp->htc); + if (pollfd[fd].revents != POLLIN) + VSL(SLT_Debug, fd, "Poll: %x / %d", + pollfd[fd].revents, i); VTAILQ_REMOVE(&sesshead, sp, list); if (i == 0) { /* Mov to front of list for speed */ @@ -172,6 +175,7 @@ SES_Delete(sp); } } + assert(v == 0); } NEEDLESS_RETURN(NULL); } From phk at projects.linpro.no Sat Feb 13 20:24:55 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 13 Feb 2010 21:24:55 +0100 (CET) Subject: r4561 - trunk/varnish-cache/bin/varnishd Message-ID: <20100213202455.60CAA1F7C32@projects.linpro.no> Author: phk Date: 2010-02-13 21:24:55 +0100 (Sat, 13 Feb 2010) New Revision: 4561 Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c Log: Be even more paranoid in the poll waiter. Don't update the pollfd state from the pipe, until we have dealt with all sessions. Strongly assert the pollfd state everywhere. Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-13 08:55:05 UTC (rev 4560) +++ trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-13 20:24:55 UTC (rev 4561) @@ -86,9 +86,14 @@ assert(fd >= 0); vca_pollspace((unsigned)fd); assert(fd < npoll); + if (hpoll < fd) hpoll = fd; + assert(pollfd[fd].fd == -1); + assert(pollfd[fd].events == 0); + assert(pollfd[fd].revents == 0); + pollfd[fd].fd = fd; pollfd[fd].events = POLLIN; } @@ -97,10 +102,14 @@ vca_unpoll(int fd) { + assert(fd >= 0); assert(fd < npoll); - assert(fd >= 0); vca_pollspace((unsigned)fd); + assert(pollfd[fd].fd == fd); + assert(pollfd[fd].events == POLLIN); + assert(pollfd[fd].revents == 0); + pollfd[fd].fd = -1; pollfd[fd].events = 0; } @@ -125,33 +134,19 @@ while (hpoll > 0 && pollfd[hpoll].fd == -1) hpoll--; assert(vca_pipes[0] <= hpoll); - assert(pollfd[vca_pipes[0]].fd = vca_pipes[0]); - assert(pollfd[vca_pipes[1]].fd = -1); + assert(pollfd[vca_pipes[0]].fd == vca_pipes[0]); + assert(pollfd[vca_pipes[1]].fd == -1); v = poll(pollfd, hpoll + 1, 100); assert(v >= 0); - if (v && pollfd[vca_pipes[0]].revents) { - - if (pollfd[vca_pipes[0]].revents != POLLIN) - VSL(SLT_Debug, 0, "pipe.revents= 0x%x", - pollfd[vca_pipes[0]].revents); - assert(pollfd[vca_pipes[0]].revents == POLLIN); - v--; - i = read(vca_pipes[0], ss, sizeof ss); - assert(i >= 0); - assert(((unsigned)i % sizeof ss[0]) == 0); - for (j = 0; j * sizeof ss[0] < i; j++) { - CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC); - assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&sesshead, ss[j], list); - vca_poll(ss[j]->fd); - } - } deadline = TIM_real() - params->sess_timeout; VTAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) { if (v == 0) break; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); fd = sp->fd; + assert(fd >= 0); + assert(fd <= hpoll); + assert(fd < npoll); assert(pollfd[fd].fd == fd); if (pollfd[fd].revents) { v--; @@ -159,6 +154,7 @@ if (pollfd[fd].revents != POLLIN) VSL(SLT_Debug, fd, "Poll: %x / %d", pollfd[fd].revents, i); + pollfd[fd].revents = 0; VTAILQ_REMOVE(&sesshead, sp, list); if (i == 0) { /* Mov to front of list for speed */ @@ -175,6 +171,24 @@ SES_Delete(sp); } } + if (v && pollfd[vca_pipes[0]].revents) { + + if (pollfd[vca_pipes[0]].revents != POLLIN) + VSL(SLT_Debug, 0, "pipe.revents= 0x%x", + pollfd[vca_pipes[0]].revents); + assert(pollfd[vca_pipes[0]].revents == POLLIN); + pollfd[vca_pipes[0]].revents = 0; + v--; + i = read(vca_pipes[0], ss, sizeof ss); + assert(i >= 0); + assert(((unsigned)i % sizeof ss[0]) == 0); + for (j = 0; j * sizeof ss[0] < i; j++) { + CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC); + assert(ss[j]->fd >= 0); + VTAILQ_INSERT_TAIL(&sesshead, ss[j], list); + vca_poll(ss[j]->fd); + } + } assert(v == 0); } NEEDLESS_RETURN(NULL); From phk at projects.linpro.no Tue Feb 16 21:05:09 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Feb 2010 22:05:09 +0100 (CET) Subject: r4562 - in trunk/varnish-cache: bin/varnishd lib/libvarnish Message-ID: <20100216210509.0C4A21F741D@projects.linpro.no> Author: phk Date: 2010-02-16 22:05:08 +0100 (Tue, 16 Feb 2010) New Revision: 4562 Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c trunk/varnish-cache/bin/varnishd/varnishd.c trunk/varnish-cache/lib/libvarnish/vpf.c Log: Print pid_t's as uintmax_t for portability (solaris) Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2010-02-13 20:24:55 UTC (rev 4561) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2010-02-16 21:05:08 UTC (rev 4562) @@ -136,7 +136,7 @@ { (void)priv; - REPORT(LOG_NOTICE, "Child (%d) said %s", child_pid, p); + REPORT(LOG_NOTICE, "Child (%ju) said %s", (uintmax_t)child_pid, p); return (0); } @@ -173,8 +173,8 @@ if (!mgt_cli_askchild(NULL, NULL, "ping\n")) return (0); REPORT(LOG_ERR, - "Child (%d) not responding to ping, killing it.", - child_pid); + "Child (%ju) not responding to ping, killing it.", + (uintmax_t)child_pid); if (params->diag_bitmap & 0x1000) (void)kill(child_pid, SIGKILL); else @@ -237,6 +237,7 @@ static inline void waive_privileges(void) { + #ifdef HAVE_SETPPRIV priv_set_t *empty; @@ -356,7 +357,7 @@ exit(1); } - REPORT(LOG_NOTICE, "child (%d) Started", pid); + REPORT(LOG_NOTICE, "child (%ju) Started", (uintmax_t)pid); /* Close stuff the child got */ closex(&heritage.std_fd); @@ -439,7 +440,7 @@ VSL_Panic(&l, &p); if (*p == '\0') return; - REPORT(LOG_ERR, "Child (%d) Panic message: %s", r, p); + REPORT(LOG_ERR, "Child (%ju) Panic message: %s", (uintmax_t)r, p); } /*--------------------------------------------------------------------*/ Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-13 20:24:55 UTC (rev 4561) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-16 21:05:08 UTC (rev 4562) @@ -350,7 +350,7 @@ buf[i] = '\0'; d_child = strtoul(buf, &p, 0); xxxassert(p != NULL); - printf("New Pid %d\n", d_child); + printf("New Pid %ju\n", (uintmax_t)d_child); xxxassert(d_child != 0); i = strlen(p); j = write(pipes[1][1], p, i); @@ -784,7 +784,7 @@ if (d_flag < 2 && !F_flag) AZ(varnish_daemon(1, d_flag)); if (d_flag == 1) - printf("%d\n", getpid()); + printf("%ju\n", (uintmax_t)getpid()); if (pfh != NULL && vpf_write(pfh)) fprintf(stderr, "NOTE: Could not write PID file\n"); Modified: trunk/varnish-cache/lib/libvarnish/vpf.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vpf.c 2010-02-13 20:24:55 UTC (rev 4561) +++ trunk/varnish-cache/lib/libvarnish/vpf.c 2010-02-16 21:05:08 UTC (rev 4562) @@ -194,7 +194,7 @@ return (-1); } - error = snprintf(pidstr, sizeof(pidstr), "%u", getpid()); + error = snprintf(pidstr, sizeof(pidstr), "%ju", (uintmax_t)getpid()); assert(error < sizeof pidstr); if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) { error = errno; From phk at projects.linpro.no Tue Feb 16 21:06:09 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Feb 2010 22:06:09 +0100 (CET) Subject: r4563 - in trunk/varnish-cache: bin/varnishd lib/libvarnishapi Message-ID: <20100216210609.DCE741F741D@projects.linpro.no> Author: phk Date: 2010-02-16 22:06:09 +0100 (Tue, 16 Feb 2010) New Revision: 4563 Modified: trunk/varnish-cache/bin/varnishd/shmlog.c trunk/varnish-cache/bin/varnishd/storage_persistent.c trunk/varnish-cache/lib/libvarnishapi/shmlog.c Log: Void* cast for mmap() and friends for portability (solaris). Modified: trunk/varnish-cache/bin/varnishd/shmlog.c =================================================================== --- trunk/varnish-cache/bin/varnishd/shmlog.c 2010-02-16 21:05:08 UTC (rev 4562) +++ trunk/varnish-cache/bin/varnishd/shmlog.c 2010-02-16 21:06:09 UTC (rev 4563) @@ -401,13 +401,13 @@ vsl_buildnew(fn, size); } - loghead = mmap(NULL, heritage.vsl_size, + loghead = (void *)mmap(NULL, heritage.vsl_size, PROT_READ|PROT_WRITE, MAP_HASSEMAPHORE | MAP_NOSYNC | MAP_SHARED, heritage.vsl_fd, 0); loghead->master_pid = getpid(); xxxassert(loghead != MAP_FAILED); - (void)mlock(loghead, heritage.vsl_size); + (void)mlock((void*)loghead, heritage.vsl_size); VSL_stats = &loghead->stats; pp = (void *)(loghead + 1); *pp = *params; Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c =================================================================== --- trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-02-16 21:05:08 UTC (rev 4562) +++ trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-02-16 21:06:09 UTC (rev 4563) @@ -295,7 +295,7 @@ int i; /* XXX: round to pages */ - i = msync(ctx->ss, ctx->ss->length + SHA256_LEN, MS_SYNC); + i = msync((void*)ctx->ss, ctx->ss->length + SHA256_LEN, MS_SYNC); if (i && 0) fprintf(stderr, "SyncSign(%p %s) = %d %s\n", ctx->ss, ctx->id, i, strerror(errno)); Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c =================================================================== --- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2010-02-16 21:05:08 UTC (rev 4562) +++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2010-02-16 21:06:09 UTC (rev 4563) @@ -160,7 +160,7 @@ return (1); } - vsl_lh = mmap(NULL, slh.size + sizeof slh, + vsl_lh = (void *)mmap(NULL, slh.size + sizeof slh, PROT_READ, MAP_SHARED|MAP_HASSEMAPHORE, vsl_fd, 0); if (vsl_lh == MAP_FAILED) { fprintf(stderr, "Cannot mmap %s: %s\n", @@ -590,7 +590,7 @@ { if (vsl_lh == NULL) return; - assert(0 == munmap(vsl_lh, vsl_lh->size + sizeof *vsl_lh)); + assert(0 == munmap((void*)vsl_lh, vsl_lh->size + sizeof *vsl_lh)); vsl_lh = NULL; assert(vsl_fd >= 0); assert(0 == close(vsl_fd)); From phk at projects.linpro.no Tue Feb 16 21:08:31 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Feb 2010 22:08:31 +0100 (CET) Subject: r4564 - trunk/varnish-cache/bin/varnishreplay Message-ID: <20100216210831.243EC1F7C60@projects.linpro.no> Author: phk Date: 2010-02-16 22:08:30 +0100 (Tue, 16 Feb 2010) New Revision: 4564 Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.c Log: Missing . Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.c =================================================================== --- trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2010-02-16 21:06:09 UTC (rev 4563) +++ trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2010-02-16 21:08:30 UTC (rev 4564) @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include From phk at projects.linpro.no Tue Feb 16 21:11:05 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Feb 2010 22:11:05 +0100 (CET) Subject: r4565 - trunk/varnish-cache/bin/varnishd Message-ID: <20100216211105.A70F51F7C60@projects.linpro.no> Author: phk Date: 2010-02-16 22:11:05 +0100 (Tue, 16 Feb 2010) New Revision: 4565 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c Log: Pretend to use the variables, even if the kernel is deficient. Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-16 21:08:30 UTC (rev 4564) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-16 21:11:05 UTC (rev 4565) @@ -118,6 +118,10 @@ assert(l == sizeof tv); if (memcmp(&tv, &tv_sndtimeo, l)) need_sndtimeo = 1; +#else + (void)tv; + (void)tv_sndtimeo; + (void)need_sndtimeo; #endif #ifdef SO_RCVTIMEO_WORKS @@ -126,6 +130,10 @@ assert(l == sizeof tv); if (memcmp(&tv, &tv_rcvtimeo, l)) need_rcvtimeo = 1; +#else + (void)tv; + (void)tv_rcvtimeo; + (void)need_rcvtimeo; #endif need_test = 0; From phk at projects.linpro.no Tue Feb 16 21:12:23 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Feb 2010 22:12:23 +0100 (CET) Subject: r4566 - trunk/varnish-cache/lib/libvarnish Message-ID: <20100216211223.9CCF61F7C60@projects.linpro.no> Author: phk Date: 2010-02-16 22:12:23 +0100 (Tue, 16 Feb 2010) New Revision: 4566 Modified: trunk/varnish-cache/lib/libvarnish/tcp.c Log: Pretend to use variable, even if kernel is deficient. Modified: trunk/varnish-cache/lib/libvarnish/tcp.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/tcp.c 2010-02-16 21:11:05 UTC (rev 4565) +++ trunk/varnish-cache/lib/libvarnish/tcp.c 2010-02-16 21:12:23 UTC (rev 4566) @@ -61,6 +61,45 @@ #include "libvarnish.h" +/*-------------------------------------------------------------------- + * Recognize errno's we see when the remote end closed the connection. + * + * This "magic" is mostly needed because solaris wrongly returns EBADF + * when they should return ECONNRESET upon receiving a TCP-RST from the + * far end. + * + * My theory is, that some genius decided that since the socket is now + * officially useless, and since they already have found and locked + * the socket/pcb, they might as well get rid off it right away. + * + * On next use from the program, EBADF happens to be the errno, but since + * all programs just call strerror(), who cares ? + * + * Well, I do. EBADF is the canonical "Programmer goofed" errno, and + * it should not be issued for other reasons. + * + * An interesting question here, is if the kernel might conceiveably + * reallocate the fd# before the application closes it, on the mistaken + * belief that it is unused ? That would be bad news... + * + */ + +int +TCP_Errno(void) +{ + + switch (errno) { + case ECONNRESET: + case ENOTCONN: +#if defined (__SVR4) && defined (__sun) + case EBADF: +#endif + return (1); + default: + return (0); + } +} + /*--------------------------------------------------------------------*/ void @@ -232,9 +271,8 @@ void TCP_close(int *s) { - assert (close(*s) == 0 || - errno == ECONNRESET || - errno == ENOTCONN); + + assert (close(*s) == 0 || TCP_Errno()); *s = -1; } @@ -246,6 +284,8 @@ timeout.tv_usec = (int)(1e6 * (seconds - timeout.tv_sec)); #ifdef SO_RCVTIMEO_WORKS AZ(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout)); +#else + (void)s; #endif } From phk at projects.linpro.no Tue Feb 16 21:21:39 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Feb 2010 22:21:39 +0100 (CET) Subject: r4567 - trunk/varnish-cache/lib/libvarnish Message-ID: <20100216212139.6AFAF1F7E2B@projects.linpro.no> Author: phk Date: 2010-02-16 22:21:39 +0100 (Tue, 16 Feb 2010) New Revision: 4567 Modified: trunk/varnish-cache/lib/libvarnish/tcp.c Log: Revert part of last commit, it's not ready for primetime yet. Modified: trunk/varnish-cache/lib/libvarnish/tcp.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/tcp.c 2010-02-16 21:12:23 UTC (rev 4566) +++ trunk/varnish-cache/lib/libvarnish/tcp.c 2010-02-16 21:21:39 UTC (rev 4567) @@ -61,45 +61,6 @@ #include "libvarnish.h" -/*-------------------------------------------------------------------- - * Recognize errno's we see when the remote end closed the connection. - * - * This "magic" is mostly needed because solaris wrongly returns EBADF - * when they should return ECONNRESET upon receiving a TCP-RST from the - * far end. - * - * My theory is, that some genius decided that since the socket is now - * officially useless, and since they already have found and locked - * the socket/pcb, they might as well get rid off it right away. - * - * On next use from the program, EBADF happens to be the errno, but since - * all programs just call strerror(), who cares ? - * - * Well, I do. EBADF is the canonical "Programmer goofed" errno, and - * it should not be issued for other reasons. - * - * An interesting question here, is if the kernel might conceiveably - * reallocate the fd# before the application closes it, on the mistaken - * belief that it is unused ? That would be bad news... - * - */ - -int -TCP_Errno(void) -{ - - switch (errno) { - case ECONNRESET: - case ENOTCONN: -#if defined (__SVR4) && defined (__sun) - case EBADF: -#endif - return (1); - default: - return (0); - } -} - /*--------------------------------------------------------------------*/ void @@ -271,8 +232,9 @@ void TCP_close(int *s) { - - assert (close(*s) == 0 || TCP_Errno()); + assert (close(*s) == 0 || + errno == ECONNRESET || + errno == ENOTCONN); *s = -1; } From phk at projects.linpro.no Tue Feb 16 21:41:17 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 16 Feb 2010 22:41:17 +0100 (CET) Subject: r4568 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20100216214117.6F1671F740A@projects.linpro.no> Author: phk Date: 2010-02-16 22:41:17 +0100 (Tue, 16 Feb 2010) New Revision: 4568 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00020.vtc trunk/varnish-cache/bin/varnishtest/tests/b00021.vtc trunk/varnish-cache/bin/varnishtest/tests/b00022.vtc trunk/varnish-cache/bin/varnishtest/tests/b00023.vtc trunk/varnish-cache/bin/varnishtest/tests/b00024.vtc trunk/varnish-cache/bin/varnishtest/tests/b00025.vtc trunk/varnish-cache/bin/varnishtest/tests/b00026.vtc trunk/varnish-cache/bin/varnishtest/vtc.c Log: Add a new "feature" command, and skip the test if we don't have the features listed on the present platform Modified: trunk/varnish-cache/bin/varnishtest/tests/b00020.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00020.vtc 2010-02-16 21:21:39 UTC (rev 4567) +++ trunk/varnish-cache/bin/varnishtest/tests/b00020.vtc 2010-02-16 21:41:17 UTC (rev 4568) @@ -2,6 +2,8 @@ test "Check the between_bytes_timeout behaves from parameters" +feature SO_RCVTIMEO_WORKS + server s1 { rxreq send "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n" Modified: trunk/varnish-cache/bin/varnishtest/tests/b00021.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00021.vtc 2010-02-16 21:21:39 UTC (rev 4567) +++ trunk/varnish-cache/bin/varnishtest/tests/b00021.vtc 2010-02-16 21:41:17 UTC (rev 4568) @@ -2,6 +2,8 @@ test "Check the between_bytes_timeout behaves from vcl" +feature SO_RCVTIMEO_WORKS + server s1 { rxreq send "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n" Modified: trunk/varnish-cache/bin/varnishtest/tests/b00022.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00022.vtc 2010-02-16 21:21:39 UTC (rev 4567) +++ trunk/varnish-cache/bin/varnishtest/tests/b00022.vtc 2010-02-16 21:41:17 UTC (rev 4568) @@ -2,6 +2,8 @@ test "Check the between_bytes_timeout behaves from backend definition" +feature SO_RCVTIMEO_WORKS + server s1 { rxreq send "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n" Modified: trunk/varnish-cache/bin/varnishtest/tests/b00023.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00023.vtc 2010-02-16 21:21:39 UTC (rev 4567) +++ trunk/varnish-cache/bin/varnishtest/tests/b00023.vtc 2010-02-16 21:41:17 UTC (rev 4568) @@ -2,6 +2,8 @@ test "Check that the first_byte_timeout works from parameters" +feature SO_RCVTIMEO_WORKS + server s1 { rxreq delay 1.5 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00024.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00024.vtc 2010-02-16 21:21:39 UTC (rev 4567) +++ trunk/varnish-cache/bin/varnishtest/tests/b00024.vtc 2010-02-16 21:41:17 UTC (rev 4568) @@ -2,6 +2,8 @@ test "Check that the first_byte_timeout works from vcl" +feature SO_RCVTIMEO_WORKS + server s1 { rxreq delay 1.5 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00025.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00025.vtc 2010-02-16 21:21:39 UTC (rev 4567) +++ trunk/varnish-cache/bin/varnishtest/tests/b00025.vtc 2010-02-16 21:41:17 UTC (rev 4568) @@ -2,6 +2,8 @@ test "Check that the first_byte_timeout works from backend definition" +feature SO_RCVTIMEO_WORKS + server s1 { rxreq delay 1.5 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00026.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00026.vtc 2010-02-16 21:21:39 UTC (rev 4567) +++ trunk/varnish-cache/bin/varnishtest/tests/b00026.vtc 2010-02-16 21:41:17 UTC (rev 4568) @@ -2,6 +2,8 @@ test "Check the precedence for timeouts" +feature SO_RCVTIMEO_WORKS + server s1 { rxreq expect req.url == "from_backend" Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-16 21:21:39 UTC (rev 4567) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-16 21:41:17 UTC (rev 4568) @@ -449,6 +449,31 @@ } /********************************************************************** + * Check features. + */ + +static void +cmd_feature(CMD_ARGS) +{ + int i; + + (void)priv; + (void)cmd; + if (av == NULL) + return; + + for (i = 1; av[i] != NULL; i++) { +#ifdef SO_RCVTIMEO_WORKS + if (!strcmp(av[i], "SO_RCVTIMEO_WORKS")) + continue; +#endif + vtc_log(vl, 1, "SKIPPING test, missing feature %s", av[i]); + vtc_stop = 1; + return; + } +} + +/********************************************************************** * Execute a file */ @@ -461,6 +486,7 @@ { "shell", cmd_shell }, { "sema", cmd_sema }, { "random", cmd_random }, + { "feature", cmd_feature }, { NULL, NULL } }; From phk at projects.linpro.no Wed Feb 17 09:24:31 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Feb 2010 10:24:31 +0100 (CET) Subject: r4569 - trunk/varnish-cache/bin/varnishd Message-ID: <20100217092431.864E31F7C45@projects.linpro.no> Author: phk Date: 2010-02-17 10:24:31 +0100 (Wed, 17 Feb 2010) New Revision: 4569 Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c Log: In one of the the first threads we launch, test that errno is thread local and working, and panic with a somewhat usable message if not. PS: And boy, are you screwed if my test sneaks though a kernel bug... Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2010-02-16 21:41:17 UTC (rev 4568) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2010-02-17 09:24:31 UTC (rev 4569) @@ -404,9 +404,21 @@ volatile unsigned u; double t_idle; struct varnish_stats vsm, *vs; + int errno_is_multi_threaded; THR_SetName("wrk_herdtimer"); + /* + * This is one of the first threads created, test to see that + * errno is really per thread. If this fails, your C-compiler + * needs some magic argument (-mt, -pthread, -pthreads etc etc). + */ + errno = 0; + AN(unlink("/")); /* This had better fail */ + errno_is_multi_threaded = errno; + assert(errno_is_multi_threaded != 0); + assert(errno == EISDIR); + memset(&vsm, 0, sizeof vsm); vs = &vsm; From phk at projects.linpro.no Wed Feb 17 09:41:39 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Feb 2010 10:41:39 +0100 (CET) Subject: r4570 - trunk/varnish-cache/bin/varnishd Message-ID: <20100217094139.DEF711F7C45@projects.linpro.no> Author: phk Date: 2010-02-17 10:41:39 +0100 (Wed, 17 Feb 2010) New Revision: 4570 Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c Log: Don't check for EISDIR, it's not portable (solaris) Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2010-02-17 09:24:31 UTC (rev 4569) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2010-02-17 09:41:39 UTC (rev 4570) @@ -417,7 +417,6 @@ AN(unlink("/")); /* This had better fail */ errno_is_multi_threaded = errno; assert(errno_is_multi_threaded != 0); - assert(errno == EISDIR); memset(&vsm, 0, sizeof vsm); vs = &vsm; From phk at projects.linpro.no Wed Feb 17 12:57:25 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Feb 2010 13:57:25 +0100 (CET) Subject: r4571 - trunk/varnish-cache/bin/varnishtest Message-ID: <20100217125725.2E5CC1F7C45@projects.linpro.no> Author: phk Date: 2010-02-17 13:57:24 +0100 (Wed, 17 Feb 2010) New Revision: 4571 Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Bail if argumets are set after varnishd is launched. Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-02-17 09:41:39 UTC (rev 4570) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-02-17 12:57:24 UTC (rev 4571) @@ -639,6 +639,7 @@ break; if (!strcmp(*av, "-arg")) { AN(av[1]); + AZ(v->pid); vsb_cat(v->args, " "); vsb_cat(v->args, av[1]); av++; From phk at projects.linpro.no Wed Feb 17 13:12:38 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Feb 2010 14:12:38 +0100 (CET) Subject: r4572 - in trunk/varnish-cache: bin/varnishd include lib/libvarnish Message-ID: <20100217131239.26D891F7C54@projects.linpro.no> Author: phk Date: 2010-02-17 14:12:07 +0100 (Wed, 17 Feb 2010) New Revision: 4572 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/include/libvarnish.h trunk/varnish-cache/lib/libvarnish/tcp.c Log: Try to handle socket state calls that return errno's relating to the client absconding the TCP connection. This comes to the fore on Solaris, where not only systemcalls which push data through sockets (read,write,select...) return these errors, but also socket-state calls (setsockopt, ioctl, fcntl) do. Root cause of trouble in #626 & al. Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-17 12:57:24 UTC (rev 4571) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2010-02-17 13:12:07 UTC (rev 4572) @@ -105,16 +105,25 @@ struct linger lin; struct timeval tv; socklen_t l; + int i; l = sizeof lin; - AZ(getsockopt(fd, SOL_SOCKET, SO_LINGER, &lin, &l)); + i = getsockopt(fd, SOL_SOCKET, SO_LINGER, &lin, &l); + if (i) { + TCP_Assert(i); + return; + } assert(l == sizeof lin); if (memcmp(&lin, &linger, l)) need_linger = 1; #ifdef SO_SNDTIMEO_WORKS l = sizeof tv; - AZ(getsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, &l)); + i = getsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, &l); + if (i) { + TCP_Assert(i); + return; + } assert(l == sizeof tv); if (memcmp(&tv, &tv_sndtimeo, l)) need_sndtimeo = 1; @@ -126,7 +135,11 @@ #ifdef SO_RCVTIMEO_WORKS l = sizeof tv; - AZ(getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, &l)); + i = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, &l); + if (i) { + TCP_Assert(i); + return; + } assert(l == sizeof tv); if (memcmp(&tv, &tv_rcvtimeo, l)) need_rcvtimeo = 1; @@ -168,16 +181,16 @@ if (need_test) sock_test(sp->fd); if (need_linger) - AZ(setsockopt(sp->fd, SOL_SOCKET, SO_LINGER, + TCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_LINGER, &linger, sizeof linger)); #ifdef SO_SNDTIMEO_WORKS if (need_sndtimeo) - AZ(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO, + TCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO, &tv_sndtimeo, sizeof tv_sndtimeo)); #endif #ifdef SO_RCVTIMEO_WORKS if (need_rcvtimeo) - AZ(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO, + TCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO, &tv_rcvtimeo, sizeof tv_rcvtimeo)); #endif } @@ -365,8 +378,9 @@ * Set nonblocking in the worker-thread, before passing to the * acceptor thread, to reduce syscall density of the latter. */ - TCP_nonblocking(sp->fd); - if (vca_act->pass == NULL) + if (TCP_nonblocking(sp->fd)) + vca_close_session(sp, "remote closed"); + else if (vca_act->pass == NULL) assert(sizeof sp == write(vca_pipes[1], &sp, sizeof sp)); else vca_act->pass(sp); Modified: trunk/varnish-cache/include/libvarnish.h =================================================================== --- trunk/varnish-cache/include/libvarnish.h 2010-02-17 12:57:24 UTC (rev 4571) +++ trunk/varnish-cache/include/libvarnish.h 2010-02-17 13:12:07 UTC (rev 4572) @@ -60,12 +60,16 @@ #define TCP_ADDRBUFSIZE 64 #define TCP_PORTBUFSIZE 16 +#define TCP_Check(a) ((a) == 0 || errno == ECONNRESET || errno == ENOTCONN) + +#define TCP_Assert(a) assert(TCP_Check(a)) + void TCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen); void TCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen); int TCP_filter_http(int sock); -void TCP_blocking(int sock); -void TCP_nonblocking(int sock); -void TCP_linger(int sock, int linger); +int TCP_blocking(int sock); +int TCP_nonblocking(int sock); +int TCP_linger(int sock, int linger); #ifdef SOL_SOCKET void TCP_name(const struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen); Modified: trunk/varnish-cache/lib/libvarnish/tcp.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/tcp.c 2010-02-17 12:57:24 UTC (rev 4571) +++ trunk/varnish-cache/lib/libvarnish/tcp.c 2010-02-17 13:12:07 UTC (rev 4572) @@ -154,22 +154,26 @@ * at least on FreeBSD. */ -void +int TCP_blocking(int sock) { - int i; + int i, j; i = 0; - AZ(ioctl(sock, FIONBIO, &i)); + j = ioctl(sock, FIONBIO, &i); + TCP_Assert(j); + return (j); } -void +int TCP_nonblocking(int sock) { - int i; + int i, j; i = 1; - AZ(ioctl(sock, FIONBIO, &i)); + j = ioctl(sock, FIONBIO, &i); + TCP_Assert(j); + return (j); } /*-------------------------------------------------------------------- @@ -255,7 +259,7 @@ * Set or reset SO_LINGER flag */ -void +int TCP_linger(int sock, int linger) { struct linger lin; @@ -264,5 +268,6 @@ memset(&lin, 0, sizeof lin); lin.l_onoff = linger; i = setsockopt(sock, SOL_SOCKET, SO_LINGER, &lin, sizeof lin); - assert(i == 0 || errno == EBADF); + TCP_Assert(i); + return (i); } From phk at projects.linpro.no Wed Feb 17 14:53:04 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Feb 2010 15:53:04 +0100 (CET) Subject: r4573 - trunk/varnish-cache/bin/varnishtest Message-ID: <20100217145304.769A31F7C3E@projects.linpro.no> Author: phk Date: 2010-02-17 15:53:01 +0100 (Wed, 17 Feb 2010) New Revision: 4573 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Use /tmp as TMPDIR if not otherwise set. Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-17 13:12:07 UTC (rev 4572) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-17 14:53:01 UTC (rev 4573) @@ -643,6 +643,7 @@ init_macro(); init_sema(); + setenv("TMPDIR", "/tmp", 0); vtc_tmpdir = tempnam(NULL, "vtc"); AN(vtc_tmpdir); AZ(mkdir(vtc_tmpdir, 0700)); From phk at projects.linpro.no Wed Feb 17 15:03:11 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Feb 2010 16:03:11 +0100 (CET) Subject: r4574 - trunk/varnish-cache/bin/varnishd Message-ID: <20100217150311.9FDAC1F7C54@projects.linpro.no> Author: phk Date: 2010-02-17 16:03:10 +0100 (Wed, 17 Feb 2010) New Revision: 4574 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Make the session_linger a one-shot timer, and apply it also to new sessions as such. If we get no request in the session_linger window, we punt the session over to the waiter, in order to not tie up a worker thread longer than necessary. This makes the session_linger a more important paramter to tune/get right, but should also reduce our vulnerability to certain DoS attacks. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-17 14:53:01 UTC (rev 4573) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-17 15:03:10 UTC (rev 4574) @@ -84,7 +84,7 @@ /*-------------------------------------------------------------------- * WAIT - * Wait until we have a full request in our htc. + * Wait (briefly) until we have a full request in our htc. */ static int @@ -99,35 +99,36 @@ assert(sp->xid == 0); i = HTC_Complete(sp->htc); - while (i == 0) { - if (params->session_linger > 0) { - pfd[0].fd = sp->fd; - pfd[0].events = POLLIN; - pfd[0].revents = 0; - i = poll(pfd, 1, params->session_linger); - if (i == 0) { - WSL(sp->wrk, SLT_Debug, sp->fd, "herding"); - sp->wrk->stats.sess_herd++; - SES_Charge(sp); - sp->wrk = NULL; - vca_return_session(sp); - return (1); - } - } - i = HTC_Rx(sp->htc); + if (i == 0 && params->session_linger > 0) { + pfd[0].fd = sp->fd; + pfd[0].events = POLLIN; + pfd[0].revents = 0; + i = poll(pfd, 1, params->session_linger); + if (i) + i = HTC_Rx(sp->htc); } + if (i == 0) { + WSL(sp->wrk, SLT_Debug, sp->fd, "herding"); + sp->wrk->stats.sess_herd++; + SES_Charge(sp); + sp->wrk = NULL; + vca_return_session(sp); + return (1); + } if (i == 1) { sp->step = STP_START; - } else { - if (i == -2) - vca_close_session(sp, "overflow"); - else if (i == -1 && Tlen(sp->htc->rxbuf) == 0 && - (errno == 0 || errno == ECONNRESET)) - vca_close_session(sp, "EOF"); - else - vca_close_session(sp, "error"); - sp->step = STP_DONE; + return (0); } + if (i == -2) { + vca_close_session(sp, "overflow"); + return (0); + } + if (i == -1 && Tlen(sp->htc->rxbuf) == 0 && + (errno == 0 || errno == ECONNRESET)) + vca_close_session(sp, "EOF"); + else + vca_close_session(sp, "error"); + sp->step = STP_DONE; return (0); } From phk at projects.linpro.no Wed Feb 17 19:03:11 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Feb 2010 20:03:11 +0100 (CET) Subject: r4575 - trunk/varnish-cache/bin/varnishd Message-ID: <20100217190311.5DEBA1F7C54@projects.linpro.no> Author: phk Date: 2010-02-17 20:03:08 +0100 (Wed, 17 Feb 2010) New Revision: 4575 Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c Log: Use %jd for pid_t's to make -1 look sensible. Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2010-02-17 15:03:10 UTC (rev 4574) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2010-02-17 19:03:08 UTC (rev 4575) @@ -136,7 +136,7 @@ { (void)priv; - REPORT(LOG_NOTICE, "Child (%ju) said %s", (uintmax_t)child_pid, p); + REPORT(LOG_NOTICE, "Child (%jd) said %s", (intmax_t)child_pid, p); return (0); } @@ -173,8 +173,8 @@ if (!mgt_cli_askchild(NULL, NULL, "ping\n")) return (0); REPORT(LOG_ERR, - "Child (%ju) not responding to ping, killing it.", - (uintmax_t)child_pid); + "Child (%jd) not responding to ping, killing it.", + (intmax_t)child_pid); if (params->diag_bitmap & 0x1000) (void)kill(child_pid, SIGKILL); else @@ -357,7 +357,7 @@ exit(1); } - REPORT(LOG_NOTICE, "child (%ju) Started", (uintmax_t)pid); + REPORT(LOG_NOTICE, "child (%jd) Started", (intmax_t)pid); /* Close stuff the child got */ closex(&heritage.std_fd); @@ -440,7 +440,7 @@ VSL_Panic(&l, &p); if (*p == '\0') return; - REPORT(LOG_ERR, "Child (%ju) Panic message: %s", (uintmax_t)r, p); + REPORT(LOG_ERR, "Child (%jd) Panic message: %s", (intmax_t)r, p); } /*--------------------------------------------------------------------*/ From phk at projects.linpro.no Wed Feb 17 19:07:24 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 17 Feb 2010 20:07:24 +0100 (CET) Subject: r4576 - in trunk/varnish-cache: bin/varnishd lib/libvarnish Message-ID: <20100217190724.CFAE11F7C45@projects.linpro.no> Author: phk Date: 2010-02-17 20:07:21 +0100 (Wed, 17 Feb 2010) New Revision: 4576 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_fetch.c trunk/varnish-cache/bin/varnishd/cache_pipe.c trunk/varnish-cache/bin/varnishd/cache_waiter_kqueue.c trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c trunk/varnish-cache/bin/varnishd/mgt_child.c trunk/varnish-cache/lib/libvarnish/tcp.c trunk/varnish-cache/lib/libvarnish/vss.c Log: Tell FlexeLint that we ignore returnvalues on purpose. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-17 19:03:08 UTC (rev 4575) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2010-02-17 19:07:21 UTC (rev 4576) @@ -271,7 +271,7 @@ * This is an orderly close of the connection; ditch nolinger * before we close, to get queued data transmitted. */ - TCP_linger(sp->fd, 0); + (void)TCP_linger(sp->fd, 0); vca_close_session(sp, sp->doclose); } @@ -1216,7 +1216,7 @@ * do the syscall in the worker thread. */ if (sp->step == STP_FIRST || sp->step == STP_START) - TCP_blocking(sp->fd); + (void)TCP_blocking(sp->fd); /* * NB: Once done is set, we can no longer touch sp! Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2010-02-17 19:03:08 UTC (rev 4575) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2010-02-17 19:07:21 UTC (rev 4576) @@ -367,7 +367,7 @@ if (!http_GetHdr(hp, H_Host, &b)) VBE_AddHostHeader(sp); - TCP_blocking(vc->fd); /* XXX: we should timeout instead */ + (void)TCP_blocking(vc->fd); /* XXX: we should timeout instead */ WRW_Reserve(w, &vc->fd); (void)http_Write(w, hp, 0); /* XXX: stats ? */ Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2010-02-17 19:03:08 UTC (rev 4575) +++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2010-02-17 19:07:21 UTC (rev 4576) @@ -79,7 +79,7 @@ if (sp->vbe == NULL) return; vc = sp->vbe; - TCP_blocking(vc->fd); + (void)TCP_blocking(vc->fd); WRW_Reserve(w, &vc->fd); sp->acct_req.hdrbytes += http_Write(w, sp->wrk->bereq, 0); @@ -100,11 +100,11 @@ memset(fds, 0, sizeof fds); - TCP_linger(vc->fd, 0); + (void)TCP_linger(vc->fd, 0); fds[0].fd = vc->fd; fds[0].events = POLLIN | POLLERR; - TCP_linger(sp->fd, 0); + (void)TCP_linger(sp->fd, 0); fds[1].fd = sp->fd; fds[1].events = POLLIN | POLLERR; Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_kqueue.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_waiter_kqueue.c 2010-02-17 19:03:08 UTC (rev 4575) +++ trunk/varnish-cache/bin/varnishd/cache_waiter_kqueue.c 2010-02-17 19:07:21 UTC (rev 4576) @@ -198,7 +198,7 @@ if (sp->t_open > deadline) break; VTAILQ_REMOVE(&sesshead, sp, list); - TCP_linger(sp->fd, 0); + (void)TCP_linger(sp->fd, 0); vca_close_session(sp, "timeout"); SES_Delete(sp); } Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-17 19:03:08 UTC (rev 4575) +++ trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-02-17 19:07:21 UTC (rev 4576) @@ -166,7 +166,7 @@ } else if (sp->t_open <= deadline) { VTAILQ_REMOVE(&sesshead, sp, list); vca_unpoll(fd); - TCP_linger(sp->fd, 0); + (void)TCP_linger(sp->fd, 0); vca_close_session(sp, "timeout"); SES_Delete(sp); } Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2010-02-17 19:03:08 UTC (rev 4575) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2010-02-17 19:07:21 UTC (rev 4576) @@ -206,7 +206,7 @@ * closes before we call accept(2) and nobody else are in * the listen queue to release us. */ - TCP_nonblocking(ls->sock); + (void)TCP_nonblocking(ls->sock); (void)TCP_filter_http(ls->sock); good++; } Modified: trunk/varnish-cache/lib/libvarnish/tcp.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/tcp.c 2010-02-17 19:03:08 UTC (rev 4575) +++ trunk/varnish-cache/lib/libvarnish/tcp.c 2010-02-17 19:07:21 UTC (rev 4576) @@ -196,7 +196,7 @@ assert(s >= 0); /* Set the socket non-blocking */ - TCP_nonblocking(s); + (void)TCP_nonblocking(s); /* Attempt the connect */ i = connect(s, name, namelen); @@ -224,7 +224,7 @@ if (k) return (-1); - TCP_blocking(s); + (void)TCP_blocking(s); return (0); } Modified: trunk/varnish-cache/lib/libvarnish/vss.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vss.c 2010-02-17 19:03:08 UTC (rev 4575) +++ trunk/varnish-cache/lib/libvarnish/vss.c 2010-02-17 19:07:21 UTC (rev 4576) @@ -250,7 +250,7 @@ return (-1); } if (nonblock) - TCP_nonblocking(sd); + (void)TCP_nonblocking(sd); i = connect(sd, &va->va_addr.sa, va->va_addrlen); if (i == 0 || (nonblock && errno == EINPROGRESS)) return (sd); From phk at projects.linpro.no Thu Feb 18 10:47:17 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 18 Feb 2010 11:47:17 +0100 (CET) Subject: r4577 - trunk/varnish-cache/bin/varnishd Message-ID: <20100218104717.415041F7C41@projects.linpro.no> Author: phk Date: 2010-02-18 11:47:16 +0100 (Thu, 18 Feb 2010) New Revision: 4577 Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c Log: Align new segments properly. Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c =================================================================== --- trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-02-17 19:07:21 UTC (rev 4576) +++ trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-02-18 10:47:16 UTC (rev 4577) @@ -1157,6 +1157,8 @@ assert(C_ALIGN(sc->objreserv) + 2 * SEG_SPACE <= smp_spaceleft(sg)); /* Write the OBJIDX */ + sg->next_addr |= 7; + sg->next_addr++; smp_def_sign(sc, sg->ctx, sg->next_addr, "OBJIDX"); smp_reset_sign(sg->ctx); smp_sync_sign(sg->ctx); From phk at projects.linpro.no Thu Feb 18 11:48:32 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 18 Feb 2010 12:48:32 +0100 (CET) Subject: r4578 - trunk/varnish-cache/bin/varnishtest Message-ID: <20100218114832.463381F7C41@projects.linpro.no> Author: phk Date: 2010-02-18 12:48:32 +0100 (Thu, 18 Feb 2010) New Revision: 4578 Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c Log: Don't emit confusing messages about errors during cleanup Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_log.c 2010-02-18 10:47:16 UTC (rev 4577) +++ trunk/varnish-cache/bin/varnishtest/vtc_log.c 2010-02-18 11:48:32 UTC (rev 4578) @@ -123,6 +123,8 @@ static void vtc_log_emit(struct vtclog *vl, unsigned lvl) { + if (vtc_stop && lvl == 0) + return; AZ(pthread_mutex_lock(&vtclog_mtx)); vsb_cat(vtclog_full, vsb_data(vl->vsb)); AZ(pthread_mutex_unlock(&vtclog_mtx)); From phk at projects.linpro.no Sun Feb 21 20:15:44 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 21 Feb 2010 21:15:44 +0100 (CET) Subject: r4579 - trunk/varnish-cache/bin/varnishd Message-ID: <20100221201544.71D491F73CA@projects.linpro.no> Author: phk Date: 2010-02-21 21:15:44 +0100 (Sun, 21 Feb 2010) New Revision: 4579 Modified: trunk/varnish-cache/bin/varnishd/flint.sh trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt.h Log: nitpicking with flexelint Modified: trunk/varnish-cache/bin/varnishd/flint.sh =================================================================== --- trunk/varnish-cache/bin/varnishd/flint.sh 2010-02-18 11:48:32 UTC (rev 4578) +++ trunk/varnish-cache/bin/varnishd/flint.sh 2010-02-21 20:15:44 UTC (rev 4579) @@ -9,4 +9,5 @@ -DVARNISH_STATE_DIR=\"foo\" \ *.c \ ../../lib/libvarnish/*.c \ + ../../lib/libvarnishcompat/execinfo.c \ ../../lib/libvcl/*.c Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2010-02-18 11:48:32 UTC (rev 4578) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2010-02-21 20:15:44 UTC (rev 4579) @@ -129,9 +129,6 @@ /* Listen depth */ unsigned listen_depth; - /* HTTP proto behaviour */ - unsigned client_http11; - /* CLI related */ unsigned cli_timeout; unsigned ping_interval; Modified: trunk/varnish-cache/bin/varnishd/mgt.h =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt.h 2010-02-18 11:48:32 UTC (rev 4578) +++ trunk/varnish-cache/bin/varnishd/mgt.h 2010-02-21 20:15:44 UTC (rev 4579) @@ -63,7 +63,9 @@ void MCF_ParamSync(void); void MCF_ParamInit(struct cli *); void MCF_ParamSet(struct cli *, const char *param, const char *val); +#ifdef DIAGNOSTICS void MCF_DumpMdoc(void); +#endif /* mgt_vcc.c */ void mgt_vcc_init(void); From phk at projects.linpro.no Sun Feb 21 20:24:12 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 21 Feb 2010 21:24:12 +0100 (CET) Subject: r4580 - trunk/varnish-cache/bin/varnishd Message-ID: <20100221202412.412371F73CA@projects.linpro.no> Author: phk Date: 2010-02-21 21:24:11 +0100 (Sun, 21 Feb 2010) New Revision: 4580 Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c Log: Evict the last *asprintf usage. Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-21 20:15:44 UTC (rev 4579) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-21 20:24:11 UTC (rev 4580) @@ -208,10 +208,10 @@ int mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) { - char *p; int i, j; va_list ap; unsigned u; + char buf[params->cli_buffer], *p; if (resp != NULL) *resp = NULL; @@ -223,13 +223,12 @@ return (CLIS_CANT); } va_start(ap, fmt); - i = vasprintf(&p, fmt, ap); + vbprintf(buf, fmt, ap); va_end(ap); - if (i < 0) - return (i); - assert(p[i - 1] == '\n'); - j = write(cli_o, p, i); - free(p); + p = strchr(buf, '\0'); + assert(p != NULL && p > buf && p[-1] == '\n'); + i = p - buf; + j = write(cli_o, buf, i); if (j != i) { if (status != NULL) *status = CLIS_COMMS; From phk at projects.linpro.no Sun Feb 21 20:36:32 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 21 Feb 2010 21:36:32 +0100 (CET) Subject: r4581 - in trunk/varnish-cache: . include include/compat lib/libvarnishcompat Message-ID: <20100221203632.1A7111F75B9@projects.linpro.no> Author: phk Date: 2010-02-21 21:36:31 +0100 (Sun, 21 Feb 2010) New Revision: 4581 Removed: trunk/varnish-cache/include/compat/asprintf.h trunk/varnish-cache/include/compat/vasprintf.h trunk/varnish-cache/lib/libvarnishcompat/asprintf.c trunk/varnish-cache/lib/libvarnishcompat/vasprintf.c Modified: trunk/varnish-cache/configure.ac trunk/varnish-cache/include/Makefile.am trunk/varnish-cache/lib/libvarnishcompat/Makefile.am Log: Evict the [v]asprintf compat & configure stuff, we have stopped using these functions. The [v]asprintf() functions are convenient shorthand, but suffer from a number of problems, portability, cornercases and performance being the most relevant to Varnish. Static buffers on the stack (see [v]bprintf macros, or sbufs (vsb) are always better choices for us. Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2010-02-21 20:24:11 UTC (rev 4580) +++ trunk/varnish-cache/configure.ac 2010-02-21 20:36:31 UTC (rev 4581) @@ -210,7 +210,6 @@ # These functions are provided by libcompat on platforms where they # are not available -AC_CHECK_FUNCS([asprintf vasprintf]) AC_CHECK_FUNCS([setproctitle]) AC_CHECK_FUNCS([srandomdev]) AC_CHECK_FUNCS([strlcat strlcpy]) Modified: trunk/varnish-cache/include/Makefile.am =================================================================== --- trunk/varnish-cache/include/Makefile.am 2010-02-21 20:24:11 UTC (rev 4580) +++ trunk/varnish-cache/include/Makefile.am 2010-02-21 20:36:31 UTC (rev 4581) @@ -13,7 +13,6 @@ cli_common.h \ cli_priv.h \ cli_serve.h \ - compat/asprintf.h \ compat/daemon.h \ compat/execinfo.h \ compat/setproctitle.h \ @@ -21,7 +20,6 @@ compat/strlcat.h \ compat/strlcpy.h \ compat/strndup.h \ - compat/vasprintf.h \ flopen.h \ http_headers.h \ http_response.h \ Deleted: trunk/varnish-cache/include/compat/asprintf.h =================================================================== --- trunk/varnish-cache/include/compat/asprintf.h 2010-02-21 20:24:11 UTC (rev 4580) +++ trunk/varnish-cache/include/compat/asprintf.h 2010-02-21 20:36:31 UTC (rev 4581) @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 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_ASPRINTF_H_INCLUDED -#define COMPAT_ASPRINTF_H_INCLUDED - -#ifndef HAVE_ASPRINTF -int asprintf(char **strp, const char *fmt, ...); -#endif - -#endif Deleted: trunk/varnish-cache/include/compat/vasprintf.h =================================================================== --- trunk/varnish-cache/include/compat/vasprintf.h 2010-02-21 20:24:11 UTC (rev 4580) +++ trunk/varnish-cache/include/compat/vasprintf.h 2010-02-21 20:36:31 UTC (rev 4581) @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 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_VASPRINTF_H_INCLUDED -#define COMPAT_VASPRINTF_H_INCLUDED - -#include - -#ifndef HAVE_VASPRINTF -int vasprintf(char **strp, const char *fmt, va_list ap); -#endif - -#endif Modified: trunk/varnish-cache/lib/libvarnishcompat/Makefile.am =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/Makefile.am 2010-02-21 20:24:11 UTC (rev 4580) +++ trunk/varnish-cache/lib/libvarnishcompat/Makefile.am 2010-02-21 20:36:31 UTC (rev 4581) @@ -7,10 +7,8 @@ libvarnishcompat_la_LDFLAGS = -version-info 1:0:0 libvarnishcompat_la_SOURCES = \ - asprintf.c \ daemon.c \ execinfo.c \ - vasprintf.c \ setproctitle.c \ srandomdev.c \ strlcat.c \ Deleted: trunk/varnish-cache/lib/libvarnishcompat/asprintf.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/asprintf.c 2010-02-21 20:24:11 UTC (rev 4580) +++ trunk/varnish-cache/lib/libvarnishcompat/asprintf.c 2010-02-21 20:36:31 UTC (rev 4581) @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 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. - * - */ - -#include "config.h" - -#include "svnid.h" -SVNID("$Id$") - -#ifndef HAVE_ASPRINTF - -#include -#include - -#include "compat/asprintf.h" -#include "compat/vasprintf.h" - -int -asprintf(char **strp, const char *fmt, ...) -{ - va_list ap; - int ret; - - va_start(ap, fmt); - ret = vasprintf(strp, fmt, ap); - va_end(ap); - return (ret); -} -#endif Deleted: trunk/varnish-cache/lib/libvarnishcompat/vasprintf.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/vasprintf.c 2010-02-21 20:24:11 UTC (rev 4580) +++ trunk/varnish-cache/lib/libvarnishcompat/vasprintf.c 2010-02-21 20:36:31 UTC (rev 4581) @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 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. - * - */ - -#include "config.h" - -#include "svnid.h" -SVNID("$Id$") - -#ifndef HAVE_VASPRINTF - -#include -#include -#include - -#include "compat/vasprintf.h" - -int -vasprintf(char **strp, const char *fmt, va_list ap) -{ - va_list aq; - int ret; - - va_copy(aq, ap); - ret = vsnprintf(NULL, 0, fmt, aq); - va_end(aq); - if ((*strp = malloc(ret + 1)) == NULL) - return (-1); - ret = vsnprintf(*strp, ret + 1, fmt, ap); - return (ret); -} -#endif From phk at projects.linpro.no Sun Feb 21 22:00:09 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 21 Feb 2010 23:00:09 +0100 (CET) Subject: r4582 - in trunk/varnish-cache: bin/varnishd include lib/libvarnishcompat Message-ID: <20100221220009.B90C01F73CA@projects.linpro.no> Author: phk Date: 2010-02-21 23:00:09 +0100 (Sun, 21 Feb 2010) New Revision: 4582 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_panic.c trunk/varnish-cache/bin/varnishd/cache_pool.c trunk/varnish-cache/bin/varnishd/flint.lnt trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/storage_persistent.c trunk/varnish-cache/include/persistent.h trunk/varnish-cache/include/vev.h trunk/varnish-cache/lib/libvarnishcompat/execinfo.c Log: Various flexelint inspired cleanups Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2010-02-21 20:36:31 UTC (rev 4581) +++ trunk/varnish-cache/bin/varnishd/cache.h 2010-02-21 22:00:09 UTC (rev 4582) @@ -695,10 +695,10 @@ void SMS_Finish(struct object *obj); /* storage_persistent.c */ -void SMP_Fixup(struct sess *sp, struct objhead *oh, struct objcore *oc); +void SMP_Fixup(struct sess *sp, const struct objhead *oh, struct objcore *oc); void SMP_BANchanged(const struct object *o, double t); void SMP_TTLchanged(const struct object *o); -void SMP_FreeObj(struct object *o); +void SMP_FreeObj(const struct object *o); void SMP_Ready(void); void SMP_NewBan(double t0, const char *ban); Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_panic.c 2010-02-21 20:36:31 UTC (rev 4581) +++ trunk/varnish-cache/bin/varnishd/cache_panic.c 2010-02-21 22:00:09 UTC (rev 4582) @@ -279,7 +279,10 @@ if (Symbol_Lookup(vsp, array[i]) < 0) { char **strings; strings = backtrace_symbols(&array[i], 1); - vsb_printf(vsp, "%p: %s", array[i], strings[0]); + if (strings != NULL && strings[0] != NULL) + vsb_printf(vsp, "%p: %s", array[i], strings[0]); + else + vsb_printf(vsp, "%p: (?)", array[i]); } vsb_printf (vsp, "\n"); } Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2010-02-21 20:36:31 UTC (rev 4581) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2010-02-21 22:00:09 UTC (rev 4582) @@ -212,13 +212,13 @@ wrk_thread(void *priv) { struct wq *qp; - volatile unsigned nhttp; + unsigned nhttp; unsigned siov; CAST_OBJ_NOTNULL(qp, priv, WQ_MAGIC); /* We need to snapshot these two for consistency */ nhttp = params->http_headers; - siov = nhttp * 2; /* XXX param ? */ + siov = nhttp * 2; if (siov > IOV_MAX) siov = IOV_MAX; return (wrk_thread_real(qp, Modified: trunk/varnish-cache/bin/varnishd/flint.lnt =================================================================== --- trunk/varnish-cache/bin/varnishd/flint.lnt 2010-02-21 20:36:31 UTC (rev 4581) +++ trunk/varnish-cache/bin/varnishd/flint.lnt 2010-02-21 22:00:09 UTC (rev 4582) @@ -201,6 +201,9 @@ -efunc(539, http_FilterFields) // Positive indentation from line -efunc(539, http_EstimateWS) // Positive indentation from line +-esym(525, __builtin_frame_address) // Not defined +-esym(525, __builtin_return_address) // Not defined + // cache_vcl.c -efunc(525, vcl_handlingname) // Negative indentation from line -esym(528, vcl_handlingname) // Not referenced Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2010-02-21 20:36:31 UTC (rev 4581) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2010-02-21 22:00:09 UTC (rev 4582) @@ -199,6 +199,10 @@ unsigned syslog_cli_traffic; }; +/* + * We declare this a volatile pointer, so that reads of parameters + * become atomic, leaving the CLI thread lattitude to change the values + */ extern volatile struct params *params; extern struct heritage heritage; Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c =================================================================== --- trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-02-21 20:36:31 UTC (rev 4581) +++ trunk/varnish-cache/bin/varnishd/storage_persistent.c 2010-02-21 22:00:09 UTC (rev 4582) @@ -648,7 +648,7 @@ */ void -SMP_Fixup(struct sess *sp, struct objhead *oh, struct objcore *oc) +SMP_Fixup(struct sess *sp, const struct objhead *oh, struct objcore *oc) { struct smp_seg *sg; struct smp_object *so; @@ -785,7 +785,7 @@ */ void -SMP_FreeObj(struct object *o) +SMP_FreeObj(const struct object *o) { struct smp_seg *sg; Modified: trunk/varnish-cache/include/persistent.h =================================================================== --- trunk/varnish-cache/include/persistent.h 2010-02-21 20:36:31 UTC (rev 4581) +++ trunk/varnish-cache/include/persistent.h 2010-02-21 22:00:09 UTC (rev 4582) @@ -137,5 +137,4 @@ double ttl; double ban; struct object *ptr; - uint64_t len; /* XXX: madvise */ }; Modified: trunk/varnish-cache/include/vev.h =================================================================== --- trunk/varnish-cache/include/vev.h 2010-02-21 20:36:31 UTC (rev 4581) +++ trunk/varnish-cache/include/vev.h 2010-02-21 22:00:09 UTC (rev 4582) @@ -50,7 +50,6 @@ #define EV_WR POLLOUT #define EV_ERR POLLERR #define EV_HUP POLLHUP -#define EV_GONE POLLNVAL #define EV_SIG -1 int sig; unsigned sig_flags; Modified: trunk/varnish-cache/lib/libvarnishcompat/execinfo.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/execinfo.c 2010-02-21 20:36:31 UTC (rev 4581) +++ trunk/varnish-cache/lib/libvarnishcompat/execinfo.c 2010-02-21 22:00:09 UTC (rev 4582) @@ -45,97 +45,88 @@ #include #include - static void *getreturnaddr(int); static void *getframeaddr(int); -#define D10(x) ceil(log10(((x) == 0) ? 2 : ((x) + 1))) - -inline static void * -realloc_safe(void *ptr, size_t size) -{ - void *nptr; - - nptr = realloc(ptr, size); - if (nptr == NULL) - free(ptr); - return nptr; -} - int backtrace(void **buffer, int size) { - int i; + int i; - for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) { - buffer[i - 1] = getreturnaddr(i); - if (buffer[i - 1] == NULL) - break; - } - - return i - 1; + for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) { + buffer[i - 1] = getreturnaddr(i); + if (buffer[i - 1] == NULL) + break; + } + return (i - 1); } +/* + * XXX: This implementation should be changed to a much more conservative + * XXX: memory strategy: Allocate 4k up front, realloc 4K more as needed. + */ + char ** backtrace_symbols(void *const *buffer, int size) { - size_t clen, alen; - int i; - char **rval; + size_t clen, alen; + int i; + char **rval; - clen = size * sizeof(char *); - rval = malloc(clen); - if (rval == NULL) - return NULL; - for (i = 0; i < size; i++) { + clen = size * sizeof(char *); + rval = malloc(clen); + if (rval == NULL) + return (NULL); + for (i = 0; i < size; i++) { #ifdef HAVE_DLADDR - { - Dl_info info; - int offset; + { + Dl_info info; + int offset; - if (dladdr(buffer[i], &info) != 0) { - if (info.dli_sname == NULL) - info.dli_sname = "???"; - if (info.dli_saddr == NULL) - info.dli_saddr = buffer[i]; - offset = (const char*)buffer[i] - (const char*)info.dli_saddr; - /* "0x01234567 at filename" */ - alen = 2 + /* "0x" */ - (sizeof(void *) * 2) + /* "01234567" */ - 2 + /* " <" */ - strlen(info.dli_sname) + /* "function" */ - 1 + /* "+" */ - 10 + /* "offset */ - 5 + /* "> at " */ - strlen(info.dli_fname) + /* "filename" */ - 1; /* "\0" */ - rval = realloc_safe(rval, clen + alen); - if (rval == NULL) - return NULL; - snprintf((char *) rval + clen, alen, "%p <%s+%d> at %s", - buffer[i], info.dli_sname, offset, info.dli_fname); - rval[i] = (char *) clen; - clen += alen; - continue; - } - } + if (dladdr(buffer[i], &info) != 0) { + if (info.dli_sname == NULL) + info.dli_sname = "?"; + if (info.dli_saddr == NULL) + info.dli_saddr = buffer[i]; + offset = (const char*)buffer[i] - + (const char*)info.dli_saddr; + /* "0x01234567 at filename" */ + alen = 2 + /* "0x" */ + (sizeof(void *) * 2) + /* "01234567" */ + 2 + /* " <" */ + strlen(info.dli_sname) + /* "function" */ + 1 + /* "+" */ + 10 + /* "offset */ + 5 + /* "> at " */ + strlen(info.dli_fname) + /* "filename" */ + 1; /* "\0" */ + rval = realloc(rval, clen + alen); + if (rval == NULL) + return NULL; + (void)snprintf((char *) rval + clen, alen, + "%p <%s+%d> at %s", buffer[i], info.dli_sname, + offset, info.dli_fname); + rval[i] = (char *) clen; + clen += alen; + continue; + } + } #endif - alen = 2 + /* "0x" */ - (sizeof(void *) * 2) + /* "01234567" */ - 1; /* "\0" */ - rval = realloc_safe(rval, clen + alen); - if (rval == NULL) - return NULL; - snprintf((char *) rval + clen, alen, "%p", buffer[i]); - rval[i] = (char *) clen; - clen += alen; - } + alen = 2 + /* "0x" */ + (sizeof(void *) * 2) + /* "01234567" */ + 1; /* "\0" */ + rval = realloc(rval, clen + alen); + if (rval == NULL) + return NULL; + (void)snprintf((char *) rval + clen, alen, "%p", buffer[i]); + rval[i] = (char *) clen; + clen += alen; + } - for (i = 0; i < size; i++) - rval[i] += (long) rval; - - return rval; + for (i = 0; i < size; i++) + rval[i] += (long) rval; + return (rval); } static void * From phk at projects.linpro.no Mon Feb 22 21:12:53 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 22 Feb 2010 22:12:53 +0100 (CET) Subject: r4583 - trunk/varnish-cache/bin/varnishd Message-ID: <20100222211253.960D31F75BE@projects.linpro.no> Author: phk Date: 2010-02-22 22:12:53 +0100 (Mon, 22 Feb 2010) New Revision: 4583 Modified: trunk/varnish-cache/bin/varnishd/mgt_pool.c trunk/varnish-cache/bin/varnishd/varnishd.c Log: Respect PTHREAD_STACK_MIN for workerthread stack size. Modified: trunk/varnish-cache/bin/varnishd/mgt_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_pool.c 2010-02-21 22:00:09 UTC (rev 4582) +++ trunk/varnish-cache/bin/varnishd/mgt_pool.c 2010-02-22 21:12:53 UTC (rev 4583) @@ -191,10 +191,11 @@ EXPERIMENTAL, "3", "requests per request" }, { "thread_pool_stack", - tweak_uint, &master.wthread_stacksize, 64*1024, UINT_MAX, - "Worker thread stack size. In particular on 32bit systems " - "you may need to tweak this down to fit many threads into " - "the limited address space.\n", + tweak_uint, &master.wthread_stacksize, + PTHREAD_STACK_MIN, UINT_MAX, + "Worker thread stack size.\n" + "On 32bit systems you may need to tweak this down to fit " + "many threads into the limited address space.\n", EXPERIMENTAL, "-1", "bytes" }, { NULL, NULL, NULL } Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-21 22:00:09 UTC (rev 4582) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-22 21:12:53 UTC (rev 4583) @@ -587,7 +587,11 @@ */ MCF_ParamSet(cli, "sess_workspace", "16384"); cli_check(cli); - MCF_ParamSet(cli, "thread_pool_stack", "65536"); + + /* Set the stacksize to min(PTHREAD_STACK_MIN, 64k) */ + bprintf(dirname, "%d", + PTHREAD_STACK_MIN > 65536 ? PTHREAD_STACK_MIN : 65536); + MCF_ParamSet(cli, "thread_pool_stack", dirname); cli_check(cli); } From phk at projects.linpro.no Mon Feb 22 21:32:33 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 22 Feb 2010 22:32:33 +0100 (CET) Subject: r4584 - trunk/varnish-cache/bin/varnishd Message-ID: <20100222213233.9261C1F75C5@projects.linpro.no> Author: phk Date: 2010-02-22 22:32:33 +0100 (Mon, 22 Feb 2010) New Revision: 4584 Modified: trunk/varnish-cache/bin/varnishd/mgt_pool.c trunk/varnish-cache/bin/varnishd/varnishd.c Log: Sigh, POSIXed again: The minimum thread stack size is not a compile time constant on all systems. Pick it up with sysconf() instead. Modified: trunk/varnish-cache/bin/varnishd/mgt_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_pool.c 2010-02-22 21:12:53 UTC (rev 4583) +++ trunk/varnish-cache/bin/varnishd/mgt_pool.c 2010-02-22 21:32:33 UTC (rev 4584) @@ -44,7 +44,10 @@ #include "svnid.h" SVNID("$Id: cache_pool.c 3429 2008-11-24 17:47:21Z phk $") +#include +#include #include +#include #include #include "cli_priv.h" @@ -64,6 +67,33 @@ (unsigned)par->min, master.wthread_max); } +/*-------------------------------------------------------------------- + * This is utterly ridiculous: POSIX does not guarantee that the + * minimum thread stack size is a compile time constant. + * XXX: "32" is a magic marker for 32bit systems. + */ + +static void +tweak_stack_size(struct cli *cli, const struct parspec *par, + const char *arg) +{ + unsigned low, u; + char buf[12]; + + low = sysconf(_SC_THREAD_STACK_MIN); + + if (arg != NULL && !strcmp(arg, "32")) { + u = 65536; + if (u < low) + u = low; + sprintf(buf, "%u", u); + arg = buf; + } + + tweak_generic_uint(cli, &master.wthread_stacksize, arg, + low, (uint)par->max); +} + /*--------------------------------------------------------------------*/ static void @@ -191,8 +221,7 @@ EXPERIMENTAL, "3", "requests per request" }, { "thread_pool_stack", - tweak_uint, &master.wthread_stacksize, - PTHREAD_STACK_MIN, UINT_MAX, + tweak_stack_size, &master.wthread_stacksize, 0, UINT_MAX, "Worker thread stack size.\n" "On 32bit systems you may need to tweak this down to fit " "many threads into the limited address space.\n", @@ -200,4 +229,3 @@ "-1", "bytes" }, { NULL, NULL, NULL } }; - Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-22 21:12:53 UTC (rev 4583) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2010-02-22 21:32:33 UTC (rev 4584) @@ -588,10 +588,7 @@ MCF_ParamSet(cli, "sess_workspace", "16384"); cli_check(cli); - /* Set the stacksize to min(PTHREAD_STACK_MIN, 64k) */ - bprintf(dirname, "%d", - PTHREAD_STACK_MIN > 65536 ? PTHREAD_STACK_MIN : 65536); - MCF_ParamSet(cli, "thread_pool_stack", dirname); + MCF_ParamSet(cli, "thread_pool_stack", "32"); cli_check(cli); } From phk at projects.linpro.no Mon Feb 22 21:51:51 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 22 Feb 2010 22:51:51 +0100 (CET) Subject: r4585 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20100222215151.AA4D31F75C5@projects.linpro.no> Author: phk Date: 2010-02-22 22:51:51 +0100 (Mon, 22 Feb 2010) New Revision: 4585 Modified: trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc Log: Put an upper limit on how many threads to create Modified: trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc 2010-02-22 21:32:33 UTC (rev 4584) +++ trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc 2010-02-22 21:51:51 UTC (rev 4585) @@ -9,9 +9,10 @@ txresp -hdr "Connection: close" -body "012345\n" } -start -varnish v1 -arg "-p thread_pool_min=2 -p thread_pools=4" -vcl+backend {} -start +varnish v1 -arg "-p thread_pool_min=2 -p thread_pool_max=2 -p thread_pools=4" -delay 1 +varnish v1 -vcl+backend {} -start + varnish v1 -expect n_wrk_create == 8 client c1 { From phk at projects.linpro.no Wed Feb 24 10:49:26 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 24 Feb 2010 11:49:26 +0100 (CET) Subject: r4586 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20100224104926.69F231F75E3@projects.linpro.no> Author: phk Date: 2010-02-24 11:49:25 +0100 (Wed, 24 Feb 2010) New Revision: 4586 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00008.vtc Log: More coverage of cli_serve.c Modified: trunk/varnish-cache/bin/varnishtest/tests/b00008.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00008.vtc 2010-02-22 21:51:51 UTC (rev 4585) +++ trunk/varnish-cache/bin/varnishtest/tests/b00008.vtc 2010-02-24 10:49:25 UTC (rev 4586) @@ -6,6 +6,20 @@ varnish v1 -cliok "help" +varnish v1 -cliok "help -a" + +varnish v1 -cliok "help -d" + +varnish v1 -cliok "help vcl.load" + +varnish v1 -cliok "help purge" + +varnish v1 -clierr 101 "FOO?" + +varnish v1 -clierr 100 "\x22" + +varnish v1 -clierr 105 "help 1 2 3" + varnish v1 -cliok "param.show" varnish v1 -cliok "param.show diag_bitmap" From phk at projects.linpro.no Fri Feb 26 08:57:01 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 09:57:01 +0100 (CET) Subject: r4587 - trunk/varnish-cache/bin/varnishadm Message-ID: <20100226085701.325811F75D7@projects.linpro.no> Author: phk Date: 2010-02-26 09:57:00 +0100 (Fri, 26 Feb 2010) New Revision: 4587 Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.c Log: Use our nice library routines instead of home-rolling. Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.c =================================================================== --- trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-02-24 10:49:25 UTC (rev 4586) +++ trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-02-26 08:57:00 UTC (rev 4587) @@ -37,48 +37,11 @@ #include #include +#include "cli.h" +#include "cli_common.h" #include "libvarnish.h" #include "vss.h" -#define STATUS_OK 200 - -static void -parse_reply(int sock, long *status, long *answerlen, char **answer) -{ - int n; - char buf[13]; - char *p, *pp; - - n = read(sock, buf, 13); - if (n != 13) { - fprintf(stderr, "An error occured in receiving status.\n"); - exit(1); - } - if (!(p = strchr(buf, ' '))) { - fprintf(stderr, - "An error occured in parsing of status code.\n"); - exit(1); - } - *p = '\0'; - *status = strtol(buf, &p, 10); - pp = p+1; - if (!(p = strchr(pp, '\n'))) { - fprintf(stderr, "An error occured " - "in parsing of number of bytes returned.\n"); - exit(1); - } - *p = '\0'; - *answerlen = strtol(pp, &p, 10); - - *answer = malloc(*answerlen+1); - n = read(sock, *answer, *answerlen); - read(sock, buf, 1); /* Read the trailing \n */ - if (n != *answerlen) { - fprintf(stderr, "An error occured in receiving answer.\n"); - exit(1); - } -} - /* * This function establishes a connection to the specified ip and port and * sends a command to varnishd. If varnishd returns an OK status, the result @@ -92,7 +55,7 @@ char *addr, *port; int i, n; int sock; - long status, bytes; + unsigned status; char *answer = NULL; XXXAZ(VSS_parse(T_arg, &addr, &port)); @@ -112,22 +75,21 @@ } free(ta); - write(sock, "ping\n", 5); - parse_reply(sock, &status, &bytes, &answer); - if (status != 200) { - fprintf(stderr, "No pong received from server\n"); - exit(1); + cli_readres(sock, &status, &answer, 2000); + if (status == CLIS_AUTH) { + fprintf(stderr, "Authentication required\n"); + exit(1); } + if (status != CLIS_OK) { + fprintf(stderr, "No pong received from server\n"); + exit(1); + } - if (strstr(answer, "PONG") == NULL) { - /* The first one was probably just the banner, - see if there are more replies.*/ - free(answer); - parse_reply(sock, &status, &bytes, &answer); - if (status != 200 || strstr(answer, "PONG") == NULL) { - fprintf(stderr, "No pong received from server\n"); - exit(1); - } + write(sock, "ping\n", 5); + cli_readres(sock, &status, &answer, 2000); + if (status != CLIS_OK || strstr(answer, "PONG") == NULL) { + fprintf(stderr, "No pong received from server\n"); + exit(1); } free(answer); @@ -138,16 +100,15 @@ } write(sock, "\n", 1); - parse_reply(sock, &status, &bytes, &answer); + cli_readres(sock, &status, &answer, 2000); - answer[bytes] = '\0'; close(sock); - if (status == STATUS_OK) { + if (status == CLIS_OK) { printf("%s\n", answer); exit(0); } - fprintf(stderr, "Command failed with error code %ld\n", status); + fprintf(stderr, "Command failed with error code %u\n", status); exit(1); } From phk at projects.linpro.no Fri Feb 26 09:35:42 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 10:35:42 +0100 (CET) Subject: r4588 - in trunk/varnish-cache: bin/varnishtest include lib/libvarnish Message-ID: <20100226093542.691F91F75D9@projects.linpro.no> Author: phk Date: 2010-02-26 10:35:42 +0100 (Fri, 26 Feb 2010) New Revision: 4588 Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/include/vss.h trunk/varnish-cache/lib/libvarnish/cli_common.c trunk/varnish-cache/lib/libvarnish/vss.c Log: Give VSS_open() a timeout argument. Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2010-02-26 08:57:00 UTC (rev 4587) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2010-02-26 09:35:42 UTC (rev 4588) @@ -97,10 +97,10 @@ vtc_log(vl, 2, "Started (%u iterations)", c->repeat); for (u = 0; u < c->repeat; u++) { vtc_log(vl, 3, "Connect to %s", vsb_data(vsb)); - fd = VSS_open(vsb_data(vsb)); + fd = VSS_open(vsb_data(vsb), 0); for (i = 0; fd < 0 && i < 3; i++) { (void)sleep(1); - fd = VSS_open(vsb_data(vsb)); + fd = VSS_open(vsb_data(vsb), 0); } if (fd < 0) vtc_log(c->vl, 0, "Failed to open %s", vsb_data(vsb)); Modified: trunk/varnish-cache/include/vss.h =================================================================== --- trunk/varnish-cache/include/vss.h 2010-02-26 08:57:00 UTC (rev 4587) +++ trunk/varnish-cache/include/vss.h 2010-02-26 09:35:42 UTC (rev 4588) @@ -35,4 +35,4 @@ int VSS_bind(const struct vss_addr *addr); int VSS_listen(const struct vss_addr *addr, int depth); int VSS_connect(const struct vss_addr *addr, int nonblock); -int VSS_open(const char *str); +int VSS_open(const char *str, double tmo); Modified: trunk/varnish-cache/lib/libvarnish/cli_common.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/cli_common.c 2010-02-26 08:57:00 UTC (rev 4587) +++ trunk/varnish-cache/lib/libvarnish/cli_common.c 2010-02-26 09:35:42 UTC (rev 4588) @@ -156,7 +156,7 @@ *ptr = strdup("CLI communication error (hdr)"); if (i != 0) return (i); - return (400); + return (*status); } assert(i == CLI_LINE0_LEN); assert(res[3] == ' '); Modified: trunk/varnish-cache/lib/libvarnish/vss.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vss.c 2010-02-26 08:57:00 UTC (rev 4587) +++ trunk/varnish-cache/lib/libvarnish/vss.c 2010-02-26 09:35:42 UTC (rev 4588) @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -264,12 +265,13 @@ */ int -VSS_open(const char *str) +VSS_open(const char *str, double tmo) { int retval; char *addr = NULL, *port = NULL; - int nvaddr, n; + int nvaddr, n, i; struct vss_addr **vaddr; + struct pollfd pfd; retval = VSS_parse(str, &addr, &port); if (retval < 0) @@ -281,7 +283,16 @@ return (-1); } for (n = 0; n < nvaddr; n++) { - retval = VSS_connect(vaddr[n], 0); + retval = VSS_connect(vaddr[n], tmo != 0.0); + if (retval >= 0 && tmo != 0.0) { + pfd.fd = retval; + pfd.events = POLLOUT; + i = poll(&pfd, 1, tmo * 1e3); + if (i == 0 || pfd.revents != POLLOUT) { + (void)close(retval); + retval = -1; + } + } if (retval >= 0) break; } From phk at projects.linpro.no Fri Feb 26 09:37:57 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 10:37:57 +0100 (CET) Subject: r4589 - trunk/varnish-cache/bin/varnishadm Message-ID: <20100226093757.AA1B11F75D9@projects.linpro.no> Author: phk Date: 2010-02-26 10:37:57 +0100 (Fri, 26 Feb 2010) New Revision: 4589 Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.1 trunk/varnish-cache/bin/varnishadm/varnishadm.c Log: Give varnishadm a -t argument, to set a timeout for operations. Use VSS_open() instead of home-rolling. Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.1 =================================================================== --- trunk/varnish-cache/bin/varnishadm/varnishadm.1 2010-02-26 09:35:42 UTC (rev 4588) +++ trunk/varnish-cache/bin/varnishadm/varnishadm.1 2010-02-26 09:37:57 UTC (rev 4589) @@ -36,6 +36,7 @@ .Nd Control a running varnish instance .Sh SYNOPSIS .Nm +.Op Fl t Ar timeout .Fl T Ar address Ns : Ns Ar port .Cm command .Op Ar ... @@ -48,6 +49,8 @@ .Pp The following options are available: .Bl -tag -width Fl +.It Fl t Ar timeout +Wait no longer than this many seconds for an operation to finish. .It Fl T Ar address Ns : Ns Ar port Connect to the management interface at the specified address and port. .El Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.c =================================================================== --- trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-02-26 09:35:42 UTC (rev 4588) +++ trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-02-26 09:37:57 UTC (rev 4589) @@ -42,6 +42,8 @@ #include "libvarnish.h" #include "vss.h" +static double timeout = 5; + /* * This function establishes a connection to the specified ip and port and * sends a command to varnishd. If varnishd returns an OK status, the result @@ -51,31 +53,18 @@ static void telnet_mgt(const char *T_arg, int argc, char *argv[]) { - struct vss_addr **ta; - char *addr, *port; - int i, n; + int i; int sock; unsigned status; char *answer = NULL; - XXXAZ(VSS_parse(T_arg, &addr, &port)); - XXXAN(n = VSS_resolve(addr, port, &ta)); - free(addr); - free(port); - if (n == 0) { - fprintf(stderr, "Could not resolve '%s'\n", T_arg); - exit(2); + sock = VSS_open(T_arg, timeout); + if (sock < 0) { + fprintf(stderr, "Connection failed\n"); + exit(1); } - sock = VSS_connect(ta[0], 0); - - for (i = 0; i < n; ++i) { - free(ta[i]); - ta[i] = NULL; - } - free(ta); - - cli_readres(sock, &status, &answer, 2000); + cli_readres(sock, &status, &answer, timeout); if (status == CLIS_AUTH) { fprintf(stderr, "Authentication required\n"); exit(1); @@ -86,7 +75,7 @@ } write(sock, "ping\n", 5); - cli_readres(sock, &status, &answer, 2000); + cli_readres(sock, &status, &answer, timeout); if (status != CLIS_OK || strstr(answer, "PONG") == NULL) { fprintf(stderr, "No pong received from server\n"); exit(1); @@ -117,7 +106,7 @@ usage(void) { fprintf(stderr, - "usage: varnishadm -T [address]:port command [...]\n"); + "usage: varnishadm [-t timeout] -T [address]:port command [...]\n"); exit(1); } @@ -127,11 +116,14 @@ const char *T_arg = NULL; int opt; - while ((opt = getopt(argc, argv, "T:")) != -1) { + while ((opt = getopt(argc, argv, "T:t:")) != -1) { switch (opt) { case 'T': T_arg = optarg; break; + case 't': + timeout = strtod(optarg, NULL); + break; default: usage(); } From phk at projects.linpro.no Fri Feb 26 12:04:06 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 13:04:06 +0100 (CET) Subject: r4590 - in trunk/varnish-cache: include lib/libvarnish Message-ID: <20100226120406.798EA1F75F0@projects.linpro.no> Author: phk Date: 2010-02-26 13:04:06 +0100 (Fri, 26 Feb 2010) New Revision: 4590 Added: trunk/varnish-cache/lib/libvarnish/cli_auth.c Modified: trunk/varnish-cache/include/cli_common.h trunk/varnish-cache/lib/libvarnish/Makefile.am Log: Add a function to calculate the proper response to a AUTH challenge from the CLI. Put in a separate source file, as it should be included in libvarnishapi as well. Modified: trunk/varnish-cache/include/cli_common.h =================================================================== --- trunk/varnish-cache/include/cli_common.h 2010-02-26 09:37:57 UTC (rev 4589) +++ trunk/varnish-cache/include/cli_common.h 2010-02-26 12:04:06 UTC (rev 4590) @@ -47,3 +47,5 @@ int cli_writeres(int fd, const struct cli *cli); int cli_readres(int fd, unsigned *status, char **ptr, double tmo); + +void CLI_response(int S_fd, const char *challenge, char *reponse); Modified: trunk/varnish-cache/lib/libvarnish/Makefile.am =================================================================== --- trunk/varnish-cache/lib/libvarnish/Makefile.am 2010-02-26 09:37:57 UTC (rev 4589) +++ trunk/varnish-cache/lib/libvarnish/Makefile.am 2010-02-26 12:04:06 UTC (rev 4590) @@ -11,6 +11,7 @@ assert.c \ binary_heap.c \ subproc.c \ + cli_auth.c \ cli_common.c \ cli_serve.c \ flopen.c \ Added: trunk/varnish-cache/lib/libvarnish/cli_auth.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/cli_auth.c (rev 0) +++ trunk/varnish-cache/lib/libvarnish/cli_auth.c 2010-02-26 12:04:06 UTC (rev 4590) @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 2010 Linpro AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * 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. + */ + +#include "config.h" + +#include "svnid.h" +SVNID("$Id$"); + +#include +#include +#include +#include +#include + +#include "cli.h" +#include "cli_common.h" +#include "vsha256.h" + +void +CLI_response(int S_fd, const char *challenge, char *response) +{ + SHA256_CTX ctx; + uint8_t buf[BUFSIZ]; + int i; + + SHA256_Init(&ctx); + SHA256_Update(&ctx, challenge, 32); + SHA256_Update(&ctx, "\n", 1); + do { + i = read(S_fd, buf, sizeof buf); + if (i > 0) + SHA256_Update(&ctx, buf, i); + } while (i > 0); + SHA256_Update(&ctx, challenge, 32); + SHA256_Update(&ctx, "\n", 1); + SHA256_Final(buf, &ctx); + for(i = 0; i < SHA256_LEN; i++) + sprintf(response + 2 * i, "%02x", buf[i]); +} From phk at projects.linpro.no Fri Feb 26 12:12:00 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 13:12:00 +0100 (CET) Subject: r4591 - in trunk/varnish-cache: include lib/libvarnish Message-ID: <20100226121200.34AF01F75F0@projects.linpro.no> Author: phk Date: 2010-02-26 13:12:00 +0100 (Fri, 26 Feb 2010) New Revision: 4591 Modified: trunk/varnish-cache/include/cli_common.h trunk/varnish-cache/lib/libvarnish/cli_auth.c Log: Make the response argument a #defined size buffer, and assert that the #define is correct. Modified: trunk/varnish-cache/include/cli_common.h =================================================================== --- trunk/varnish-cache/include/cli_common.h 2010-02-26 12:04:06 UTC (rev 4590) +++ trunk/varnish-cache/include/cli_common.h 2010-02-26 12:12:00 UTC (rev 4591) @@ -48,4 +48,7 @@ int cli_writeres(int fd, const struct cli *cli); int cli_readres(int fd, unsigned *status, char **ptr, double tmo); -void CLI_response(int S_fd, const char *challenge, char *reponse); +#define CLI_AUTH_RESPONSE_LEN 65 /* 64 hex + NUL */ + +void CLI_response(int S_fd, const char *challenge, + char reponse[CLI_AUTH_RESPONSE_LEN]); Modified: trunk/varnish-cache/lib/libvarnish/cli_auth.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/cli_auth.c 2010-02-26 12:04:06 UTC (rev 4590) +++ trunk/varnish-cache/lib/libvarnish/cli_auth.c 2010-02-26 12:12:00 UTC (rev 4591) @@ -32,6 +32,7 @@ SVNID("$Id$"); #include +#include #include #include #include @@ -41,13 +42,17 @@ #include "cli_common.h" #include "vsha256.h" + void -CLI_response(int S_fd, const char *challenge, char *response) +CLI_response(int S_fd, const char *challenge, + char response[CLI_AUTH_RESPONSE_LEN]) { SHA256_CTX ctx; uint8_t buf[BUFSIZ]; int i; + assert(CLI_AUTH_RESPONSE_LEN == (SHA256_LEN * 2 + 1)); + SHA256_Init(&ctx); SHA256_Update(&ctx, challenge, 32); SHA256_Update(&ctx, "\n", 1); From phk at projects.linpro.no Fri Feb 26 12:17:31 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 13:17:31 +0100 (CET) Subject: r4592 - trunk/varnish-cache/bin/varnishd Message-ID: <20100226121731.EC3831F75F0@projects.linpro.no> Author: phk Date: 2010-02-26 13:17:31 +0100 (Fri, 26 Feb 2010) New Revision: 4592 Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c Log: Use the library function to check the authentication response. Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-26 12:12:00 UTC (rev 4591) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-26 12:17:31 UTC (rev 4592) @@ -55,7 +55,6 @@ #include "cli_common.h" #include "cli_serve.h" #include "vev.h" -#include "vsha256.h" #include "shmlog.h" #include "vlu.h" #include "vss.h" @@ -289,10 +288,8 @@ static void mcf_auth(struct cli *cli, const char *const *av, void *priv) { - char buf[1025]; - int i, fd; - struct SHA256Context sha256ctx; - unsigned char digest[SHA256_LEN]; + int fd; + char buf[CLI_AUTH_RESPONSE_LEN]; AN(av[2]); (void)priv; @@ -304,33 +301,8 @@ cli_result(cli, CLIS_CANT); return; } - i = read(fd, buf, sizeof buf); - if (i == 0) { - cli_out(cli, "Empty secret file"); - cli_result(cli, CLIS_CANT); - return; - } - if (i < 0) { - cli_out(cli, "Read error on secret file (%s)\n", - strerror(errno)); - cli_result(cli, CLIS_CANT); - return; - } - if (i == sizeof buf) { - cli_out(cli, "Secret file too long (> %d)\n", - sizeof buf - 1); - cli_result(cli, CLIS_CANT); - return; - } - buf[i] = '\0'; + CLI_response(fd, cli->challenge, buf); AZ(close(fd)); - SHA256_Init(&sha256ctx); - SHA256_Update(&sha256ctx, cli->challenge, strlen(cli->challenge)); - SHA256_Update(&sha256ctx, buf, i); - SHA256_Update(&sha256ctx, cli->challenge, strlen(cli->challenge)); - SHA256_Final(digest, &sha256ctx); - for (i = 0; i < SHA256_LEN; i++) - sprintf(buf + i + i, "%02x", digest[i]); if (strcasecmp(buf, av[2])) { mgt_cli_challenge(cli); return; From phk at projects.linpro.no Fri Feb 26 12:18:44 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 13:18:44 +0100 (CET) Subject: r4593 - trunk/varnish-cache/bin/varnishadm Message-ID: <20100226121844.96F0B1F75F0@projects.linpro.no> Author: phk Date: 2010-02-26 13:18:44 +0100 (Fri, 26 Feb 2010) New Revision: 4593 Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.1 trunk/varnish-cache/bin/varnishadm/varnishadm.c Log: Add "-S secret_file" support to varnishadm. Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.1 =================================================================== --- trunk/varnish-cache/bin/varnishadm/varnishadm.1 2010-02-26 12:17:31 UTC (rev 4592) +++ trunk/varnish-cache/bin/varnishadm/varnishadm.1 2010-02-26 12:18:44 UTC (rev 4593) @@ -37,6 +37,7 @@ .Sh SYNOPSIS .Nm .Op Fl t Ar timeout +.Op Fl S Ar secret_file .Fl T Ar address Ns : Ns Ar port .Cm command .Op Ar ... @@ -51,6 +52,8 @@ .Bl -tag -width Fl .It Fl t Ar timeout Wait no longer than this many seconds for an operation to finish. +.It Fl S Ar secret_file +Specify the authentication secret file .It Fl T Ar address Ns : Ns Ar port Connect to the management interface at the specified address and port. .El Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.c =================================================================== --- trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-02-26 12:17:31 UTC (rev 4592) +++ trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-02-26 12:18:44 UTC (rev 4593) @@ -32,6 +32,7 @@ #include "svnid.h" SVNID("$Id$") +#include #include #include #include @@ -51,12 +52,13 @@ * returned */ static void -telnet_mgt(const char *T_arg, int argc, char *argv[]) +telnet_mgt(const char *T_arg, const char *S_arg, int argc, char *argv[]) { - int i; + int i, fd; int sock; unsigned status; char *answer = NULL; + char buf[CLI_AUTH_RESPONSE_LEN]; sock = VSS_open(T_arg, timeout); if (sock < 0) { @@ -66,11 +68,25 @@ cli_readres(sock, &status, &answer, timeout); if (status == CLIS_AUTH) { - fprintf(stderr, "Authentication required\n"); - exit(1); + if (S_arg == NULL) { + fprintf(stderr, "Authentication required\n"); + exit(1); + } + fd = open(S_arg, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "Cannot open \"%s\": %s\n", + S_arg, strerror(errno)); + exit (1); + } + CLI_response(fd, answer, buf); + AZ(close(fd)); + write(sock, "auth ", 5); + write(sock, buf, strlen(buf)); + write(sock, "\n", 1); + cli_readres(sock, &status, &answer, timeout); } if (status != CLIS_OK) { - fprintf(stderr, "No pong received from server\n"); + fprintf(stderr, "Rejected %u\n%s\n", status, answer); exit(1); } @@ -106,7 +122,7 @@ usage(void) { fprintf(stderr, - "usage: varnishadm [-t timeout] -T [address]:port command [...]\n"); + "usage: varnishadm [-t timeout] [-S secretfile] -T [address]:port command [...]\n"); exit(1); } @@ -114,10 +130,14 @@ main(int argc, char *argv[]) { const char *T_arg = NULL; + const char *S_arg = NULL; int opt; - while ((opt = getopt(argc, argv, "T:t:")) != -1) { + while ((opt = getopt(argc, argv, "S:T:t:")) != -1) { switch (opt) { + case 'S': + S_arg = optarg; + break; case 'T': T_arg = optarg; break; @@ -135,7 +155,7 @@ if (T_arg == NULL || argc < 1) usage(); - telnet_mgt(T_arg, argc, argv); + telnet_mgt(T_arg, S_arg, argc, argv); exit(0); } From phk at projects.linpro.no Fri Feb 26 19:16:07 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 20:16:07 +0100 (CET) Subject: r4594 - trunk/varnish-cache/lib/libvarnish Message-ID: <20100226191607.3A5B21F75CC@projects.linpro.no> Author: phk Date: 2010-02-26 20:16:06 +0100 (Fri, 26 Feb 2010) New Revision: 4594 Modified: trunk/varnish-cache/lib/libvarnish/cli_auth.c Log: Clean up #includes Modified: trunk/varnish-cache/lib/libvarnish/cli_auth.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/cli_auth.c 2010-02-26 12:18:44 UTC (rev 4593) +++ trunk/varnish-cache/lib/libvarnish/cli_auth.c 2010-02-26 19:16:06 UTC (rev 4594) @@ -32,14 +32,12 @@ SVNID("$Id$"); #include -#include #include #include -#include -#include #include "cli.h" #include "cli_common.h" +#include "libvarnish.h" #include "vsha256.h" From phk at projects.linpro.no Fri Feb 26 19:16:39 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 20:16:39 +0100 (CET) Subject: r4595 - trunk/varnish-cache/bin/varnishtest Message-ID: <20100226191639.C806A1F75CC@projects.linpro.no> Author: phk Date: 2010-02-26 20:16:39 +0100 (Fri, 26 Feb 2010) New Revision: 4595 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Use -S with varnishtest Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-26 19:16:06 UTC (rev 4594) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2010-02-26 19:16:39 UTC (rev 4595) @@ -88,13 +88,14 @@ macro_def(struct vtclog *vl, const char *instance, const char *name, const char *fmt, ...) { - char buf[256]; + char buf1[256]; + char buf2[256]; struct macro *m; va_list ap; if (instance != NULL) { - bprintf(buf, "%s_%s", instance, name); - name = buf; + bprintf(buf1, "%s_%s", instance, name); + name = buf1; } AZ(pthread_mutex_lock(¯o_mtx)); @@ -112,9 +113,9 @@ va_start(ap, fmt); free(m->val); m->val = NULL; - vbprintf(buf, fmt, ap); + vbprintf(buf2, fmt, ap); va_end(ap); - m->val = strdup(buf); + m->val = strdup(buf2); AN(m->val); vtc_log(vl, 4, "macro def %s=%s", name, m->val); } else if (m != NULL) { Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-02-26 19:16:06 UTC (rev 4594) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-02-26 19:16:39 UTC (rev 4595) @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -92,11 +93,13 @@ unsigned retval; char *r; - vtc_dump(v->vl, 4, "CLI TX", cmd); - i = write(v->cli_fd, cmd, strlen(cmd)); - assert(i == strlen(cmd)); - i = write(v->cli_fd, "\n", 1); - assert(i == 1); + if (cmd != NULL) { + vtc_dump(v->vl, 4, "CLI TX", cmd); + i = write(v->cli_fd, cmd, strlen(cmd)); + assert(i == strlen(cmd)); + i = write(v->cli_fd, "\n", 1); + assert(i == 1); + } i = cli_readres(v->cli_fd, &retval, &r, 20.0); if (i != 0) { vtc_log(v->vl, 0, "CLI failed (%s) = %d %u %s", @@ -104,8 +107,8 @@ return ((enum cli_status_e)retval); } assert(i == 0); + vtc_log(v->vl, 3, "CLI RX %u", retval); vtc_dump(v->vl, 4, "CLI RX", r); - vtc_log(v->vl, 3, "CLI STATUS (%s) %u", cmd, retval); if (repl != NULL) *repl = r; else @@ -154,7 +157,8 @@ v->workdir = strdup(buf); AN(v->workdir); - bprintf(buf, "rm -rf %s ; mkdir -p %s", v->workdir, v->workdir); + bprintf(buf, "rm -rf %s ; mkdir -p %s ; echo ' %ld' > %s/_S", + v->workdir, v->workdir, random(), v->workdir); AZ(system(buf)); v->vl = vtc_logopen(name); @@ -241,9 +245,9 @@ struct vsb *vsb; int i, nfd, nap; struct vss_addr **ap; - char abuf[128],pbuf[128]; + char abuf[128], pbuf[128]; struct pollfd fd; - unsigned retval; + enum cli_status_e u; char *r; /* Create listener socket */ @@ -262,6 +266,7 @@ vsb_printf(vsb, " -p auto_restart=off"); vsb_printf(vsb, " -p syslog_cli_traffic=off"); vsb_printf(vsb, " -a '%s'", "127.0.0.1:0"); + vsb_printf(vsb, " -S %s/_S", v->workdir); vsb_printf(vsb, " -M %s:%s", abuf, pbuf); vsb_printf(vsb, " -P %s/varnishd.pid", v->workdir); vsb_printf(vsb, " %s", vsb_data(v->args)); @@ -312,16 +317,37 @@ AZ(close(v->cli_fd)); v->cli_fd = nfd; + nfd = -1; vtc_log(v->vl, 3, "CLI connection fd = %d", v->cli_fd); assert(v->cli_fd >= 0); - i = cli_readres(v->cli_fd, &retval, &r, 20.0); - if (i != 0 || retval != CLIS_OK) - vtc_log(v->vl, 0, "CLI banner fail", v->cli_fd); - vtc_log(v->vl, 4, "CLI banner %03u", retval); + + /* Receive the banner or auth response */ + u = varnish_ask_cli(v, NULL, &r); + if (vtc_error) + return; + if (u != CLIS_AUTH) + vtc_log(v->vl, 0, "CLI auth demand expected: %u %s", u, r); + + bprintf(abuf, "%s/_S", v->workdir); + nfd = open(abuf, O_RDONLY); + assert(nfd >= 0); + + assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 6); + strcpy(abuf, "auth "); + CLI_response(nfd, r, abuf + 5); + AZ(close(nfd)); free(r); + strcat(abuf, "\n"); + u = varnish_ask_cli(v, abuf, &r); + if (vtc_error) + return; + if (u != CLIS_OK) + vtc_log(v->vl, 0, "CLI auth command failed: %u %s", u, r); + free(r); + if (v->stats != NULL) VSL_Close(); v->stats = VSL_OpenStats(v->workdir); From phk at projects.linpro.no Fri Feb 26 19:17:58 2010 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 26 Feb 2010 20:17:58 +0100 (CET) Subject: r4596 - trunk/varnish-cache/bin/varnishadm Message-ID: <20100226191758.22AB61F75CC@projects.linpro.no> Author: phk Date: 2010-02-26 20:17:57 +0100 (Fri, 26 Feb 2010) New Revision: 4596 Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.1 trunk/varnish-cache/bin/varnishadm/varnishadm.c Log: Add a "pass" mode, where varnishadm just passes your commands, but does handle the -S authentication for you. You can now get a secure remote CLI connection by: ssh foohost varnisadm -T :8081 -S/etc/varnish_secret Or you can: echo "help" | ssh foohost varnisadm -T :8081 -S/etc/varnish_secret Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.1 =================================================================== --- trunk/varnish-cache/bin/varnishadm/varnishadm.1 2010-02-26 19:16:39 UTC (rev 4595) +++ trunk/varnish-cache/bin/varnishadm/varnishadm.1 2010-02-26 19:17:57 UTC (rev 4596) @@ -39,21 +39,40 @@ .Op Fl t Ar timeout .Op Fl S Ar secret_file .Fl T Ar address Ns : Ns Ar port -.Cm command -.Op Ar ... +.Op Cm command Op Ar ... .Sh DESCRIPTION The .Nm -utility sends the given command and arguments to the -.Xr varnishd 1 -instance at the specified address and port and prints the results. +utility establishes a CLI connection using the +.Fl T +and +.Fl S +arguments. .Pp +If a +.Cm command +is given, the command and arguments are sent over the +CLI connection and the result returned on stdout. +.Pp +If no +.Cm command +argument is given +.Nm +will pass commands and replies between the CLI socket and +stdin/stdout. +.Pp The following options are available: .Bl -tag -width Fl .It Fl t Ar timeout Wait no longer than this many seconds for an operation to finish. .It Fl S Ar secret_file -Specify the authentication secret file +Specify the authentication secret file. +.Pp +This should be the same -S argument as was given to +.Nm varnishd . +.Pp +Only processes which can read the contents of this file, will be able +to authenticate the CLI connection. .It Fl T Ar address Ns : Ns Ar port Connect to the management interface at the specified address and port. .El @@ -67,9 +86,20 @@ .Cm param.show command. .Sh EXIT STATUS -The exit status of the +If a +.Cm command +is given, +the exit status of the .Nm utility is zero if the command succeeded, and non-zero otherwise. +.Sh EXAMPLES +Some ways you can use varnishadm: +.Pp +.Dl varnishadm -T localhost:999 -S /var/db/secret vcl.use foo +.Pp +.Dl echo vcl.use foo | varnishadm -T localhost:999 -S /var/db/secret +.Pp +.Dl echo vcl.use foo | ssh vhost varnishadm -T localhost:999 -S /var/db/secret .Sh SEE ALSO .Xr varnishd 1 .Sh HISTORY Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.c =================================================================== --- trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-02-26 19:16:39 UTC (rev 4595) +++ trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-02-26 19:17:57 UTC (rev 4596) @@ -33,11 +33,14 @@ SVNID("$Id$") #include +#include #include #include #include #include +#include + #include "cli.h" #include "cli_common.h" #include "libvarnish.h" @@ -45,16 +48,29 @@ static double timeout = 5; +static void +cli_write(int sock, const char *s) +{ + int i, l; + + i = strlen(s); + l = write (sock, s, i); + if (i == l) + return; + perror("Write error CLI socket"); + exit (1); +} + /* * This function establishes a connection to the specified ip and port and * sends a command to varnishd. If varnishd returns an OK status, the result * is printed and 0 returned. Else, an error message is printed and 1 is * returned */ -static void -telnet_mgt(const char *T_arg, const char *S_arg, int argc, char *argv[]) +static int +cli_sock(const char *T_arg, const char *S_arg) { - int i, fd; + int fd; int sock; unsigned status; char *answer = NULL; @@ -66,7 +82,7 @@ exit(1); } - cli_readres(sock, &status, &answer, timeout); + (void)cli_readres(sock, &status, &answer, timeout); if (status == CLIS_AUTH) { if (S_arg == NULL) { fprintf(stderr, "Authentication required\n"); @@ -80,58 +96,125 @@ } CLI_response(fd, answer, buf); AZ(close(fd)); - write(sock, "auth ", 5); - write(sock, buf, strlen(buf)); - write(sock, "\n", 1); - cli_readres(sock, &status, &answer, timeout); + free(answer); + + cli_write(sock, "auth "); + cli_write(sock, buf); + cli_write(sock, "\n"); + (void)cli_readres(sock, &status, &answer, timeout); } if (status != CLIS_OK) { fprintf(stderr, "Rejected %u\n%s\n", status, answer); exit(1); } + free(answer); - write(sock, "ping\n", 5); - cli_readres(sock, &status, &answer, timeout); + cli_write(sock, "ping\n"); + (void)cli_readres(sock, &status, &answer, timeout); if (status != CLIS_OK || strstr(answer, "PONG") == NULL) { fprintf(stderr, "No pong received from server\n"); exit(1); } free(answer); + return (sock); +} + +static void +do_args(int sock, int argc, char * const *argv) +{ + int i; + unsigned status; + char *answer = NULL; + for (i=0; i 0) - write(sock, " ", 1); - write(sock, argv[i], strlen(argv[i])); + cli_write(sock, " "); + cli_write(sock, argv[i]); } - write(sock, "\n", 1); + cli_write(sock, "\n"); - cli_readres(sock, &status, &answer, 2000); + (void)cli_readres(sock, &status, &answer, 2000); - close(sock); + /* XXX: AZ() ? */ + (void)close(sock); + printf("%s\n", answer); if (status == CLIS_OK) { - printf("%s\n", answer); exit(0); } fprintf(stderr, "Command failed with error code %u\n", status); exit(1); +} +/* + * No arguments given, simply pass bytes on stdin/stdout and CLI socket + * Send a "banner" to varnish, to provoke a welcome message. + */ +static void +pass(int sock) +{ + struct pollfd fds[2]; + char buf[1024]; + int i, n, m; + + cli_write(sock, "banner\n"); + fds[0].fd = sock; + fds[0].events = POLLIN; + fds[1].fd = 0; + fds[1].events = POLLIN; + while (1) { + i = poll(fds, 2, -1); + assert(i > 0); + if (fds[0].revents & POLLIN) { + n = read(fds[0].fd, buf, sizeof buf); + if (n == 0) + exit (0); + if (n < 0) { + perror("Read error reading CLI socket"); + exit (0); + } + assert(n > 0); + m = write(1, buf, n); + if (n != m) { + perror("Write error writing stdout"); + exit (1); + } + } + if (fds[1].revents & POLLIN) { + n = read(fds[1].fd, buf, sizeof buf); + if (n == 0) { + AZ(shutdown(sock, SHUT_WR)); + fds[1].fd = -1; + } else if (n < 0) { + exit(0); + } else { + m = write(sock, buf, n); + if (n != m) { + perror("Write error writing CLI socket"); + exit (1); + } + } + } + } } static void usage(void) { fprintf(stderr, - "usage: varnishadm [-t timeout] [-S secretfile] -T [address]:port command [...]\n"); + "usage: varnishadm [-t timeout] [-S secretfile] " + "-T [address]:port command [...]\n"); exit(1); } int -main(int argc, char *argv[]) +main(int argc, char * const *argv) { const char *T_arg = NULL; const char *S_arg = NULL; - int opt; + int opt, sock; while ((opt = getopt(argc, argv, "S:T:t:")) != -1) { switch (opt) { @@ -152,10 +235,16 @@ argc -= optind; argv += optind; - if (T_arg == NULL || argc < 1) + if (T_arg == NULL) usage(); - telnet_mgt(T_arg, S_arg, argc, argv); + assert(T_arg != NULL); + sock = cli_sock(T_arg, S_arg); + if (argc > 0) + do_args(sock, argc, argv); + else + pass(sock); + exit(0); }