From daghf at varnish-cache.org Tue Oct 9 13:01:59 2012 From: daghf at varnish-cache.org (Dag Haavi Finstad) Date: Tue, 09 Oct 2012 15:01:59 +0200 Subject: [3.0] 3a63dd0 Typo in tutorial Message-ID: commit 3a63dd0fbc90eeb3e19c5cf1acbd2c1d373993c2 Author: Dag Haavi Finstad Date: Tue Oct 9 15:01:48 2012 +0200 Typo in tutorial diff --git a/doc/sphinx/tutorial/troubleshooting.rst b/doc/sphinx/tutorial/troubleshooting.rst index 5bbcf6c..0e86319 100644 --- a/doc/sphinx/tutorial/troubleshooting.rst +++ b/doc/sphinx/tutorial/troubleshooting.rst @@ -65,7 +65,7 @@ errors will be logged in syslog. It might look like this:: Specifically if you see the "Error in munmap" error on Linux you might want to increase the amount of maps available. Linux is limited to a -maximum of 64k maps. Setting vm.max_max_count i sysctl.conf will +maximum of 64k maps. Setting vm.max_map_count in sysctl.conf will enable you to increase this limit. You can inspect the number of maps your program is consuming by counting the lines in /proc/$PID/maps From martin at varnish-cache.org Wed Oct 10 07:49:17 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:17 +0200 Subject: [master] 47f4078 Add a EXP_NukeLRU() function to nuke an entire LRU structure at a time. Message-ID: commit 47f4078d0239f8016f2ebaefa26467dfa0f1286f Author: Martin Blix Grydeland Date: Fri May 18 12:30:30 2012 +0200 Add a EXP_NukeLRU() function to nuke an entire LRU structure at a time. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 15db84c..7533782 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -790,6 +790,7 @@ void EXP_Init(void); void EXP_Rearm(const struct object *o); int EXP_Touch(struct objcore *oc); int EXP_NukeOne(struct busyobj *, struct lru *lru); +void EXP_NukeLRU(struct worker *wrk, struct vsl_log *vsl, struct lru *lru); /* cache_fetch.c */ struct storage *FetchStorage(struct busyobj *, ssize_t sz); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 3d18d78..6e27c08 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -460,6 +460,65 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru) } /*-------------------------------------------------------------------- + * Nukes an entire LRU + */ + +#define NUKEBUF 10 /* XXX: Randomly chosen to be bigger than one */ + +void +EXP_NukeLRU(struct worker *wrk, struct vsl_log *vsl, struct lru *lru) +{ + struct objcore *oc; + struct objcore *oc_array[NUKEBUF]; + struct object *o; + int i, n; + double t; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); + + t = VTIM_real(); + Lck_Lock(&lru->mtx); + while (!VTAILQ_EMPTY(&lru->lru_head)) { + Lck_Lock(&exp_mtx); + n = 0; + while (n < NUKEBUF) { + oc = VTAILQ_FIRST(&lru->lru_head); + if (oc == NULL) + break; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + assert(oc_getlru(oc) == lru); + + /* Remove from the LRU and binheap */ + VTAILQ_REMOVE(&lru->lru_head, oc, lru_list); + assert(oc->timer_idx != BINHEAP_NOIDX); + binheap_delete(exp_heap, oc->timer_idx); + assert(oc->timer_idx == BINHEAP_NOIDX); + + oc_array[n++] = oc; + VSC_C_main->n_lru_nuked++; + } + assert(n > 0); + Lck_Unlock(&exp_mtx); + Lck_Unlock(&lru->mtx); + + for (i = 0; i < n; i++) { + oc = oc_array[i]; + o = oc_getobj(&wrk->stats, oc); + VSLb(vsl, SLT_ExpKill, "%u %.0f LRU", + oc_getxid(&wrk->stats, oc), EXP_Ttl(NULL, o) - t); + EXP_Set_ttl(&o->exp, 0.); + (void)HSH_Deref(&wrk->stats, oc, NULL); + } + + Lck_Lock(&lru->mtx); + } + Lck_Unlock(&lru->mtx); + + WRK_SumStat(wrk); +} + +/*-------------------------------------------------------------------- * BinHeap helper functions for objcore. */ From martin at varnish-cache.org Wed Oct 10 07:49:17 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:17 +0200 Subject: [master] a0c9a8e Create and use a smp_signspace structure to have range checking on the growing signed data structures. Message-ID: commit a0c9a8e9b762efe5326971f58bbfb10726ab201e Author: Martin Blix Grydeland Date: Tue Sep 25 15:20:18 2012 +0200 Create and use a smp_signspace structure to have range checking on the growing signed data structures. diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 5d31caf..b54f497 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -68,13 +68,14 @@ static VTAILQ_HEAD(,smp_sc) silos = VTAILQ_HEAD_INITIALIZER(silos); */ static void -smp_appendban(struct smp_sc *sc, struct smp_signctx *ctx, +smp_appendban(struct smp_sc *sc, struct smp_signspace *spc, uint32_t len, const uint8_t *ban) { uint8_t *ptr, *ptr2; (void)sc; - ptr = ptr2 = SIGN_END(ctx); + ptr = ptr2 = SIGNSPACE_FRONT(spc); + assert(SIGNSPACE_FREE(spc) >= 4 + 4 + len); memcpy(ptr, "BAN", 4); ptr += 4; @@ -85,7 +86,7 @@ smp_appendban(struct smp_sc *sc, struct smp_signctx *ctx, memcpy(ptr, ban, len); ptr += len; - smp_append_sign(ctx, ptr2, ptr - ptr2); + smp_append_signspace(spc, ptr - ptr2); } /* Trust that cache_ban.c takes care of locking */ @@ -106,7 +107,7 @@ SMP_NewBan(const uint8_t *ban, unsigned ln) */ static int -smp_open_bans(struct smp_sc *sc, struct smp_signctx *ctx) +smp_open_bans(struct smp_sc *sc, struct smp_signspace *spc) { uint8_t *ptr, *pe; uint32_t length; @@ -114,11 +115,11 @@ smp_open_bans(struct smp_sc *sc, struct smp_signctx *ctx) ASSERT_CLI(); (void)sc; - i = smp_chk_sign(ctx); + i = smp_chk_signspace(spc); if (i) return (i); - ptr = SIGN_DATA(ctx); - pe = ptr + ctx->ss->length; + ptr = SIGNSPACE_DATA(spc); + pe = SIGNSPACE_FRONT(spc); while (ptr < pe) { if (memcmp(ptr, "BAN", 4)) { @@ -148,7 +149,7 @@ smp_open_bans(struct smp_sc *sc, struct smp_signctx *ctx) */ static int -smp_open_segs(struct smp_sc *sc, struct smp_signctx *ctx) +smp_open_segs(struct smp_sc *sc, struct smp_signspace *spc) { uint64_t length, l; struct smp_segptr *ss, *se; @@ -156,12 +157,12 @@ smp_open_segs(struct smp_sc *sc, struct smp_signctx *ctx) int i, n = 0; ASSERT_CLI(); - i = smp_chk_sign(ctx); + i = smp_chk_signspace(spc); if (i) return (i); - ss = SIGN_DATA(ctx); - length = ctx->ss->length; + ss = SIGNSPACE_DATA(spc); + length = SIGNSPACE_LEN(spc); if (length == 0) { /* No segments */ diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index c817faf..ec97d3e 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -55,6 +55,21 @@ struct smp_signctx { const char *id; }; +/* + * A space wrapped by a signature + * + * A signspace is a chunk of the silo that is wrapped by a + * signature. It has attributes for size, so range checking can be + * performed. + * + */ + +struct smp_signspace { + struct smp_signctx ctx; + uint8_t *start; + uint64_t size; +}; + struct smp_sc; /* XXX: name confusion with on-media version ? */ @@ -116,10 +131,10 @@ struct smp_sc { VTAILQ_ENTRY(smp_sc) list; struct smp_signctx idn; - struct smp_signctx ban1; - struct smp_signctx ban2; - struct smp_signctx seg1; - struct smp_signctx seg2; + struct smp_signspace ban1; + struct smp_signspace ban2; + struct smp_signspace seg1; + struct smp_signspace seg2; struct ban *tailban; @@ -161,6 +176,11 @@ struct smp_sc { #define SIGN_DATA(ctx) ((void *)((ctx)->ss + 1)) #define SIGN_END(ctx) ((void *)((int8_t *)SIGN_DATA(ctx) + (ctx)->ss->length)) +#define SIGNSPACE_DATA(spc) (SIGN_DATA(&(spc)->ctx)) +#define SIGNSPACE_FRONT(spc) (SIGN_END(&(spc)->ctx)) +#define SIGNSPACE_LEN(spc) ((spc)->ctx.ss->length) +#define SIGNSPACE_FREE(spc) ((spc)->size - SIGNSPACE_LEN(spc)) + /* storage_persistent_mgt.c */ void smp_mgt_init(struct stevedore *parent, int ac, char * const *av); @@ -181,6 +201,13 @@ int smp_chk_sign(struct smp_signctx *ctx); void smp_append_sign(struct smp_signctx *ctx, const void *ptr, uint32_t len); void smp_reset_sign(struct smp_signctx *ctx); void smp_sync_sign(const struct smp_signctx *ctx); + +void smp_def_signspace(const struct smp_sc *sc, struct smp_signspace *spc, + uint64_t off, uint64_t size, const char *id); +int smp_chk_signspace(struct smp_signspace *spc); +void smp_append_signspace(struct smp_signspace *spc, uint32_t len); +void smp_reset_signspace(struct smp_signspace *spc); + void smp_newsilo(struct smp_sc *sc); int smp_valid_silo(struct smp_sc *sc); diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index ff53af8..6ed80d2 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -58,15 +58,15 @@ */ static void -smp_save_seg(const struct smp_sc *sc, struct smp_signctx *ctx) +smp_save_seg(const struct smp_sc *sc, struct smp_signspace *spc) { struct smp_segptr *ss; struct smp_seg *sg; uint64_t length; Lck_AssertHeld(&sc->mtx); - smp_reset_sign(ctx); - ss = SIGN_DATA(ctx); + smp_reset_signspace(spc); + ss = SIGNSPACE_DATA(spc); length = 0; VTAILQ_FOREACH(sg, &sc->segments, list) { assert(sg->p.offset < sc->mediasize); @@ -75,8 +75,8 @@ smp_save_seg(const struct smp_sc *sc, struct smp_signctx *ctx) ss++; length += sizeof *ss; } - smp_append_sign(ctx, SIGN_DATA(ctx), length); - smp_sync_sign(ctx); + smp_append_signspace(spc, length); + smp_sync_sign(&spc->ctx); } void diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index 004bba3..ac93544 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -179,6 +179,64 @@ smp_new_sign(const struct smp_sc *sc, struct smp_signctx *ctx, } /*-------------------------------------------------------------------- + * Define a signature space by location, size and identifier + */ + +void +smp_def_signspace(const struct smp_sc *sc, struct smp_signspace *spc, + uint64_t off, uint64_t size, const char *id) +{ + smp_def_sign(sc, &spc->ctx, off, id); + spc->start = SIGN_DATA(&spc->ctx); + spc->size = size - SMP_SIGN_SPACE; +} + +/*-------------------------------------------------------------------- + * Check that a signspace's signature space is good, leave state ready + * for append + */ + +int +smp_chk_signspace(struct smp_signspace *spc) +{ + return (smp_chk_sign(&spc->ctx)); +} + +/*-------------------------------------------------------------------- + * Append data to a signature space + */ + +void +smp_append_signspace(struct smp_signspace *spc, uint32_t len) +{ + assert(len <= SIGNSPACE_FREE(spc)); + smp_append_sign(&spc->ctx, SIGNSPACE_FRONT(spc), len); +} + +/*-------------------------------------------------------------------- + * Reset a signature space to empty, prepare for appending. + */ + +void +smp_reset_signspace(struct smp_signspace *spc) +{ + smp_reset_sign(&spc->ctx); +} + +/*-------------------------------------------------------------------- + * Create a new signature space and force the signature to backing store. + */ + +static void +smp_new_signspace(const struct smp_sc *sc, struct smp_signspace *spc, + uint64_t off, uint64_t size, const char *id) +{ + smp_new_sign(sc, &spc->ctx, off, id); + spc->start = SIGN_DATA(&spc->ctx); + spc->size = size - SMP_SIGN_SPACE; +} + +/*-------------------------------------------------------------------- * Initialize a Silo with a valid but empty structure. * * XXX: more intelligent sizing of things. @@ -220,10 +278,14 @@ smp_newsilo(struct smp_sc *sc) si->stuff[SMP_END_STUFF] = si->mediasize; assert(si->stuff[SMP_SPC_STUFF] < si->stuff[SMP_END_STUFF]); - smp_new_sign(sc, &sc->ban1, si->stuff[SMP_BAN1_STUFF], "BAN 1"); - smp_new_sign(sc, &sc->ban2, si->stuff[SMP_BAN2_STUFF], "BAN 2"); - smp_new_sign(sc, &sc->seg1, si->stuff[SMP_SEG1_STUFF], "SEG 1"); - smp_new_sign(sc, &sc->seg2, si->stuff[SMP_SEG2_STUFF], "SEG 2"); + smp_new_signspace(sc, &sc->ban1, si->stuff[SMP_BAN1_STUFF], + smp_stuff_len(sc, SMP_BAN1_STUFF), "BAN 1"); + smp_new_signspace(sc, &sc->ban2, si->stuff[SMP_BAN2_STUFF], + smp_stuff_len(sc, SMP_BAN2_STUFF), "BAN 2"); + smp_new_signspace(sc, &sc->seg1, si->stuff[SMP_SEG1_STUFF], + smp_stuff_len(sc, SMP_SEG1_STUFF), "SEG 1"); + smp_new_signspace(sc, &sc->seg2, si->stuff[SMP_SEG2_STUFF], + smp_stuff_len(sc, SMP_SEG2_STUFF), "SEG 2"); smp_append_sign(&sc->idn, si, sizeof *si); smp_sync_sign(&sc->idn); @@ -282,20 +344,24 @@ smp_valid_silo(struct smp_sc *sc) assert(smp_stuff_len(sc, SMP_BAN1_STUFF) == smp_stuff_len(sc, SMP_BAN2_STUFF)); - smp_def_sign(sc, &sc->ban1, si->stuff[SMP_BAN1_STUFF], "BAN 1"); - smp_def_sign(sc, &sc->ban2, si->stuff[SMP_BAN2_STUFF], "BAN 2"); - smp_def_sign(sc, &sc->seg1, si->stuff[SMP_SEG1_STUFF], "SEG 1"); - smp_def_sign(sc, &sc->seg2, si->stuff[SMP_SEG2_STUFF], "SEG 2"); + smp_def_signspace(sc, &sc->ban1, si->stuff[SMP_BAN1_STUFF], + smp_stuff_len(sc, SMP_BAN1_STUFF), "BAN 1"); + smp_def_signspace(sc, &sc->ban2, si->stuff[SMP_BAN2_STUFF], + smp_stuff_len(sc, SMP_BAN2_STUFF), "BAN 2"); + smp_def_signspace(sc, &sc->seg1, si->stuff[SMP_SEG1_STUFF], + smp_stuff_len(sc, SMP_SEG1_STUFF), "SEG 1"); + smp_def_signspace(sc, &sc->seg2, si->stuff[SMP_SEG2_STUFF], + smp_stuff_len(sc, SMP_SEG2_STUFF), "SEG 2"); /* We must have one valid BAN table */ - i = smp_chk_sign(&sc->ban1); - j = smp_chk_sign(&sc->ban2); + i = smp_chk_signspace(&sc->ban1); + j = smp_chk_signspace(&sc->ban2); if (i && j) return (100 + i * 10 + j); /* We must have one valid SEG table */ - i = smp_chk_sign(&sc->seg1); - j = smp_chk_sign(&sc->seg2); + i = smp_chk_signspace(&sc->seg1); + j = smp_chk_signspace(&sc->seg2); if (i && j) return (200 + i * 10 + j); return (0); From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] f3617f9 Add smp_copy_signspace() and smp_trunc_signspace() utility functions Message-ID: commit f3617f9d85cf2bfba4b778fa10a17bdc0862df11 Author: Martin Blix Grydeland Date: Wed Sep 26 13:25:38 2012 +0200 Add smp_copy_signspace() and smp_trunc_signspace() utility functions smp_copy_signspace() will copy the sign data of one space onto another. smp_trunc_signspace() will truncate the signed space to len bytes and resign the space. diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index ec97d3e..c4837b9 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -207,6 +207,9 @@ void smp_def_signspace(const struct smp_sc *sc, struct smp_signspace *spc, int smp_chk_signspace(struct smp_signspace *spc); void smp_append_signspace(struct smp_signspace *spc, uint32_t len); void smp_reset_signspace(struct smp_signspace *spc); +void smp_copy_signspace(struct smp_signspace *dst, + const struct smp_signspace *src); +void smp_trunc_signspace(struct smp_signspace *spc, uint32_t len); void smp_newsilo(struct smp_sc *sc); int smp_valid_silo(struct smp_sc *sc); diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index ac93544..f7c748e 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -224,6 +224,37 @@ smp_reset_signspace(struct smp_signspace *spc) } /*-------------------------------------------------------------------- + * Copy the contents of one signspace to another. Prepare for + * appending. + */ + +void +smp_copy_signspace(struct smp_signspace *dst, const struct smp_signspace *src) +{ + assert(SIGNSPACE_LEN(src) <= dst->size); + smp_reset_signspace(dst); + memcpy(SIGNSPACE_DATA(dst), SIGNSPACE_DATA(src), SIGNSPACE_LEN(src)); + smp_append_signspace(dst, SIGNSPACE_LEN(src)); + assert(SIGNSPACE_LEN(src) == SIGNSPACE_LEN(dst)); +} + +/*-------------------------------------------------------------------- + * Reapplies the sign over the len first bytes of the + * signspace. Prepares for appending. + */ + +void +smp_trunc_signspace(struct smp_signspace *spc, uint32_t len) +{ + assert(len <= SIGNSPACE_LEN(spc)); + spc->ctx.ss->length = 0; + SHA256_Init(&spc->ctx.ctx); + SHA256_Update(&spc->ctx.ctx, spc->ctx.ss, + offsetof(struct smp_sign, length)); + smp_append_signspace(spc, len); +} + +/*-------------------------------------------------------------------- * Create a new signature space and force the signature to backing store. */ From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] d49f707 Sync the complete sign area on smp_sync_sign Message-ID: commit d49f707a5d7e76d484d1d8923dae06f0cfdaac7a Author: Martin Blix Grydeland Date: Tue May 29 13:34:59 2012 +0200 Sync the complete sign area on smp_sync_sign diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index f7c748e..9933541 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -159,7 +159,7 @@ smp_sync_sign(const struct smp_signctx *ctx) int i; /* XXX: round to pages */ - i = msync((void*)ctx->ss, ctx->ss->length + SHA256_LEN, MS_SYNC); + i = msync((void*)ctx->ss, ctx->ss->length + SMP_SIGN_SPACE, MS_SYNC); if (i && 0) fprintf(stderr, "SyncSign(%p %s) = %d %s\n", ctx->ss, ctx->id, i, strerror(errno)); diff --git a/include/persistent.h b/include/persistent.h index ff9207e..f0cb7f5 100644 --- a/include/persistent.h +++ b/include/persistent.h @@ -111,6 +111,8 @@ struct smp_sign { char ident[8]; uint32_t unique; uint64_t mapped; + /* The length field is the length of the signed data only + * (does not include struct smp_sign) */ uint64_t length; /* NB: Must be last */ }; From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] 1f172c7 Round to page sizes on signature syncs Message-ID: commit 1f172c75d589197206f92517e9edfccd230e4580 Author: Martin Blix Grydeland Date: Wed Sep 26 16:35:03 2012 +0200 Round to page sizes on signature syncs diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index c4837b9..aceb996 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -210,6 +210,7 @@ void smp_reset_signspace(struct smp_signspace *spc); void smp_copy_signspace(struct smp_signspace *dst, const struct smp_signspace *src); void smp_trunc_signspace(struct smp_signspace *spc, uint32_t len); +void smp_msync(void *addr, size_t length); void smp_newsilo(struct smp_sc *sc); int smp_valid_silo(struct smp_sc *sc); diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index 9933541..f73ae06 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -156,13 +156,7 @@ smp_reset_sign(struct smp_signctx *ctx) void smp_sync_sign(const struct smp_signctx *ctx) { - int i; - - /* XXX: round to pages */ - i = msync((void*)ctx->ss, ctx->ss->length + SMP_SIGN_SPACE, MS_SYNC); - if (i && 0) - fprintf(stderr, "SyncSign(%p %s) = %d %s\n", - ctx->ss, ctx->id, i, strerror(errno)); + smp_msync(ctx->ss, SMP_SIGN_SPACE + ctx->ss->length); } /*-------------------------------------------------------------------- @@ -268,6 +262,25 @@ smp_new_signspace(const struct smp_sc *sc, struct smp_signspace *spc, } /*-------------------------------------------------------------------- + * Force a write of a memory block (rounded to nearest pages) to + * the backing store. + */ + +void +smp_msync(void *addr, size_t length) +{ + uintptr_t start, end; + int pagesize; + + pagesize = getpagesize(); + assert(pagesize > 0 && PWR2(pagesize)); + start = RDN2((uintptr_t)addr, pagesize); + end = RUP2((uintptr_t)addr + length, pagesize); + assert(start < end); + AZ(msync((void *)start, end - start, MS_SYNC)); +} + +/*-------------------------------------------------------------------- * Initialize a Silo with a valid but empty structure. * * XXX: more intelligent sizing of things. From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] c74c457 Free the LRU object and set free_offset when dropping empty segments in smp_close_seg() Message-ID: commit c74c457414847d5a1a56894fd9797ce2e4d2e208 Author: Martin Blix Grydeland Date: Sun Jun 3 23:57:48 2012 +0200 Free the LRU object and set free_offset when dropping empty segments in smp_close_seg() Fixes: #1146 diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 6ed80d2..e7dc597 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -253,9 +253,13 @@ smp_close_seg(struct smp_sc *sc, struct smp_seg *sg) sc->cur_seg = NULL; if (sg->nalloc == 0) { - /* XXX: if segment is empty, delete instead */ + /* If segment is empty, delete instead */ VTAILQ_REMOVE(&sc->segments, sg, list); - free(sg); + assert(sg->p.offset >= sc->ident->stuff[SMP_SPC_STUFF]); + assert(sg->p.offset < sc->mediasize); + sc->free_offset = sg->p.offset; + LRU_Free(sg->lru); + FREE_OBJ(sg); return; } From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] f9cb909 Don't exit on full silo Message-ID: commit f9cb90917258d2ffd5f2984e9de9be588be2a308 Author: Martin Blix Grydeland Date: Fri May 18 15:19:37 2012 +0200 Don't exit on full silo This then also breaks the previous expectation that cur_seg would always be non-NULL. Change the code to take this into account. diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index b54f497..744a5da 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -368,7 +368,9 @@ smp_close(const struct stevedore *st) CAST_OBJ_NOTNULL(sc, st->priv, SMP_SC_MAGIC); Lck_Lock(&sc->mtx); - smp_close_seg(sc, sc->cur_seg); + if (sc->cur_seg != NULL) + smp_close_seg(sc, sc->cur_seg); + AZ(sc->cur_seg); Lck_Unlock(&sc->mtx); /* XXX: reap thread */ @@ -393,7 +395,6 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size, struct smp_sc *sc; struct storage *ss; struct smp_seg *sg; - unsigned tries; uint64_t left, extra; CAST_OBJ_NOTNULL(sc, st->priv, SMP_SC_MAGIC); @@ -411,14 +412,22 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size, Lck_Lock(&sc->mtx); sg = NULL; ss = NULL; - for (tries = 0; tries < 3; tries++) { + + left = 0; + if (sc->cur_seg != NULL) left = smp_spaceleft(sc, sc->cur_seg); - if (left >= extra + min_size) - break; - smp_close_seg(sc, sc->cur_seg); + if (left < extra + min_size) { + if (sc->cur_seg != NULL) + smp_close_seg(sc, sc->cur_seg); smp_new_seg(sc); + if (sc->cur_seg != NULL) + left = smp_spaceleft(sc, sc->cur_seg); + else + left = 0; } + if (left >= extra + min_size) { + AN(sc->cur_seg); if (left < extra + max_size) max_size = IRNDN(sc, left - extra); @@ -611,7 +620,8 @@ debug_persistent(struct cli *cli, const char * const * av, void *priv) } Lck_Lock(&sc->mtx); if (!strcmp(av[3], "sync")) { - smp_close_seg(sc, sc->cur_seg); + if (sc->cur_seg != NULL) + smp_close_seg(sc, sc->cur_seg); smp_new_seg(sc); } else if (!strcmp(av[3], "dump")) { debug_report_silo(cli, sc, 1); diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index e7dc597..7d68e48 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -171,48 +171,50 @@ smp_load_seg(struct worker *wrk, const struct smp_sc *sc, void smp_new_seg(struct smp_sc *sc) { - struct smp_seg *sg, *sg2; + struct smp_seg tmpsg; + struct smp_seg *sg; + AZ(sc->cur_seg); Lck_AssertHeld(&sc->mtx); - ALLOC_OBJ(sg, SMP_SEG_MAGIC); - AN(sg); - sg->sc = sc; - sg->lru = LRU_Alloc(); - CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC); /* XXX: find where it goes in silo */ - sg->p.offset = sc->free_offset; - // XXX: align */ - assert(sg->p.offset >= sc->ident->stuff[SMP_SPC_STUFF]); - assert(sg->p.offset < sc->mediasize); - - sg->p.length = sc->aim_segl; - sg->p.length &= ~7; - - if (smp_segend(sg) > sc->mediasize) { - sc->free_offset = sc->ident->stuff[SMP_SPC_STUFF]; - sg->p.offset = sc->free_offset; - sg2 = VTAILQ_FIRST(&sc->segments); - if (smp_segend(sg) > sg2->p.offset) { - printf("Out of space in persistent silo\n"); - printf("Committing suicide, restart will make space\n"); - exit (0); - } + memset(&tmpsg, 0, sizeof tmpsg); + tmpsg.magic = SMP_SEG_MAGIC; + tmpsg.sc = sc; + tmpsg.p.offset = sc->free_offset; + /* XXX: align */ + assert(tmpsg.p.offset >= sc->ident->stuff[SMP_SPC_STUFF]); + assert(tmpsg.p.offset < sc->mediasize); + + tmpsg.p.length = sc->aim_segl; + tmpsg.p.length = RDN2(tmpsg.p.length, 8); + + if (smp_segend(&tmpsg) > sc->mediasize) + /* XXX: Consider truncation in this case */ + tmpsg.p.offset = sc->ident->stuff[SMP_SPC_STUFF]; + + assert(smp_segend(&tmpsg) <= sc->mediasize); + + sg = VTAILQ_FIRST(&sc->segments); + if (sg != NULL && tmpsg.p.offset <= sg->p.offset) { + if (smp_segend(&tmpsg) > sg->p.offset) + /* No more space, return (cur_seg will be NULL) */ + /* XXX: Consider truncation instead of failing */ + return; + assert(smp_segend(&tmpsg) <= sg->p.offset); } + if (tmpsg.p.offset == sc->ident->stuff[SMP_SPC_STUFF]) + printf("Wrapped silo\n"); - assert(smp_segend(sg) <= sc->mediasize); - - sg2 = VTAILQ_FIRST(&sc->segments); - if (sg2 != NULL && sg2->p.offset > sc->free_offset) { - if (smp_segend(sg) > sg2->p.offset) { - printf("Out of space in persistent silo\n"); - printf("Committing suicide, restart will make space\n"); - exit (0); - } - assert(smp_segend(sg) <= sg2->p.offset); - } + ALLOC_OBJ(sg, SMP_SEG_MAGIC); + if (sg == NULL) + /* Failed allocation */ + return; + *sg = tmpsg; + sg->lru = LRU_Alloc(); + CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC); sg->p.offset = IRNUP(sc, sg->p.offset); sg->p.length = IRNDN(sc, sg->p.length); @@ -248,6 +250,7 @@ smp_close_seg(struct smp_sc *sc, struct smp_seg *sg) Lck_AssertHeld(&sc->mtx); + CHECK_OBJ_NOTNULL(sg, SMP_SEG_MAGIC); assert(sg == sc->cur_seg); AN(sg->p.offset); sc->cur_seg = NULL; From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] b468fff Add an assert that segment rounding doesn't overstep our previous allocation calculations. Message-ID: commit b468fff3603182fd1f36f3d1ab21c50e90ce9c2f Author: Martin Blix Grydeland Date: Thu Sep 27 14:02:18 2012 +0200 Add an assert that segment rounding doesn't overstep our previous allocation calculations. diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 7d68e48..7ca79d6 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -218,6 +218,7 @@ smp_new_seg(struct smp_sc *sc) sg->p.offset = IRNUP(sc, sg->p.offset); sg->p.length = IRNDN(sc, sg->p.length); + assert(sg->p.offset + sg->p.length <= tmpsg.p.offset + tmpsg.p.length); sc->free_offset = sg->p.offset + sg->p.length; VTAILQ_INSERT_TAIL(&sc->segments, sg, list); From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] b04b136 Add a signal_close callback method to stevedores, which can be used to signal background threads to stop in preparation for the coming close callback. Message-ID: commit b04b136cb52ef420002a29f28e1a0bcb8cbe1770 Author: Martin Blix Grydeland Date: Thu Sep 27 14:43:55 2012 +0200 Add a signal_close callback method to stevedores, which can be used to signal background threads to stop in preparation for the coming close callback. diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index cd1a316..fa5a683 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -436,6 +436,15 @@ STV_close(void) { struct stevedore *stv; + /* Signal intent to close */ + VTAILQ_FOREACH(stv, &stv_stevedores, list) + if (stv->signal_close != NULL) + stv->signal_close(stv); + stv = stv_transient; + if (stv->signal_close != NULL) + stv->signal_close(stv); + + /* Close each in turn */ VTAILQ_FOREACH(stv, &stv_stevedores, list) if (stv->close != NULL) stv->close(stv); diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index aae9186..fd1adef 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -47,6 +47,7 @@ typedef void storage_free_f(struct storage *); typedef struct object *storage_allocobj_f(struct stevedore *, struct busyobj *, struct objcore **, unsigned ltot, const struct stv_objsecrets *); typedef void storage_close_f(const struct stevedore *); +typedef void storage_signal_close_f(const struct stevedore *); /* Prototypes for VCL variable responders */ #define VRTSTVTYPE(ct) typedef ct storage_var_##ct(const struct stevedore *); @@ -69,6 +70,7 @@ struct stevedore { storage_free_f *free; /* --//-- */ storage_close_f *close; /* --//-- */ storage_allocobj_f *allocobj; /* --//-- */ + storage_signal_close_f *signal_close; /* --//-- */ struct lru *lru; From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] c6e3eae smp_thread() stopping Message-ID: commit c6e3eae7fc299a42c7f2a1805a78035fcbc43806 Author: Martin Blix Grydeland Date: Fri Jun 1 16:11:23 2012 +0200 smp_thread() stopping diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 744a5da..6b8764f 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -51,6 +51,7 @@ #include "vcli_priv.h" #include "vend.h" #include "vsha256.h" +#include "vtim.h" #include "persistent.h" #include "storage/storage_persistent.h" @@ -287,15 +288,24 @@ smp_thread(struct worker *wrk, void *priv) BAN_TailDeref(&sc->tailban); AZ(sc->tailban); printf("Silo completely loaded\n"); - while (1) { - (void)sleep (1); + + /* Housekeeping loop */ + Lck_Lock(&sc->mtx); + while (!(sc->flags & SMP_SC_STOP)) { sg = VTAILQ_FIRST(&sc->segments); - if (sg != NULL && sg -> sc->cur_seg && sg->nobj == 0) { - Lck_Lock(&sc->mtx); + if (sg != NULL && sg != sc->cur_seg && sg->nobj == 0) smp_save_segs(sc); - Lck_Unlock(&sc->mtx); - } + + Lck_Unlock(&sc->mtx); + VTIM_sleep(3.14159265359 - 2); + Lck_Lock(&sc->mtx); } + + smp_save_segs(sc); + + Lck_Unlock(&sc->mtx); + pthread_exit(0); + NEEDLESS_RETURN(NULL); } @@ -307,7 +317,6 @@ static void smp_open(const struct stevedore *st) { struct smp_sc *sc; - pthread_t pt; ASSERT_CLI(); @@ -349,7 +358,7 @@ smp_open(const struct stevedore *st) smp_new_seg(sc); /* Start the worker silo worker thread, it will load the objects */ - WRK_BgThread(&pt, "persistence", smp_thread, sc); + WRK_BgThread(&sc->bgthread, "persistence", smp_thread, sc); VTAILQ_INSERT_TAIL(&silos, sc, list); Lck_Unlock(&sc->mtx); @@ -360,7 +369,7 @@ smp_open(const struct stevedore *st) */ static void -smp_close(const struct stevedore *st) +smp_signal_close(const struct stevedore *st) { struct smp_sc *sc; @@ -371,9 +380,22 @@ smp_close(const struct stevedore *st) if (sc->cur_seg != NULL) smp_close_seg(sc, sc->cur_seg); AZ(sc->cur_seg); + sc->flags |= SMP_SC_STOP; Lck_Unlock(&sc->mtx); +} + +static void +smp_close(const struct stevedore *st) +{ + struct smp_sc *sc; + void *status; + + ASSERT_CLI(); + + CAST_OBJ_NOTNULL(sc, st->priv, SMP_SC_MAGIC); - /* XXX: reap thread */ + pthread_join(sc->bgthread, &status); + AZ(status); } /*-------------------------------------------------------------------- @@ -561,6 +583,7 @@ const struct stevedore smp_stevedore = { .alloc = smp_alloc, .allocobj = smp_allocobj, .free = smp_free, + .signal_close = smp_signal_close, }; /*-------------------------------------------------------------------- diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index aceb996..cb2efb3 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -104,8 +104,10 @@ struct smp_sc { #define SMP_SC_MAGIC 0x7b73af0a struct stevedore *parent; + pthread_t bgthread; unsigned flags; #define SMP_SC_LOADED (1 << 0) +#define SMP_SC_STOP (1 << 1) const struct stevedore *stevedore; int fd; From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] 445f3c5 Generalize the ban reporting to the stevedores using their API. This way any stevedore interested in new bans can request to be notified (not just the persistent). Message-ID: commit 445f3c53332c687316a98941d894e62b6746576e Author: Martin Blix Grydeland Date: Wed May 23 09:16:29 2012 +0200 Generalize the ban reporting to the stevedores using their API. This way any stevedore interested in new bans can request to be notified (not just the persistent). Also report dropped bans to the stevedores. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7533782..b6c33cb 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -188,6 +188,15 @@ enum httpwhence { HTTP_Obj }; +/*-------------------------------------------------------------------- + * Ban info event types + */ + +enum baninfo { + BI_NEW, + BI_DROP +}; + /* NB: remember to update http_Copy() if you add fields */ struct http { unsigned magic; @@ -1054,6 +1063,7 @@ void STV_free(struct storage *st); void STV_open(void); void STV_close(void); void STV_Freestore(struct object *o); +void STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len); /* storage_synth.c */ struct vsb *SMS_Makesynth(struct object *obj); @@ -1063,7 +1073,6 @@ void SMS_Init(void); /* storage_persistent.c */ void SMP_Init(void); void SMP_Ready(void); -void SMP_NewBan(const uint8_t *ban, unsigned len); /* * A normal pointer difference is signed, but we never want a negative value diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 2054d3e..aa8bca9 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -66,6 +66,7 @@ #include #include "cache.h" +#include "storage/storage.h" #include "hash/hash_slinger.h" #include "vcli.h" @@ -413,7 +414,7 @@ BAN_Insert(struct ban *b) else be = NULL; - SMP_NewBan(b->spec, ln); + STV_BanInfo(BI_NEW, b->spec, ln); /* Notify stevedores */ Lck_Unlock(&ban_mtx); if (be == NULL) @@ -595,7 +596,9 @@ BAN_Compile(void) ASSERT_CLI(); - SMP_NewBan(ban_magic->spec, ban_len(ban_magic->spec)); + /* Notify stevedores */ + STV_BanInfo(BI_NEW, ban_magic->spec, ban_len(ban_magic->spec)); + ban_start = VTAILQ_FIRST(&ban_head); WRK_BgThread(&ban_thread, "ban-lurker", ban_lurker, NULL); } @@ -812,6 +815,9 @@ ban_lurker_work(struct worker *wrk, struct vsl_log *vsl, unsigned pass) do { Lck_Lock(&ban_mtx); b2 = ban_CheckLast(); + if (b2 != NULL) + /* Notify stevedores */ + STV_BanInfo(BI_DROP, b2->spec, ban_len(b2->spec)); Lck_Unlock(&ban_mtx); if (b2 != NULL) BAN_Free(b2); @@ -959,6 +965,10 @@ ban_lurker(struct worker *wrk, void *priv) */ Lck_Lock(&ban_mtx); bf = ban_CheckLast(); + if (bf != NULL) + /* Notify stevedores */ + STV_BanInfo(BI_DROP, bf->spec, + ban_len(bf->spec)); Lck_Unlock(&ban_mtx); if (bf != NULL) BAN_Free(bf); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index fa5a683..5262b70 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -453,6 +453,15 @@ STV_close(void) stv->close(stv); } +void +STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len) +{ + struct stevedore *stv; + + VTAILQ_FOREACH(stv, &stv_stevedores, list) + if (stv->baninfo != NULL) + stv->baninfo(stv, event, ban, len); +} /*-------------------------------------------------------------------- * VRT functions for stevedores diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index fd1adef..e4a02c1 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -38,6 +38,7 @@ struct busyobj; struct objcore; struct worker; struct lru; +enum baninfo; typedef void storage_init_f(struct stevedore *, int ac, char * const *av); typedef void storage_open_f(const struct stevedore *); @@ -48,6 +49,8 @@ typedef struct object *storage_allocobj_f(struct stevedore *, struct busyobj *, struct objcore **, unsigned ltot, const struct stv_objsecrets *); typedef void storage_close_f(const struct stevedore *); typedef void storage_signal_close_f(const struct stevedore *); +typedef void storage_baninfo_f(struct stevedore *, enum baninfo event, + const uint8_t *ban, unsigned len); /* Prototypes for VCL variable responders */ #define VRTSTVTYPE(ct) typedef ct storage_var_##ct(const struct stevedore *); @@ -71,6 +74,7 @@ struct stevedore { storage_close_f *close; /* --//-- */ storage_allocobj_f *allocobj; /* --//-- */ storage_signal_close_f *signal_close; /* --//-- */ + storage_baninfo_f *baninfo; /* --//-- */ struct lru *lru; diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 6b8764f..d0d40e2 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -92,14 +92,23 @@ smp_appendban(struct smp_sc *sc, struct smp_signspace *spc, /* Trust that cache_ban.c takes care of locking */ -void -SMP_NewBan(const uint8_t *ban, unsigned ln) +static void +smp_baninfo(struct stevedore *stv, enum baninfo event, + const uint8_t *ban, unsigned len) { struct smp_sc *sc; - VTAILQ_FOREACH(sc, &silos, list) { - smp_appendban(sc, &sc->ban1, ln, ban); - smp_appendban(sc, &sc->ban2, ln, ban); + (void)stv; + switch (event) { + case BI_NEW: + VTAILQ_FOREACH(sc, &silos, list) { + smp_appendban(sc, &sc->ban1, len, ban); + smp_appendban(sc, &sc->ban2, len, ban); + } + break; + default: + /* Ignored */ + break; } } @@ -584,6 +593,7 @@ const struct stevedore smp_stevedore = { .allocobj = smp_allocobj, .free = smp_free, .signal_close = smp_signal_close, + .baninfo = smp_baninfo, }; /*-------------------------------------------------------------------- From martin at varnish-cache.org Wed Oct 10 07:49:18 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 10 Oct 2012 09:49:18 +0200 Subject: [master] fbf3424 Add consistency checks between the ban lists at startup Message-ID: commit fbf34247f0d09060260672c502ccac3947123059 Author: Martin Blix Grydeland Date: Fri May 25 15:51:44 2012 +0200 Add consistency checks between the ban lists at startup diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index d0d40e2..5f756b7 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -343,9 +343,18 @@ smp_open(const struct stevedore *st) sc->ident = SIGN_DATA(&sc->idn); - /* We attempt ban1 first, and if that fails, try ban2 */ - if (smp_open_bans(sc, &sc->ban1)) - AZ(smp_open_bans(sc, &sc->ban2)); + /* Check ban lists */ + if (smp_chk_signspace(&sc->ban1)) { + /* Ban list 1 is broken, use ban2 */ + AZ(smp_chk_signspace(&sc->ban2)); + smp_copy_signspace(&sc->ban1, &sc->ban2); + smp_sync_sign(&sc->ban1.ctx); + } else { + /* Ban1 is OK, copy to ban2 for consistency */ + smp_copy_signspace(&sc->ban2, &sc->ban1); + smp_sync_sign(&sc->ban2.ctx); + } + AZ(smp_open_bans(sc, &sc->ban1)); /* We attempt seg1 first, and if that fails, try seg2 */ if (smp_open_segs(sc, &sc->seg1)) From phk at varnish-cache.org Wed Oct 10 07:54:16 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 10 Oct 2012 09:54:16 +0200 Subject: [master] 9357447 Change VCL::INT from C::int to C::long to gain more range on 64bit architectures. Message-ID: commit 935744727402361ee69133a84e880fff939ad2a4 Author: Poul-Henning Kamp Date: Wed Oct 10 07:52:32 2012 +0000 Change VCL::INT from C::int to C::long to gain more range on 64bit architectures. NB: VMOD writers need to review/revise use of the INT type. Fixes #1204 diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 477d337..a2dd8cd 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -315,20 +315,20 @@ VRT_IP_string(const struct req *req, const struct sockaddr_storage *sa) } char * -VRT_int_string(const struct req *req, int num) +VRT_INT_string(const struct req *req, long num) { char *p; int size; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - size = snprintf(NULL, 0, "%d", num) + 1; + size = snprintf(NULL, 0, "%ld", num) + 1; AN(p = WS_Alloc(req->http->ws, size)); - assert(snprintf(p, size, "%d", num) < size); + assert(snprintf(p, size, "%ld", num) < size); return (p); } char * -VRT_double_string(const struct req *req, double num) +VRT_REAL_string(const struct req *req, double num) { char *p; int size; @@ -341,7 +341,7 @@ VRT_double_string(const struct req *req, double num) } char * -VRT_time_string(const struct req *req, double t) +VRT_TIME_string(const struct req *req, double t) { char *p; @@ -353,7 +353,7 @@ VRT_time_string(const struct req *req, double t) } const char * -VRT_backend_string(const struct req *req, const struct director *d) +VRT_BACKEND_string(const struct req *req, const struct director *d) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); if (d == NULL) @@ -364,7 +364,7 @@ VRT_backend_string(const struct req *req, const struct director *d) } const char * -VRT_bool_string(const struct req *req, unsigned val) +VRT_BOOL_string(const struct req *req, unsigned val) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 61000a1..535e5ee 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -98,7 +98,7 @@ VRT_DO_HDR(beresp, response, req->busyobj->beresp, HTTP_HDR_RESPONSE) #define VRT_DO_STATUS(obj, http) \ void \ -VRT_l_##obj##_status(const struct req *req, int num) \ +VRT_l_##obj##_status(const struct req *req, long num) \ { \ \ CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ @@ -106,7 +106,7 @@ VRT_l_##obj##_status(const struct req *req, int num) \ http->status = (uint16_t)num; \ } \ \ -int \ +long \ VRT_r_##obj##_status(const struct req *req) \ { \ \ @@ -271,7 +271,7 @@ VRT_r_beresp_backend_ip(const struct req *req) return(req->busyobj->vbc->addr); } -int +long VRT_r_beresp_backend_port(const struct req *req) { @@ -342,7 +342,7 @@ VRT_r_req_esi(const struct req *req) return (!req->disable_esi); } -int +long VRT_r_req_esi_level(const struct req *req) { @@ -363,7 +363,7 @@ VRT_r_req_can_gzip(const struct req *req) /*--------------------------------------------------------------------*/ -int +long VRT_r_req_restarts(const struct req *req) { @@ -517,7 +517,7 @@ VRT_r_server_hostname(const struct req *req) * XXX: This is pessimistically silly */ -int +long VRT_r_server_port(const struct req *req) { int i; @@ -533,7 +533,7 @@ VRT_r_server_port(const struct req *req) /*--------------------------------------------------------------------*/ -int +long VRT_r_obj_hits(const struct req *req) { diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 2a15a34..f0dfd9a 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -113,6 +113,9 @@ -emacro(436, SLTM) ////////////// ++libh netinet/tcp.h +-elib(46) +////////////// +libh mgt_event.h diff --git a/include/vrt.h b/include/vrt.h index 20545fc..2029f7a 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -208,11 +208,11 @@ int VRT_Stv(const char *nm); /* Convert things to string */ char *VRT_IP_string(const struct req *, const struct sockaddr_storage *sa); -char *VRT_int_string(const struct req *, int); -char *VRT_double_string(const struct req *, double); -char *VRT_time_string(const struct req *, double); -const char *VRT_bool_string(const struct req *, unsigned); -const char *VRT_backend_string(const struct req *, const struct director *d); +char *VRT_INT_string(const struct req *, long); +char *VRT_REAL_string(const struct req *, double); +char *VRT_TIME_string(const struct req *, double); +const char *VRT_BOOL_string(const struct req *, unsigned); +const char *VRT_BACKEND_string(const struct req *, const struct director *d); #define VRT_done(req, hand) \ do { \ diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 3a1daa1..ecc3a14 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -482,7 +482,7 @@ vcltypes = { 'TIME': "double", 'DURATION': "double", 'BYTES': "double", - 'INT': "int", + 'INT': "long", 'HEADER': "const char *", } diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 8fbaa04..72c26a9 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -423,15 +423,15 @@ vcc_expr_tostring(struct expr **e, enum var_type fmt) p = NULL; switch((*e)->fmt) { - case BACKEND: p = "VRT_backend_string(req, \v1)"; break; - case BOOL: p = "VRT_bool_string(req, \v1)"; break; - case DURATION: p = "VRT_double_string(req, \v1)"; break; + case BACKEND: p = "VRT_BACKEND_string(req, \v1)"; break; + case BOOL: p = "VRT_BOOL_string(req, \v1)"; break; + case DURATION: p = "VRT_REAL_string(req, \v1)"; break; /* XXX: should DURATION insist on "s" suffix ? */ - case INT: p = "VRT_int_string(req, \v1)"; break; + case INT: p = "VRT_INT_string(req, \v1)"; break; case IP: p = "VRT_IP_string(req, \v1)"; break; - case BYTES: p = "VRT_double_string(req, \v1)"; break; /* XXX */ - case REAL: p = "VRT_double_string(req, \v1)"; break; - case TIME: p = "VRT_time_string(req, \v1)"; break; + case BYTES: p = "VRT_REAL_string(req, \v1)"; break; /* XXX */ + case REAL: p = "VRT_REAL_string(req, \v1)"; break; + case TIME: p = "VRT_TIME_string(req, \v1)"; break; default: break; } if (p != NULL) { diff --git a/lib/libvcl/vmodtool.py b/lib/libvcl/vmodtool.py index d32eb4a..e7edbde 100755 --- a/lib/libvcl/vmodtool.py +++ b/lib/libvcl/vmodtool.py @@ -55,7 +55,7 @@ ctypes = { 'TIME': "double", 'REAL': "double", 'DURATION': "double", - 'INT': "int", + 'INT': "long", 'HEADER': "enum gethdr_e, const char *", 'PRIV_VCL': "struct vmod_priv *", 'PRIV_CALL': "struct vmod_priv *", diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 037ffdd..e31b0c8 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -46,12 +46,13 @@ #include "vcc_if.h" void __match_proto__(td_std_set_ip_tos) -vmod_set_ip_tos(struct req *req, int tos) +vmod_set_ip_tos(struct req *req, long tos) { + int itos = tos; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); VTCP_Assert(setsockopt(req->sp->fd, - IPPROTO_IP, IP_TOS, &tos, sizeof(tos))); + IPPROTO_IP, IP_TOS, &itos, sizeof(itos))); } static const char * @@ -150,7 +151,7 @@ vmod_log(struct req *req, const char *fmt, ...) } void __match_proto__(td_std_syslog) -vmod_syslog(struct req *req, int fac, const char *fmt, ...) +vmod_syslog(struct req *req, long fac, const char *fmt, ...) { char *p; unsigned u; @@ -163,7 +164,7 @@ vmod_syslog(struct req *req, int fac, const char *fmt, ...) p = VRT_StringList(p, u, fmt, ap); va_end(ap); if (p != NULL) - syslog(fac, "%s", p); + syslog((int)fac, "%s", p); WS_Release(req->ws, 0); } diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index 45cc7a1..e728611 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -88,11 +88,11 @@ vmod_duration(struct req *req, const char *p, double d) return (r); } -int __match_proto__() -vmod_integer(struct req *req, const char *p, int i) +long __match_proto__() +vmod_integer(struct req *req, const char *p, long i) { char *e; - int r; + long r; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); From phk at varnish-cache.org Wed Oct 10 08:41:01 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 10 Oct 2012 10:41:01 +0200 Subject: [master] 68644d8 Strictly speaking it is not legal to forward declare an enum. Message-ID: commit 68644d8b0eb6af4efd92ac30ddf59b72de5829bc Author: Poul-Henning Kamp Date: Wed Oct 10 08:40:43 2012 +0000 Strictly speaking it is not legal to forward declare an enum. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b6c33cb..6d4fe86 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -192,11 +192,6 @@ enum httpwhence { * Ban info event types */ -enum baninfo { - BI_NEW, - BI_DROP -}; - /* NB: remember to update http_Copy() if you add fields */ struct http { unsigned magic; diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index f665e52..8140734 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -40,6 +40,16 @@ #include "vqueue.h" #include "vsb.h" +/* + * Enums cannot be forward declared (any more...) so put it here + * to make everybody see it. + */ + +enum baninfo { + BI_NEW, + BI_DROP +}; + struct cli; /********************************************************************** diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index e4a02c1..e9971e7 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -38,7 +38,6 @@ struct busyobj; struct objcore; struct worker; struct lru; -enum baninfo; typedef void storage_init_f(struct stevedore *, int ac, char * const *av); typedef void storage_open_f(const struct stevedore *); From phk at varnish-cache.org Wed Oct 10 09:20:27 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 10 Oct 2012 11:20:27 +0200 Subject: [master] e60cfbc A bit of FlexeLint nit-pickery Message-ID: commit e60cfbcff3b427376d24b0cba5cb324514b5df1c Author: Poul-Henning Kamp Date: Wed Oct 10 09:20:14 2012 +0000 A bit of FlexeLint nit-pickery diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 6e27c08..80c630f 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -477,6 +477,8 @@ EXP_NukeLRU(struct worker *wrk, struct vsl_log *vsl, struct lru *lru) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); + memset(oc_array, 0, sizeof oc_array); + t = VTIM_real(); Lck_Lock(&lru->mtx); while (!VTAILQ_EMPTY(&lru->lru_head)) { diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 5f756b7..24a4d08 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -76,7 +76,7 @@ smp_appendban(struct smp_sc *sc, struct smp_signspace *spc, (void)sc; ptr = ptr2 = SIGNSPACE_FRONT(spc); - assert(SIGNSPACE_FREE(spc) >= 4 + 4 + len); + assert(SIGNSPACE_FREE(spc) >= 4L + 4 + len); memcpy(ptr, "BAN", 4); ptr += 4; @@ -412,7 +412,7 @@ smp_close(const struct stevedore *st) CAST_OBJ_NOTNULL(sc, st->priv, SMP_SC_MAGIC); - pthread_join(sc->bgthread, &status); + AZ(pthread_join(sc->bgthread, &status)); AZ(status); } diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index f73ae06..0b1b7da 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -269,8 +269,7 @@ smp_new_signspace(const struct smp_sc *sc, struct smp_signspace *spc, void smp_msync(void *addr, size_t length) { - uintptr_t start, end; - int pagesize; + uintptr_t start, end, pagesize; pagesize = getpagesize(); assert(pagesize > 0 && PWR2(pagesize)); From tfheen at varnish-cache.org Wed Oct 10 11:55:29 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 10 Oct 2012 13:55:29 +0200 Subject: [master] 9f1cdbe Don't put POLLHUP in .events Message-ID: commit 9f1cdbeeb5b0bcefb57ed87a4ac7322537b861d0 Author: Tollef Fog Heen Date: Tue Oct 2 08:38:49 2012 +0200 Don't put POLLHUP in .events POLLHUP is always checked for, and is output-only on Linux and OSX, so avoid putting it in the list of events we check for. diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 0678efd..4f084ad 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1043,7 +1043,7 @@ cmd_http_expect_close(CMD_ARGS) 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].events = POLLIN | POLLERR; fds[0].revents = 0; i = poll(fds, 1, 1000); if (i == 0) diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 0036720..794080f 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -395,16 +395,8 @@ varnish_launch(struct varnish *v) fd[0].fd = v->cli_fd; fd[0].events = POLLIN; fd[1].fd = v->fds[0]; - fd[1].events = POLLHUP; -#ifdef __APPLE__ - /* - * OSX cannot poll a pipe for POLLHUP only, poll just returns - * zero with no revents. - */ - i = poll(fd, 1, 10000); -#else + fd[1].events = 0; /* Only care about POLLHUP, which is output-only */ i = poll(fd, 2, 10000); -#endif vtc_log(v->vl, 4, "CLIPOLL %d 0x%x 0x%x", i, fd[0].revents, fd[1].revents); if (i == 0) { From phk at varnish-cache.org Thu Oct 11 11:02:24 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 11 Oct 2012 13:02:24 +0200 Subject: [master] 968d11d Add ability to use regexp's for expect in HTTP. Message-ID: commit 968d11d1082001730d4b536d23c93382ec321128 Author: Poul-Henning Kamp Date: Thu Oct 11 11:01:59 2012 +0000 Add ability to use regexp's for expect in HTTP. diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 4f084ad..fa3ae3b 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -40,6 +40,7 @@ #include "vct.h" #include "vgz.h" +#include "vre.h" #include "vtcp.h" #define MAX_HDR 50 @@ -213,6 +214,10 @@ cmd_http_expect(CMD_ARGS) const char *lhs; char *cmp; const char *rhs; + vre_t *vre; + const char *error; + int erroroffset; + int i; (void)cmd; (void)vl; @@ -241,6 +246,19 @@ cmd_http_expect(CMD_ARGS) else vtc_log(hp->vl, 4, "EXPECT %s (%s) %s %s (%s) match", av[0], lhs, av[1], av[2], rhs); + } else if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { + vre = VRE_compile(rhs, 0, &error, &erroroffset); + if (vre == NULL) + vtc_log(hp->vl, 0, "REGEXP error: %s (@%d) (%s)", + error, erroroffset, rhs); + i = VRE_exec(vre, lhs, strlen(lhs), 0, 0, NULL, 0, 0); + if ((i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!')) + vtc_log(hp->vl, 4, "EXPECT %s (%s) %s \"%s\" match", + av[0], lhs, cmp, rhs); + else + vtc_log(hp->vl, 0, "EXPECT %s (%s) %s \"%s\" failed", + av[0], lhs, cmp, rhs); + VRE_free(&vre); } else { vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s) test not implemented", From phk at varnish-cache.org Thu Oct 11 11:08:10 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 11 Oct 2012 13:08:10 +0200 Subject: [master] cc513fd Fix a VCL expression type error: TIME +/- DURATION should return TIME Message-ID: commit cc513fdc6cc098fcdc378af6ec80959a5c744054 Author: Poul-Henning Kamp Date: Thu Oct 11 11:07:25 2012 +0000 Fix a VCL expression type error: TIME +/- DURATION should return TIME Fixes #1211 Thanks to: Federico G. Schwindt diff --git a/bin/varnishtest/tests/r01211.vtc b/bin/varnishtest/tests/r01211.vtc new file mode 100644 index 0000000..83914b7 --- /dev/null +++ b/bin/varnishtest/tests/r01211.vtc @@ -0,0 +1,22 @@ +varnishtest "TIME +/- DURATION -> TIME" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + + sub vcl_deliver { + set resp.http.bar = now + 4 d; + set resp.http.foo = now - 4 d; + } + +} -start + +client c1 { + txreq + rxresp + expect resp.http.bar ~ "..., .. ... 20[1-9][0-9] ..:..:.. GMT" + expect resp.http.foo ~ "..., .. ... 20[1-9][0-9] ..:..:.. GMT" +} -run diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 72c26a9..06f93ec 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -847,6 +847,9 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) ERRCHK(tl); if (tk->tok == '-' && (*e)->fmt == TIME && e2->fmt == TIME) { /* OK */ + } else if ((*e)->fmt == TIME && e2->fmt == DURATION) { + f2 = TIME; + /* OK */ } else if (tk->tok == '-' && (*e)->fmt == BYTES && e2->fmt == BYTES) { /* OK */ From tfheen at varnish-cache.org Mon Oct 15 08:39:40 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 15 Oct 2012 10:39:40 +0200 Subject: [master] 1ebcb83 .gitignore log files from make check Message-ID: commit 1ebcb83aab1eafec9a3135c6cfa85dc49dbcd5f3 Author: Tollef Fog Heen Date: Mon Oct 15 10:39:38 2012 +0200 .gitignore log files from make check diff --git a/.gitignore b/.gitignore index 6680eb8..81f58b7 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,8 @@ TAGS # NetBeans insists on this /nbproject/private/ + +# Test droppings +bin/varnishtest/tests/*.log +bin/varnishtest/tests/*.log-t +bin/varnishtest/test-suite.log From tfheen at varnish-cache.org Mon Oct 15 11:02:55 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 15 Oct 2012 13:02:55 +0200 Subject: [master] b2d19c5 Use memchr rather than strchr/index Message-ID: commit b2d19c5f6d3c3d661720a4c4ed2ff0b4695e6f04 Author: Tollef Fog Heen Date: Mon Oct 15 12:56:15 2012 +0200 Use memchr rather than strchr/index the strings we get from the libvarnishapi functions are not necessarily null-terminated, so avoid using str* functions on them. Thanks to lampe for the patch. Fixes #1115 diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 9c9267e..88c73eb 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -312,7 +312,7 @@ collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec, clean_logline(lp); break; } - qs = index(ptr, '?'); + qs = memchr(ptr, '?', len); if (qs) { lp->df_U = trimline(ptr, qs); lp->df_q = trimline(qs, end); @@ -356,7 +356,7 @@ collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec, case SLT_BereqHeader: if (!lp->active) break; - split = strchr(ptr, ':'); + split = memchr(ptr, ':', len); if (split == NULL) break; if (isprefix(ptr, "authorization:", end, &next) && @@ -431,7 +431,7 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, clean_logline(lp); break; } - qs = index(ptr, '?'); + qs = memchr(ptr, '?', len); if (qs) { lp->df_U = trimline(ptr, qs); lp->df_q = trimline(qs, end); @@ -464,7 +464,7 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, case SLT_ReqHeader: if (!lp->active) break; - split = strchr(ptr, ':'); + split = memchr(ptr, ':', len); if (split == NULL) break; if (tag == SLT_ReqHeader && @@ -490,7 +490,7 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, if(!lp->active) break; - split = strchr(ptr, ':'); + split = memchr(ptr, ':', len); if (split == NULL) break; From tfheen at varnish-cache.org Tue Oct 16 12:23:41 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 16 Oct 2012 14:23:41 +0200 Subject: [master] 4f6eaa2 test Message-ID: commit 4f6eaa245f961edf67f22a554c72f26e790ad658 Author: Tollef Fog Heen Date: Mon Oct 15 13:22:58 2012 +0200 test diff --git a/bin/flint.lnt b/bin/flint.lnt deleted file mode 100644 index 18a8d27..0000000 --- a/bin/flint.lnt +++ /dev/null @@ -1,105 +0,0 @@ --passes=3 - --ffc // No automatic custody - --printf(2, VSB_printf) - - -/////////////////////////////////////////////////////////////////////// -// Weirdness relating to varnish includes etc. - --header(../../config.h) -+libh ../../config.h --efile(451, ../../config.h) // No include guard - --efile(451, "tbl/*.h") // No include guard - -/////////////////////////////////////////////////////////////////////// -// assert() support, common to libvarnish and libvarnishapi --sem(VAS_Fail, r_no) --emacro(506, assert) // constant value boolean --emacro(827, assert) // loop not reachable --emacro(774, assert) // booelan always true --emacro(731, assert) // booelan arg to eq/non-eq --emacro(731, xxxassert) // arg to eq/non-eq --emacro(527, WRONG) // unreachable code - -/////////////////////////////////////////////////////////////////////// -// - --esym(755, VLIST_*) // Global macro not ref. --esym(755, VSLIST_*) --esym(755, VSTAILQ_*) --esym(755, VTAILQ_*) - --emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small) --emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small) --emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean --emacro(506, VSTAILQ_FOREACH_SAFE) // constant value boolean --emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types) --emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types) --esym(755, VTAILQ_*) - -/////////////////////////////////////////////////////////////////////// -// miniobj - -// -emacro(755, CAST_OBJ) // glob macro not ref --emacro(779, REPLACE) // string constant != --emacro(774, REPLACE) // if(bool) always true --emacro(506, REPLACE) // const bool - -/////////////////////////////////////////////////////////////////////// -// VMB --emacro(755, VMB) // glob macro not ref --emacro(755, VRMB) // glob macro not ref --emacro(755, VWMB) // glob macro not ref - -/////////////////////////////////////////////////////////////////////// -// VSB - --esym(759, VSB_*) // header decl could be moved --esym(765, VSB_*) // exten could be made static --esym(714, VSB_*) // symb not ref --sem(VSB_new, @p == (1p ? 1p : malloc(1))) --sem(VSB_delete, custodial(1)) - --esym(534, VSB_cat) // Ignore retval --esym(534, VSB_bcat) --esym(534, VSB_putc) --esym(534, VSB_printf) --esym(534, VSB_vprintf) --esym(534, VSB_putc) - -/////////////////////////////////////////////////////////////////////// -// System library/POSIX related -/////////////////////////////////////////////////////////////////////// - -// vararg simulation is imperfect (XXX: why ??) --emacro((???), va_arg) // 415, 416, 416, 661, 662, 796, 797 ... - -// Fix strchr() semtics, it can only return NULL if arg2 != 0 --sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 )) - --esym(534, printf) // Ignore retval --esym(534, fprintf) --esym(534, sprintf) - --esym(534, memset) --esym(534, memcpy) --esym(534, memmove) - --esym(534, strcat) --esym(534, strcpy) --esym(534, strlcpy) - -+typename(844) --etype(844, struct pthread *) --sem(pthread_create, custodial(4)) --emacro(413, offsetof) // likely null pointer --emacro(736, isnan) // loss of prec. - -+libh(/usr/include/curses.h) --elib(659) // no tokens after struct def. --elib(123) // macro def. with arg at, (just warn) - --emacro(702, WEXITSTATUS) // signed shift right From tfheen at varnish-cache.org Tue Oct 16 12:23:41 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 16 Oct 2012 14:23:41 +0200 Subject: [master] 6b06573 Fix markup of function list Message-ID: commit 6b065731e82ca2ff241e99fa0e5fc42c08ff4152 Author: Magnus Hagander Date: Tue Oct 16 14:23:16 2012 +0200 Fix markup of function list ban() was previously not in bold on the man page. Turn it into two separate entries with separate descritions to fix that. diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index c87ade4..4971315 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -326,6 +326,7 @@ regsuball(str, regex, sub) As regsub() but this replaces all occurrences. ban(ban expression) + Bans all objects in cache that match the expression. ban_url(regex) Bans all objects in cache whose URLs match regex. From tfheen at varnish-cache.org Wed Oct 17 07:07:30 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 17 Oct 2012 09:07:30 +0200 Subject: [master] a69baba Revert "test" Message-ID: commit a69baba8e41783b61a07dba59f6c1b33373f508b Author: Tollef Fog Heen Date: Wed Oct 17 09:06:46 2012 +0200 Revert "test" 0ad568 should never have been pushed. This reverts commit 4f6eaa245f961edf67f22a554c72f26e790ad658. diff --git a/bin/flint.lnt b/bin/flint.lnt new file mode 100644 index 0000000..18a8d27 --- /dev/null +++ b/bin/flint.lnt @@ -0,0 +1,105 @@ +-passes=3 + +-ffc // No automatic custody + +-printf(2, VSB_printf) + + +/////////////////////////////////////////////////////////////////////// +// Weirdness relating to varnish includes etc. + +-header(../../config.h) ++libh ../../config.h +-efile(451, ../../config.h) // No include guard + +-efile(451, "tbl/*.h") // No include guard + +/////////////////////////////////////////////////////////////////////// +// assert() support, common to libvarnish and libvarnishapi +-sem(VAS_Fail, r_no) +-emacro(506, assert) // constant value boolean +-emacro(827, assert) // loop not reachable +-emacro(774, assert) // booelan always true +-emacro(731, assert) // booelan arg to eq/non-eq +-emacro(731, xxxassert) // arg to eq/non-eq +-emacro(527, WRONG) // unreachable code + +/////////////////////////////////////////////////////////////////////// +// + +-esym(755, VLIST_*) // Global macro not ref. +-esym(755, VSLIST_*) +-esym(755, VSTAILQ_*) +-esym(755, VTAILQ_*) + +-emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small) +-emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small) +-emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean +-emacro(506, VSTAILQ_FOREACH_SAFE) // constant value boolean +-emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types) +-emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types) +-esym(755, VTAILQ_*) + +/////////////////////////////////////////////////////////////////////// +// miniobj + +// -emacro(755, CAST_OBJ) // glob macro not ref +-emacro(779, REPLACE) // string constant != +-emacro(774, REPLACE) // if(bool) always true +-emacro(506, REPLACE) // const bool + +/////////////////////////////////////////////////////////////////////// +// VMB +-emacro(755, VMB) // glob macro not ref +-emacro(755, VRMB) // glob macro not ref +-emacro(755, VWMB) // glob macro not ref + +/////////////////////////////////////////////////////////////////////// +// VSB + +-esym(759, VSB_*) // header decl could be moved +-esym(765, VSB_*) // exten could be made static +-esym(714, VSB_*) // symb not ref +-sem(VSB_new, @p == (1p ? 1p : malloc(1))) +-sem(VSB_delete, custodial(1)) + +-esym(534, VSB_cat) // Ignore retval +-esym(534, VSB_bcat) +-esym(534, VSB_putc) +-esym(534, VSB_printf) +-esym(534, VSB_vprintf) +-esym(534, VSB_putc) + +/////////////////////////////////////////////////////////////////////// +// System library/POSIX related +/////////////////////////////////////////////////////////////////////// + +// vararg simulation is imperfect (XXX: why ??) +-emacro((???), va_arg) // 415, 416, 416, 661, 662, 796, 797 ... + +// Fix strchr() semtics, it can only return NULL if arg2 != 0 +-sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 )) + +-esym(534, printf) // Ignore retval +-esym(534, fprintf) +-esym(534, sprintf) + +-esym(534, memset) +-esym(534, memcpy) +-esym(534, memmove) + +-esym(534, strcat) +-esym(534, strcpy) +-esym(534, strlcpy) + ++typename(844) +-etype(844, struct pthread *) +-sem(pthread_create, custodial(4)) +-emacro(413, offsetof) // likely null pointer +-emacro(736, isnan) // loss of prec. + ++libh(/usr/include/curses.h) +-elib(659) // no tokens after struct def. +-elib(123) // macro def. with arg at, (just warn) + +-emacro(702, WEXITSTATUS) // signed shift right From phk at varnish-cache.org Wed Oct 17 10:04:36 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 17 Oct 2012 12:04:36 +0200 Subject: [master] 6a9d2f2 Emit a regular error, rather than a VCC assert. Message-ID: commit 6a9d2f2fa1140e8e41a45f44c6c2a4ee6c1afcfe Author: Poul-Henning Kamp Date: Wed Oct 17 10:03:54 2012 +0000 Emit a regular error, rather than a VCC assert. Found & Fixed by: Federico G. Schwindt Fixes #1212 diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 06f93ec..1b6bf12 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -529,6 +529,7 @@ void vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) { const char *p, *r; + const struct var *v; struct expr *e1, *e2; enum var_type fmt; char buf[32]; @@ -581,7 +582,7 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) if (*p != '\0') SkipToken(tl, ','); } else if (fmt == HEADER) { - const struct var *v; + ExpectErr(tl, ID); sym = VCC_FindSymbol(tl, tl->t, SYM_NONE); ERRCHK(tl); SkipToken(tl, ID); From phk at varnish-cache.org Wed Oct 17 10:12:28 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 17 Oct 2012 12:12:28 +0200 Subject: [master] 881ebc7 Add more test-coverage for VCL expressions Message-ID: commit 881ebc72f2810506ea0c415b816b80c0135d3534 Author: Poul-Henning Kamp Date: Wed Oct 17 10:12:09 2012 +0000 Add more test-coverage for VCL expressions diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 1e36b43..62a7cbc 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -26,7 +26,7 @@ varnish v1 -vcl { varnish v1 -badvcl { sub vcl_recv { if (!req.restarts != req.url) { - set req.http.foo = "foo" + 3; + set req.http.foo = "foo"; } } @@ -79,3 +79,111 @@ varnish v1 -badvcl { } } } + +varnish v1 -vcl { + backend b { .host = "127.0.0.1"; } + sub vcl_recv { + set req.http.foo = "foo" + "bar"; + set req.http.foo = "foo" + 1; + set req.http.foo = "foo" + now; + + set req.http.foo = now + 1s; + set req.http.foo = now - 1s; + set req.http.foo = now - now; + + set req.http.foo = 1 + 1; + set req.http.foo = 1 - 1; + + set req.ttl = 1s; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = "foo" - "bar"; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = now + "foo"; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = now + now; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = now + 1; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = 1 + "foo"; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = 1 + now; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = 1 + 1s; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = 1s; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = 1s + 1; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = 1s + now; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = 1s + "foo"; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.http.foo = "foo" + 1s; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.ttl = 1s + 1; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.ttl = 1s + now; + } +} + +varnish v1 -badvcl { + sub vcl_recv { + set req.ttl = 1s + "foo"; + } +} From phk at varnish-cache.org Wed Oct 17 10:25:01 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 17 Oct 2012 12:25:01 +0200 Subject: [master] ff2647b Don't do conditional processing for hit-for-pass objects. Message-ID: commit ff2647b2828888f3e39637f3688dad6a05354500 Author: Poul-Henning Kamp Date: Wed Oct 17 10:23:37 2012 +0000 Don't do conditional processing for hit-for-pass objects. Fixes #1206 Found & Fixed by: DocWilco diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index cb152a5..3fecd27 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -108,6 +108,7 @@ RES_BuildHttp(struct req *req) char time_str[30]; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); http_ClrHeader(req->resp); http_FilterResp(req->obj->http, req->resp, 0); @@ -122,7 +123,9 @@ RES_BuildHttp(struct req *req) if (req->res_mode & RES_GUNZIP) http_Unset(req->resp, H_Content_Encoding); - if (req->obj->response == 200 + if (req->obj->objcore != NULL + && !(req->obj->objcore->flags & OC_F_PASS) + && req->obj->response == 200 && req->http->conds && RFC2616_Do_Cond(req)) { req->wantbody = 0; http_SetResp(req->resp, "HTTP/1.1", 304, "Not Modified"); diff --git a/bin/varnishtest/tests/r01206.vtc b/bin/varnishtest/tests/r01206.vtc new file mode 100644 index 0000000..dc403ed --- /dev/null +++ b/bin/varnishtest/tests/r01206.vtc @@ -0,0 +1,48 @@ +varnishtest "Pass shouldn't honor IMS/INM if the backend doesn't" + +server s1 { + rxreq + txresp -bodylen 6 + + rxreq + txresp -hdr "ETag: 123456789" \ + -bodylen 7 + + rxreq + txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ + -bodylen 8 +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + return(pass); + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.bodylen == 6 + + txreq -hdr "If-None-Match: 123456789" + rxresp + expect resp.status == 200 + expect resp.bodylen == 7 + + txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" + rxresp + expect resp.status == 200 + expect resp.bodylen == 8 +} -run + +server s1 -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + set beresp.do_pass = true; + } +} + +client c1 -run + From phk at varnish-cache.org Thu Oct 18 10:39:53 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 18 Oct 2012 12:39:53 +0200 Subject: [master] 7480dff Assert that the thread-workspace is empty on state transitions. We want to keep it light and small, so we forbid any long-term usage an detect leakage with this assert. Message-ID: commit 7480dff735bba2fa82cd71f3de4a1cd1d7eff77f Author: Poul-Henning Kamp Date: Thu Oct 18 10:39:07 2012 +0000 Assert that the thread-workspace is empty on state transitions. We want to keep it light and small, so we forbid any long-term usage an detect leakage with this assert. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 9f996c3..edd986c 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1205,9 +1205,16 @@ CNT_Request(struct worker *wrk, struct req *req) */ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC); - WS_Assert(wrk->aws); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + /* + * We don't want the thread workspace to be used for + * anything of long duration, so mandate that it be + * empty on state-transitions. + */ + WS_Assert(wrk->aws); + assert(wrk->aws->s == wrk->aws->f); + switch (req->req_step) { #define REQ_STEP(l,u,arg) \ case R_STP_##u: \ From phk at varnish-cache.org Thu Oct 18 11:49:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 18 Oct 2012 13:49:37 +0200 Subject: [master] 16d7395 Snapshot the thread workspace around VCL executions. Message-ID: commit 16d7395da8fde7bebcf6f418031f8a9db06d0b54 Author: Poul-Henning Kamp Date: Thu Oct 18 11:48:38 2012 +0000 Snapshot the thread workspace around VCL executions. Ideally we could just reset it, but other in-fsm-state uses of this workspace is allowed, so we cannot know for sure that the workspace is empty when we begin. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 07c1687..b54717c 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -337,10 +337,12 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) void \ VCL_##func##_method(struct req *req) \ { \ + char *aws; \ \ CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); \ AN(req->sp); \ + aws = WS_Snapshot(req->wrk->aws); \ req->handling = 0; \ req->cur_method = VCL_MET_ ## upper; \ VSLb(req->vsl, SLT_VCL_call, "%s", #func); \ @@ -350,6 +352,7 @@ VCL_##func##_method(struct req *req) \ req->cur_method = 0; \ assert((1U << req->handling) & bitmap); \ assert(!((1U << req->handling) & ~bitmap)); \ + WS_Reset(req->wrk->aws, aws); \ } #include "tbl/vcl_returns.h" From martin at varnish-cache.org Thu Oct 18 13:08:24 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Thu, 18 Oct 2012 15:08:24 +0200 Subject: [3.0] 01a2a5c req.url, not req.http.url Message-ID: commit 01a2a5c4dfc2fb95ac516f49f0b43ded80a6c374 Author: Tollef Fog Heen Date: Wed May 30 11:17:17 2012 +0200 req.url, not req.http.url diff --git a/doc/sphinx/tutorial/purging.rst b/doc/sphinx/tutorial/purging.rst index 22056a7..422f9f4 100644 --- a/doc/sphinx/tutorial/purging.rst +++ b/doc/sphinx/tutorial/purging.rst @@ -88,7 +88,7 @@ Support for bans is built into Varnish and available in the CLI interface. To ban every png object belonging on example.com, issue the following command:: - ban req.http.host == "example.com" && req.http.url ~ "\.png$" + ban req.http.host == "example.com" && req.url ~ "\.png$" Quite powerful, really. From phk at varnish-cache.org Thu Oct 18 17:16:59 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 18 Oct 2012 19:16:59 +0200 Subject: [master] cc16852 White space nit Message-ID: commit cc16852f2261557ef632e375c9a012c09aab829d Author: Poul-Henning Kamp Date: Thu Oct 18 17:16:49 2012 +0000 White space nit diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index fa3ae3b..f867168 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -252,7 +252,7 @@ cmd_http_expect(CMD_ARGS) vtc_log(hp->vl, 0, "REGEXP error: %s (@%d) (%s)", error, erroroffset, rhs); i = VRE_exec(vre, lhs, strlen(lhs), 0, 0, NULL, 0, 0); - if ((i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!')) + if ((i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!')) vtc_log(hp->vl, 4, "EXPECT %s (%s) %s \"%s\" match", av[0], lhs, cmp, rhs); else From phk at varnish-cache.org Thu Oct 18 17:19:27 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 18 Oct 2012 19:19:27 +0200 Subject: [master] 8b0b76f Since we have already begun reworking the VCL type definitions, move the goal-posts a serious distance while we're at it: Message-ID: commit 8b0b76f6434b81db0215a4568b0f0aaac0b88d2c Author: Poul-Henning Kamp Date: Thu Oct 18 17:17:57 2012 +0000 Since we have already begun reworking the VCL type definitions, move the goal-posts a serious distance while we're at it: We can use the thread workspace for small temporary allocations during VCL execution, use this to allocate a compound type for the HEADER type, to get us closer to typedef-ability for VCL mapped types. diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index a2dd8cd..c58af62 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -53,6 +53,22 @@ const void * const vrt_magic_string_end = &vrt_magic_string_end; /*--------------------------------------------------------------------*/ +const struct gethdr_s * +VRT_MkGethdr(struct req *req, enum gethdr_e where, const char *what) +{ + struct gethdr_s *retval; + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + retval = (void*)WS_Alloc(req->wrk->aws, sizeof *retval); + AN(retval); + retval->where = where; + retval->what = what; + return (retval); +} + + +/*--------------------------------------------------------------------*/ + void VRT_error(struct req *req, unsigned code, const char *reason) { diff --git a/include/vrt.h b/include/vrt.h index 2029f7a..ec07f65 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -38,6 +38,13 @@ struct director; struct VCL_conf; struct sockaddr_storage; +enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP }; + +struct gethdr_s { + enum gethdr_e where; + const char *what; +}; + /* * A backend probe specification */ @@ -158,7 +165,7 @@ int VRT_rewrite(const char *, const char *); void VRT_error(struct req *, unsigned, const char *); int VRT_switch_config(const char *); -enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP }; +const struct gethdr_s *VRT_MkGethdr(struct req *,enum gethdr_e, const char *); char *VRT_GetHdr(const struct req *, enum gethdr_e where, const char *); void VRT_SetHdr(struct req *, enum gethdr_e where, const char *, const char *, ...); diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 1b6bf12..c3fbef4 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -605,7 +605,8 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) vcc_ErrWhere(tl, tl->t); return; } - e1 = vcc_mk_expr(VOID, "%s, \"%s\"", v->http, v->hdr); + e1 = vcc_mk_expr(VOID, "VRT_MkGethdr(req, %s, \"%s\")", + v->http, v->hdr); if (*p != '\0') SkipToken(tl, ','); } else { diff --git a/lib/libvcl/vmodtool.py b/lib/libvcl/vmodtool.py index e7edbde..56e361b 100755 --- a/lib/libvcl/vmodtool.py +++ b/lib/libvcl/vmodtool.py @@ -56,7 +56,7 @@ ctypes = { 'REAL': "double", 'DURATION': "double", 'INT': "long", - 'HEADER': "enum gethdr_e, const char *", + 'HEADER': "const struct gethdr_s *", 'PRIV_VCL': "struct vmod_priv *", 'PRIV_CALL': "struct vmod_priv *", 'VOID': "void", diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index e31b0c8..b90d847 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -169,12 +169,12 @@ vmod_syslog(struct req *req, long fac, const char *fmt, ...) } void __match_proto__(td_std_collect) -vmod_collect(struct req *req, enum gethdr_e e, const char *h) +vmod_collect(struct req *req, const struct gethdr_s *hdr) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (e == HDR_REQ) - http_CollectHdr(req->http, h); - else if (e == HDR_BERESP && req->busyobj != NULL) - http_CollectHdr(req->busyobj->beresp, h); + if (hdr->where == HDR_REQ) + http_CollectHdr(req->http, hdr->what); + else if (hdr->where == HDR_BERESP && req->busyobj != NULL) + http_CollectHdr(req->busyobj->beresp, hdr->what); } From phk at varnish-cache.org Thu Oct 18 21:58:22 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 18 Oct 2012 23:58:22 +0200 Subject: [master] 949edaa Salvage more bits from experimental tree: Message-ID: commit 949edaa89c0fb2a3c984517f2384b1d499702ee6 Author: Poul-Henning Kamp Date: Thu Oct 18 21:57:29 2012 +0000 Salvage more bits from experimental tree: Be more aggressive about tracking const values and merge more const strings at compile time. diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index c3fbef4..f32208d 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -233,9 +233,19 @@ struct expr { enum var_type fmt; struct vsb *vsb; uint8_t constant; +#define EXPR_VAR (1<<0) +#define EXPR_CONST (1<<1) +#define EXPR_STR_CONST (1<<2) struct token *t1, *t2; }; +static inline int +vcc_isconst(const struct expr *e) +{ + AN(e->constant); + return (e->constant & EXPR_CONST); +} + static void vcc_expr0(struct vcc *tl, struct expr **e, enum var_type fmt); static struct expr * @@ -329,10 +339,13 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, case '-': VSB_cat(e->vsb, "\v-"); break; case '1': case '2': - if (*p == '1') + if (*p == '1') { + AN(e1); + AN(e1->constant); VSB_cat(e->vsb, VSB_data(e1->vsb)); - else { + } else { AN(e2); + AN(e2->constant); VSB_cat(e->vsb, VSB_data(e2->vsb)); } break; @@ -350,8 +363,10 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, e->t2 = e2->t1; else if (e1 != NULL) e->t1 = e1->t1; - if ((e1 == NULL || e1->constant) && (e2 == NULL || e2->constant)) - e->constant = 1; + if ((e1 == NULL || vcc_isconst(e1)) && (e2 == NULL || vcc_isconst(e2))) + e->constant = EXPR_CONST; + else + e->constant = EXPR_VAR; vcc_delete_expr(e1); vcc_delete_expr(e2); e->fmt = fmt; @@ -417,6 +432,7 @@ static void vcc_expr_tostring(struct expr **e, enum var_type fmt) { const char *p; + uint8_t constant = EXPR_VAR; CHECK_OBJ_NOTNULL(*e, EXPR_MAGIC); AN(fmt == STRING || fmt == STRING_LIST); @@ -427,7 +443,14 @@ vcc_expr_tostring(struct expr **e, enum var_type fmt) case BOOL: p = "VRT_BOOL_string(req, \v1)"; break; case DURATION: p = "VRT_REAL_string(req, \v1)"; break; /* XXX: should DURATION insist on "s" suffix ? */ - case INT: p = "VRT_INT_string(req, \v1)"; break; + case INT: + if (vcc_isconst(*e)) { + p = "\"\v1\""; + constant = EXPR_CONST; + } else { + p = "VRT_INT_string(req, \v1)"; + } + break; case IP: p = "VRT_IP_string(req, \v1)"; break; case BYTES: p = "VRT_REAL_string(req, \v1)"; break; /* XXX */ case REAL: p = "VRT_REAL_string(req, \v1)"; break; @@ -436,7 +459,7 @@ vcc_expr_tostring(struct expr **e, enum var_type fmt) } if (p != NULL) { *e = vcc_expr_edit(fmt, p, *e, NULL); - (*e)->constant = 0; + (*e)->constant = constant; } } @@ -488,7 +511,7 @@ vcc_Eval_BoolConst(struct vcc *tl, struct expr **e, const struct symbol *sym) vcc_NextToken(tl); *e = vcc_mk_expr(BOOL, "(0==%d)", sym->eval_priv == NULL ? 1 : 0); - (*e)->constant = 1; + (*e)->constant = EXPR_CONST; } /*-------------------------------------------------------------------- @@ -503,6 +526,7 @@ vcc_Eval_Backend(struct vcc *tl, struct expr **e, const struct symbol *sym) vcc_ExpectCid(tl); vcc_AddRef(tl, tl->t, SYM_BACKEND); *e = vcc_mk_expr(BACKEND, "VGCDIR(_%.*s)", PF(tl->t)); + (*e)->constant = EXPR_VAR; /* XXX ? */ vcc_NextToken(tl); } @@ -519,6 +543,7 @@ vcc_Eval_Var(struct vcc *tl, struct expr **e, const struct symbol *sym) ERRCHK(tl); assert(vp != NULL); *e = vcc_mk_expr(vp->fmt, "%s", vp->rname); + (*e)->constant = EXPR_VAR; vcc_NextToken(tl); } @@ -541,6 +566,7 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) SkipToken(tl, '('); p = sym->args; e2 = vcc_mk_expr(vcc_arg_type(&p), "%s(req\v+", sym->cfunc); + e2->constant = EXPR_VAR; while (*p != '\0') { e1 = NULL; fmt = vcc_arg_type(&p); @@ -549,11 +575,13 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) AN(r); e1 = vcc_mk_expr(VOID, "&vmod_priv_%.*s", (int) (r - sym->name), sym->name); + e1->constant = EXPR_VAR; p += strlen(p) + 1; } else if (fmt == VOID && !strcmp(p, "PRIV_CALL")) { bprintf(buf, "vmod_priv_%u", tl->nvmodpriv++); Fh(tl, 0, "struct vmod_priv %s;\n", buf); e1 = vcc_mk_expr(VOID, "&%s", buf); + e1->constant = EXPR_VAR; p += strlen(p) + 1; } else if (fmt == ENUM) { ExpectErr(tl, ID); @@ -575,6 +603,7 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) return; } e1 = vcc_mk_expr(VOID, "\"%.*s\"", PF(tl->t)); + e1->constant = EXPR_VAR; while (*p != '\0') p += strlen(p) + 1; p++; @@ -607,6 +636,7 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) } e1 = vcc_mk_expr(VOID, "VRT_MkGethdr(req, %s, \"%s\")", v->http, v->hdr); + e1->constant = EXPR_VAR; if (*p != '\0') SkipToken(tl, ','); } else { @@ -631,10 +661,12 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) SkipToken(tl, ','); } e2 = vcc_expr_edit(e2->fmt, "\v1,\n\v2", e2, e1); + e2->constant = EXPR_VAR; } SkipToken(tl, ')'); e2 = vcc_expr_edit(e2->fmt, "\v1\n)\v-", e2, NULL); *e = e2; + (*e)->constant = EXPR_VAR; } /*-------------------------------------------------------------------- @@ -699,7 +731,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) EncToken(e1->vsb, tl->t); e1->fmt = STRING; e1->t1 = tl->t; - e1->constant = 1; + e1->constant = EXPR_CONST; vcc_NextToken(tl); AZ(VSB_finish(e1->vsb)); *e = e1; @@ -726,7 +758,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) e1 = vcc_mk_expr(INT, "%.*s", PF(tl->t)); vcc_NextToken(tl); } - e1->constant = 1; + e1->constant = EXPR_CONST; *e = e1; break; default: @@ -786,51 +818,83 @@ vcc_expr_mul(struct vcc *tl, struct expr **e, enum var_type fmt) * SYNTAX: * ExprAdd: * ExprMul { {'+'|'-'} ExprMul } * + * + * For reasons of memory allocation/copying and general performance, + * STRINGs in VCL are quite special. Addition/concatenation is split + * into it's own subfunction to encapsulate this. */ static void -vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) +vcc_expr_string_add(struct vcc *tl, struct expr **e, enum var_type fmt) { struct expr *e2; enum var_type f2; - struct token *tk; - *e = NULL; - vcc_expr_mul(tl, e, fmt); - ERRCHK(tl); + AN((*e)->constant); f2 = (*e)->fmt; - if ((f2 == STRING_LIST || f2 == STRING) && tl->t->tok == '+') { - while (tl->t->tok == '+') { - vcc_NextToken(tl); - vcc_expr_mul(tl, &e2, STRING); - ERRCHK(tl); - if (e2->fmt != STRING && e2->fmt != STRING_LIST) - vcc_expr_tostring(&e2, f2); - ERRCHK(tl); - assert(e2->fmt == STRING || e2->fmt == STRING_LIST); - if ((*e)->constant && e2->constant) { - assert((*e)->fmt == STRING); - assert(e2->fmt == STRING); - *e = vcc_expr_edit(STRING, "\v1\n\v2", *e, e2); - } else { - *e = vcc_expr_edit(STRING_LIST, - "\v1,\n\v2", *e, e2); - } + while (tl->t->tok == '+') { + vcc_NextToken(tl); + vcc_expr_mul(tl, &e2, STRING); + ERRCHK(tl); + if (e2->fmt != STRING && e2->fmt != STRING_LIST) + vcc_expr_tostring(&e2, f2); + ERRCHK(tl); + assert(e2->fmt == STRING || e2->fmt == STRING_LIST); + + AN((*e)->constant); + AN(e2->constant); + + if (vcc_isconst(*e) && vcc_isconst(e2)) { + assert((*e)->fmt == STRING); + assert(e2->fmt == STRING); + *e = vcc_expr_edit(STRING, "\v1\n\v2", *e, e2); + (*e)->constant = EXPR_CONST; + } else if (((*e)->constant & EXPR_STR_CONST) && + vcc_isconst(e2)) { + assert((*e)->fmt == STRING_LIST); + assert(e2->fmt == STRING); + *e = vcc_expr_edit(STRING_LIST, "\v1\n\v2", *e, e2); + (*e)->constant |= EXPR_STR_CONST; + } else if (e2->fmt == STRING && vcc_isconst(e2)) { + *e = vcc_expr_edit(STRING_LIST, "\v1,\n\v2", *e, e2); + (*e)->constant = EXPR_VAR | EXPR_STR_CONST; + } else { + *e = vcc_expr_edit(STRING_LIST, "\v1,\n\v2", *e, e2); + (*e)->constant = EXPR_VAR; } } - if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST) + AN((*e)->constant); + if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST) { *e = vcc_expr_edit(STRING, "\v+VRT_ReqString(req,\n\v1,\nvrt_magic_string_end)", *e, NULL); - if (fmt == STRING_LIST && (*e)->fmt == STRING) + (*e)->constant = EXPR_VAR; + } if (fmt == STRING_LIST && (*e)->fmt == STRING) { (*e)->fmt = STRING_LIST; + } + AN((*e)->constant); +} + +static void +vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) +{ + struct expr *e2; + enum var_type f2; + struct token *tk; + + *e = NULL; + vcc_expr_mul(tl, e, fmt); + ERRCHK(tl); + f2 = (*e)->fmt; switch(f2) { - case INT: break; - case TIME: break; - case DURATION: break; - case BYTES: break; + case STRING: break; + case STRING_LIST: break; + case INT: break; + case TIME: break; + case DURATION: break; + case BYTES: break; default: if (tl->t->tok != '+' && tl->t->tok != '-') return; @@ -840,6 +904,11 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) return; } + if (f2 == STRING || f2 == STRING_LIST) { + vcc_expr_string_add(tl, e, fmt); + return; + } + while (tl->t->tok == '+' || tl->t->tok == '-') { if (f2 == TIME) f2 = DURATION; From phk at varnish-cache.org Thu Oct 18 22:09:01 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 19 Oct 2012 00:09:01 +0200 Subject: [master] 0e984bd Make Message-ID: commit 0e984bd491faa3742601ee8c64a69955445bc7a0 Author: Poul-Henning Kamp Date: Thu Oct 18 22:07:29 2012 +0000 Make set req.http.Cookie = req.http.Cookie + " " + req.http.Cookie-sess; do the obvious thing, even if req.http.Cookie does not exist. The underlying issue was a badly though through overloading of the NULL value to mean "Unset". Now it has its own magic marker. Fixes #1218 diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index c58af62..c4573ff 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -50,6 +50,7 @@ #include "vtim.h" const void * const vrt_magic_string_end = &vrt_magic_string_end; +const void * const vrt_magic_string_unset = &vrt_magic_string_unset; /*--------------------------------------------------------------------*/ @@ -239,7 +240,7 @@ VRT_SetHdr(struct req *req , enum gethdr_e where, const char *hdr, CHECK_OBJ_NOTNULL(req, REQ_MAGIC); hp = vrt_selecthttp(req, where); va_start(ap, p); - if (p == NULL) { + if (p == vrt_magic_string_unset) { http_Unset(hp, hdr); } else { b = VRT_String(hp->ws, hdr + 1, p, ap); diff --git a/bin/varnishtest/tests/r01218.vtc b/bin/varnishtest/tests/r01218.vtc new file mode 100644 index 0000000..ed87746 --- /dev/null +++ b/bin/varnishtest/tests/r01218.vtc @@ -0,0 +1,20 @@ +varnishtest "regression for NULL string concatenation" + +server s1 { + rxreq + expect req.http.Candy == "FOOBAR" + expect req.http.Cookie == "FOOBAR" + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.http.Candy = " FOOBAR" + req.http.Cookie; + set req.http.Cookie = req.http.Cookie + " FOOBAR"; + } +} -start + +client c1 { + txreq + rxresp +} -run diff --git a/include/vrt.h b/include/vrt.h index ec07f65..332d3e0 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -50,6 +50,7 @@ struct gethdr_s { */ extern const void * const vrt_magic_string_end; +extern const void * const vrt_magic_string_unset; struct vrt_backend_probe { const char *url; diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index 7eecc33..ecf0069 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -163,7 +163,7 @@ parse_unset(struct vcc *tl) return; } ERRCHK(tl); - Fb(tl, 1, "%s0);\n", vp->lname); + Fb(tl, 1, "%svrt_magic_string_unset);\n", vp->lname); vcc_NextToken(tl); } From phk at varnish-cache.org Fri Oct 19 08:06:28 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 19 Oct 2012 10:06:28 +0200 Subject: [master] 1cf3f7f Fix an indentation problem in the produced C source. Message-ID: commit 1cf3f7fe8c202fd0a3a05f5da6c9dbfa2cc31e9a Author: Poul-Henning Kamp Date: Fri Oct 19 08:06:07 2012 +0000 Fix an indentation problem in the produced C source. diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index ecf0069..4b3d69b 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -120,7 +120,8 @@ parse_set(struct vcc *tl) vp = vcc_FindVar(tl, tl->t, 1, "cannot be set"); ERRCHK(tl); assert(vp != NULL); - Fb(tl, 1, "%s", vp->lname); + Fb(tl, 1, "%s\n", vp->lname); + tl->indent += INDENT; vcc_NextToken(tl); fmt = vp->fmt; for (ap = arith; ap->type != VOID; ap++) { @@ -129,7 +130,7 @@ parse_set(struct vcc *tl) if (ap->oper != tl->t->tok) continue; if (ap->oper != '=') - Fb(tl, 0, "%s %c ", vp->rname, *tl->t->b); + Fb(tl, 1, "%s %c ", vp->rname, *tl->t->b); vcc_NextToken(tl); fmt = ap->want; break; @@ -141,6 +142,7 @@ parse_set(struct vcc *tl) } else { vcc_Expr(tl, fmt); } + tl->indent -= INDENT; Fb(tl, 1, ");\n"); } From phk at varnish-cache.org Fri Oct 19 08:07:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 19 Oct 2012 10:07:37 +0200 Subject: [master] f68b7c4 Default all expressions to be variable. Message-ID: commit f68b7c425a73a485372d51eb40fe60b81b367590 Author: Poul-Henning Kamp Date: Fri Oct 19 08:07:05 2012 +0000 Default all expressions to be variable. Various cleanup and tightening of code. diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index f32208d..3710490 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -258,6 +258,7 @@ vcc_new_expr(void) AN(e); e->vsb = VSB_new_auto(); e->fmt = VOID; + e->constant = EXPR_VAR; return (e); } @@ -319,38 +320,27 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, e = vcc_new_expr(); while (*p != '\0') { - if (*p == '\n') { - if (!nl) - VSB_putc(e->vsb, *p); - nl = 1; - p++; - continue; - } - nl = 0; if (*p != '\v') { - VSB_putc(e->vsb, *p); + if (*p != '\n' || !nl) + VSB_putc(e->vsb, *p); + nl = (*p == '\n'); p++; continue; } assert(*p == '\v'); - p++; - switch(*p) { + switch(*++p) { case '+': VSB_cat(e->vsb, "\v+"); break; case '-': VSB_cat(e->vsb, "\v-"); break; case '1': + AN(e1); + VSB_cat(e->vsb, VSB_data(e1->vsb)); + break; case '2': - if (*p == '1') { - AN(e1); - AN(e1->constant); - VSB_cat(e->vsb, VSB_data(e1->vsb)); - } else { - AN(e2); - AN(e2->constant); - VSB_cat(e->vsb, VSB_data(e2->vsb)); - } + AN(e2); + VSB_cat(e->vsb, VSB_data(e2->vsb)); break; default: - assert(__LINE__ == 0); + WRONG("Illegal edit in VCC expression"); } p++; } @@ -360,13 +350,9 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, else if (e2 != NULL) e->t1 = e2->t1; if (e2 != NULL) - e->t2 = e2->t1; + e->t2 = e2->t2; else if (e1 != NULL) - e->t1 = e1->t1; - if ((e1 == NULL || vcc_isconst(e1)) && (e2 == NULL || vcc_isconst(e2))) - e->constant = EXPR_CONST; - else - e->constant = EXPR_VAR; + e->t2 = e1->t2; vcc_delete_expr(e1); vcc_delete_expr(e2); e->fmt = fmt; @@ -543,7 +529,6 @@ vcc_Eval_Var(struct vcc *tl, struct expr **e, const struct symbol *sym) ERRCHK(tl); assert(vp != NULL); *e = vcc_mk_expr(vp->fmt, "%s", vp->rname); - (*e)->constant = EXPR_VAR; vcc_NextToken(tl); } @@ -566,7 +551,6 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) SkipToken(tl, '('); p = sym->args; e2 = vcc_mk_expr(vcc_arg_type(&p), "%s(req\v+", sym->cfunc); - e2->constant = EXPR_VAR; while (*p != '\0') { e1 = NULL; fmt = vcc_arg_type(&p); @@ -575,13 +559,11 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) AN(r); e1 = vcc_mk_expr(VOID, "&vmod_priv_%.*s", (int) (r - sym->name), sym->name); - e1->constant = EXPR_VAR; p += strlen(p) + 1; } else if (fmt == VOID && !strcmp(p, "PRIV_CALL")) { bprintf(buf, "vmod_priv_%u", tl->nvmodpriv++); Fh(tl, 0, "struct vmod_priv %s;\n", buf); e1 = vcc_mk_expr(VOID, "&%s", buf); - e1->constant = EXPR_VAR; p += strlen(p) + 1; } else if (fmt == ENUM) { ExpectErr(tl, ID); @@ -603,7 +585,6 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) return; } e1 = vcc_mk_expr(VOID, "\"%.*s\"", PF(tl->t)); - e1->constant = EXPR_VAR; while (*p != '\0') p += strlen(p) + 1; p++; @@ -636,7 +617,6 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) } e1 = vcc_mk_expr(VOID, "VRT_MkGethdr(req, %s, \"%s\")", v->http, v->hdr); - e1->constant = EXPR_VAR; if (*p != '\0') SkipToken(tl, ','); } else { @@ -661,12 +641,10 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) SkipToken(tl, ','); } e2 = vcc_expr_edit(e2->fmt, "\v1,\n\v2", e2, e1); - e2->constant = EXPR_VAR; } SkipToken(tl, ')'); e2 = vcc_expr_edit(e2->fmt, "\v1\n)\v-", e2, NULL); *e = e2; - (*e)->constant = EXPR_VAR; } /*-------------------------------------------------------------------- @@ -830,7 +808,6 @@ vcc_expr_string_add(struct vcc *tl, struct expr **e, enum var_type fmt) struct expr *e2; enum var_type f2; - AN((*e)->constant); f2 = (*e)->fmt; while (tl->t->tok == '+') { @@ -842,9 +819,6 @@ vcc_expr_string_add(struct vcc *tl, struct expr **e, enum var_type fmt) ERRCHK(tl); assert(e2->fmt == STRING || e2->fmt == STRING_LIST); - AN((*e)->constant); - AN(e2->constant); - if (vcc_isconst(*e) && vcc_isconst(e2)) { assert((*e)->fmt == STRING); assert(e2->fmt == STRING); @@ -855,7 +829,7 @@ vcc_expr_string_add(struct vcc *tl, struct expr **e, enum var_type fmt) assert((*e)->fmt == STRING_LIST); assert(e2->fmt == STRING); *e = vcc_expr_edit(STRING_LIST, "\v1\n\v2", *e, e2); - (*e)->constant |= EXPR_STR_CONST; + (*e)->constant = EXPR_VAR | EXPR_STR_CONST; } else if (e2->fmt == STRING && vcc_isconst(e2)) { *e = vcc_expr_edit(STRING_LIST, "\v1,\n\v2", *e, e2); (*e)->constant = EXPR_VAR | EXPR_STR_CONST; @@ -864,16 +838,12 @@ vcc_expr_string_add(struct vcc *tl, struct expr **e, enum var_type fmt) (*e)->constant = EXPR_VAR; } } - AN((*e)->constant); - if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST) { + if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST) *e = vcc_expr_edit(STRING, "\v+VRT_ReqString(req,\n\v1,\nvrt_magic_string_end)", *e, NULL); - (*e)->constant = EXPR_VAR; - } if (fmt == STRING_LIST && (*e)->fmt == STRING) { + if (fmt == STRING_LIST && (*e)->fmt == STRING) (*e)->fmt = STRING_LIST; - } - AN((*e)->constant); } static void From phk at varnish-cache.org Fri Oct 19 10:19:41 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 19 Oct 2012 12:19:41 +0200 Subject: [master] 32d5bc3 Generate "tbl/vcc_types.h" from generate.py Message-ID: commit 32d5bc323432144908cd5c7091c9443132646f0b Author: Poul-Henning Kamp Date: Fri Oct 19 10:19:04 2012 +0000 Generate "tbl/vcc_types.h" from generate.py diff --git a/include/Makefile.am b/include/Makefile.am index 15df374..2d15805 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -75,7 +75,7 @@ nobase_pkgdatainclude_HEADERS = \ vsb.h \ vsha256.h -tbl/vrt_stv_var.h tbl/vcl_returns.h vcl.h vrt_obj.h: $(top_srcdir)/lib/libvcl/generate.py $(top_srcdir)/include/vrt.h +tbl/vrt_stv_var.h tbl/vcl_returns.h tbl/vcc_types.h vcl.h vrt_obj.h: $(top_srcdir)/lib/libvcl/generate.py $(top_srcdir)/include/vrt.h mkdir -p tbl @PYTHON@ $(top_srcdir)/lib/libvcl/generate.py $(top_srcdir) $(top_builddir) diff --git a/include/tbl/vcc_types.h b/include/tbl/vcc_types.h deleted file mode 100644 index 469b56c..0000000 --- a/include/tbl/vcc_types.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 2010 Varnish Software 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. - * - */ - -/*lint -save -e525 -e539 */ -VCC_TYPE(VOID) -VCC_TYPE(BACKEND) -VCC_TYPE(BOOL) -VCC_TYPE(INT) -VCC_TYPE(TIME) -VCC_TYPE(DURATION) -VCC_TYPE(STRING) -VCC_TYPE(STRING_LIST) -VCC_TYPE(IP) -VCC_TYPE(HEADER) -VCC_TYPE(BYTES) -VCC_TYPE(REAL) -VCC_TYPE(ENUM) -/*lint -restore */ diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index ecc3a14..30dc711 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -484,6 +484,10 @@ vcltypes = { 'BYTES': "double", 'INT': "long", 'HEADER': "const char *", + 'VOID': "void", + 'REAL': "double", + 'STRING_LIST': "void*", + 'ENUM': "const char *", } ####################################################################### @@ -899,6 +903,19 @@ fo.write(""" fo.close() ####################################################################### +ft = open(buildroot + "/include/tbl/vcc_types.h", "w") +file_header(ft) + +ft.write("/*lint -save -e525 -e539 */\n") + +i = list(vcltypes.keys()) +i.sort() +for j in i: + ft.write("VCC_TYPE(" + j + ")\n") +ft.write("/*lint -restore */\n") +ft.close() + +####################################################################### fo = open(buildroot + "/include/tbl/vrt_stv_var.h", "w") From phk at varnish-cache.org Fri Oct 19 11:04:47 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 19 Oct 2012 13:04:47 +0200 Subject: [master] fa7b4f2 Use the new VCL_* typedefs. Message-ID: commit fa7b4f2b33e8f50f24cc5d0c214f4e3c32c99dbc Author: Poul-Henning Kamp Date: Fri Oct 19 11:04:31 2012 +0000 Use the new VCL_* typedefs. diff --git a/lib/libvcl/vmodtool.py b/lib/libvcl/vmodtool.py index 56e361b..d5681ee 100755 --- a/lib/libvcl/vmodtool.py +++ b/lib/libvcl/vmodtool.py @@ -46,20 +46,20 @@ else: specfile = "vmod.vcc" ctypes = { - 'IP': "struct sockaddr_storage *", - 'STRING': "const char *", - 'STRING_LIST': "const char *, ...", - 'BOOL': "unsigned", - 'BACKEND': "struct director *", - 'ENUM': "const char *", - 'TIME': "double", - 'REAL': "double", - 'DURATION': "double", - 'INT': "long", + 'BACKEND': "VCL_BACKEND", + 'BOOL': "VCL_BOOL", + 'DURATION': "VCL_DURATION", + 'ENUM': "VCL_ENUM", 'HEADER': "const struct gethdr_s *", - 'PRIV_VCL': "struct vmod_priv *", + 'INT': "VCL_INT", + 'IP': "VCL_IP", 'PRIV_CALL': "struct vmod_priv *", - 'VOID': "void", + 'PRIV_VCL': "struct vmod_priv *", + 'REAL': "VCL_REAL", + 'STRING': "VCL_STRING", + 'STRING_LIST': "const char *, ...", + 'TIME': "VCL_TIME", + 'VOID': "VCL_VOID", } ####################################################################### diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index fd1a135..ee062ac 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -35,7 +35,7 @@ #include "vrt.h" #include "vcc_if.h" -void __match_proto__(td_debug_panic) +VCL_VOID __match_proto__(td_debug_panic) vmod_panic(struct req *req, const char *str, ...) { va_list ap; @@ -48,8 +48,8 @@ vmod_panic(struct req *req, const char *str, ...) VAS_Fail("VCL", "", 0, b, 0, VAS_VCL); } -const char * __match_proto__(td_debug_author) -vmod_author(struct req *req, const char *id) +VCL_STRING __match_proto__(td_debug_author) +vmod_author(struct req *req, VCL_ENUM id) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -74,7 +74,7 @@ init_function(struct vmod_priv *priv, const struct VCL_conf *cfg) return (0); } -void __match_proto__(td_debug_test_priv_call) +VCL_VOID __match_proto__(td_debug_test_priv_call) vmod_test_priv_call(struct req *req, struct vmod_priv *priv) { @@ -87,7 +87,7 @@ vmod_test_priv_call(struct req *req, struct vmod_priv *priv) } } -void __match_proto__(td_debug_test_priv_vcl) +VCL_VOID __match_proto__(td_debug_test_priv_vcl) vmod_test_priv_vcl(struct req *req, struct vmod_priv *priv) { diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index b90d847..86b2ad3 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -45,8 +45,8 @@ #include "vcc_if.h" -void __match_proto__(td_std_set_ip_tos) -vmod_set_ip_tos(struct req *req, long tos) +VCL_VOID __match_proto__(td_std_set_ip_tos) +vmod_set_ip_tos(struct req *req, VCL_INT tos) { int itos = tos; @@ -91,7 +91,7 @@ vmod_updown(struct req *req, int up, const char *s, va_list ap) } } -const char * __match_proto__(td_std_toupper) +VCL_STRING __match_proto__(td_std_toupper) vmod_toupper(struct req *req, const char *s, ...) { const char *p; @@ -104,7 +104,7 @@ vmod_toupper(struct req *req, const char *s, ...) return (p); } -const char * __match_proto__(td_std_tolower) +VCL_STRING __match_proto__(td_std_tolower) vmod_tolower(struct req *req, const char *s, ...) { const char *p; @@ -117,8 +117,8 @@ vmod_tolower(struct req *req, const char *s, ...) return (p); } -double __match_proto__(td_std_random) -vmod_random(struct req *req, double lo, double hi) +VCL_REAL __match_proto__(td_std_random) +vmod_random(struct req *req, VCL_REAL lo, VCL_REAL hi) { double a; @@ -129,7 +129,7 @@ vmod_random(struct req *req, double lo, double hi) return (a); } -void __match_proto__(td_std_log) +VCL_VOID __match_proto__(td_std_log) vmod_log(struct req *req, const char *fmt, ...) { unsigned u; @@ -150,8 +150,8 @@ vmod_log(struct req *req, const char *fmt, ...) WS_Release(req->ws, 0); } -void __match_proto__(td_std_syslog) -vmod_syslog(struct req *req, long fac, const char *fmt, ...) +VCL_VOID __match_proto__(td_std_syslog) +vmod_syslog(struct req *req, VCL_INT fac, const char *fmt, ...) { char *p; unsigned u; @@ -168,7 +168,7 @@ vmod_syslog(struct req *req, long fac, const char *fmt, ...) WS_Release(req->ws, 0); } -void __match_proto__(td_std_collect) +VCL_VOID __match_proto__(td_std_collect) vmod_collect(struct req *req, const struct gethdr_s *hdr) { diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index e728611..96456b2 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -38,8 +38,8 @@ #include "vrt.h" #include "vcc_if.h" -double __match_proto__() -vmod_duration(struct req *req, const char *p, double d) +VCL_DURATION __match_proto__() +vmod_duration(struct req *req, const char *p, VCL_DURATION d) { char *e; double r; @@ -88,8 +88,8 @@ vmod_duration(struct req *req, const char *p, double d) return (r); } -long __match_proto__() -vmod_integer(struct req *req, const char *p, long i) +VCL_INT __match_proto__() +vmod_integer(struct req *req, const char *p, VCL_INT i) { char *e; long r; diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c index d424d75..163926c 100644 --- a/lib/libvmod_std/vmod_std_fileread.c +++ b/lib/libvmod_std/vmod_std_fileread.c @@ -82,8 +82,8 @@ free_frfile(void *ptr) } } -const char * __match_proto__(td_std_fileread) -vmod_fileread(struct req *req, struct vmod_priv *priv, const char *file_name) +VCL_STRING __match_proto__(td_std_fileread) +vmod_fileread(struct req *req, struct vmod_priv *priv, VCL_STRING file_name) { struct frfile *frf = NULL; char *s; From phk at varnish-cache.org Fri Oct 19 11:04:47 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 19 Oct 2012 13:04:47 +0200 Subject: [master] 0b877e6 Introduce a bunch of canonical typedefs to map VCL types to C types. Have the python code learn the mapping from them. Message-ID: commit 0b877e6a701729a506b7aba16f08314074a3c743 Author: Poul-Henning Kamp Date: Fri Oct 19 10:47:58 2012 +0000 Introduce a bunch of canonical typedefs to map VCL types to C types. Have the python code learn the mapping from them. diff --git a/include/vrt.h b/include/vrt.h index 332d3e0..8ca31de 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -38,6 +38,26 @@ struct director; struct VCL_conf; struct sockaddr_storage; +/*********************************************************************** + * This is the central definition of the mapping from VCL types to + * C-types. The python scripts read these from here. + */ + +typedef struct director * VCL_BACKEND; +typedef unsigned VCL_BOOL; +typedef double VCL_BYTES; +typedef double VCL_DURATION; +typedef const char * VCL_ENUM; +typedef const char * VCL_HEADER; +typedef long VCL_INT; +typedef struct sockaddr_storage * VCL_IP; +typedef double VCL_REAL; +typedef const char * VCL_STRING; +typedef double VCL_TIME; +typedef void VCL_VOID; + +/***********************************************************************/ + enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP }; struct gethdr_s { diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 30dc711..7ddafeb 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -475,21 +475,25 @@ stv_variables = ( # VCL to C type conversion vcltypes = { - 'IP': "struct sockaddr_storage *", - 'STRING': "const char *", - 'BOOL': "unsigned", - 'BACKEND': "struct director *", - 'TIME': "double", - 'DURATION': "double", - 'BYTES': "double", - 'INT': "long", - 'HEADER': "const char *", - 'VOID': "void", - 'REAL': "double", 'STRING_LIST': "void*", - 'ENUM': "const char *", } +fi = open(buildroot + "/include/vrt.h") + +for i in fi: + j = i.split(); + if len(j) < 3: + continue + if j[0] != "typedef": + continue + if j[-1][-1] != ";": + continue + if j[-1][:4] != "VCL_": + continue + d = " ".join(j[1:-1]) + vcltypes[j[-1][4:-1]] = d +fi.close() + ####################################################################### # Nothing is easily configurable below this line. ####################################################################### From phk at varnish-cache.org Mon Oct 22 06:16:56 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Oct 2012 08:16:56 +0200 Subject: [master] 419304a Stagger ramp-up to avoid large -j from becoming thundering herd Message-ID: commit 419304a9f07f1d8cad956744614a342b08955a54 Author: Poul-Henning Kamp Date: Mon Oct 22 06:16:20 2012 +0000 Stagger ramp-up to avoid large -j from becoming thundering herd diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index fb1c42e..04aba0d 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -405,6 +405,9 @@ main(int argc, char * const *argv) if (!VTAILQ_EMPTY(&tst_head) && njob < npar) { start_test(); njob++; + /* Stagger ramp-up */ + if (njob < npar) + (void)usleep(random() % 100000L); i = 1; continue; } From phk at varnish-cache.org Mon Oct 22 07:08:05 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Oct 2012 09:08:05 +0200 Subject: [master] 3e66986 If the acceptor thread can hand work off to other threads, release any VCL reference it might have, in order to not hold on to discarded VCLs forever. Message-ID: commit 3e66986396418558d70194196813d9526b54f3f0 Author: Poul-Henning Kamp Date: Mon Oct 22 07:07:27 2012 +0000 If the acceptor thread can hand work off to other threads, release any VCL reference it might have, in order to not hold on to discarded VCLs forever. diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 336c76a..0e0d9dd 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -163,6 +163,13 @@ pool_accept(struct worker *wrk, void *arg) wrk2->task.func = SES_pool_accept_task; wrk2->task.priv = pp->sesspool; AZ(pthread_cond_signal(&wrk2->cond)); + + /* + * We were able to hand off, so release this threads VCL + * reference (if any) so we don't hold on to discarded VCLs. + */ + if (wrk->vcl != NULL) + VCL_Rel(&wrk->vcl); } } From phk at varnish-cache.org Mon Oct 22 07:21:00 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Oct 2012 09:21:00 +0200 Subject: [master] e1f7207 Try to make this test more robust Message-ID: commit e1f72076cbd9a0262d0f79362892f4e9299636f4 Author: Poul-Henning Kamp Date: Mon Oct 22 07:20:26 2012 +0000 Try to make this test more robust diff --git a/bin/varnishtest/tests/v00006.vtc b/bin/varnishtest/tests/v00006.vtc index 494007f..31018e9 100644 --- a/bin/varnishtest/tests/v00006.vtc +++ b/bin/varnishtest/tests/v00006.vtc @@ -1,23 +1,32 @@ varnishtest "VCL: Test backend retirement" +# +# This case is quite sensitive to ordering of the worker threads because +# it has so little actual traffic. In a real world setting, this should +# not be an issue. +# # First do one request to get a work-thread that holds a VCL reference server s1 { rxreq + expect req.url == "/bar" txresp } -start # Only one pool, to avoid getting more than one work thread -varnish v1 -arg "-p thread_pools=1" -vcl+backend { -} -start +varnish v1 -arg "-p thread_pools=1" -vcl+backend { } -start + +# Give the varnishd a chance to start and create workers etc. +# NB: This is important for to avoid mis-ordering of the workers. +delay 1 client c1 { - txreq + txreq -url /bar rxresp -} -start + expect resp.status == 200 +} -run server s1 -wait -client c1 -wait varnish v1 -expect n_backend == 1 varnish v1 -expect n_vcl_avail == 1 @@ -27,6 +36,7 @@ varnish v1 -expect n_vcl_discard == 0 server s2 { rxreq + expect req.url == "/foo" txresp } -start @@ -59,8 +69,11 @@ varnish v1 -expect n_vcl_discard == 1 client c1 { txreq -url /foo rxresp + expect resp.status == 200 } -run +server s2 -wait + # The workthread should have released its VCL reference now # but we need to tickle the CLI to notice From phk at varnish-cache.org Mon Oct 22 07:21:00 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Oct 2012 09:21:00 +0200 Subject: [master] aede588 I think we can do with even less VSM for testcases. Message-ID: commit aede5884e08420dc1661ac7b22856832498687bb Author: Poul-Henning Kamp Date: Mon Oct 22 07:20:48 2012 +0000 I think we can do with even less VSM for testcases. diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 794080f..10c1d31 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -347,7 +347,7 @@ varnish_launch(struct varnish *v) AN(vsb); VSB_printf(vsb, "cd ${pwd} &&"); VSB_printf(vsb, " ${varnishd} -d -d -n %s", v->workdir); - VSB_printf(vsb, " -l 10m,1m,-"); + VSB_printf(vsb, " -l 2m,1m,-"); 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"); From tfheen at varnish-cache.org Mon Oct 22 11:37:36 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Oct 2012 13:37:36 +0200 Subject: [master] 7157107 Reopen log file in varnishtop if varnish restarts Message-ID: commit 7157107e77432bb6824899032a93ff1c742ca07f Author: Tollef Fog Heen Date: Mon Oct 22 13:34:41 2012 +0200 Reopen log file in varnishtop if varnish restarts Use VSL_Dispatch instead of VSL_NextSLT in varnishtop, which does this automatically for us. Clean up accumulate() a bit in the process. Fixes #1213 diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 716b35b..04b97d7 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -78,37 +78,40 @@ static int f_flag = 0; static unsigned maxfieldlen = 0; -static void -accumulate(uint32_t * const p) +static int +accumulate(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, + unsigned spec, const char *ptr, uint64_t bm) { struct top *tp, *tp2; const char *q; - unsigned int u, l; - uint8_t t; + unsigned int u; int i; + (void)priv; + (void)fd; + (void)spec; + (void)bm; // fprintf(stderr, "%p %08x %08x\n", p, p[0], p[1]); u = 0; - q = VSL_DATA(p); - l = VSL_LEN(p); - t = VSL_TAG(p); - for (i = 0; i < l; i++, q++) { + q = ptr; + for (i = 0; i < len; i++, q++) { if (f_flag && (*q == ':' || isspace(*q))) { - l = q - VSL_DATA(p); + len = q - ptr; break; } u += *q; } + AZ(pthread_mutex_lock(&mtx)); VTAILQ_FOREACH(tp, &top_head, list) { if (tp->hash != u) continue; - if (tp->tag != t) + if (tp->tag != tag) continue; - if (tp->clen != l) + if (tp->clen != len) continue; - if (memcmp(VSL_DATA(p), tp->rec_data, l)) + if (memcmp(ptr, tp->rec_data, len)) continue; tp->count += 1.0; break; @@ -117,14 +120,14 @@ accumulate(uint32_t * const p) ntop++; tp = calloc(sizeof *tp, 1); assert(tp != NULL); - tp->rec_data = calloc(l + 1, 1); + tp->rec_data = calloc(len + 1, 1); assert(tp->rec_data != NULL); tp->hash = u; tp->count = 1.0; - tp->clen = l; - tp->tag = t; - memcpy(tp->rec_data, VSL_DATA(p), l); - tp->rec_data[l] = '\0'; + tp->clen = len; + tp->tag = tag; + memcpy(tp->rec_data, ptr, len); + tp->rec_data[len] = '\0'; VTAILQ_INSERT_TAIL(&top_head, tp, list); } while (1) { @@ -141,6 +144,9 @@ accumulate(uint32_t * const p) VTAILQ_REMOVE(&top_head, tp2, list); VTAILQ_INSERT_BEFORE(tp, tp2, list); } + AZ(pthread_mutex_unlock(&mtx)); + + return (0); } static void @@ -190,22 +196,15 @@ static void * accumulate_thread(void *arg) { struct VSM_data *vd = arg; - uint32_t *p; int i; for (;;) { - i = VSL_NextSLT(vd, &p, NULL); + i = VSL_Dispatch(vd, accumulate, NULL); if (i < 0) break; - if (i == 0) { - AZ(usleep(50000)); - continue; - } - - AZ(pthread_mutex_lock(&mtx)); - accumulate(p); - AZ(pthread_mutex_unlock(&mtx)); + if (i == 0) + usleep(50000); } return (arg); } @@ -290,10 +289,8 @@ dump(void) static void do_once(struct VSM_data *vd) { - uint32_t *p; - - while (VSL_NextSLT(vd, &p, NULL) > 0) - accumulate(p); + while (VSL_Dispatch(vd, accumulate, NULL) > 0) + ; dump(); } From tfheen at varnish-cache.org Mon Oct 22 11:43:29 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Oct 2012 13:43:29 +0200 Subject: [3.0] ae6c64f Reopen log file in varnishtop if varnish restarts Message-ID: commit ae6c64fb0e8da67ba33270487c23d64a6d2efa79 Author: Tollef Fog Heen Date: Mon Oct 22 13:34:41 2012 +0200 Reopen log file in varnishtop if varnish restarts Use VSL_Dispatch instead of VSL_NextSLT in varnishtop, which does this automatically for us. Clean up accumulate() a bit in the process. Fixes #1213 diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 8459ab5..48d7c2a 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -78,37 +78,40 @@ static int f_flag = 0; static unsigned maxfieldlen = 0; -static void -accumulate(uint32_t * const p) +static int +accumulate(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, + unsigned spec, const char *ptr, uint64_t bm) { struct top *tp, *tp2; const char *q; - unsigned int u, l; - uint8_t t; + unsigned int u; int i; + (void)priv; + (void)fd; + (void)spec; + (void)bm; // fprintf(stderr, "%p %08x %08x\n", p, p[0], p[1]); u = 0; - q = VSL_DATA(p); - l = VSL_LEN(p); - t = VSL_TAG(p); - for (i = 0; i < l; i++, q++) { + q = ptr; + for (i = 0; i < len; i++, q++) { if (f_flag && (*q == ':' || isspace(*q))) { - l = q - VSL_DATA(p); + len = q - ptr; break; } u += *q; } + AZ(pthread_mutex_lock(&mtx)); VTAILQ_FOREACH(tp, &top_head, list) { if (tp->hash != u) continue; - if (tp->tag != t) + if (tp->tag != tag) continue; - if (tp->clen != l) + if (tp->clen != len) continue; - if (memcmp(VSL_DATA(p), tp->rec_data, l)) + if (memcmp(ptr, tp->rec_data, len)) continue; tp->count += 1.0; break; @@ -117,14 +120,14 @@ accumulate(uint32_t * const p) ntop++; tp = calloc(sizeof *tp, 1); assert(tp != NULL); - tp->rec_data = calloc(l + 1, 1); + tp->rec_data = calloc(len + 1, 1); assert(tp->rec_data != NULL); tp->hash = u; tp->count = 1.0; - tp->clen = l; - tp->tag = t; - memcpy(tp->rec_data, VSL_DATA(p), l); - tp->rec_data[l] = '\0'; + tp->clen = len; + tp->tag = tag; + memcpy(tp->rec_data, ptr, len); + tp->rec_data[len] = '\0'; VTAILQ_INSERT_TAIL(&top_head, tp, list); } while (1) { @@ -141,6 +144,9 @@ accumulate(uint32_t * const p) VTAILQ_REMOVE(&top_head, tp2, list); VTAILQ_INSERT_BEFORE(tp, tp2, list); } + AZ(pthread_mutex_unlock(&mtx)); + + return (0); } static void @@ -190,22 +196,15 @@ static void * accumulate_thread(void *arg) { struct VSM_data *vd = arg; - uint32_t *p; int i; for (;;) { - i = VSL_NextLog(vd, &p, NULL); + i = VSL_Dispatch(vd, accumulate, NULL); if (i < 0) break; - if (i == 0) { - AZ(usleep(50000)); - continue; - } - - AZ(pthread_mutex_lock(&mtx)); - accumulate(p); - AZ(pthread_mutex_unlock(&mtx)); + if (i == 0) + usleep(50000); } return (arg); } @@ -290,10 +289,8 @@ dump(void) static void do_once(struct VSM_data *vd) { - uint32_t *p; - - while (VSL_NextLog(vd, &p, NULL) > 0) - accumulate(p); + while (VSL_Dispatch(vd, accumulate, NULL) > 0) + ; dump(); } From phk at varnish-cache.org Tue Oct 23 21:06:31 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 23 Oct 2012 23:06:31 +0200 Subject: [master] d445e56 Turn "HEADER" into a full blown VCL data type, this is actually simpler and more orthogonal. Message-ID: commit d445e56abf19792c6bdd1ab989d82eedb186f314 Author: Poul-Henning Kamp Date: Tue Oct 23 21:02:44 2012 +0000 Turn "HEADER" into a full blown VCL data type, this is actually simpler and more orthogonal. This is a "it works!" snapshot, there are improvements to the generated C-code in the pipeline. diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index c4573ff..ed7ae59 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -138,14 +138,14 @@ vrt_selecthttp(const struct req *req, enum gethdr_e where) } char * -VRT_GetHdr(const struct req *req, enum gethdr_e where, const char *n) +VRT_GetHdr(const struct req *req, const struct gethdr_s *hs) { char *p; struct http *hp; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - hp = vrt_selecthttp(req, where); - if (!http_GetHdr(hp, n, &p)) + hp = vrt_selecthttp(req, hs->where); + if (!http_GetHdr(hp, hs->what, &p)) return (NULL); return (p); } @@ -230,24 +230,25 @@ VRT_ReqString(struct req *req, const char *p, ...) /*--------------------------------------------------------------------*/ void -VRT_SetHdr(struct req *req , enum gethdr_e where, const char *hdr, - const char *p, ...) +VRT_SetHdr(struct req *req , const struct gethdr_s *hs, const char *p, ...) { struct http *hp; va_list ap; char *b; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - hp = vrt_selecthttp(req, where); + AN(hs); + AN(hs->what); + hp = vrt_selecthttp(req, hs->where); va_start(ap, p); if (p == vrt_magic_string_unset) { - http_Unset(hp, hdr); + http_Unset(hp, hs->what); } else { - b = VRT_String(hp->ws, hdr + 1, p, ap); + b = VRT_String(hp->ws, hs->what + 1, p, ap); if (b == NULL) { - VSLb(req->vsl, SLT_LostHeader, "%s", hdr + 1); + VSLb(req->vsl, SLT_LostHeader, "%s", hs->what + 1); } else { - http_Unset(hp, hdr); + http_Unset(hp, hs->what); http_SetHeader(hp, b); } } diff --git a/include/vrt.h b/include/vrt.h index 8ca31de..c98e085 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -187,9 +187,8 @@ void VRT_error(struct req *, unsigned, const char *); int VRT_switch_config(const char *); const struct gethdr_s *VRT_MkGethdr(struct req *,enum gethdr_e, const char *); -char *VRT_GetHdr(const struct req *, enum gethdr_e where, const char *); -void VRT_SetHdr(struct req *, enum gethdr_e where, const char *, - const char *, ...); +char *VRT_GetHdr(const struct req *, const struct gethdr_s *); +void VRT_SetHdr(struct req *, const struct gethdr_s *, const char *, ...); void VRT_handling(struct req *, unsigned hand); void VRT_hashdata(struct req *, const char *str, ...); diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 7ddafeb..6efff05 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -158,7 +158,7 @@ sp_variables = ( 'const struct req *' ), ('req.http.', - 'HDR_REQ', + 'HEADER', ( 'proc',), ( 'proc',), 'const struct req *' @@ -254,7 +254,7 @@ sp_variables = ( 'const struct req *' ), ('bereq.http.', - 'HDR_BEREQ', + 'HEADER', ( 'pipe', 'pass', 'miss', 'fetch',), ( 'pipe', 'pass', 'miss', 'fetch',), 'const struct req *' @@ -302,7 +302,7 @@ sp_variables = ( 'const struct req *' ), ('beresp.http.', - 'HDR_BERESP', + 'HEADER', ( 'fetch',), ( 'fetch',), 'const struct req *' @@ -404,7 +404,7 @@ sp_variables = ( 'const struct req *' ), ('obj.http.', - 'HDR_OBJ', + 'HEADER', ( 'hit', 'error',), ( 'error',), # XXX ? 'const struct req *' @@ -452,7 +452,7 @@ sp_variables = ( 'const struct req *' ), ('resp.http.', - 'HDR_RESP', + 'HEADER', ( 'deliver',), ( 'deliver',), 'const struct req *' @@ -787,7 +787,7 @@ fo.close() def restrict(fo, spec): if len(spec) == 0: - fo.write("\t 0,\n") + fo.write("\t\t0,\n") return if spec[0] == 'all': spec = vcls @@ -803,7 +803,7 @@ def restrict(fo, spec): fo.write("\n") n = 0 if n == 0: - fo.write("\t ") + fo.write("\t\t") n += 1 fo.write(p + "VCL_MET_" + j.upper()) p = " | " @@ -830,38 +830,38 @@ const struct var vcc_vars[] = { for i in sp_variables: typ = i[1] - if typ[:4] == "HDR_": - typ = "HEADER" - cnam = i[0].replace(".", "_") ctyp = vcltypes[typ] fo.write("\t{ \"%s\", %s, %d,\n" % (i[0], typ, len(i[0]))) - if len(i[2]) > 0: - fo.write('\t "VRT_r_%s(req)",\n' % cnam) - if typ != "HEADER": - fh.write(ctyp + " VRT_r_%s(const %s);\n" % (cnam, i[4])) - else: + if len(i[2]) == 0: fo.write('\t NULL,\t/* No reads allowed */\n') + elif typ == "HEADER": + fo.write('\t "VRT_MkGethdr(req, HDR_') + fo.write(i[0].split(".")[0].upper()) + fo.write(', ",\n') + else: + fo.write('\t "VRT_r_%s(req)",\n' % cnam) + fh.write(ctyp + " VRT_r_%s(const %s);\n" % (cnam, i[4])) restrict(fo, i[2]) - if len(i[3]) > 0: - fo.write('\t "VRT_l_%s(req, ",\n' % cnam) - if typ != "HEADER": - fh.write("void VRT_l_%s(%s, " % (cnam, i[4])) - if typ != "STRING": - fh.write(ctyp + ");\n") - else: - fh.write(ctyp + ", ...);\n") - else: + if len(i[3]) == 0: fo.write('\t NULL,\t/* No writes allowed */\n') + elif typ == "HEADER": + fo.write('\t "VRT_SetHdr(req, VRT_MkGethdr(req, HDR_') + fo.write(i[0].split(".")[0].upper()) + fo.write(', ",\n') + else: + fo.write('\t "VRT_l_%s(req, ",\n' % cnam) + fh.write("void VRT_l_%s(%s, " % (cnam, i[4])) + if typ != "STRING": + fh.write(ctyp + ");\n") + else: + fh.write(ctyp + ", ...);\n") restrict(fo, i[3]) - if typ == "HEADER": - fo.write('\t "%s",\n' % i[1]) - else: - fo.write('\t 0,\n') # XXX: shoule be NULL + fo.write('\t 0,\n') # XXX: shoule be NULL fo.write("\t},\n") fo.write("\t{ NULL }\n};\n") diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index 4b3d69b..eae6231 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -137,7 +137,9 @@ parse_set(struct vcc *tl) } if (ap->type == VOID) SkipToken(tl, ap->oper); - if (fmt == STRING) { + if (fmt == HEADER) { + vcc_Expr(tl, STRING_LIST); + } else if (fmt == STRING) { vcc_Expr(tl, STRING_LIST); } else { vcc_Expr(tl, fmt); @@ -153,12 +155,13 @@ parse_unset(struct vcc *tl) { const struct var *vp; + /* XXX: Wrong, should use VCC_Expr(HEADER) */ vcc_NextToken(tl); ExpectErr(tl, ID); vp = vcc_FindVar(tl, tl->t, 1, "cannot be unset"); ERRCHK(tl); assert(vp != NULL); - if (vp->fmt != STRING || vp->http == NULL) { + if (vp->fmt != HEADER) { VSB_printf(tl->sb, "Only http header variables can be unset.\n"); vcc_ErrWhere(tl, tl->t); diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 3710490..17b0853 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -441,7 +441,14 @@ vcc_expr_tostring(struct expr **e, enum var_type fmt) case BYTES: p = "VRT_REAL_string(req, \v1)"; break; /* XXX */ case REAL: p = "VRT_REAL_string(req, \v1)"; break; case TIME: p = "VRT_TIME_string(req, \v1)"; break; - default: break; + case HEADER: p = "VRT_GetHdr(req, \v1)"; break; + case ENUM: + case STRING: + case STRING_LIST: + break; + default: + INCOMPL(); + break; } if (p != NULL) { *e = vcc_expr_edit(fmt, p, *e, NULL); @@ -539,7 +546,7 @@ void vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) { const char *p, *r; - const struct var *v; + // const struct var *v; struct expr *e1, *e2; enum var_type fmt; char buf[32]; @@ -591,34 +598,6 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) SkipToken(tl, ID); if (*p != '\0') SkipToken(tl, ','); - } else if (fmt == HEADER) { - ExpectErr(tl, ID); - sym = VCC_FindSymbol(tl, tl->t, SYM_NONE); - ERRCHK(tl); - SkipToken(tl, ID); - if (sym == NULL) { - VSB_printf(tl->sb, "Symbol not found.\n"); - vcc_ErrWhere(tl, tl->t); - return; - } - vcc_AddUses(tl, tl->t, sym->r_methods, "Not available"); - if (sym->kind != SYM_VAR) { - VSB_printf(tl->sb, "Wrong kind of symbol.\n"); - vcc_ErrWhere(tl, tl->t); - return; - } - AN(sym->var); - v = sym->var; - if (v->http == NULL) { - VSB_printf(tl->sb, - "Variable not an HTTP header.\n"); - vcc_ErrWhere(tl, tl->t); - return; - } - e1 = vcc_mk_expr(VOID, "VRT_MkGethdr(req, %s, \"%s\")", - v->http, v->hdr); - if (*p != '\0') - SkipToken(tl, ','); } else { vcc_expr0(tl, &e1, fmt); ERRCHK(tl); @@ -803,7 +782,7 @@ vcc_expr_mul(struct vcc *tl, struct expr **e, enum var_type fmt) */ static void -vcc_expr_string_add(struct vcc *tl, struct expr **e, enum var_type fmt) +vcc_expr_string_add(struct vcc *tl, struct expr **e) { struct expr *e2; enum var_type f2; @@ -838,12 +817,6 @@ vcc_expr_string_add(struct vcc *tl, struct expr **e, enum var_type fmt) (*e)->constant = EXPR_VAR; } } - if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST) - *e = vcc_expr_edit(STRING, - "\v+VRT_ReqString(req,\n\v1,\nvrt_magic_string_end)", - *e, NULL); - if (fmt == STRING_LIST && (*e)->fmt == STRING) - (*e)->fmt = STRING_LIST; } static void @@ -858,6 +831,16 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) ERRCHK(tl); f2 = (*e)->fmt; + /* Unless we specifically ask for a HEADER, fold them to string here */ + if (fmt != HEADER && f2 == HEADER) { + vcc_expr_tostring(e, STRING); + f2 = (*e)->fmt; + assert(f2 == STRING); + } + + if (tl->t->tok != '+' && tl->t->tok != '-') + return; + switch(f2) { case STRING: break; case STRING_LIST: break; @@ -865,9 +848,8 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) case TIME: break; case DURATION: break; case BYTES: break; + case HEADER: break; default: - if (tl->t->tok != '+' && tl->t->tok != '-') - return; VSB_printf(tl->sb, "Operator %.*s not possible on type %s.\n", PF(tl->t), vcc_Type(f2)); vcc_ErrWhere(tl, tl->t); @@ -875,7 +857,7 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) } if (f2 == STRING || f2 == STRING_LIST) { - vcc_expr_string_add(tl, e, fmt); + vcc_expr_string_add(tl, e); return; } @@ -910,6 +892,24 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) } /*-------------------------------------------------------------------- + * Fold the STRING types correctly + */ + +static void +vcc_expr_strfold(struct vcc *tl, struct expr **e, enum var_type fmt) +{ + + vcc_expr_add(tl, e, fmt); + + if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST) + *e = vcc_expr_edit(STRING, + "\v+VRT_ReqString(req,\n\v1,\nvrt_magic_string_end)", + *e, NULL); + if (fmt == STRING_LIST && (*e)->fmt == STRING) + (*e)->fmt = STRING_LIST; +} + +/*-------------------------------------------------------------------- * SYNTAX: * ExprCmp: * ExprAdd @@ -958,7 +958,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt) *e = NULL; - vcc_expr_add(tl, e, fmt); + vcc_expr_strfold(tl, e, fmt); ERRCHK(tl); if ((*e)->fmt == BOOL) @@ -970,7 +970,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt) break; if (cp->fmt != VOID) { vcc_NextToken(tl); - vcc_expr_add(tl, &e2, (*e)->fmt); + vcc_expr_strfold(tl, &e2, (*e)->fmt); ERRCHK(tl); if (e2->fmt != (*e)->fmt) { /* XXX */ VSB_printf(tl->sb, "Comparison of different types: "); diff --git a/lib/libvcl/vcc_var.c b/lib/libvcl/vcc_var.c index aa728e6..661ca85 100644 --- a/lib/libvcl/vcc_var.c +++ b/lib/libvcl/vcc_var.c @@ -50,19 +50,19 @@ vcc_Var_Wildcard(struct vcc *tl, const struct token *t, const struct symbol *wc) v = TlAlloc(tl, sizeof *v); AN(v); + assert(vh->fmt == HEADER); v->name = TlDupTok(tl, t); v->r_methods = vh->r_methods; v->w_methods = vh->w_methods; - v->fmt = STRING; + v->fmt = vh->fmt; v->http = vh->http; l = strlen(v->name + vh->len) + 1; bprintf(buf, "\\%03o%s:", (unsigned)l, v->name + vh->len); v->hdr = TlDup(tl, buf); - bprintf(buf, "VRT_GetHdr(req, %s, \"%s\")", v->http, v->hdr); + bprintf(buf, "%s\"%s\")", vh->rname, v->hdr); v->rname = TlDup(tl, buf); - - bprintf(buf, "VRT_SetHdr(req, %s, \"%s\", ", v->http, v->hdr); + bprintf(buf, "%s\"%s\"), ", vh->lname, v->hdr); v->lname = TlDup(tl, buf); sym = VCC_AddSymbolTok(tl, t, SYM_VAR); @@ -108,7 +108,6 @@ vcc_FindVar(struct vcc *tl, const struct token *t, int wr_access, } else { vcc_AddUses(tl, t, v->r_methods, use); } - assert(v->fmt != HEADER); return (v); } VSB_printf(tl->sb, "Unknown variable "); From phk at varnish-cache.org Wed Oct 24 08:07:58 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 10:07:58 +0200 Subject: [master] 7fe9889 Optimize the compiled code by generating static const gethdr_s's Message-ID: commit 7fe9889a6b280b190f3cb4517f2ddc83317bc80c Author: Poul-Henning Kamp Date: Wed Oct 24 08:07:27 2012 +0000 Optimize the compiled code by generating static const gethdr_s's diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 6efff05..dbf31af 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -838,9 +838,9 @@ for i in sp_variables: if len(i[2]) == 0: fo.write('\t NULL,\t/* No reads allowed */\n') elif typ == "HEADER": - fo.write('\t "VRT_MkGethdr(req, HDR_') + fo.write('\t "HDR_') fo.write(i[0].split(".")[0].upper()) - fo.write(', ",\n') + fo.write('",\n') else: fo.write('\t "VRT_r_%s(req)",\n' % cnam) fh.write(ctyp + " VRT_r_%s(const %s);\n" % (cnam, i[4])) @@ -849,9 +849,9 @@ for i in sp_variables: if len(i[3]) == 0: fo.write('\t NULL,\t/* No writes allowed */\n') elif typ == "HEADER": - fo.write('\t "VRT_SetHdr(req, VRT_MkGethdr(req, HDR_') + fo.write('\t "HDR_') fo.write(i[0].split(".")[0].upper()) - fo.write(', ",\n') + fo.write('",\n') else: fo.write('\t "VRT_l_%s(req, ",\n' % cnam) fh.write("void VRT_l_%s(%s, " % (cnam, i[4])) @@ -861,7 +861,6 @@ for i in sp_variables: fh.write(ctyp + ", ...);\n") restrict(fo, i[3]) - fo.write('\t 0,\n') # XXX: shoule be NULL fo.write("\t},\n") fo.write("\t{ NULL }\n};\n") diff --git a/lib/libvcl/vcc_compile.h b/lib/libvcl/vcc_compile.h index c85af5b..a8c6e02 100644 --- a/lib/libvcl/vcc_compile.h +++ b/lib/libvcl/vcc_compile.h @@ -205,8 +205,6 @@ struct var { unsigned r_methods; const char *lname; unsigned w_methods; - const char *http; - const char *hdr; }; struct method { diff --git a/lib/libvcl/vcc_var.c b/lib/libvcl/vcc_var.c index 661ca85..5afec43 100644 --- a/lib/libvcl/vcc_var.c +++ b/lib/libvcl/vcc_var.c @@ -33,6 +33,7 @@ #include #include "vcc_compile.h" +#include "vct.h" /*--------------------------------------------------------------------*/ @@ -42,8 +43,10 @@ vcc_Var_Wildcard(struct vcc *tl, const struct token *t, const struct symbol *wc) struct symbol *sym; struct var *v; const struct var *vh; - int l; + int l, i; + char c; char buf[258]; + char cnam[256]; vh = wc->var; @@ -55,14 +58,27 @@ vcc_Var_Wildcard(struct vcc *tl, const struct token *t, const struct symbol *wc) v->r_methods = vh->r_methods; v->w_methods = vh->w_methods; v->fmt = vh->fmt; - v->http = vh->http; + + /* Create a C-name version of the header name */ l = strlen(v->name + vh->len) + 1; + for (i = 0; i < l - 1; i++) { + c = *(v->name + vh->len + i); + if (vct_isalpha(c) || vct_isdigit(c)) + cnam[i] = c; + else + cnam[i] = '_'; + } + cnam[i] = '\0'; + + /* Create the static identifier */ + Fh(tl, 0, "static const struct gethdr_s VGC_%s_%s =\n", + vh->rname, cnam); + Fh(tl, 0, " { %s, \"\\%03o%s:\"};\n", + vh->rname, (unsigned)l, v->name + vh->len); - bprintf(buf, "\\%03o%s:", (unsigned)l, v->name + vh->len); - v->hdr = TlDup(tl, buf); - bprintf(buf, "%s\"%s\")", vh->rname, v->hdr); + bprintf(buf, "&VGC_%s_%s", vh->rname, cnam); v->rname = TlDup(tl, buf); - bprintf(buf, "%s\"%s\"), ", vh->lname, v->hdr); + bprintf(buf, "VRT_SetHdr(req, %s, ", v->rname); v->lname = TlDup(tl, buf); sym = VCC_AddSymbolTok(tl, t, SYM_VAR); From phk at varnish-cache.org Wed Oct 24 08:43:30 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 10:43:30 +0200 Subject: [master] f0530c9 Fix indentation for regsub Message-ID: commit f0530c9ee20f527a73fe53c06d3e290225533c7b Author: Poul-Henning Kamp Date: Wed Oct 24 08:43:17 2012 +0000 Fix indentation for regsub diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 17b0853..00e5994 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -482,7 +482,7 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym) p = vcc_regexp(tl); vcc_NextToken(tl); - bprintf(buf, "VRT_regsub(req, %d,\n\v1,\n%s\n", all, p); + bprintf(buf, "VRT_regsub(req, %d,\v+\n\v1,\n%s", all, p); *e = vcc_expr_edit(STRING, buf, e2, *e); SkipToken(tl, ','); @@ -491,7 +491,7 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym) return; if (e2->fmt != STRING) vcc_expr_tostring(&e2, STRING); - *e = vcc_expr_edit(STRING, "\v1, \v2)", *e, e2); + *e = vcc_expr_edit(STRING, "\v1,\n\v2)\v-",*e, e2); SkipToken(tl, ')'); } From phk at varnish-cache.org Wed Oct 24 09:12:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 11:12:37 +0200 Subject: [master] c6b8697 Eliminate vcc_RTimeVal(), rename vcc_TimeVal() to Vcc_Duration(). Clean up some asserts. Message-ID: commit c6b8697b7784eac9ab0601eef818541929e3218b Author: Poul-Henning Kamp Date: Wed Oct 24 09:12:08 2012 +0000 Eliminate vcc_RTimeVal(), rename vcc_TimeVal() to Vcc_Duration(). Clean up some asserts. diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c index 6404a3e..319eef1 100644 --- a/lib/libvcl/vcc_backend.c +++ b/lib/libvcl/vcc_backend.c @@ -278,12 +278,12 @@ vcc_ParseProbeSpec(struct vcc *tl) Fh(tl, 0, "\t\t\"\\r\\n\",\n"); } else if (vcc_IdIs(t_field, "timeout")) { Fh(tl, 0, "\t.timeout = "); - vcc_TimeVal(tl, &t); + vcc_Duration(tl, &t); ERRCHK(tl); Fh(tl, 0, "%g,\n", t); } else if (vcc_IdIs(t_field, "interval")) { Fh(tl, 0, "\t.interval = "); - vcc_TimeVal(tl, &t); + vcc_Duration(tl, &t); ERRCHK(tl); Fh(tl, 0, "%g,\n", t); } else if (vcc_IdIs(t_field, "window")) { @@ -470,19 +470,19 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname) SkipToken(tl, ';'); } else if (vcc_IdIs(t_field, "connect_timeout")) { Fb(tl, 0, "\t.connect_timeout = "); - vcc_TimeVal(tl, &t); + vcc_Duration(tl, &t); ERRCHK(tl); Fb(tl, 0, "%g,\n", t); SkipToken(tl, ';'); } else if (vcc_IdIs(t_field, "first_byte_timeout")) { Fb(tl, 0, "\t.first_byte_timeout = "); - vcc_TimeVal(tl, &t); + vcc_Duration(tl, &t); ERRCHK(tl); Fb(tl, 0, "%g,\n", t); SkipToken(tl, ';'); } else if (vcc_IdIs(t_field, "between_bytes_timeout")) { Fb(tl, 0, "\t.between_bytes_timeout = "); - vcc_TimeVal(tl, &t); + vcc_Duration(tl, &t); ERRCHK(tl); Fb(tl, 0, "%g,\n", t); SkipToken(tl, ';'); diff --git a/lib/libvcl/vcc_compile.h b/lib/libvcl/vcc_compile.h index a8c6e02..99a1169 100644 --- a/lib/libvcl/vcc_compile.h +++ b/lib/libvcl/vcc_compile.h @@ -272,8 +272,7 @@ parsedirector_f vcc_ParseRandomDirector; parsedirector_f vcc_ParseRoundRobinDirector; /* vcc_expr.c */ -void vcc_RTimeVal(struct vcc *tl, double *); -void vcc_TimeVal(struct vcc *tl, double *); +void vcc_Duration(struct vcc *tl, double *); unsigned vcc_UintVal(struct vcc *tl); void vcc_Expr(struct vcc *tl, enum var_type typ); void vcc_Expr_Call(struct vcc *tl, const struct symbol *sym); diff --git a/lib/libvcl/vcc_dir_dns.c b/lib/libvcl/vcc_dir_dns.c index 55ed921..4d61585 100644 --- a/lib/libvcl/vcc_dir_dns.c +++ b/lib/libvcl/vcc_dir_dns.c @@ -194,17 +194,17 @@ vcc_dir_dns_parse_backend_options(struct vcc *tl) vcc_NextToken(tl); SkipToken(tl, ';'); } else if (vcc_IdIs(t_field, "connect_timeout")) { - vcc_TimeVal(tl, &t); + vcc_Duration(tl, &t); ERRCHK(tl); b_defaults.connect_timeout = t; SkipToken(tl, ';'); } else if (vcc_IdIs(t_field, "first_byte_timeout")) { - vcc_TimeVal(tl, &t); + vcc_Duration(tl, &t); ERRCHK(tl); b_defaults.first_byte_timeout = t; SkipToken(tl, ';'); } else if (vcc_IdIs(t_field, "between_bytes_timeout")) { - vcc_TimeVal(tl, &t); + vcc_Duration(tl, &t); ERRCHK(tl); b_defaults.between_bytes_timeout = t; SkipToken(tl, ';'); @@ -333,7 +333,7 @@ vcc_ParseDnsDirector(struct vcc *tl) vcc_NextToken(tl); ExpectErr(tl, ';'); } else if (vcc_IdIs(t_field, "ttl")) { - vcc_RTimeVal(tl, &ttl); + vcc_Duration(tl, &ttl); ExpectErr(tl, ';'); } else if (vcc_IdIs(t_field, "list")) { vcc_dir_dns_parse_list(tl,&nelem); diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 00e5994..a5f9147 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -154,26 +154,7 @@ vcc_DoubleVal(struct vcc *tl) /*--------------------------------------------------------------------*/ void -vcc_RTimeVal(struct vcc *tl, double *d) -{ - double v, sc; - int sign = 1; - - if (tl->t->tok == '-') { - sign *= -1; - vcc_NextToken(tl); - } - v = vcc_DoubleVal(tl); - ERRCHK(tl); - ExpectErr(tl, ID); - sc = vcc_TimeUnit(tl); - *d = sign * v * sc; -} - -/*--------------------------------------------------------------------*/ - -void -vcc_TimeVal(struct vcc *tl, double *d) +vcc_Duration(struct vcc *tl, double *d) { double v, sc; @@ -318,6 +299,7 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, struct expr *e; int nl = 1; + AN(e1); e = vcc_new_expr(); while (*p != '\0') { if (*p != '\v') { @@ -332,7 +314,6 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, case '+': VSB_cat(e->vsb, "\v+"); break; case '-': VSB_cat(e->vsb, "\v-"); break; case '1': - AN(e1); VSB_cat(e->vsb, VSB_data(e1->vsb)); break; case '2': @@ -345,14 +326,10 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, p++; } AZ(VSB_finish(e->vsb)); - if (e1 != NULL) - e->t1 = e1->t1; - else if (e2 != NULL) - e->t1 = e2->t1; + e->t1 = e1->t1; + e->t2 = e1->t2; if (e2 != NULL) e->t2 = e2->t2; - else if (e1 != NULL) - e->t2 = e1->t2; vcc_delete_expr(e1); vcc_delete_expr(e2); e->fmt = fmt; @@ -392,7 +369,7 @@ vcc_expr_fmt(struct vsb *d, int ind, const struct expr *e1) case '+': ind += 2; break; case '-': ind -= 2; break; default: - assert(__LINE__ == 0); + WRONG("Illegal format in VCC expression"); } p++; } @@ -491,7 +468,7 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym) return; if (e2->fmt != STRING) vcc_expr_tostring(&e2, STRING); - *e = vcc_expr_edit(STRING, "\v1,\n\v2)\v-",*e, e2); + *e = vcc_expr_edit(STRING, "\v1,\n\v2)\v-", *e, e2); SkipToken(tl, ')'); } @@ -700,7 +677,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) */ assert(fmt != VOID); if (fmt == DURATION) { - vcc_RTimeVal(tl, &d); + vcc_Duration(tl, &d); ERRCHK(tl); e1 = vcc_mk_expr(DURATION, "%g", d); } else if (fmt == BYTES) { From phk at varnish-cache.org Wed Oct 24 09:18:32 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 11:18:32 +0200 Subject: [master] 76f0f3b Add missing ERRCHK() Message-ID: commit 76f0f3b149392822d3291d0e0ff48c34d45eb5fc Author: Poul-Henning Kamp Date: Wed Oct 24 09:18:25 2012 +0000 Add missing ERRCHK() diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index a5f9147..3c0599c 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -877,6 +877,7 @@ vcc_expr_strfold(struct vcc *tl, struct expr **e, enum var_type fmt) { vcc_expr_add(tl, e, fmt); + ERRCHK(tl); if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST) *e = vcc_expr_edit(STRING, From phk at varnish-cache.org Wed Oct 24 09:24:07 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 11:24:07 +0200 Subject: [master] a04e309 Imrpove the VCC:vcc_expr.c coverage tests Message-ID: commit a04e30950b0226c87d762fcd44585b9fa8a6f75b Author: Poul-Henning Kamp Date: Wed Oct 24 09:23:51 2012 +0000 Imrpove the VCC:vcc_expr.c coverage tests diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 62a7cbc..564db09 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -99,91 +99,130 @@ varnish v1 -vcl { } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = "foo" - "bar"; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = now + "foo"; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = now + now; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = now + 1; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1 + "foo"; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1 + now; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1 + 1s; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s + 1; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s + now; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s + "foo"; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = "foo" + 1s; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.ttl = 1s + 1; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.ttl = 1s + now; } } varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.ttl = 1s + "foo"; } } + +varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } + sub vcl_fetch { + if (req.url || beresp.ttl) { + } + } +} + +varnish v1 -badvcl { + backend b { .host = "127.0.0.1"; } + sub vcl_fetch { + if (req.url && beresp.ttl) { + } + } +} + +varnish v1 -vcl { + backend b { .host = "127.0.0.1"; } + sub vcl_fetch { + if (!req.url) { + } + } +} From phk at varnish-cache.org Wed Oct 24 15:02:54 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 17:02:54 +0200 Subject: [master] 2a29afd polishing Message-ID: commit 2a29afdbe38f11892fe35ec4e545f6214b9e766b Author: Poul-Henning Kamp Date: Wed Oct 24 15:02:30 2012 +0000 polishing diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 3c0599c..9e0f360 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -819,13 +819,14 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) return; switch(f2) { - case STRING: break; - case STRING_LIST: break; + case STRING: + case STRING_LIST: + vcc_expr_string_add(tl, e); + return; case INT: break; case TIME: break; case DURATION: break; case BYTES: break; - case HEADER: break; default: VSB_printf(tl->sb, "Operator %.*s not possible on type %s.\n", PF(tl->t), vcc_Type(f2)); @@ -833,11 +834,6 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) return; } - if (f2 == STRING || f2 == STRING_LIST) { - vcc_expr_string_add(tl, e); - return; - } - while (tl->t->tok == '+' || tl->t->tok == '-') { if (f2 == TIME) f2 = DURATION; From phk at varnish-cache.org Wed Oct 24 20:38:16 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 22:38:16 +0200 Subject: [master] 557aff1 Fix these testcases to fail for the right reason. Message-ID: commit 557aff1d1b5ae895181e2661213048b003aad801 Author: Poul-Henning Kamp Date: Wed Oct 24 20:38:03 2012 +0000 Fix these testcases to fail for the right reason. diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index 504601b..c26c766 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -30,14 +30,14 @@ client c1 { } -run varnish v1 -badvcl { - import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so.1" ; + import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so" ; sub vcl_deliver { set resp.http.who = debug.author(jfk); } } varnish v1 -badvcl { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so.1" ; + import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; sub vcl_deliver { set resp.http.who = std.random("foo", "bar"); } diff --git a/bin/varnishtest/tests/m00001.vtc b/bin/varnishtest/tests/m00001.vtc index 9f4a743..47c5ba6 100644 --- a/bin/varnishtest/tests/m00001.vtc +++ b/bin/varnishtest/tests/m00001.vtc @@ -48,12 +48,12 @@ varnish v1 -cliok "vcl.list" varnish v1 -cliok "debug.vmod" varnish v1 -badvcl { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so.1" ; - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so.1" ; + import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; } varnish v1 -badvcl { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so.1" ; + import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; sub vcl_recv { if (std == 2) { From phk at varnish-cache.org Wed Oct 24 21:13:34 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 23:13:34 +0200 Subject: [master] 10b7f26 Add "-errvcl $expect_error $vcl" facility, which is better than badvcl in that you can make sure it fails for the right reason. Message-ID: commit 10b7f26c8d874778379f798e0622c70f932c5148 Author: Poul-Henning Kamp Date: Wed Oct 24 21:12:31 2012 +0000 Add "-errvcl $expect_error $vcl" facility, which is better than badvcl in that you can make sure it fails for the right reason. All -badvcl's should be converted to -errvcl without undue delay. diff --git a/bin/varnishtest/tests/m00001.vtc b/bin/varnishtest/tests/m00001.vtc index 47c5ba6..5d07b97 100644 --- a/bin/varnishtest/tests/m00001.vtc +++ b/bin/varnishtest/tests/m00001.vtc @@ -47,12 +47,12 @@ varnish v1 -cliok "vcl.discard vcl1" varnish v1 -cliok "vcl.list" varnish v1 -cliok "debug.vmod" -varnish v1 -badvcl { +varnish v1 -errvcl {Module std already imported.} { import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; } -varnish v1 -badvcl { +varnish v1 -errvcl {Symbol not found: 'std' (expected type BOOL):} { import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; sub vcl_recv { diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 10c1d31..b38a289 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -594,7 +594,7 @@ varnish_cli(struct varnish *v, const char *cli, unsigned exp) */ static void -varnish_vcl(struct varnish *v, const char *vcl, enum VCLI_status_e expect) +varnish_vcl(struct varnish *v, const char *vcl, enum VCLI_status_e expect, char **resp) { struct vsb *vsb; enum VCLI_status_e u; @@ -610,7 +610,7 @@ varnish_vcl(struct varnish *v, const char *vcl, enum VCLI_status_e expect) ++v->vcl_nbr, NONSENSE, vcl, NONSENSE); AZ(VSB_finish(vsb)); - u = varnish_ask_cli(v, VSB_data(vsb), NULL); + u = varnish_ask_cli(v, VSB_data(vsb), resp); if (u != expect) { VSB_delete(vsb); vtc_log(v->vl, 0, @@ -857,13 +857,30 @@ cmd_varnish(CMD_ARGS) } if (!strcmp(*av, "-badvcl")) { AN(av[1]); - varnish_vcl(v, av[1], CLIS_PARAM); + varnish_vcl(v, av[1], CLIS_PARAM, NULL); av++; continue; } + if (!strcmp(*av, "-errvcl")) { + char *r = NULL; + AN(av[1]); + AN(av[2]); + varnish_vcl(v, av[2], CLIS_PARAM, &r); + if (strstr(r, av[1]) == NULL) + vtc_log(v->vl, 0, + "Did not find expected string: (\"%s\")", + av[1]); + else + vtc_log(v->vl, 3, + "Found expected string: (\"%s\")", + av[1]); + free(r); + av += 2; + continue; + } if (!strcmp(*av, "-vcl")) { AN(av[1]); - varnish_vcl(v, av[1], CLIS_OK); + varnish_vcl(v, av[1], CLIS_OK, NULL); av++; continue; } From phk at varnish-cache.org Wed Oct 24 21:42:53 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 23:42:53 +0200 Subject: [master] b43e362 Change from -badvcl to -errvcl and notice that quite a lot of the actual error messages are somewhat less than helpful. Message-ID: commit b43e36295905bd60bc59fc5b91f28760d00f35b7 Author: Poul-Henning Kamp Date: Wed Oct 24 21:42:22 2012 +0000 Change from -badvcl to -errvcl and notice that quite a lot of the actual error messages are somewhat less than helpful. diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 564db09..bcdebac 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -7,9 +7,20 @@ varnish v1 -vcl { }C } -varnish v1 -badvcl { 0; } +varnish v1 -errvcl {Found: '0' at} { 0; } -varnish v1 -badvcl " sub vcl_recv { { } { " +# The next test issues a quite confusing error message: +# Expected an action, 'if', '{' or '}'\n +# ('Default' Line 42 Pos 1)\n +# sub vcl_recv {\n +# ###-----------\n +# \n +# It's actually complaining about the first token in +# the default.vcl which is appended after the proffered +# VCLs tokenstream. +# XXX: A better error message would be desirable + +varnish v1 -errvcl {Expected an action, 'if', } " sub vcl_recv { { } { " varnish v1 -vcl { backend b { .host = "127.0.0.1"; } @@ -23,7 +34,7 @@ varnish v1 -vcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {Comparison of different types: INT '!=' STRING} { sub vcl_recv { if (!req.restarts != req.url) { set req.http.foo = "foo"; @@ -32,13 +43,14 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {Symbol not found: 'vcl_recv' (expected type STRING_LIST)} { sub vcl_recv { set req.http.foo = vcl_recv; } } -varnish v1 -badvcl { +# XXX: not obvious if this actually fails for the desired reason ? +varnish v1 -errvcl {Unknown token '-' when looking for DURATION} { sub vcl_recv { if (req.grace < -3s || req.grace) { set req.http.foo = vcl_recv; @@ -46,7 +58,7 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {'&&' must be followed by BOOL, found DURATION.} { sub vcl_recv { if (req.grace < 3s && req.grace) { set req.http.foo = vcl_recv; @@ -54,26 +66,26 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {Operator * not possible on type STRING.} { sub vcl_recv { set req.http.foo = "bla" * "foo"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {DURATION + INT not possible.} { sub vcl_fetch { set req.http.foo = req.grace + beresp.status; } } -varnish v1 -badvcl { +varnish v1 -errvcl {'!' must be followed by BOOL, found DURATION.} { sub vcl_fetch { if (! req.grace) { } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Operator + not possible on type BOOL.} { sub vcl_fetch { if (beresp.do_gzip + beresp.do_gunzip) { } @@ -98,112 +110,121 @@ varnish v1 -vcl { } } -varnish v1 -badvcl { +# XXX: not the most clear error message +varnish v1 -errvcl {Expected ';' got '-'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = "foo" - "bar"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {TIME + STRING not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = now + "foo"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {TIME + TIME not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = now + now; } } -varnish v1 -badvcl { +# XXX: error message should say something about DURATION +varnish v1 -errvcl {Expected ID got ';'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = now + 1; } } -varnish v1 -badvcl { +varnish v1 -errvcl {INT + STRING not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1 + "foo"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {INT + TIME not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1 + now; } } -varnish v1 -badvcl { +# XXX: error message should spot DURATION +varnish v1 -errvcl {Expected ';' got 's'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1 + 1s; } } -varnish v1 -badvcl { +# XXX: should spot DURATION +varnish v1 -errvcl {Expected ';' got 's'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s; } } -varnish v1 -badvcl { +# XXX: should spot DURATION +varnish v1 -errvcl {Expected ';' got 's'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s + 1; } } -varnish v1 -badvcl { +# XXX: should spot DURATION +varnish v1 -errvcl {Expected ';' got 's'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s + now; } } -varnish v1 -badvcl { +# XXX: should spot DURATION +varnish v1 -errvcl {Expected ';' got 's'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s + "foo"; } } -varnish v1 -badvcl { +# XXX: should spot DURATION +varnish v1 -errvcl {Expected ';' got 's'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = "foo" + 1s; } } -varnish v1 -badvcl { +# XXX: should spot DURATION +varnish v1 -errvcl {Expected ID got ';'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.ttl = 1s + 1; } } -varnish v1 -badvcl { +varnish v1 -errvcl {DURATION + TIME not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.ttl = 1s + now; } } -varnish v1 -badvcl { +varnish v1 -errvcl {DURATION + STRING not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.ttl = 1s + "foo"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {'||' must be followed by BOOL, found DURATION.} { backend b { .host = "127.0.0.1"; } sub vcl_fetch { if (req.url || beresp.ttl) { @@ -211,7 +232,7 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {'&&' must be followed by BOOL, found DURATION.} { backend b { .host = "127.0.0.1"; } sub vcl_fetch { if (req.url && beresp.ttl) { From phk at varnish-cache.org Wed Oct 24 21:51:44 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 23:51:44 +0200 Subject: [master] d65ee24 Improve layout of a couple of error messages. Message-ID: commit d65ee2403419957708ce01b6d32d695a7da02b2e Author: Poul-Henning Kamp Date: Wed Oct 24 21:51:26 2012 +0000 Improve layout of a couple of error messages. diff --git a/lib/libvcl/vcc_parse.c b/lib/libvcl/vcc_parse.c index 10170b3..da50811 100644 --- a/lib/libvcl/vcc_parse.c +++ b/lib/libvcl/vcc_parse.c @@ -160,7 +160,7 @@ vcc_Compound(struct vcc *tl) vcc_NextToken(tl); } else { VSB_printf(tl->sb, - "Inline-C not allowed"); + "Inline-C not allowed\n"); vcc_ErrWhere(tl, tl->t); } break; @@ -287,7 +287,7 @@ vcc_Parse(struct vcc *tl) vcc_NextToken(tl); } else { VSB_printf(tl->sb, - "Inline-C not allowed"); + "Inline-C not allowed\n"); vcc_ErrWhere(tl, tl->t); } break; diff --git a/lib/libvcl/vcc_vmod.c b/lib/libvcl/vcc_vmod.c index 4ce4f95..c3a2a83 100644 --- a/lib/libvcl/vcc_vmod.c +++ b/lib/libvcl/vcc_vmod.c @@ -91,8 +91,7 @@ vcc_ParseImport(struct vcc *tl) return; } if (!vcc_IdIs(tl->t, "from")) { - VSB_printf(tl->sb, "Expected 'from path...' at "); - vcc_ErrToken(tl, tl->t); + VSB_printf(tl->sb, "Expected 'from path...'\n"); vcc_ErrWhere(tl, tl->t); return; } From phk at varnish-cache.org Wed Oct 24 21:56:07 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Oct 2012 23:56:07 +0200 Subject: [master] 6434572 More badvcl->errvcl conversions. Message-ID: commit 6434572b005dbbe59bc410051da359a025a71ce3 Author: Poul-Henning Kamp Date: Wed Oct 24 21:55:50 2012 +0000 More badvcl->errvcl conversions. Now only 100 more to go. diff --git a/bin/varnishtest/tests/c00041.vtc b/bin/varnishtest/tests/c00041.vtc index 78e8af2..c51cf53 100644 --- a/bin/varnishtest/tests/c00041.vtc +++ b/bin/varnishtest/tests/c00041.vtc @@ -92,7 +92,7 @@ client c1 { expect resp.bodylen == 22 } -run -varnish v1 -badvcl { +varnish v1 -errvcl {'purge': not a valid action in method 'vcl_recv'.} { backend s1 { .host = "${s1_addr}"; } sub vcl_recv { if (req.http.purge == "yes") { purge; } } } diff --git a/bin/varnishtest/tests/c00052.vtc b/bin/varnishtest/tests/c00052.vtc index e640230..5de1430 100644 --- a/bin/varnishtest/tests/c00052.vtc +++ b/bin/varnishtest/tests/c00052.vtc @@ -15,14 +15,14 @@ varnish v1 -vcl+backend { varnish v1 -cliok "param.set vcc_allow_inline_c false" -varnish v1 -badvcl { +varnish v1 -errvcl {Inline-C not allowed} { backend default { .host = "${s1_sock}"; } C{ getpid(); }C } -varnish v1 -badvcl { +varnish v1 -errvcl {Inline-C not allowed} { backend default { .host = "${s1_sock}"; } diff --git a/bin/varnishtest/tests/c00053.vtc b/bin/varnishtest/tests/c00053.vtc index c326293..a5c2264 100644 --- a/bin/varnishtest/tests/c00053.vtc +++ b/bin/varnishtest/tests/c00053.vtc @@ -13,7 +13,7 @@ varnish v1 -vcl+backend { varnish v1 -cliok "param.set vcc_unsafe_path off" -varnish v1 -badvcl { +varnish v1 -errvcl {Include path is unsafe} { backend default { .host = "${s1_sock}"; } diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index c26c766..9233628 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -29,14 +29,14 @@ client c1 { expect resp.http.bar == "foo" } -run -varnish v1 -badvcl { +varnish v1 -errvcl {Wrong enum value. Expected one of:} { import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so" ; sub vcl_deliver { set resp.http.who = debug.author(jfk); } } -varnish v1 -badvcl { +varnish v1 -errvcl {Wrong argument type. Expected REAL. Got STRING.} { import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; sub vcl_deliver { set resp.http.who = std.random("foo", "bar"); diff --git a/bin/varnishtest/tests/m00003.vtc b/bin/varnishtest/tests/m00003.vtc index 67d984d..0251a77 100644 --- a/bin/varnishtest/tests/m00003.vtc +++ b/bin/varnishtest/tests/m00003.vtc @@ -26,6 +26,6 @@ client c1 { expect resp.http.bar == "foo" } -run -varnish v1 -badvcl { +varnish v1 -errvcl {Expected 'from path...'} { import std to; } diff --git a/bin/varnishtest/tests/m00006.vtc b/bin/varnishtest/tests/m00006.vtc index 9da650c..c35cc38 100644 --- a/bin/varnishtest/tests/m00006.vtc +++ b/bin/varnishtest/tests/m00006.vtc @@ -27,7 +27,7 @@ client c1 { expect resp.bodylen == 1 } -run -varnish v1 -badvcl { +varnish v1 -errvcl {'beresp.http.bar': Not available in method 'vcl_recv'} { import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; backend b { .host = "127.0.0.1"; } diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc index 3d1d665..30d39b7 100644 --- a/bin/varnishtest/tests/m00008.vtc +++ b/bin/varnishtest/tests/m00008.vtc @@ -11,7 +11,7 @@ varnish v1 -vcl+backend { varnish v1 -cliok "param.set vcc_unsafe_path off" -varnish v1 -badvcl { +varnish v1 -errvcl {'import ... from path...' not allowed.} { backend default { .host = "${s1_sock}"; } import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; } From phk at varnish-cache.org Thu Oct 25 08:10:33 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 25 Oct 2012 10:10:33 +0200 Subject: [master] 2fc4064 Test-case improvements. Message-ID: commit 2fc4064dca0e7e58fb2b70d883cde0cccf2873b7 Author: Poul-Henning Kamp Date: Thu Oct 25 08:10:00 2012 +0000 Test-case improvements. Submitted by: Federico G. Schwindt diff --git a/bin/varnishtest/tests/r00263.vtc b/bin/varnishtest/tests/r00263.vtc index d97ec70..79df874 100644 --- a/bin/varnishtest/tests/r00263.vtc +++ b/bin/varnishtest/tests/r00263.vtc @@ -1,6 +1,6 @@ varnishtest "Test refcounting backends from director" -varnish v1 -vcl+backend { +varnish v1 -vcl { backend node1 { .host = "10.0.0.1"; .port = "80"; } backend node2 { .host = "10.0.0.2"; .port = "80"; } backend node3 { .host = "10.0.0.3"; .port = "80"; } diff --git a/bin/varnishtest/tests/r00310.vtc b/bin/varnishtest/tests/r00310.vtc index 5a7d98a..6a5ce22 100644 --- a/bin/varnishtest/tests/r00310.vtc +++ b/bin/varnishtest/tests/r00310.vtc @@ -1,6 +1,6 @@ varnishtest "Test obj.http.x-cache in vcl_hit" -varnish v1 -badvcl { +varnish v1 -errvcl {'obj.http.x-cache': cannot be set in method 'vcl_hit'.} { backend foo { .host = "localhost"; } sub vcl_hit { diff --git a/bin/varnishtest/tests/r00409.vtc b/bin/varnishtest/tests/r00409.vtc index 4857fff..80acd34 100644 --- a/bin/varnishtest/tests/r00409.vtc +++ b/bin/varnishtest/tests/r00409.vtc @@ -1,6 +1,7 @@ varnishtest "Regression test for ticket 409" -varnish v1 -badvcl { +varnish v1 -errvcl {Expected CSTR got '!'} { + backend b { .host = "127.0.0.1"; } sub vcl_recv { if ( req.url ~ ! "\.(png|jpg|gif|js|css)$" ) { return (pass); diff --git a/bin/varnishtest/tests/r00655.vtc b/bin/varnishtest/tests/r00655.vtc index c788219..6363914 100644 --- a/bin/varnishtest/tests/r00655.vtc +++ b/bin/varnishtest/tests/r00655.vtc @@ -1,7 +1,6 @@ varnishtest "Test nested /*...*/ comments " - -varnish v1 -badvcl { +varnish v1 -errvcl {/* ... */ comment contains /*} { /* foo /* bar diff --git a/bin/varnishtest/tests/r00916.vtc b/bin/varnishtest/tests/r00916.vtc index bf2ee63..27f3f1a 100644 --- a/bin/varnishtest/tests/r00916.vtc +++ b/bin/varnishtest/tests/r00916.vtc @@ -5,7 +5,8 @@ server s1 { txresp -body "FOO" } -start -varnish v1 -badvcl { +varnish v1 -errvcl {Symbol not found: 's-1' (expected type BACKEND)} { + backend b { .host = "127.0.0.1"; } sub s1 { } sub vcl_fetch { diff --git a/bin/varnishtest/tests/r00936.vtc b/bin/varnishtest/tests/r00936.vtc index 544245a..176cc7c 100644 --- a/bin/varnishtest/tests/r00936.vtc +++ b/bin/varnishtest/tests/r00936.vtc @@ -5,7 +5,7 @@ server s1 { txresp } -start -varnish v1 -badvcl { +varnish v1 -errvcl {'synthetic': not a valid action in method 'vcl_recv'} { backend foo { .host = "127.0.0.1"; } sub vcl_recv { diff --git a/bin/varnishtest/tests/r00971.vtc b/bin/varnishtest/tests/r00971.vtc index f8b57f0..232f568 100644 --- a/bin/varnishtest/tests/r00971.vtc +++ b/bin/varnishtest/tests/r00971.vtc @@ -1,7 +1,7 @@ varnishtest "Test DNS director order" -varnish v1 -vcl+backend { +varnish v1 -vcl { backend test { .host = "192.168.0.1"; diff --git a/bin/varnishtest/tests/r01027.vtc b/bin/varnishtest/tests/r01027.vtc index 6c20b00..347f623 100644 --- a/bin/varnishtest/tests/r01027.vtc +++ b/bin/varnishtest/tests/r01027.vtc @@ -1,6 +1,7 @@ varnishtest "Test if you can error in vcl_deliver" -varnish v1 -badvcl { +varnish v1 -errvcl {'error': not a valid action in method 'vcl_deliver'} { + backend b { .host = "127.0.0.1"; } sub vcl_deliver { error 201 "ok"; } diff --git a/bin/varnishtest/tests/r01144.vtc b/bin/varnishtest/tests/r01144.vtc index b08060d..dcd1505 100644 --- a/bin/varnishtest/tests/r01144.vtc +++ b/bin/varnishtest/tests/r01144.vtc @@ -24,7 +24,7 @@ client c1 { expect resp.status == 200 } -run -varnish v1 -badvcl { +varnish v1 -errvcl {Expected ID got '0'} { backend 0fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210 { .host = "127.0.0.1"; From phk at varnish-cache.org Thu Oct 25 08:12:40 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 25 Oct 2012 10:12:40 +0200 Subject: [master] adf520d (re)add the testcase for #1212 Message-ID: commit adf520dfad0e71f731f7f2b0940d631d1f4a3e78 Author: Poul-Henning Kamp Date: Thu Oct 25 08:12:00 2012 +0000 (re)add the testcase for #1212 Submitted by: Federico G. Schwindt diff --git a/bin/varnishtest/tests/r01212.vtc b/bin/varnishtest/tests/r01212.vtc new file mode 100644 index 0000000..ca8d5379 --- /dev/null +++ b/bin/varnishtest/tests/r01212.vtc @@ -0,0 +1,9 @@ +varnishtest "#1212 - Vmod with HEADER argument given a STRING asserts the VCL compiler" + +varnish v1 -errvcl {Wrong argument type. Expected HEADER. Got STRING.} { + import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so"; + backend b { .host = "127.0.0.1"; } + sub vcl_recv { + std.collect("foo"); + } +} From phk at varnish-cache.org Thu Oct 25 08:34:51 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 25 Oct 2012 10:34:51 +0200 Subject: [master] 574e757 Fix an off-by-one in an error message Message-ID: commit 574e757006f9eb4238c85de6aa8029949141f99c Author: Poul-Henning Kamp Date: Thu Oct 25 08:30:29 2012 +0000 Fix an off-by-one in an error message diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c index 319eef1..78cb0b2 100644 --- a/lib/libvcl/vcc_backend.c +++ b/lib/libvcl/vcc_backend.c @@ -644,7 +644,7 @@ vcc_DefBackend(struct vcc *tl, const struct token *nm) sym = VCC_GetSymbolTok(tl, nm, SYM_BACKEND); AN(sym); if (sym->ndef > 0) { - VSB_printf(tl->sb, "Backend %.*s redefined\n", PF(tl->t)); + VSB_printf(tl->sb, "Backend %.*s redefined\n", PF(nm)); vcc_ErrWhere(tl, nm); return; } From phk at varnish-cache.org Thu Oct 25 08:34:51 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 25 Oct 2012 10:34:51 +0200 Subject: [master] c30012a More badvcl->errvcl changes. Message-ID: commit c30012a02b7f1bc3a9fe2cf64dbe4964db9207d6 Author: Poul-Henning Kamp Date: Thu Oct 25 08:34:31 2012 +0000 More badvcl->errvcl changes. At least one case was b?rked. diff --git a/bin/varnishtest/tests/v00002.vtc b/bin/varnishtest/tests/v00002.vtc index d9d33d6..93f2f31 100644 --- a/bin/varnishtest/tests/v00002.vtc +++ b/bin/varnishtest/tests/v00002.vtc @@ -1,11 +1,11 @@ varnishtest "VCL: test syntax/semantic checks on backend decls. (vcc_backend.c)" # Missing backend -varnish v1 -badvcl { +varnish v1 -errvcl {No backends or directors found in VCL program} { } # Reference to non-existent backend -varnish v1 -badvcl { +varnish v1 -errvcl {Symbol not found: 'b2' (expected type BACKEND):} { backend b1 { .host = "127.0.0.1"; } @@ -15,14 +15,14 @@ varnish v1 -badvcl { } # Missing .host -varnish v1 -badvcl { +varnish v1 -errvcl {Mandatory field 'host' missing.} { backend b1 { .port = "http"; } } # Too many .host -varnish v1 -badvcl { +varnish v1 -errvcl {Field 'host' redefined at:} { backend b1 { .host = "foo"; .host = "bar"; @@ -30,7 +30,7 @@ varnish v1 -badvcl { } # Too many .port -varnish v1 -badvcl { +varnish v1 -errvcl {Field 'port' redefined at:} { backend b1 { .host = "foo"; .port = "http"; @@ -39,7 +39,7 @@ varnish v1 -badvcl { } # Too many .connect_timeout -varnish v1 -badvcl { +varnish v1 -errvcl {Field 'connect_timeout' redefined at:} { backend b1 { .host = "foo"; .connect_timeout = 1m; @@ -48,7 +48,7 @@ varnish v1 -badvcl { } # unknown field -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown field: 'foobar' at} { backend b1 { .host = "127.0.0.1"; .foobar = 123; @@ -56,7 +56,7 @@ varnish v1 -badvcl { } # Check backend reference by name -varnish v1 -badvcl { +varnish v1 -errvcl {Expected a backend host specification here, either by name or by {...}} { backend b1 { .host = "${bad_ip}"; } director r1 random { { .weight = 1; .backend = b1; } @@ -66,18 +66,18 @@ varnish v1 -badvcl { } # Check backend reference by name -varnish v1 -badvcl { +varnish v1 -errvcl "Expected '{' got 'b1'" { backend b1 { .host = "${bad_ip}"; } backend b2 b1; } # Check backend reference by non-C-compat name -varnish v1 -badvcl { +varnish v1 -errvcl {Identifier 'b-1' contains illegal characters, use [0-9a-zA-Z_] only.} { backend b-1 { .host = "${bad_ip}"; } } # Check backend reference by non-C-compat name -varnish v1 -badvcl { +varnish v1 -errvcl {Symbol not found: 'b-1' (expected type BACKEND):} { backend b1 { .host = "${bad_ip}"; } sub vcl_recv { set req.backend = b-1; @@ -85,52 +85,52 @@ varnish v1 -badvcl { } # Old backend syntax -varnish v1 -badvcl { +varnish v1 -errvcl {Remove "set" and "backend" in front of backend fields.} { backend b1 { set host = "127.0.0.1"; } } # Too many .connect_timeout -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown time unit 'q'. Legal are 's', 'm', 'h' and 'd'} { backend b1 { - .host = k"foo"; + .host = "foo"; .connect_timeout = 1 q; } } # Two clashing backends -varnish v1 -badvcl { +varnish v1 -errvcl {Backend b1 redefined} { backend b1 { .host = "127.0.0.1"; } backend b1 { .host = "127.0.0.1"; } } # Unknown director policy -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown director policy: 'anarchy' at} { director r1 anarchy { .host = "127.0.0.1"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Backend host "v00002.freebsd.dk": resolves to multiple IPv4 addresses.} { /* too many IP numbers */ backend b1 { .host = "v00002.freebsd.dk"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Backend host '"////."' could not be resolved to an IP address:} { backend b1 { .host = "////."; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Backend host '"127.0.0.1"' could not be resolved to an IP address:} { backend b1 { .host = "127.0.0.1"; .port = "////."; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown field: 'foobar' at} { backend b1 { .host = "127.0.0.1"; .foobar = "foo"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown field: 'ice' at} { backend b1 { .host = "127.0.0.1"; .probe = { @@ -139,14 +139,14 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {Must specify .threshold with .window} { backend b1 { .host = "127.0.0.1"; .probe = { .window = 8; } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Threshold must be 64 or less.} { backend b1 { .host = "127.0.0.1"; .probe = { .threshold = 65; } @@ -160,14 +160,13 @@ varnish v1 -vcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {Window must be 64 or less.} { backend b1 { .host = "127.0.0.1"; .probe = { .threshold = 32; .window = 65; } } } - varnish v1 -vcl { backend b1 { .host = "127.0.0.1"; @@ -175,16 +174,14 @@ varnish v1 -vcl { } } - -varnish v1 -badvcl { +varnish v1 -errvcl {Threshold can not be greater than window.} { backend b1 { .host = "127.0.0.1"; .probe = { .threshold = 32; .window = 31; } } } - -varnish v1 -badvcl { +varnish v1 -errvcl {Must specify .expected_response with exactly three digits (100 <= x <= 999)} { backend b1 { .host = "127.0.0.1"; .probe = { .expected_response = 13; } diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc index 70a3266..697de15 100644 --- a/bin/varnishtest/tests/v00021.vtc +++ b/bin/varnishtest/tests/v00021.vtc @@ -1,38 +1,38 @@ varnishtest "VCL compiler coverage test: vcc_xref.c" -varnish v1 -badvcl { +varnish v1 -errvcl {'obj.ttl': cannot be set in method 'vcl_recv'.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set obj.ttl = 1 w; } } -varnish v1 -badvcl { +varnish v1 -errvcl {'obj.ttl': cannot be set from method 'foo'.} { backend b { .host = "127.0.0.1"; } sub foo { set obj.ttl = 1 w; } sub vcl_recv { call foo ; } } -varnish v1 -badvcl { +varnish v1 -errvcl "Expected an action, 'if', '{' or '}'" { backend b { .host = "127.0.0.1"; } sub vcl_recv { discard; } } -varnish v1 -badvcl { +varnish v1 -errvcl "Expected an action, 'if', '{' or '}'" { backend b { .host = "127.0.0.1"; } sub foo { discard; } sub vcl_recv { call foo; } } -varnish v1 -badvcl { +varnish v1 -errvcl "Function recurses on" { backend b { .host = "127.0.0.1"; } sub foo { call foo; } sub vcl_recv { call foo; } } -varnish v1 -badvcl { +varnish v1 -errvcl "Function recurses on" { backend b { .host = "127.0.0.1"; } sub bar { call foo; } @@ -41,14 +41,14 @@ varnish v1 -badvcl { } -varnish v1 -badvcl { +varnish v1 -errvcl {Unused acl foo, defined:} { backend b { .host = "127.0.0.1"; } acl foo { "localhost"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Unused sub foo, defined:} { backend b { .host = "127.0.0.1"; } sub foo { @@ -56,7 +56,7 @@ varnish v1 -badvcl { } -varnish v1 -badvcl { +varnish v1 -errvcl {Invalid return "deliver"} { backend b { .host = "127.0.0.1"; } sub vcl_recv { From phk at varnish-cache.org Thu Oct 25 09:03:20 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 25 Oct 2012 11:03:20 +0200 Subject: [master] d532867 More badvcl->errvcl changes Message-ID: commit d532867f03bb48a0602bc762c06b5bce2796d564 Author: Poul-Henning Kamp Date: Thu Oct 25 08:41:43 2012 +0000 More badvcl->errvcl changes diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc index d1c0d5f..7a9ccbc 100644 --- a/bin/varnishtest/tests/v00018.vtc +++ b/bin/varnishtest/tests/v00018.vtc @@ -18,7 +18,7 @@ varnish v1 -vcl { sub vcl_fetch { error beresp.status req.url; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Variable 'server.port' is read only.} { backend b { .host = "127.0.0.1"; } sub vcl_miss { set server.port = 1000; } } @@ -28,28 +28,28 @@ varnish v1 -vcl { sub vcl_fetch { set beresp.ttl /= 2; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected '=' got '>>'} { backend b { .host = "127.0.0.1"; } sub vcl_fetch { set beresp.ttl >>= 2; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected '=' got '+='} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.backend += b; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected '=' got '+='} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.url += server.port; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected ';' got 'if'} { backend b { .host = "127.0.0.1"; } /* XXX: This should not really be an error */ sub vcl_recv { set req.url = "foo" if "bar"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Symbol not found: 'req.hash' (expected type STRING_LIST):} { backend b { .host = "127.0.0.1"; } sub vcl_hash { hash_data(req.hash); } } @@ -59,7 +59,7 @@ varnish v1 -vcl { sub vcl_recv { set req.url = 1; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected '=' got '+='} { backend b { .host = "127.0.0.1"; } sub vcl_fetch { set beresp.do_gzip += 1; } } @@ -74,22 +74,22 @@ varnish v1 -vcl { sub vcl_fetch { set beresp.do_gzip = false; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Symbol not found: 'mu' (expected type BOOL):} { backend b { .host = "127.0.0.1"; } sub vcl_fetch { set beresp.do_gzip = mu; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Only http header variables can be unset.} { backend b { .host = "127.0.0.1"; } sub vcl_fetch { unset beresp.do_gzip; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown token 'if' when looking for STRING} { backend b { .host = "127.0.0.1"; } sub vcl_recv { ban_url (if); } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected an action, 'if', '{' or '}'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { ban_hash (if); } } @@ -99,13 +99,12 @@ varnish v1 -vcl { sub vcl_recv { ban_url ("foo"); } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected an action, 'if', '{' or '}'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { kluf ; } } - -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown token 'if' when looking for STRING_LIST} { backend b { .host = "127.0.0.1"; } sub vcl_error { synthetic if "foo"; } } From phk at varnish-cache.org Thu Oct 25 09:03:20 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 25 Oct 2012 11:03:20 +0200 Subject: [master] eb0e6a4 Improve a couple of error messages. Message-ID: commit eb0e6a4d08f85139a1c22a64348b8d60f0ec71c5 Author: Poul-Henning Kamp Date: Thu Oct 25 09:03:03 2012 +0000 Improve a couple of error messages. diff --git a/lib/libvcl/vcc_acl.c b/lib/libvcl/vcc_acl.c index 3e037ec..d3db319 100644 --- a/lib/libvcl/vcc_acl.c +++ b/lib/libvcl/vcc_acl.c @@ -100,7 +100,7 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l, if (fam == PF_INET && ae->mask > 32) { VSB_printf(tl->sb, - "Too wide mask (%u) for IPv4 address", ae->mask); + "Too wide mask (%u) for IPv4 address\n", ae->mask); if (ae->t_mask != NULL) vcc_ErrWhere(tl, ae->t_mask); else @@ -109,7 +109,7 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l, } if (fam == PF_INET6 && ae->mask > 128) { VSB_printf(tl->sb, - "Too wide mask (%u) for IPv6 address", ae->mask); + "Too wide mask (%u) for IPv6 address\n", ae->mask); vcc_ErrWhere(tl, ae->t_mask); return; } diff --git a/lib/libvcl/vcc_dir_random.c b/lib/libvcl/vcc_dir_random.c index 4166918..e647bfd 100644 --- a/lib/libvcl/vcc_dir_random.c +++ b/lib/libvcl/vcc_dir_random.c @@ -38,7 +38,7 @@ void vcc_ParseRandomDirector(struct vcc *tl) { - struct token *t_field, *t_be; + struct token *t_field, *t_be, *t_x; int nelem; struct fld_spec *fs, *mfs; unsigned u, retries; @@ -86,15 +86,14 @@ vcc_ParseRandomDirector(struct vcc *tl) first, p); } else if (vcc_IdIs(t_field, "weight")) { ExpectErr(tl, CNUM); + t_x = tl->t; u = vcc_UintVal(tl); ERRCHK(tl); if (u == 0) { VSB_printf(tl->sb, "The .weight must be higher " - "than zero."); - vcc_ErrToken(tl, tl->t); - VSB_printf(tl->sb, " at\n"); - vcc_ErrWhere(tl, tl->t); + "than zero.\n"); + vcc_ErrWhere(tl, t_x); return; } Fc(tl, 0, "%s .weight = %u", first, u); From phk at varnish-cache.org Thu Oct 25 09:13:24 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 25 Oct 2012 11:13:24 +0200 Subject: [master] 4edf07e Change the remaining badvcl to errvcl Message-ID: commit 4edf07ee3ede3fd48a1ceaf20bd9df98dc0da8b4 Author: Poul-Henning Kamp Date: Thu Oct 25 09:13:06 2012 +0000 Change the remaining badvcl to errvcl diff --git a/bin/varnishtest/tests/v00003.vtc b/bin/varnishtest/tests/v00003.vtc index ec4248d..f519721 100644 --- a/bin/varnishtest/tests/v00003.vtc +++ b/bin/varnishtest/tests/v00003.vtc @@ -1,35 +1,35 @@ varnishtest "VCL: test syntax/semantic checks on director decls." # syntax in inline backend -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown field: 'foo' at} { director r1 random { { .backend = { .foo = 2; }; .weight = 1;} } } # reference to unknown backend host -varnish v1 -badvcl { +varnish v1 -errvcl {Reference to unknown backend 'b2' at} { director r1 random { { .backend = b2; .weight = 1; } } } # missing backend -varnish v1 -badvcl { +varnish v1 -errvcl {Mandatory field 'backend' missing.} { director r1 random { { .weight = 1; } } } # invalid weight -varnish v1 -badvcl { +varnish v1 -errvcl {Expected CNUM got 'k'} { director r1 random { { .backend = {.host = "127.0.0.1";} .weight = k; } } } # invalid weight -varnish v1 -badvcl { +varnish v1 -errvcl {The .weight must be higher than zero.} { director r1 random { { .backend = {.host = "127.0.0.1";} .weight = 0; } } @@ -43,14 +43,14 @@ varnish v1 -vcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown field: 'foobar' at} { director r1 random { .foobar = 3; { .backend = {.host = "127.0.0.1";} .weight = 1; } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected CNUM got 'x'} { director r1 random { .retries = x; { .backend = {.host = "127.0.0.1";} .weight = 1; } diff --git a/bin/varnishtest/tests/v00005.vtc b/bin/varnishtest/tests/v00005.vtc index a84d3be..0b4b780 100644 --- a/bin/varnishtest/tests/v00005.vtc +++ b/bin/varnishtest/tests/v00005.vtc @@ -33,7 +33,7 @@ varnish v1 -vcl { } # Check redefinition -varnish v1 -badvcl { +varnish v1 -errvcl {Probe request redefinition at:} { backend b1 { .host = "127.0.0.1"; .probe = { @@ -46,7 +46,7 @@ varnish v1 -badvcl { } # Check redefinition the other way -varnish v1 -badvcl { +varnish v1 -errvcl {Probe request redefinition at:} { backend b1 { .host = "127.0.0.1"; .probe = { diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index 691cc56..5b17ed6 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -7,14 +7,14 @@ varnish v1 -vcl { include "${tmpdir}/_varnishtest_empty_file" ; } -varnish v1 -badvcl { +varnish v1 -errvcl {include not followed by semicolon.} { backend b { .host = "127.0.0.1"; } include "${tmpdir}/_varnishtest_empty_file" | } shell "rm -f ${tmpdir}/_varnishtest_empty_file" -varnish v1 -badvcl { +varnish v1 -errvcl {include not followed by string constant.} { backend b { .host = "127.0.0.1"; } include << } @@ -29,7 +29,7 @@ varnish v1 -vcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {include not followed by string constant.} { /* token test */ error lookup hash pipe pass fetch deliver discard keep restart include @@ -73,22 +73,22 @@ varnish v1 -vcl { } -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown time unit 'k'. Legal are 's', 'm', 'h' and 'd'} { backend b { .host = "127.0.0.1"; } sub vcl_fetch { set obj.ttl = 1. k; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expression has type DURATION, expected BOOL} { backend b { .host = "127.0.0.1"; } sub vcl_fetch { if (obj.ttl *= 2) { } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Operator > not possible on BACKEND} { backend b { .host = "127.0.0.1"; } sub vcl_recv { if (req.backend > b) { } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Symbol not found: 'req.hash' (expected type BOOL):} { backend b { .host = "127.0.0.1"; } sub vcl_hash { if (req.hash != "foo") { } } } diff --git a/bin/varnishtest/tests/v00017.vtc b/bin/varnishtest/tests/v00017.vtc index 66d54fb..9c385f5 100644 --- a/bin/varnishtest/tests/v00017.vtc +++ b/bin/varnishtest/tests/v00017.vtc @@ -1,12 +1,12 @@ varnishtest "VCL compiler coverage test: vcc_acl.c" -varnish v1 -badvcl { +varnish v1 -errvcl {Too wide mask (33) for IPv4 address} { backend b { .host = "127.0.0.1"; } acl a { "10.1.2.3"/33; } sub vcl_recv { if (client.ip ~ a) { return(pass); } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Too wide mask (129) for IPv6 address} { backend b { .host = "127.0.0.1"; } acl a { "1::2"/129; } sub vcl_recv { if (client.ip ~ a) { return(pass); } } @@ -21,7 +21,7 @@ varnish v1 -vcl { sub vcl_recv { if (client.ip ~ a) { return(pass); } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Conflicting ACL entries:} { backend b { .host = "127.0.0.1"; } acl a { "1.2.3.4"; @@ -30,25 +30,25 @@ varnish v1 -badvcl { sub vcl_recv { if (client.ip ~ a) { return(pass); } } } -varnish v1 -badvcl { +varnish v1 -errvcl {DNS lookup(...com): } { backend b { .host = "127.0.0.1"; } acl a { "...com"; } sub vcl_recv { if (client.ip ~ a) { return(pass); } } } -varnish v1 -badvcl { +varnish v1 -errvcl {DNS lookup(10.1.2.): } { backend b { .host = "127.0.0.1"; } acl a { "10.1.2."; } sub vcl_recv { if (client.ip ~ a) { return(pass); } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected ')' got ';'} { backend b { .host = "127.0.0.1"; } acl a { ( "10.1.2"; } sub vcl_recv { if (client.ip ~ a) { return(pass); } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected ';' got ')'} { backend b { .host = "127.0.0.1"; } acl a { "10.1.2" ); } sub vcl_recv { if (client.ip ~ a) { return(pass); } } @@ -70,7 +70,7 @@ varnish v1 -vcl { sub vcl_miss { if (client.ip != "127.0.0.1") { return(pass); } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Operator > not possible on IP} { backend b { .host = "127.0.0.1"; } sub vcl_recv { if (client.ip > "127.0.0.1") { return(pass); } } } diff --git a/bin/varnishtest/tests/v00019.vtc b/bin/varnishtest/tests/v00019.vtc index eabcdd0..b8e5466 100644 --- a/bin/varnishtest/tests/v00019.vtc +++ b/bin/varnishtest/tests/v00019.vtc @@ -1,6 +1,6 @@ varnishtest "VCL compiler coverage test: vcc_token.c" -varnish v1 -badvcl " C{ " +varnish v1 -errvcl {Unterminated inline C source, starting at} " C{ " varnish v1 -vcl { backend b { .host = "127.0.0.1"; } @@ -8,17 +8,17 @@ varnish v1 -vcl { sub vcl_recv { set req.url = "x"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Unterminated /* ... */ comment, starting at} { backend b { .host = "127.0.0.1"; } /* } -varnish v1 -badvcl { +varnish v1 -errvcl {Unterminated long-string, starting at} { backend b { .host = "127.0.0.1"; } {" } } -varnish v1 -badvcl { +varnish v1 -errvcl {Unterminated string at} { backend b { .host = "127.0.0.1"; } " } @@ -28,12 +28,12 @@ varnish v1 -vcl { sub vcl_recv { C{ int i; (void)i; }C } } -varnish v1 -badvcl { +varnish v1 -errvcl {Syntax error at} { backend b { .host = "127.0.0.1"; } ? } -varnish v1 -badvcl { +varnish v1 -errvcl {Comparison of different types: STRING '==' INT} { backend b { .host = "127.0.0.1"; } sub vcl_recv { if ("foo" + "bar" == 777) { @@ -42,7 +42,7 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {Comparison of different types: STRING '==' INT} { backend b { .host = "127.0.0.1"; } sub vcl_recv { if ("foo" + "bar" == @@ -52,7 +52,7 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {Comparison of different types: STRING '==' INT} { backend b { .host = "127.0.0.1"; } sub vcl_recv { if ("foo" + "bar" == diff --git a/bin/varnishtest/tests/v00030.vtc b/bin/varnishtest/tests/v00030.vtc index a2dff48..9e855ec 100644 --- a/bin/varnishtest/tests/v00030.vtc +++ b/bin/varnishtest/tests/v00030.vtc @@ -1,6 +1,6 @@ varnishtest "DNS director bad VCL tests" -varnish v1 -badvcl { +varnish v1 -errvcl {Expected '.' got '192'} { director directorname dns { .list = { 192.168.15.0/24; @@ -8,7 +8,7 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl "Expected '.' got '}'" { director directorname dns { .list = { .host_header = "www.example.com"; @@ -18,7 +18,7 @@ varnish v1 -badvcl { } } -varnish v9 -badvcl { +varnish v9 -errvcl {Unknown field: 'host_hdr' at} { director directorname dns { .list = { .host_hdr = "192.168.1.1"; @@ -26,7 +26,7 @@ varnish v9 -badvcl { } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown field: 'host_hdr' at} { director directorname dns { .list = { .host_hdr = "www.example.com"; @@ -35,7 +35,7 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +varnish v1 -errvcl {Expected CSTR got '80'} { director directorname dns { .list = { .port = 80; @@ -43,7 +43,9 @@ varnish v1 -badvcl { } } } -varnish v1 -badvcl { + +# XXX: reported token should be improved +varnish v1 -errvcl {IP and network mask not compatible: ';' at} { director directorname dns { .list = { "192.168.15.0"/33; @@ -51,7 +53,8 @@ varnish v1 -badvcl { } } -varnish v1 -badvcl { +# XXX: reported token should be improved +varnish v1 -errvcl {IP and network mask not compatible: ';' at} { director directorname dns { .list = { "192.168.16.255"/24; diff --git a/bin/varnishtest/tests/v00031.vtc b/bin/varnishtest/tests/v00031.vtc index 0bae6e0..70ca757 100644 --- a/bin/varnishtest/tests/v00031.vtc +++ b/bin/varnishtest/tests/v00031.vtc @@ -1,6 +1,6 @@ varnishtest "param vcc_err_unref" -varnish v1 -badvcl { +varnish v1 -errvcl {Unused backend c, defined:} { backend b { .host = "127.0.0.1"; } backend c { .host = "127.0.0.1"; } } @@ -14,7 +14,7 @@ varnish v1 -vcl { varnish v1 -cliok "param.set vcc_err_unref true" -varnish v1 -badvcl { +varnish v1 -errvcl {Unused backend c, defined:} { backend b { .host = "127.0.0.1"; } backend c { .host = "127.0.0.1"; } } diff --git a/bin/varnishtest/tests/v00033.vtc b/bin/varnishtest/tests/v00033.vtc index 403931d..ceb5c12 100644 --- a/bin/varnishtest/tests/v00033.vtc +++ b/bin/varnishtest/tests/v00033.vtc @@ -37,13 +37,13 @@ client c1 { expect resp.http.bar == true } -run -varnish v1 -badvcl { +varnish v1 -errvcl {Expected BYTES unit (B, KB, MB...) got '"X"'} { sub vcl_recv { if (storage.nowhere.free_space > 4 "X") { } } } -varnish v1 -badvcl { +varnish v1 -errvcl {Unknown BYTES unit 'X'. Legal are 'B', 'KB', 'MB', 'GB' and 'TB'} { sub vcl_recv { if (storage.nowhere.free_space > 4 X) { } diff --git a/bin/varnishtest/tests/v00034.vtc b/bin/varnishtest/tests/v00034.vtc index fdc6e20..f7d4ed0 100644 --- a/bin/varnishtest/tests/v00034.vtc +++ b/bin/varnishtest/tests/v00034.vtc @@ -7,19 +7,19 @@ server s1 { varnish v1 -vcl+backend { } -start -varnish v1 -badvcl { +varnish v1 -errvcl {Function c1 redefined} { backend foo { .host = "127.0.0.1"; } sub c1 { } sub c1 { } sub vcl_recv { call c1; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Backend s1 redefined} { backend s1 { .host = "127.0.0.1"; } backend s1 { .host = "127.0.0.1"; } } -varnish v1 -badvcl { +varnish v1 -errvcl {Probe p1 redefined} { backend s1 { .host = "127.0.0.1"; .probe = p1;} probe p1 { } probe p1 { } From phk at varnish-cache.org Thu Oct 25 09:14:00 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 25 Oct 2012 11:14:00 +0200 Subject: [master] 85ee808 Remove support for -badvcl, use -errvcl instead Message-ID: commit 85ee808d4273303d1a8723ac403d52b19a253ac9 Author: Poul-Henning Kamp Date: Thu Oct 25 09:13:48 2012 +0000 Remove support for -badvcl, use -errvcl instead diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index b38a289..9857c24 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -855,12 +855,6 @@ cmd_varnish(CMD_ARGS) av++; continue; } - if (!strcmp(*av, "-badvcl")) { - AN(av[1]); - varnish_vcl(v, av[1], CLIS_PARAM, NULL); - av++; - continue; - } if (!strcmp(*av, "-errvcl")) { char *r = NULL; AN(av[1]); From daghf at varnish-cache.org Mon Oct 29 09:00:20 2012 From: daghf at varnish-cache.org (Dag Haavi Finstad) Date: Mon, 29 Oct 2012 10:00:20 +0100 Subject: [master] ee1af67 Documentation fix for error in vcl_deliver. Message-ID: commit ee1af675bab963920014e60d1076042ae6c7caea Author: Dag Haavi Finstad Date: Mon Oct 29 09:58:03 2012 +0100 Documentation fix for error in vcl_deliver. Fixed by: Federico G. Schwindt Fixes: #1216 diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 4971315..1c1d8a2 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -512,9 +512,6 @@ vcl_deliver deliver Deliver the object to the client. - error code [reason] - Return the specified error code to the client and abandon the request. - restart Restart the transaction. Increases the restart counter. If the number of restarts is higher than *max_restarts* varnish emits a guru meditation From phk at varnish-cache.org Mon Oct 29 13:17:07 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Oct 2012 14:17:07 +0100 Subject: [master] e14ddae Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit e14ddaee5994cb851983a6881afd2c12cad35db8 Merge: 06b74e3 ee1af67 Author: Poul-Henning Kamp Date: Mon Oct 29 13:16:49 2012 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From phk at varnish-cache.org Mon Oct 29 13:17:07 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Oct 2012 14:17:07 +0100 Subject: [master] 06b74e3 Add tbl/vcc_types.h Message-ID: commit 06b74e315b5c6772b21bf93dd3ae78909c8fb331 Author: Poul-Henning Kamp Date: Mon Oct 29 13:16:36 2012 +0000 Add tbl/vcc_types.h diff --git a/.gitignore b/.gitignore index 81f58b7..4ec89a6 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ TAGS /include/tbl/vcl_returns.h /include/vrt_obj.h /include/tbl/vrt_stv_var.h +/include/tbl/vcc_types.h /include/vcs_version.h /lib/libvcl/vcc_fixed_token.c /lib/libvcl/vcc_obj.c From phk at varnish-cache.org Mon Oct 29 20:35:47 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Oct 2012 21:35:47 +0100 Subject: [master] a3533da Remember to initialize the version number, so we don't start out processing all the old entries, unless -d was specified. Message-ID: commit a3533dae312582657c519a9f8ce7da6d906ad53f Author: Poul-Henning Kamp Date: Mon Oct 29 20:34:56 2012 +0000 Remember to initialize the version number, so we don't start out processing all the old entries, unless -d was specified. Fixes #1170 diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index da9e5df..1c36b3f 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -145,6 +145,7 @@ vsl_open(struct VSM_data *vd) } if (vsl->log_ptr >= vsl->log_end) vsl->log_ptr = vsl->log_start + 1; + vsl->last_seq = vsl->log_start[0]; return (0); } From phk at varnish-cache.org Mon Oct 29 21:04:14 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Oct 2012 22:04:14 +0100 Subject: [master] f2367b2 Increase stack-size for the benefit of i386 Message-ID: commit f2367b221d99babf54ad8e565afeaf3ef107c40f Author: Poul-Henning Kamp Date: Mon Oct 29 21:03:38 2012 +0000 Increase stack-size for the benefit of i386 Fixes #1201 diff --git a/bin/varnishtest/tests/r01109.vtc b/bin/varnishtest/tests/r01109.vtc index 50f0a0e..e6b43e8 100644 --- a/bin/varnishtest/tests/r01109.vtc +++ b/bin/varnishtest/tests/r01109.vtc @@ -21,7 +21,7 @@ server s1 { txresp -bodylen 4074 } -start -varnish v1 -arg "-pfetch_chunksize=4k" -arg "-pgzip_level=0" -vcl+backend { +varnish v1 -arg "-pfetch_chunksize=4k" -arg "-pgzip_level=0" -arg "-pthread_pool_stack=131072" -vcl+backend { sub vcl_fetch { if (req.url ~ "/test") { set beresp.do_esi = true; From tfheen at varnish-cache.org Wed Oct 31 07:18:57 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 31 Oct 2012 08:18:57 +0100 Subject: [master] 8b7dbe7 PATCH: remove non-ascii characters and don't manually split words. Message-ID: commit 8b7dbe7b5d58e68955a9c112b8b520ef520ed5d1 Author: Federico G. Schwindt Date: Mon Oct 29 22:12:47 2012 +0000 PATCH: remove non-ascii characters and don't manually split words. diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 1c1d8a2..398127e 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -276,7 +276,7 @@ which can later be used to match client addresses: } If an ACL entry specifies a host name which Varnish is unable to -resolve, it will match any address it is com? pared to. Consequently, +resolve, it will match any address it is compared to. Consequently, if it is preceded by a negation mark, it will reject any address it is compared to, which may not be what you intended. If the entry is enclosed in parentheses, however, it will simply be ignored. @@ -407,8 +407,8 @@ vcl_pipe vcl_pass Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response is passed on to the - client, but is not entered into the cache. Subsequent requests sub? - mitted over the same client connection are handled normally. + client, but is not entered into the cache. Subsequent requests + submitted over the same client connection are handled normally. The vcl_pass subroutine may terminate with calling return() with one of the following keywords: From tfheen at varnish-cache.org Wed Oct 31 07:32:44 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 31 Oct 2012 08:32:44 +0100 Subject: [master] 64b4a12 PATCH: document beresp.http.header Message-ID: commit 64b4a1246a90b713cf58d6feaf49626abf44acec Author: Federico G. Schwindt Date: Mon Oct 29 22:09:08 2012 +0000 PATCH: document beresp.http.header diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 398127e..60daaa3 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -719,6 +719,9 @@ beresp.do_gunzip Boolean. Unzip the object before storing it in the cache. Defaults to false. +beresp.http.header + The corresponding HTTP header. + beresp.proto The HTTP protocol version used the backend replied with.