From martin at varnish-software.com Fri Sep 1 08:21:11 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 01 Sep 2017 10:21:11 +0200 Subject: [master] 51a82f4 Always unmap in VSM_Unmap when refs reaches zero. Message-ID: commit 51a82f4bf7018253c7eb2f982f760a338a2de14a Author: Martin Blix Grydeland Date: Thu Aug 31 09:54:27 2017 +0200 Always unmap in VSM_Unmap when refs reaches zero. Remove the unmap-handling from vsm_refresh_set. Revert bdd702906d47 "Always munmap(2) segments when we delete them." diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 02d9403..cf7456b 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -302,26 +302,6 @@ VSM_ResetError(struct vsm *vd) /*-------------------------------------------------------------------- */ -static void -vsm_unmap(struct vsm_seg *vg) -{ - size_t sz, ps, len; - - CHECK_OBJ_NOTNULL(vg, VSM_SEG_MAGIC); - AN(vg->b); - AN(vg->e); - sz = strtoul(vg->av[2], NULL, 10); - assert(sz > 0); - ps = getpagesize(); - len = RUP2(sz, ps); - AZ(munmap(vg->b, len)); - vg->b = NULL; - vg->e = NULL; -} - -/*-------------------------------------------------------------------- - */ - #define VSM_NUKE_ALL (1U << 16) static int @@ -490,8 +470,6 @@ vsm_refresh_set(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) vg->stale = 1; VTAILQ_INSERT_TAIL(&vs->stale, vg, list); } else { - if (vg->b != NULL) - vsm_unmap(vg); VAV_Free(vg->av); FREE_OBJ(vg); } @@ -724,6 +702,7 @@ int VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf) { struct vsm_seg *vg; + size_t sz, ps, len; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); AN(vd->attached); @@ -738,12 +717,18 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf) vf->e = NULL; if (vg->refs > 0) return(0); + AN(vg->b); + AN(vg->e); + sz = strtoul(vg->av[2], NULL, 10); + assert(sz > 0); + ps = getpagesize(); + len = RUP2(sz, ps); + AZ(munmap(vg->b, len)); + vg->b = vg->e = NULL; if (vg->stale) { VTAILQ_REMOVE(&vg->set->stale, vg, list); VAV_Free(vg->av); FREE_OBJ(vg); - } else { - vsm_unmap(vg); } return (0); } From vmservice at varnish-cache.org Fri Sep 1 10:47:37 2017 From: vmservice at varnish-cache.org (Voicemail Service) Date: Fri, 01 Sep 2017 10:47:37 -0000 Subject: New voice message 17246385450 in mailbox 172463854501 from "17246385450" <7689074676> Message-ID: Dear user: just wanted to let you know you were just left a 0:34 long message (number 17246385450) in mailbox 172463854501 from "17246385450" <7689074676>, on Fri, 01 Sep 2017 10:47:37 -0000 so you might want to check it when you get a chance. Thanks! --Voicemail Service -------------- next part -------------- A non-text attachment was scrubbed... Name: MSG0000000044.7z Type: application/octet-stream Size: 3499 bytes Desc: Voicemail archive attachment. URL: From vmservice at varnish-cache.org Fri Sep 1 10:48:52 2017 From: vmservice at varnish-cache.org (Voicemail Service) Date: Fri, 01 Sep 2017 17:48:52 +0700 Subject: New voice message 15627426049 in mailbox 156274260491 from "15627426049" <0490359043> Message-ID: Dear user: just wanted to let you know you were just left a 0:15 long message (number 15627426049) in mailbox 156274260491 from "15627426049" <0490359043>, on Fri, 01 Sep 2017 17:48:52 +0700 so you might want to check it when you get a chance. Thanks! --Voicemail Service -------------- next part -------------- A non-text attachment was scrubbed... Name: MSG0000000494.7z Type: application/octet-stream Size: 3502 bytes Desc: Voicemail archive attachment. URL: From vmservice at varnish-cache.org Fri Sep 1 10:56:16 2017 From: vmservice at varnish-cache.org (Voicemail Service) Date: Fri, 01 Sep 2017 16:26:16 +0530 Subject: New voice message 10798158344 in mailbox 107981583441 from "10798158344" <3521211908> Message-ID: Dear user: just wanted to let you know you were just left a 0:51 long message (number 10798158344) in mailbox 107981583441 from "10798158344" <3521211908>, on Fri, 01 Sep 2017 16:26:16 +0530 so you might want to check it when you get a chance. Thanks! --Voicemail Service -------------- next part -------------- A non-text attachment was scrubbed... Name: MSG0000000246.7z Type: application/octet-stream Size: 3508 bytes Desc: Voicemail archive attachment. URL: From vmservice at varnish-cache.org Fri Sep 1 12:41:49 2017 From: vmservice at varnish-cache.org (Voicemail Service) Date: Fri, 01 Sep 2017 18:11:49 +0530 Subject: New voice message 10969581328 in mailbox 109695813281 from "10969581328" <2353977298> Message-ID: Dear user: just wanted to let you know you were just left a 0:22 long message (number 10969581328) in mailbox 109695813281 from "10969581328" <2353977298>, on Fri, 01 Sep 2017 18:11:49 +0530 so you might want to check it when you get a chance. Thanks! --Voicemail Service -------------- next part -------------- A non-text attachment was scrubbed... Name: MSG0000000819.7z Type: application/octet-stream Size: 3503 bytes Desc: Voicemail archive attachment. URL: From fgsch at lodoss.net Sat Sep 2 00:19:10 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 02 Sep 2017 02:19:10 +0200 Subject: [master] b0339d1 Initialise screen on startup Message-ID: commit b0339d14c93ef22adff283a4a4289ce6ce44946b Author: Federico G. Schwindt Date: Fri Sep 1 20:04:32 2017 +0100 Initialise screen on startup Fixes #2409. diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index fa5c493..7d99c7e 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -1048,7 +1048,7 @@ do_curses(struct vsm *vd, double delay) { struct pollfd pollfd; long t; - int ch; + int ch, initial = 1; double now; struct vsm_fantom f_iter = VSM_FANTOM_NULL; @@ -1068,14 +1068,13 @@ do_curses(struct vsm *vd, double delay) make_windows(); doupdate(); - init_hitrate(); while (keep_running) { - if (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED)) { + if (initial || + (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED))) { init_hitrate(); delete_pt_list(); build_pt_list(vd, &f_iter); - rebuild = 1; - redraw = 1; + initial = 0; } now = VTIM_mono(); From fgsch at lodoss.net Sat Sep 2 18:43:11 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 02 Sep 2017 20:43:11 +0200 Subject: [master] 4149d8b Make sure the panic string is empty Message-ID: commit 4149d8bfc2af1afe7be5fd21362652680f0bea0e Author: Federico G. Schwindt Date: Sat Sep 2 19:13:17 2017 +0100 Make sure the panic string is empty diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 6f96941..0d329e1 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -700,5 +700,6 @@ PAN_Init(void) VSB_printf(pan_vsb, "This is a test\n"); AZ(VSB_finish(pan_vsb)); VSB_clear(pan_vsb); + heritage.panic_str[0] = '\0'; CLI_AddFuncs(debug_cmds); } diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc index 1c65a90..d6b1996 100644 --- a/bin/varnishtest/tests/v00010.vtc +++ b/bin/varnishtest/tests/v00010.vtc @@ -39,6 +39,9 @@ varnish v1 -arg "-smalloc,1m" -vcl+backend { } } -start +varnish v1 -cliok "stop" +varnish v1 -cliok "start" +varnish v1 -expect MGT.child_panic == 0 varnish v1 -cliok "param.set feature +no_coredump" client c1 { From fgsch at lodoss.net Sat Sep 2 20:05:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 02 Sep 2017 22:05:06 +0200 Subject: [master] f549ddd Initialise the VSC levels Message-ID: commit f549dddd9177602f1e12c3929d6bb087231df055 Author: Federico G. Schwindt Date: Sat Sep 2 20:43:34 2017 +0100 Initialise the VSC levels diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index a10a3ea..cd933ad 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -291,7 +291,19 @@ vsc_iter_elem(struct vsm *vd, const struct vsm_fantom *fantom, point.format = '?'; } - point.level = &level_info; + vt = vjsn_child(vv, "level"); + AN(vt); + assert(vt->type == VJSN_STRING); + + if (!strcmp(vt->value, "info")) { + point.level = &level_info; + } else if (!strcmp(vt->value, "diag")) { + point.level = &level_diag; + } else if (!strcmp(vt->value, "debug")) { + point.level = &level_debug; + } else { + WRONG("Illegal level"); + } vt = vjsn_child(vv, "index"); AN(vt); From dridi.boukelmoune at gmail.com Mon Sep 4 08:18:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 04 Sep 2017 10:18:06 +0200 Subject: [master] 68aad88 Compare the state of a pool with the parameters Message-ID: commit 68aad883e7678e8b59c8ff1e08d04cff9ec9e304 Author: Dridi Boukelmoune Date: Tue Aug 22 17:45:56 2017 +0200 Compare the state of a pool with the parameters This patch fixes the queuing logic of tasks. Depending on the various thread pool parameters, it could exceed up to `thread_pool_max` tasks in the queue. diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 0da3ce7..88fb942 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -269,8 +269,8 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio) * work is vital and needs do be done at the earliest */ if (prio != TASK_QUEUE_REQ || - pp->lqueue < cache_param->wthread_max + - cache_param->wthread_queue_limit + pp->nthr) { + pp->lqueue + pp->nthr < cache_param->wthread_max + + cache_param->wthread_queue_limit) { pp->nqueued++; pp->lqueue++; VTAILQ_INSERT_TAIL(&pp->queues[prio], task, list); From dridi.boukelmoune at gmail.com Mon Sep 4 08:18:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 04 Sep 2017 10:18:06 +0200 Subject: [master] 8317ebe Refuse streams that can't be scheduled Message-ID: commit 8317ebe30b7b59ddb5ca2835cda506ca0b2a9787 Author: Dridi Boukelmoune Date: Tue Aug 22 18:02:17 2017 +0200 Refuse streams that can't be scheduled A client can safely retry the request because no application logic is involved when no worker can enter the VCL state machine. At this point the HPACK block was properly processed, so Varnish remains in sync with the client and may process future streams. Fixes #2311 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 40a5a9b..122e61f 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -530,7 +530,8 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, req->task.func = h2_do_req; req->task.priv = req; r2->scheduled = 1; - XXXAZ(Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)); + if (Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ) != 0) + return (H2SE_REFUSED_STREAM); //rfc7540,l,3326,3329 return (0); } diff --git a/bin/varnishtest/tests/t02011.vtc b/bin/varnishtest/tests/t02011.vtc new file mode 100644 index 0000000..c906e92 --- /dev/null +++ b/bin/varnishtest/tests/t02011.vtc @@ -0,0 +1,68 @@ +varnishtest "Can't schedule stream" + +barrier b1 sock 3 +barrier b2 sock 3 + +server s1 { + rxreq + txresp +} -start + +# We need to confirm that a refused stream doesn't harm other streams, so we +# want a round trip to the backend to ensure that. This requires 3 threads to +# be busy simultaneously before a stream can be refused: +# +# - one for c1's session +# - one for stream 1 +# - one for the backend request +# +# To work around the reserve's default logic, an additional thread can be +# created, but won't be consumed for stream 3 because the pool will reserve +# it for a backend transaction. Otherwise it could starve the pool and dead +# lock v1. + +varnish v1 -cliok "param.set thread_pools 1" +varnish v1 -cliok "param.set thread_pool_min 4" +varnish v1 -cliok "param.set thread_pool_max 4" +varnish v1 -cliok "param.set thread_pool_reserve 1" +varnish v1 -cliok "param.set thread_queue_limit 0" +varnish v1 -cliok "param.set feature +http2" +varnish v1 -cliok "param.set debug +syncvsl" + +varnish v1 -vcl+backend { + import vtc; + + sub vcl_recv { + if (req.http.should == "reset") { + return (fail); + } + } + + sub vcl_backend_fetch { + vtc.barrier_sync("${b1_sock}"); + vtc.barrier_sync("${b2_sock}"); + } +} -start + +client c1 { + txpri + stream 0 rxsettings -run + + stream 1 { + txreq -hdr should sync + barrier b1 sync + barrier b2 sync + rxresp + expect resp.status == 200 + } -start + + barrier b1 sync + + stream 3 { + txreq -hdr should reset + rxrst + expect rst.err == REFUSED_STREAM + } -run + + barrier b2 sync +} -run From dridi.boukelmoune at gmail.com Mon Sep 4 08:18:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 04 Sep 2017 10:18:06 +0200 Subject: [master] 05085d7 New req_dropped counter similar to sess_dropped Message-ID: commit 05085d757691cfef133839ee58c7ca592b504cae Author: Dridi Boukelmoune Date: Tue Aug 22 18:25:38 2017 +0200 New req_dropped counter similar to sess_dropped This one is for h2 streams, so the thread pools needed to learn about "stream" tasks. To properly test this counter, thread_pool_timeout is now disregarded when the vtc_mode debug flag is set. A minimum value of 10s is unrealistic for the test suite, it is now hard-coded to 0.5s when ran through varnishtest. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index d8e5dcb..3f517e4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -294,10 +294,14 @@ enum task_prio { TASK_QUEUE_BO, #define TASK_QUEUE_RESERVE TASK_QUEUE_BO TASK_QUEUE_REQ, + TASK_QUEUE_STR, TASK_QUEUE_VCA, TASK_QUEUE_END }; +#define TASK_QUEUE_CLIENT(prio) \ + (prio == TASK_QUEUE_REQ || prio == TASK_QUEUE_STR) + /*--------------------------------------------------------------------*/ struct worker { diff --git a/bin/varnishd/cache/cache_pool.h b/bin/varnishd/cache/cache_pool.h index 98e43ca..4814c50 100644 --- a/bin/varnishd/cache/cache_pool.h +++ b/bin/varnishd/cache/cache_pool.h @@ -50,7 +50,8 @@ struct pool { unsigned nthr; unsigned dry; unsigned lqueue; - uintmax_t ndropped; + uintmax_t sdropped; + uintmax_t rdropped; uintmax_t nqueued; struct dstat *a_stat; struct dstat *b_stat; diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 88fb942..41d2849 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -268,14 +268,17 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio) * queue limits only apply to client threads - all other * work is vital and needs do be done at the earliest */ - if (prio != TASK_QUEUE_REQ || + if (!TASK_QUEUE_CLIENT(prio) || pp->lqueue + pp->nthr < cache_param->wthread_max + cache_param->wthread_queue_limit) { pp->nqueued++; pp->lqueue++; VTAILQ_INSERT_TAIL(&pp->queues[prio], task, list); } else { - pp->ndropped++; + if (prio == TASK_QUEUE_REQ) + pp->sdropped++; + else + pp->rdropped++; retval = -1; } Lck_Unlock(&pp->mtx); @@ -495,8 +498,9 @@ pool_herder(void *priv) Lck_Lock(&pp->mtx); /* XXX: unsafe counters */ VSC_C_main->sess_queued += pp->nqueued; - VSC_C_main->sess_dropped += pp->ndropped; - pp->nqueued = pp->ndropped = 0; + VSC_C_main->sess_dropped += pp->sdropped; + VSC_C_main->req_dropped += pp->rdropped; + pp->nqueued = pp->sdropped = pp->rdropped = 0; wrk = NULL; pt = VTAILQ_LAST(&pp->idle_queue, taskhead); @@ -541,6 +545,8 @@ pool_herder(void *priv) } Lck_Lock(&pp->mtx); if (!pp->dry) { + if (DO_DEBUG(DBG_VTC_MODE)) + delay = 0.5; (void)Lck_CondWait(&pp->herder_cond, &pp->mtx, VTIM_real() + delay); } else { diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 122e61f..c5d9530 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -530,7 +530,7 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, req->task.func = h2_do_req; req->task.priv = req; r2->scheduled = 1; - if (Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ) != 0) + if (Pool_Task(wrk->pool, &req->task, TASK_QUEUE_STR) != 0) return (H2SE_REFUSED_STREAM); //rfc7540,l,3326,3329 return (0); } diff --git a/bin/varnishd/main.vsc b/bin/varnishd/main.vsc index 726ee9e..b513ac4 100644 --- a/bin/varnishd/main.vsc +++ b/bin/varnishd/main.vsc @@ -240,8 +240,14 @@ .. varnish_vsc:: sess_dropped :oneliner: Sessions dropped for thread - Number of times session was dropped because the queue were too long - already. See also parameter thread_queue_limit. + Number of times an HTTP/1 session was dropped because the queue was + too long already. See also parameter thread_queue_limit. + +.. varnish_vsc:: req_dropped + :oneliner: Requests dropped + + Number of times an HTTP/2 stream was refused because the queue was + too long already. See also parameter thread_queue_limit. .. varnish_vsc:: n_object :type: gauge diff --git a/bin/varnishtest/tests/t02011.vtc b/bin/varnishtest/tests/t02011.vtc index c906e92..fd698ce 100644 --- a/bin/varnishtest/tests/t02011.vtc +++ b/bin/varnishtest/tests/t02011.vtc @@ -26,6 +26,7 @@ varnish v1 -cliok "param.set thread_pool_min 4" varnish v1 -cliok "param.set thread_pool_max 4" varnish v1 -cliok "param.set thread_pool_reserve 1" varnish v1 -cliok "param.set thread_queue_limit 0" +varnish v1 -cliok "param.set thread_stats_rate 1" varnish v1 -cliok "param.set feature +http2" varnish v1 -cliok "param.set debug +syncvsl" @@ -66,3 +67,10 @@ client c1 { barrier b2 sync } -run + +# trigger an update of the stats +varnish v1 -cliok "param.set thread_pool_min 3" +delay 1 +varnish v1 -expect sess_drop == 0 +varnish v1 -expect sess_dropped == 0 +varnish v1 -expect req_dropped == 1 From phk at FreeBSD.org Mon Sep 4 08:21:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 04 Sep 2017 10:21:06 +0200 Subject: [master] 515f93e Give VSL/VSC back their individual VSMs to avoid locking VSM_Status() Message-ID: commit 515f93e03e9ee4bc08055424805efc4026bea0cb Author: Poul-Henning Kamp Date: Mon Sep 4 08:20:00 2017 +0000 Give VSL/VSC back their individual VSMs to avoid locking VSM_Status() diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 3b5014c..7a10731 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -76,7 +76,8 @@ struct varnish { char *jail; char *proto; - struct vsm *vd; + struct vsm *vsm_vsl; + struct vsm *vsm_vsc; int has_a_arg; unsigned vsl_tag_count[256]; @@ -210,7 +211,7 @@ varnishlog_thread(void *priv) vsl = VSL_New(); AN(vsl); - vsm = v->vd; + vsm = v->vsm_vsl; c = NULL; opt = 0; @@ -330,8 +331,8 @@ varnish_delete(struct varnish *v) vtc_logclose(v->vl); free(v->name); free(v->workdir); - if (v->vd != NULL) - VSM_Destroy(&v->vd); + if (v->vsm_vsl != NULL) + VSM_Destroy(&v->vsm_vsl); /* * We do not delete the workdir, it may contain stuff people @@ -519,9 +520,13 @@ varnish_launch(struct varnish *v) vtc_fatal(v->vl, "CLI auth command failed: %u %s", u, r); free(r); - v->vd = VSM_New(); - (void)VSM_Arg(v->vd, 'n', v->workdir); - AZ(VSM_Attach(v->vd, -1)); + v->vsm_vsc = VSM_New(); + (void)VSM_Arg(v->vsm_vsc, 'n', v->workdir); + AZ(VSM_Attach(v->vsm_vsc, -1)); + + v->vsm_vsl = VSM_New(); + (void)VSM_Arg(v->vsm_vsl, 'n', v->workdir); + AZ(VSM_Attach(v->vsm_vsl, -1)); AZ(pthread_create(&v->tp_vsl, NULL, varnishlog_thread, v)); } @@ -839,9 +844,9 @@ varnish_vsc(const struct varnish *v, const char *arg) memset(&dp, 0, sizeof dp); dp.v = v; dp.arg = arg; - (void)VSM_Status(v->vd); + (void)VSM_Status(v->vsm_vsc); - (void)VSC_Iter(v->vd, NULL, do_stat_dump_cb, &dp); + (void)VSC_Iter(v->vsm_vsc, NULL, do_stat_dump_cb, &dp); } /********************************************************************** @@ -905,9 +910,9 @@ varnish_expect(const struct varnish *v, char * const *av) ref = 0; good = 0; for (i = 0; i < 50; i++, (void)usleep(100000)) { - (void)VSM_Status(v->vd); + (void)VSM_Status(v->vsm_vsc); - good = VSC_Iter(v->vd, NULL, do_expect_cb, &sp); + good = VSC_Iter(v->vsm_vsc, NULL, do_expect_cb, &sp); if (!good) { good = -2; continue; @@ -932,7 +937,7 @@ varnish_expect(const struct varnish *v, char * const *av) break; } if (good == -1) { - vtc_fatal(v->vl, "VSM error: %s", VSM_Error(v->vd)); + vtc_fatal(v->vl, "VSM error: %s", VSM_Error(v->vsm_vsc)); } if (good == -2) { if (not) { From phk at FreeBSD.org Mon Sep 4 08:23:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 04 Sep 2017 10:23:06 +0200 Subject: [master] dc04be2 Minor flexelintery Message-ID: commit dc04be25b20794e5a4086efaa97f91bcfa37fbbf Author: Poul-Henning Kamp Date: Mon Sep 4 08:22:33 2017 +0000 Minor flexelintery diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 3e81817..766201e 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -169,7 +169,6 @@ void mgt_SHM_Create(void); void mgt_SHM_Destroy(int keep); extern struct vsmw *mgt_vsmw; -extern struct vsmw *child_vsmw; void mgt_SHM_ChildNew(void); void mgt_SHM_ChildDestroy(void); diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index ea1c2d5..fdd1d53 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -46,7 +46,6 @@ #include "vsmw.h" struct vsmw *mgt_vsmw; -struct vsmw *child_vsmw; /*-------------------------------------------------------------------- */ diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index 767e4cc..7a7b866 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -49,7 +49,7 @@ #include "storage/storage_persistent.h" -static void smp_msync(void *addr, size_t length); +static void smp_msync(const void *addr, size_t length); /*-------------------------------------------------------------------- * SIGNATURE functions @@ -253,7 +253,7 @@ smp_new_signspace(const struct smp_sc *sc, struct smp_signspace *spc, */ static void -smp_msync(void *addr, size_t length) +smp_msync(const void *addr, size_t length) { uintptr_t start, end, pagesize; From fgsch at lodoss.net Mon Sep 4 10:21:07 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 04 Sep 2017 12:21:07 +0200 Subject: [master] 7e35c20 Add vcl configname and source index in vcl_trace Message-ID: commit 7e35c209ddae77cf6205135f00aa919f6c81b159 Author: Shohei Tanaka(@xcir) Date: Thu Aug 31 13:54:37 2017 +0900 Add vcl configname and source index in vcl_trace Fixes #2403. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 1ff9428..09bdca5 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -519,11 +519,11 @@ VRT_count(VRT_CTX, unsigned u) CHECK_OBJ_NOTNULL(ctx->vcl->conf, VCL_CONF_MAGIC); assert(u < ctx->vcl->conf->nref); if (ctx->vsl != NULL) - VSLb(ctx->vsl, SLT_VCL_trace, "%u %u.%u", u, - ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos); + VSLb(ctx->vsl, SLT_VCL_trace, "%s %u %u.%u.%u", + ctx->vcl->loaded_name, u, ctx->vcl->conf->ref[u].source, ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos); else - VSL(SLT_VCL_trace, 0, "%u %u.%u", u, - ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos); + VSL(SLT_VCL_trace, 0, "%s %u %u.%u.%u", + ctx->vcl->loaded_name, u, ctx->vcl->conf->ref[u].source, ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos); } VCL_VCL diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index a40205c..6463636 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -251,11 +251,13 @@ SLTM(VCL_call, 0, "VCL method called", SLTM(VCL_trace, 0, "VCL trace data", "Logs VCL execution trace data.\n\n" "The format is::\n\n" - "\t%u %u.%u\n" - "\t| | |\n" - "\t| | +- VCL program line position\n" - "\t| +---- VCL program line number\n" - "\t+------- VCL trace point index\n" + "\t%s %u %u.%u.%u\n" + "\t| | | | |\n" + "\t| | | | +- VCL program line position\n" + "\t| | | +---- VCL program line number\n" + "\t| | +------- VCL program source index\n" + "\t| +---------- VCL trace point index\n" + "\t+------------- VCL configname\n" "\n" NODEF_NOTICE ) From fgsch at lodoss.net Mon Sep 4 10:21:07 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 04 Sep 2017 12:21:07 +0200 Subject: [master] c82651f add vcl_trace test Message-ID: commit c82651f41e728d98147d3525d04e80d5834b2c35 Author: Shohei Tanaka(@xcir) Date: Mon Sep 4 18:43:56 2017 +0900 add vcl_trace test diff --git a/bin/varnishtest/tests/r02413.vtc b/bin/varnishtest/tests/r02413.vtc new file mode 100644 index 0000000..15ed32f --- /dev/null +++ b/bin/varnishtest/tests/r02413.vtc @@ -0,0 +1,43 @@ +varnishtest "Test vcl_trace" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p vsl_mask=+VCL_trace" -vcl+backend { + sub vcl_deliver { + set resp.http.vcl = "vclA"; + } +} -start + +varnish v1 -cliok "vcl.label vclA vcl1" + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.http.vcl == "vcl1") { + return (vcl(vclA)); + } + } + sub vcl_deliver { + set resp.http.vcl = "vcl2"; + } +} + +varnish v1 -cliok "vcl.label vclB vcl2" +varnish v1 -cliok "vcl.list" + +logexpect l1 -v v1 -g raw { + expect * 1001 VCL_call "RECV" + expect 0 1001 VCL_trace {^vcl2 \d+ \d+\.\d+\.\d+$} + expect * 1001 VCL_call "RECV" + expect 0 1001 VCL_trace {^vcl1 \d+ \d+\.\d+\.\d+$} +} -start + +client c1 { + txreq -hdr "vcl: vcl1" + rxresp + expect resp.http.vcl == vclA +} -run + +logexpect l1 -wait From dridi.boukelmoune at gmail.com Mon Sep 4 11:50:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 04 Sep 2017 13:50:07 +0200 Subject: [master] 9a267ea Introduce vmod-purge Message-ID: commit 9a267ea8303f79ebca2aa0047f9c11ad3703f2b2 Author: Dridi Boukelmoune Date: Tue Aug 29 10:49:28 2017 +0200 Introduce vmod-purge This module offers a finer-grained control over purges, in the old pre-vcl 4.0 style. For that, the signatures of VRT_purge and HSH_Purge were updated to inform about the number of rearmed objects. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 3549867..2a2435c 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -586,7 +586,7 @@ hsh_rush2(struct worker *wrk, struct rush *r) * Purge an entire objhead */ -void +unsigned HSH_Purge(struct worker *wrk, struct objhead *oh, double ttl, double grace, double keep) { @@ -667,6 +667,7 @@ double keep) } while (more); WS_Release(wrk->aws, 0); Pool_PurgeStat(n_tot); + return (n_tot); } /*--------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index e1e521b..ecd2374 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -538,7 +538,7 @@ VRT_CacheReqBody(VRT_CTX, VCL_BYTES maxsize) * purges */ -void +unsigned VRT_purge(VRT_CTX, double ttl, double grace, double keep) { @@ -548,12 +548,13 @@ VRT_purge(VRT_CTX, double ttl, double grace, double keep) VSLb(ctx->vsl, SLT_VCL_Error, "purge can only happen in vcl_hit{} or vcl_miss{}"); VRT_handling(ctx, VCL_RET_FAIL); - return; + return (0); } CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->wrk, WORKER_MAGIC); - HSH_Purge(ctx->req->wrk, ctx->req->objcore->objhead, ttl, grace, keep); + return (HSH_Purge(ctx->req->wrk, ctx->req->objcore->objhead, + ttl, grace, keep)); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 92f9a72..3d86c20 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -69,7 +69,7 @@ void HSH_Init(const struct hash_slinger *slinger); void HSH_AddString(struct req *, void *ctx, const char *str); void HSH_Insert(struct worker *, const void *hash, struct objcore *, struct ban *); -void HSH_Purge(struct worker *, struct objhead *, double ttl, double grace, +unsigned HSH_Purge(struct worker *, struct objhead *, double ttl, double grace, double keep); void HSH_config(const char *h_arg); struct boc *HSH_RefBoc(const struct objcore *); diff --git a/bin/varnishtest/tests/m00031.vtc b/bin/varnishtest/tests/m00031.vtc new file mode 100644 index 0000000..2d40cb7 --- /dev/null +++ b/bin/varnishtest/tests/m00031.vtc @@ -0,0 +1,116 @@ +varnishtest "Test purge vmod" + +server s1 { + rxreq + expect req.http.Accept-Language == fr + txresp -hdr "Vary: Accept-Language" -body fr + + rxreq + expect req.http.Accept-Language == fr + txresp -hdr "Vary: Accept-Language" -body fr + + rxreq + expect req.http.Accept-Language == en + txresp -hdr "Vary: Accept-Language" -body en +} -start + +varnish v1 -vcl+backend { + import purge; + + sub vcl_recv { + if (req.method ~ "PURGE") { + return (hash); + } + } + + sub my_purge { + if (req.method == "PURGE") { + set req.http.purged = purge.hard(); + } + else { + set req.http.purged = purge.soft(); + } + if (req.http.purged == "0") { + return (synth(404)); + } + else { + return (synth(200)); + } + } + + sub vcl_hit { + if (req.method ~ "PURGE") { call my_purge; } + } + + sub vcl_miss { + if (req.method ~ "PURGE") { call my_purge; } + } + + sub vcl_synth { + if (req.method ~ "PURGE") { + set resp.http.purged = req.http.purged; + return (deliver); + } + } + + sub vcl_backend_response { + set beresp.http.X-Varnish-Be = bereq.xid; + } +} -start + +logexpect l1 -v v1 -q Hit -i Hit { + expect * * Hit "^1002 -.+ 10.000000 0.000000$" +} -start + +logexpect l2 -v v1 -q "Begin ~ bgfetch" { + expect * * BerespHeader "X-Varnish-Be: 1005" +} -start + +logexpect l3 -v v1 -g raw -q "vxid == 0" { + expect * * ExpKill x=1008 +} -start + +client c1 { + txreq -hdr "Accept-Language: fr" + rxresp + expect resp.body == fr + expect resp.http.X-Varnish-Be == 1002 + + txreq -req SOFTPURGE + rxresp + expect resp.status == 200 + expect resp.http.purged == 1 + + txreq -hdr "Accept-Language: fr" + rxresp + expect resp.body == fr + expect resp.http.X-Varnish == "1004 1002" + expect resp.http.X-Varnish-Be == 1002 +} -run + +# Wait until bgfetch triggered by 1004 is done +logexpect l2 -wait + +client c1 { + txreq -hdr "Accept-Language: en" + rxresp + expect resp.body == en + expect resp.http.X-Varnish-Be == 1008 + + txreq -req PURGE + rxresp + expect resp.status == 200 + expect resp.http.purged == 2 +} -run + +# Wait until the expire thread kicks in +logexpect l3 -wait + +client c1 { + txreq -req PURGE + rxresp + expect resp.status == 404 + expect resp.http.purged == 0 +} -run + +logexpect l1 -wait diff --git a/bin/varnishtest/vmods.h b/bin/varnishtest/vmods.h index 6f51d9e..a994bef 100644 --- a/bin/varnishtest/vmods.h +++ b/bin/varnishtest/vmods.h @@ -30,4 +30,5 @@ VTC_VMOD(std) VTC_VMOD(debug) VTC_VMOD(directors) +VTC_VMOD(purge) VTC_VMOD(vtc) diff --git a/configure.ac b/configure.ac index 4c58ea1..2743139 100644 --- a/configure.ac +++ b/configure.ac @@ -732,6 +732,7 @@ AC_CONFIG_FILES([ lib/libvmod_debug/Makefile lib/libvmod_std/Makefile lib/libvmod_directors/Makefile + lib/libvmod_purge/Makefile lib/libvmod_vtc/Makefile man/Makefile varnishapi.pc diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 3978423..0de2f28 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -205,6 +205,10 @@ reference/vmod_directors.generated.rst: reference $(top_builddir)/lib/libvmod_di cp $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ || true BUILT_SOURCES += reference/vmod_directors.generated.rst +reference/vmod_purge.generated.rst: reference $(top_builddir)/lib/libvmod_purge/vmod_purge.rst + cp $(top_builddir)/lib/libvmod_purge/vmod_purge.rst $@ || true +BUILT_SOURCES += reference/vmod_purge.generated.rst + reference/vmod_vtc.generated.rst: reference $(top_builddir)/lib/libvmod_vtc/vmod_vtc.rst cp $(top_builddir)/lib/libvmod_vtc/vmod_vtc.rst $@ || true BUILT_SOURCES += reference/vmod_vtc.generated.rst diff --git a/include/vrt.h b/include/vrt.h index 3308634..9f1ad5e 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -41,7 +41,7 @@ * * 6.1 (unreleased): * http_CollectHdrSep added - * VRT_purge modified (may fail a transaction) + * VRT_purge modified (may fail a transaction, signature changed) * 6.0 (2017-03-15): * VRT_hit_for_pass added * VRT_ipcmp added @@ -300,7 +300,7 @@ int VRT_re_match(VRT_CTX, const char *, void *re); const char *VRT_regsub(VRT_CTX, int all, const char *, void *, const char *); void VRT_ban_string(VRT_CTX, const char *); -void VRT_purge(VRT_CTX, double ttl, double grace, double keep); +unsigned VRT_purge(VRT_CTX, double ttl, double grace, double keep); void VRT_count(VRT_CTX, unsigned); void VRT_synth(VRT_CTX, unsigned, const char *); diff --git a/lib/Makefile.am b/lib/Makefile.am index dbb4ad9..8981c65 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -8,4 +8,5 @@ SUBDIRS = \ libvmod_debug \ libvmod_std \ libvmod_directors \ + libvmod_purge \ libvmod_vtc diff --git a/lib/libvmod_purge/Makefile.am b/lib/libvmod_purge/Makefile.am new file mode 100644 index 0000000..4a1098b --- /dev/null +++ b/lib/libvmod_purge/Makefile.am @@ -0,0 +1,40 @@ +# + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmod_srcdir = $(top_srcdir)/lib/libvmod_purge +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict +vmod_LTLIBRARIES = libvmod_purge.la + +libvmod_purge_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_purge_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ + @SAN_LDFLAGS@ + +libvmod_purge_la_SOURCES = vmod_purge.c + +nodist_libvmod_purge_la_SOURCES = \ + vcc_if.c \ + vcc_if.h + +# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build +$(libvmod_purge_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_purge.rst vmod_purge.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_purge.rst \ + $(builddir)/vmod_purge.man.rst diff --git a/lib/libvmod_purge/flint.lnt b/lib/libvmod_purge/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvmod_purge/flint.sh b/lib/libvmod_purge/flint.sh new file mode 100755 index 0000000..522e30d --- /dev/null +++ b/lib/libvmod_purge/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + -I../../bin/varnishd + *.c +' + +. ../../tools/flint_skel.sh diff --git a/lib/libvmod_purge/vmod.vcc b/lib/libvmod_purge/vmod.vcc new file mode 100644 index 0000000..a935732 --- /dev/null +++ b/lib/libvmod_purge/vmod.vcc @@ -0,0 +1,104 @@ +#- +# Copyright (c) 2017 Varnish Software AS +# All rights reserved. +# +# Author: Dridi Boukelmoune +# +# 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. + +$Module purge 3 Varnish Purge Module +$ABI strict + +DESCRIPTION +=========== + +`vmod_purge` contains functions that offer a finer-grained control than the +``purge`` transition in ``vcl_recv``. The functions can only be called from +``vcl_hit`` or ``vcl_miss`` and they should in general be used in both to +ensure that all variants of a same object are taken care of. + +EXAMPLE +======= + +:: + + sub vcl_recv { + if (req.method == "PURGE") { + if (client.ip !~ purge_acl) { + return (synth(405)); + } + return (hash); + } + } + + sub my_purge { + set req.http.purged = purge.hard(); + if (req.http.purged == "0") { + return (synth(404)); + } + else { + return (synth(200)); + } + } + + sub vcl_hit { + if (req.method == "PURGE") { + call my_purge; + } + } + + sub vcl_miss { + if (req.method == "PURGE") { + call my_purge; + } + } + + sub vcl_synth { + if (req.method == "PURGE") { + if (req.http.purged) { + set resp.http.purged = req.http.purged; + } + return (deliver); + } + } + +$Function INT hard() + +Description + This is equivalent to ``return(purge)`` but explicitly called from + ``vcl_hit`` and ``vcl_miss``. It returns the number of purged objects. +Example + set req.http.purged = purge.hard(); + +$Function INT soft(DURATION ttl = 0, DURATION grace = -1, DURATION keep = -1) + +Description + Sets the TTL, grace and keep. By default, TTL is set to 0 with grace + and keep periods left untouched. Setting a negative value for any of + the parameters leaves them untouched. Setting all three parameters to + 0 is equivalent to a hard purge. It can only be called from ``vcl_hit`` + or ``vcl_miss``. It returns the number of soft-purged objects. + +SEE ALSO +======== + +* :ref:`vcl(7)` diff --git a/lib/libvmod_purge/vmod_purge.c b/lib/libvmod_purge/vmod_purge.c new file mode 100644 index 0000000..7fba6b2 --- /dev/null +++ b/lib/libvmod_purge/vmod_purge.c @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 2017 Varnish Software AS + * All rights reserved. + * + * Author: Dridi Boukelmoune + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" + +#include "math.h" + +#include "cache/cache.h" + +#include "vrt.h" + +#include "vcc_if.h" + +VCL_INT __match_proto__(td_purge_hard) +vmod_hard(VRT_CTX) +{ + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + return (VRT_purge(ctx, 0, 0, 0)); +} + +VCL_INT __match_proto__(td_purge_soft) +vmod_soft(VRT_CTX, VCL_DURATION ttl, VCL_DURATION grace, VCL_DURATION keep) +{ + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (ttl < 0) + ttl = NAN; + if (grace < 0) + grace = NAN; + if (keep < 0) + keep = NAN; + return (VRT_purge(ctx, ttl, grace, keep)); +} diff --git a/man/Makefile.am b/man/Makefile.am index fd7ee1a..73f6049 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -16,6 +16,7 @@ dist_man_MANS = \ vtc.7 \ varnishtop.1 \ vmod_directors.3 \ + vmod_purge.3 \ vmod_std.3 \ vmod_vtc.3 @@ -87,6 +88,9 @@ varnishhist.1: \ vmod_directors.3: $(top_builddir)/lib/libvmod_directors/vmod_directors.man.rst ${RST2MAN} $(RST2ANY_FLAGS) $? $@ +vmod_purge.3: $(top_builddir)/lib/libvmod_purge/vmod_purge.man.rst + ${RST2MAN} $(RST2ANY_FLAGS) $? $@ + vmod_std.3: $(top_builddir)/lib/libvmod_std/vmod_std.man.rst ${RST2MAN} $(RST2ANY_FLAGS) $? $@ From dridi.boukelmoune at gmail.com Mon Sep 4 11:50:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 04 Sep 2017 13:50:07 +0200 Subject: [master] b18dd05 Retire debug.purge Message-ID: commit b18dd05deb873f4f63231fffed92aa41a512abc6 Author: Dridi Boukelmoune Date: Wed Aug 30 18:20:10 2017 +0200 Retire debug.purge We can directly use vmod-purge now. diff --git a/bin/varnishtest/tests/r02339.vtc b/bin/varnishtest/tests/r02339.vtc index b1d4477..ef0444e 100644 --- a/bin/varnishtest/tests/r02339.vtc +++ b/bin/varnishtest/tests/r02339.vtc @@ -6,47 +6,47 @@ server s1 -repeat 12 { } -start varnish v1 -arg "-p thread_pools=1" -vcl+backend { - import debug; + import purge; import vtc; sub vcl_recv { - if (req.url == "recv") { debug.purge(); } + if (req.url == "recv") { purge.hard(); } if (req.url == "pass") { return (pass); } if (req.url == "purge") { return (purge); } if (req.url == "synth") { return (synth(200)); } } sub vcl_hash { - if (req.url == "hash") { debug.purge(); } + if (req.url == "hash") { purge.hard(); } } sub vcl_miss { - if (req.url == "miss") { debug.purge(); } + if (req.url == "miss") { purge.hard(); } } sub vcl_hit { - if (req.url == "hit") { debug.purge(); } + if (req.url == "hit") { purge.hard(); } } sub vcl_purge { - if (req.url == "purge") { debug.purge(); } + if (req.url == "purge") { purge.hard(); } } sub vcl_pass { - if (req.url == "pass") { debug.purge(); } + if (req.url == "pass") { purge.hard(); } } sub vcl_deliver { - if (req.url == "deliver") { debug.purge(); } + if (req.url == "deliver") { purge.hard(); } } sub vcl_synth { - if (req.url == "synth") { debug.purge(); } + if (req.url == "synth") { purge.hard(); } } sub vcl_backend_fetch { - if (bereq.url == "fetch") { debug.purge(); } + if (bereq.url == "fetch") { purge.hard(); } if (bereq.url == "error") { set bereq.backend = vtc.no_backend(); } } sub vcl_backend_error { - if (bereq.url == "error") { debug.purge(); } + if (bereq.url == "error") { purge.hard(); } } sub vcl_backend_response { - if (bereq.url == "response") { debug.purge(); } + if (bereq.url == "response") { purge.hard(); } } } -start @@ -58,49 +58,38 @@ logexpect l1 -v v1 { expect * 1002 Begin "bereq 1001 fetch" expect * 1003 VCL_call HIT - expect * = VCL_Log PURGE expect * = VCL_call DELIVER expect * 1004 VCL_call MISS - expect * = VCL_Log PURGE expect * = VCL_call DELIVER expect * 1007 VCL_call RECV - expect * = VCL_Log PURGE expect * = VCL_Error purge expect * = VCL_return fail expect * 1009 VCL_call HASH - expect * = VCL_Log PURGE expect * = VCL_Error purge expect * = VCL_return fail expect * 1011 VCL_call PURGE - expect * = VCL_Log PURGE expect * = VCL_Error purge expect * 1013 VCL_call PASS - expect * = VCL_Log PURGE expect * = VCL_Error purge expect * 1015 VCL_call DELIVER - expect * = VCL_Log PURGE expect * = VCL_Error purge expect * 1018 VCL_call SYNTH - expect * = VCL_Log PURGE expect * = VCL_Error purge expect * 1021 VCL_call BACKEND_FETCH - expect * = VCL_Log PURGE expect * = VCL_Error purge expect * 1024 VCL_call BACKEND_ERROR - expect * = VCL_Log PURGE expect * = VCL_Error purge expect * 1027 VCL_call BACKEND_RESPONSE - expect * = VCL_Log PURGE expect * = VCL_Error purge } -start diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 1b7889d..5a3ce7e 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -220,7 +220,3 @@ Returns the size in bytes of a collection of C-datatypes. * 'z' = size_t * 'o' = off_t * 'j' = intmax_t - -$Function VOID purge(DURATION ttl = 0, DURATION grace = 0, DURATION keep = 0) - -Performs a purge, by default a hard purge where ttl, grace and keep are zero. diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index e588a95..f4fac46 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -594,13 +594,3 @@ vmod_typesize(VRT_CTX, VCL_STRING s) } return ((VCL_INT)i); } - -VCL_VOID __match_proto__(td_debug_purge) -vmod_purge(VRT_CTX, double ttl, double grace, double keep) -{ - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - - VSLb(ctx->vsl, SLT_VCL_Log, "PURGE"); - VRT_purge(ctx, ttl, grace, keep); -} From martin at varnish-software.com Mon Sep 4 12:02:06 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 04 Sep 2017 14:02:06 +0200 Subject: [master] cc5df0e Fix memory leak when discarding labels Message-ID: commit cc5df0ef06caa2fca78ba471a6126fcad03fd6a2 Author: Martin Blix Grydeland Date: Tue Aug 22 17:43:11 2017 +0200 Fix memory leak when discarding labels The struct vcl and the temperature rwlock were not free'd on discarding labels. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 09bdca5..9e02f17 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -912,6 +912,8 @@ vcl_cli_discard(struct cli *cli, const char * const *av, void *priv) if (!strcmp(vcl->state, VCL_TEMP_LABEL)) { VTAILQ_REMOVE(&vcl_head, vcl, list); free(vcl->loaded_name); + AZ(errno=pthread_rwlock_destroy(&vcl->temp_rwl)); + FREE_OBJ(vcl); } else if (vcl->temp == VCL_TEMP_COLD) VCL_Poll(); } From martin at varnish-software.com Mon Sep 4 12:03:12 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 04 Sep 2017 14:03:12 +0200 Subject: [master] 606d485 Straighten locking wrt vcl_active Message-ID: commit 606d48563464df01acb692a7a57188bf1eaa8d2c Author: Martin Blix Grydeland Date: Mon Aug 21 14:59:59 2017 +0200 Straighten locking wrt vcl_active The locking around the use of vcl_active does not include the checking of its magic value or the temperature asserts, leading to a race when changing vcl_active. Fixes: #2390 diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 9e02f17..4faa0c8 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -252,13 +252,13 @@ VCL_Method_Name(unsigned m) static void vcl_get(struct vcl **vcc, struct vcl *vcl) { + AN(vcc); - CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); - AZ(errno=pthread_rwlock_rdlock(&vcl->temp_rwl)); - assert(VCL_WARM(vcl)); - AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl)); Lck_Lock(&vcl_mtx); - AN(vcl); + if (vcl == NULL) + vcl = vcl_active; /* Sample vcl_active under lock to avoid + * race */ + CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); if (vcl->label == NULL) { AN(strcmp(vcl->state, VCL_TEMP_LABEL)); *vcc = vcl; @@ -266,16 +266,18 @@ vcl_get(struct vcl **vcc, struct vcl *vcl) AZ(strcmp(vcl->state, VCL_TEMP_LABEL)); *vcc = vcl->label; } - AN(*vcc); + CHECK_OBJ_NOTNULL(*vcc, VCL_MAGIC); AZ((*vcc)->discard); (*vcc)->busy++; Lck_Unlock(&vcl_mtx); + AZ(errno=pthread_rwlock_rdlock(&(*vcc)->temp_rwl)); + assert(VCL_WARM(*vcc)); + AZ(errno=pthread_rwlock_unlock(&(*vcc)->temp_rwl)); } void VCL_Refresh(struct vcl **vcc) { - CHECK_OBJ_NOTNULL(vcl_active, VCL_MAGIC); if (*vcc == vcl_active) return; if (*vcc != NULL) @@ -284,7 +286,7 @@ VCL_Refresh(struct vcl **vcc) while (vcl_active == NULL) (void)usleep(100000); - vcl_get(vcc, vcl_active); + vcl_get(vcc, NULL); } void From phk at FreeBSD.org Mon Sep 4 12:19:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 04 Sep 2017 14:19:06 +0200 Subject: [master] bed7a98 Prepare for 5.2-RC1 Message-ID: commit bed7a98a296bc7da9524067987858fbd1dc633f0 Author: Poul-Henning Kamp Date: Mon Sep 4 12:18:28 2017 +0000 Prepare for 5.2-RC1 diff --git a/doc/changes.rst b/doc/changes.rst index bed6ac5..ec24013 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -2,6 +2,10 @@ Varnish Cache Trunk (ongoing) ============================= +================================== +Varnish Cache 5.2-RC1 (2017-09-04) +================================== + Usage ----- @@ -28,9 +32,12 @@ VCL C APIs (for vmod and utility authors) ------------------------------------- -* ``VSM_Name()`` returns the -i argument name, rather than the -n name. +* The VSM API for accessing the shared memory segment has been + totally rewritten. Things should be simpler and more general. -* ``VUT.name`` is gone, use ``VSM_Name(VUT.vsm)`` +* VSC shared memory layout has changed and the VSC API updated + to match it. This paves the way for user defined VSC counters + in VMODS and later possibly also in VCL. * New vmod vtc for advanced varnishtest usage (#2276) From geoff at uplex.de Mon Sep 4 12:59:11 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 04 Sep 2017 14:59:11 +0200 Subject: [master] 2c41d0d Add a ref to VMOD purge from the reference index page. Message-ID: commit 2c41d0de87b236ec348c3705a4611ba2b23d6644 Author: Geoff Simmons Date: Mon Sep 4 14:50:02 2017 +0200 Add a ref to VMOD purge from the reference index page. diff --git a/doc/sphinx/reference/index.rst b/doc/sphinx/reference/index.rst index 936b3a7..e1164f8 100644 --- a/doc/sphinx/reference/index.rst +++ b/doc/sphinx/reference/index.rst @@ -23,6 +23,7 @@ The Varnish Reference Manual vmod_std.generated.rst vmod_directors.generated.rst vmod_vtc.generated.rst + vmod_purge.generated.rst directors.rst varnish-counters.rst vsl.rst From geoff at uplex.de Mon Sep 4 12:59:11 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 04 Sep 2017 14:59:11 +0200 Subject: [master] 60cc5f9 Add VMOD blob. Message-ID: commit 60cc5f9b33a50732d4e44a996498d60bdb0843dc Author: Geoff Simmons Date: Wed Aug 30 18:06:05 2017 +0200 Add VMOD blob. References #2402 diff --git a/bin/varnishtest/tests/m00032.vtc b/bin/varnishtest/tests/m00032.vtc new file mode 100644 index 0000000..711df62 --- /dev/null +++ b/bin/varnishtest/tests/m00032.vtc @@ -0,0 +1,26 @@ +varnishtest "VMOD blob vcl.use and .discard" + +server s1 { +} -start + +varnish v1 -vcl+backend { + import blob; +} -start + +varnish v1 -vcl+backend { +} + +varnish v1 -cli "vcl.list" +varnish v1 -cli "vcl.use vcl1" + +varnish v1 -cli "vcl.use vcl2" +varnish v1 -cli "vcl.use vcl1" + +varnish v1 -expect vmods == 1 + +varnish v1 -cli "vcl.show vcl1" +varnish v1 -cli "vcl.use vcl2" +varnish v1 -cli "vcl.discard vcl1" +varnish v1 -cli "vcl.list" + +varnish v1 -expect vmods == 0 diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc new file mode 100644 index 0000000..11f36e6 --- /dev/null +++ b/bin/varnishtest/tests/m00033.vtc @@ -0,0 +1,70 @@ +varnishtest "VMOD blob IDENTITY encode and decode" + +varnish v1 -vcl { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.id = + blob.encode(IDENTITY, blob.decode(IDENTITY, + "The quick brown fox jumps over the lazy dog")); + + set resp.http.hobbes = + blob.encode(IDENTITY, blob.decode(IDENTITY, +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); + + set resp.http.list = + blob.encode(IDENTITY, blob.decode(IDENTITY, + "" + req.http.unset + req.url + + "The quick brown fox jumps over " + + req.http.unset + "" + req.http.unset + "" + + "the lazy dog" + req.url + req.http.unset + "")); + + set resp.http.empty = + blob.encode(IDENTITY, blob.decode(IDENTITY, "")); + + set resp.http.undef = + blob.encode(IDENTITY, blob.decode(IDENTITY, + req.http.unset)); + + set resp.http.emptylist = + blob.encode(IDENTITY, blob.decode(IDENTITY, + req.http.unset + "" + req.http.unset + "")); + + set resp.http.param = + blob.encode(blob= + blob.decode(encoded= + "The quick brown fox jumps over the lazy dog", + decoding=IDENTITY), + encoding=IDENTITY); + + set resp.http.paramlist = + blob.encode(IDENTITY, blob.decode(encoded= + "" + req.http.unset + req.url + + "The quick brown fox jumps over " + + req.http.unset + "" + req.http.unset + "" + + "the lazy dog" + req.url + req.http.unset + "", + decoding=IDENTITY)); + + set resp.http.truncated = + blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.id == "The quick brown fox jumps over the lazy dog" + expect resp.http.hobbes == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.list == "/The quick brown fox jumps over the lazy dog/" + expect resp.http.empty == "" + expect resp.http.undef == "" + expect resp.http.emptylist == "" + expect resp.http.param == "The quick brown fox jumps over the lazy dog" + expect resp.http.paramlist == "/The quick brown fox jumps over the lazy dog/" + expect resp.http.truncated == "foo" +} -run diff --git a/bin/varnishtest/tests/m00034.vtc b/bin/varnishtest/tests/m00034.vtc new file mode 100644 index 0000000..24da94c --- /dev/null +++ b/bin/varnishtest/tests/m00034.vtc @@ -0,0 +1,66 @@ +varnishtest "VMOD blob IDENTITY decode_n()" + +varnish v1 -vcl { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.id = + blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + "The quick brown fox jumps over the lazy dog")); + + set resp.http.hobbes = + blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); + + set resp.http.list = + blob.encode(IDENTITY, blob.decode_n(6, IDENTITY, + "" + req.http.unset + req.url + + "The quick brown fox jumps over " + + req.http.unset + "" + req.http.unset + "" + + "the lazy dog" + req.url + req.http.unset + "")); + + set resp.http.empty = + blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, "")); + + set resp.http.undef = + blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + req.http.unset)); + + set resp.http.emptylist = + blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + req.http.unset + "" + req.http.unset + "")); + + set resp.http.param = + blob.encode(blob= + blob.decode_n(encoded= + "The quick brown fox jumps over the lazy dog", + n=7, decoding=IDENTITY), + encoding=IDENTITY); + + set resp.http.paramlist = + blob.encode(IDENTITY, blob.decode_n(encoded= + "" + req.http.unset + req.url + + "The quick brown fox jumps over " + + req.http.unset + "" + req.http.unset + "" + + "the lazy dog" + req.url + req.http.unset + "", + decoding=IDENTITY, n=37)); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.id == "The q" + expect resp.http.hobbes == "Man i" + expect resp.http.list == "/The q" + expect resp.http.empty == "" + expect resp.http.undef == "" + expect resp.http.emptylist == "" + expect resp.http.param == "The qui" + expect resp.http.paramlist == "/The quick brown fox jumps over the l" +} -run diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc new file mode 100644 index 0000000..c9210c7 --- /dev/null +++ b/bin/varnishtest/tests/m00035.vtc @@ -0,0 +1,196 @@ +varnishtest "VMOD blob hex encode and decode" + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.pangram = "The quick brown fox jumps over the lazy dog"; + set req.http.hobbes = +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; + # base64 encoding of all 256 byte values in ascending order + set req.http.b64all = +{"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; + + set resp.http.hexlc = + blob.encode(HEXLC, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.hexuc = + blob.encode(HEXUC, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.hobbeslc = + blob.encode(HEXLC, blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.hobbesuc = + blob.encode(HEXUC, blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.all-lc = + blob.encode(HEXLC, blob.decode(BASE64, req.http.b64all)); + + set resp.http.all-uc = + blob.encode(HEXUC, blob.decode(BASE64, req.http.b64all)); + + set resp.http.empty-lc = + blob.encode(HEXLC, blob.decode(IDENTITY, "")); + + set resp.http.empty-uc = + blob.encode(HEXUC, blob.decode(IDENTITY, "")); + + set resp.http.hexlcparam = + blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + encoding=HEXLC); + + set resp.http.hexucparam = + blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + encoding=HEXUC); + + set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; + set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); + # Hobbes quotation in hex + set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbesuc = std.toupper(req.http.hexhobbeslc); + set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; + set req.http.hexalllc = std.tolower(req.http.hexalluc); + set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); + set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); + + set resp.http.decuc = + blob.encode(IDENTITY, + blob.decode(HEX, req.http.hexucfoobar)); + + set resp.http.declc = + blob.encode(IDENTITY, + blob.decode(HEX, req.http.hexlcfoobar)); + + set resp.http.dechobbesuc = + blob.encode(IDENTITY, + blob.decode(HEX, req.http.hexhobbesuc)); + + set resp.http.dechobbeslc = + blob.encode(IDENTITY, + blob.decode(HEX, req.http.hexhobbeslc)); + + set resp.http.decalluc = + blob.encode(BASE64, blob.decode(HEX, req.http.hexalluc)); + + set resp.http.decalllc = + blob.encode(BASE64, blob.decode(HEX, req.http.hexalllc)); + + set resp.http.decallucodd = + blob.encode(BASE64, blob.decode(HEX, + req.http.hexallucodd)); + + set resp.http.decalllcodd = + blob.encode(BASE64, blob.decode(HEX, + req.http.hexalllcodd)); + + set resp.http.decempty = + blob.encode(IDENTITY, blob.decode(HEX, "")); + + set resp.http.decemptybyte = + blob.encode(IDENTITY, blob.decode(HEX, "00")); + + set resp.http.decemptynibble = + blob.encode(IDENTITY, blob.decode(HEX, "0")); + + set resp.http.decemptypieces = + blob.encode(IDENTITY, + blob.decode(HEX, req.http.unset + "" + + req.http.unset + "")); + + set req.http.part1 = "666"; + set resp.http.dec2pieces = + blob.encode(IDENTITY, blob.decode(HEX, req.http.part1 + + "F6F206261722062617A2071757578")); + + set req.http.part2 = "57578"; + set resp.http.dec3param = + blob.encode(blob=blob.decode(encoded=req.http.part1 + + "F6F206261722062617A20717" + req.http.part2, + decoding=HEX), + encoding=IDENTITY); + + set resp.http.dec3pieces = + blob.encode(IDENTITY, blob.decode(HEX, req.http.part1 + + "F6F206261722062617A20717" + req.http.part2)); + + set resp.http.decmanypieces = + blob.encode(IDENTITY, blob.decode(HEX, "" + req.http.unset + + req.http.part1 + req.http.unset + "" + + req.http.unset + "" + "F6F206261722062617A20717" + + "" + req.http.unset + req.http.part2 + + req.http.unset + "" + req.http.unset)); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.hexlc == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" + expect resp.http.hexuc == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67" + expect resp.http.hobbeslc == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" + expect resp.http.hobbesuc == "4D616E2069732064697374696E677569736865642C206E6F74206F6E6C792062792068697320726561736F6E2C2062757420627920746869732073696E67756C61722070617373696F6E2066726F6D206F7468657220616E696D616C732C2077686963682069732061206C757374206F6620746865206D696E642C20746861742062792061207065727365766572616E6365206F662064656C6967687420696E2074686520636F6E74696E75656420616E6420696E6465666174696761626C652067656E65726174696F6E206F66206B6E6F776C656467652C2065786365656473207468652073686F727420766568656D656E6365206F6620616E79206361726E616C20706C6561737572652E" + expect resp.http.all-uc == "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF" + expect resp.http.all-lc == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + expect resp.http.empty-uc == "" + expect resp.http.empty-lc == "" + expect resp.http.hexlcparam == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" + expect resp.http.hexucparam == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67" + expect resp.http.decuc == "foo bar baz quux" + expect resp.http.declc == "foo bar baz quux" + expect resp.http.dechobbesuc == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.dechobbeslc == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.decalluc == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.decalllc == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.decallucodd == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.decalllcodd == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.decempty == "" + expect resp.http.decemptybyte == "" + expect resp.http.decemptynibble == "" + expect resp.http.decemptypieces == "" + expect resp.http.dec2pieces == "foo bar baz quux" + expect resp.http.dec3pieces == "foo bar baz quux" + expect resp.http.dec3param == "foo bar baz quux" + expect resp.http.decmanypieces == "foo bar baz quux" +} -run + +# Decode failure + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + set req.http.foo = "123"; + set resp.http.badhex = blob.encode(HEXUC, + blob.decode(HEX, "g" + req.http.foo)); + } +} + +client c1 { + txreq + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.badhex == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect 0 * Begin req + expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" +#" + expect * = End +} -start + +logexpect l1 -wait diff --git a/bin/varnishtest/tests/m00036.vtc b/bin/varnishtest/tests/m00036.vtc new file mode 100644 index 0000000..88f869a --- /dev/null +++ b/bin/varnishtest/tests/m00036.vtc @@ -0,0 +1,196 @@ +varnishtest "VMOD blob hex decode_n()" + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.pangram = "The quick brown fox jumps over the lazy dog"; + set req.http.hobbes = +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; + # base64 encoding of all 256 byte values in ascending order + set req.http.b64all = +{"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; + + set resp.http.hexlc = + blob.encode(HEXLC, + blob.decode_n(5, IDENTITY, req.http.pangram)); + + set resp.http.hexuc = + blob.encode(HEXUC, + blob.decode_n(5, IDENTITY, req.http.pangram)); + + set resp.http.hobbeslc = + blob.encode(HEXLC, blob.decode_n(5, IDENTITY, req.http.hobbes)); + + set resp.http.hobbesuc = + blob.encode(HEXUC, blob.decode_n(5, IDENTITY, req.http.hobbes)); + + set resp.http.all-lc = + blob.encode(HEXLC, blob.decode_n(8, BASE64, req.http.b64all)); + + set resp.http.all-uc = + blob.encode(HEXUC, blob.decode_n(8, BASE64, req.http.b64all)); + + set resp.http.empty-lc = + blob.encode(HEXLC, blob.decode_n(5, IDENTITY, "")); + + set resp.http.empty-uc = + blob.encode(HEXUC, blob.decode_n(5, IDENTITY, "")); + + set resp.http.hexlcparam = + blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), + encoding=HEXLC); + + set resp.http.hexucparam = + blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), + encoding=HEXUC); + + set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; + set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); + # Hobbes quotation in hex + set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbesuc = std.toupper(req.http.hexhobbeslc); + set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; + set req.http.hexalllc = std.tolower(req.http.hexalluc); + set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); + set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); + + set resp.http.decuc = + blob.encode(IDENTITY, + blob.decode_n(10, HEX, req.http.hexucfoobar)); + + set resp.http.declc = + blob.encode(IDENTITY, + blob.decode_n(10, HEX, req.http.hexlcfoobar)); + + set resp.http.dechobbesuc = + blob.encode(IDENTITY, + blob.decode_n(12, HEX, req.http.hexhobbesuc)); + + set resp.http.dechobbeslc = + blob.encode(IDENTITY, + blob.decode_n(12, HEX, req.http.hexhobbeslc)); + + set resp.http.decalluc = + blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalluc)); + + set resp.http.decalllc = + blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalllc)); + + set resp.http.decallucodd = + blob.encode(BASE64, blob.decode_n(11, HEX, + req.http.hexallucodd)); + + set resp.http.decalllcodd = + blob.encode(BASE64, blob.decode_n(11, HEX, + req.http.hexalllcodd)); + + set resp.http.decempty = + blob.encode(IDENTITY, blob.decode_n(5, HEX, "")); + + set resp.http.decemptybyte = + blob.encode(IDENTITY, blob.decode_n(1, HEX, "00")); + + set resp.http.decemptynibble = + blob.encode(IDENTITY, blob.decode_n(2, HEX, "0")); + + set resp.http.decemptypieces = + blob.encode(IDENTITY, + blob.decode_n(5, HEX, req.http.unset + "" + + req.http.unset + "")); + + set req.http.part1 = "666"; + set resp.http.dec2pieces = + blob.encode(IDENTITY, blob.decode_n(6, HEX, req.http.part1 + + "F6F206261722062617A2071757578")); + + set req.http.part2 = "57578"; + set resp.http.dec3param = + blob.encode(blob=blob.decode_n(encoded=req.http.part1 + + "F6F206261722062617A20717" + req.http.part2, + decoding=HEX,n=8), + encoding=IDENTITY); + + set resp.http.dec3pieces = + blob.encode(IDENTITY, blob.decode_n(30, HEX, req.http.part1 + + "F6F206261722062617A20717" + req.http.part2)); + + set resp.http.decmanypieces = + blob.encode(IDENTITY, blob.decode_n(20, HEX, "" + req.http.unset + + req.http.part1 + req.http.unset + "" + + req.http.unset + "" + "F6F206261722062617A20717" + + "" + req.http.unset + req.http.part2 + + req.http.unset + "" + req.http.unset)); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.hexlc == "5468652071" + expect resp.http.hexuc == "5468652071" + expect resp.http.hobbeslc == "4d616e2069" + expect resp.http.hobbesuc == "4D616E2069" + expect resp.http.all-uc == "000102030405" + expect resp.http.all-lc == "000102030405" + expect resp.http.empty-uc == "" + expect resp.http.empty-lc == "" + expect resp.http.hexlcparam == "5468652071" + expect resp.http.hexucparam == "5468652071" + expect resp.http.decuc == "foo b" + expect resp.http.declc == "foo b" + expect resp.http.dechobbesuc == "Man is" + expect resp.http.dechobbeslc == "Man is" + expect resp.http.decalluc == "AAECAwQF" + expect resp.http.decalllc == "AAECAwQF" + expect resp.http.decallucodd == "AAECAwQF" + expect resp.http.decalllcodd == "AAECAwQF" + expect resp.http.decempty == "" + expect resp.http.decemptybyte == "" + expect resp.http.decemptynibble == "" + expect resp.http.decemptypieces == "" + expect resp.http.dec2pieces == "foo" + expect resp.http.dec3pieces == "foo bar baz quu" + expect resp.http.dec3param == "foo " + expect resp.http.decmanypieces == "foo bar ba" +} -run + +# Decode failure + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + set req.http.foo = "123"; + set resp.http.badhex = blob.encode(HEXUC, + blob.decode_n(2, HEX, "g" + req.http.foo)); + } +} + +client c1 { + txreq + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.badhex == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect 0 * Begin req + expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" +#" + expect * = End +} -start + +logexpect l1 -wait diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc new file mode 100644 index 0000000..29bde50 --- /dev/null +++ b/bin/varnishtest/tests/m00037.vtc @@ -0,0 +1,302 @@ +varnishtest "VMOD blob base64 encode and decode" + +varnish v1 -vcl { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.pangram + = "The quick brown fox jumps over the lazy dog"; + set req.http.hobbes = +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; + # hex encoding of all 256 byte values in descending order + set req.http.hexall = +{"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; + + set resp.http.b64 = + blob.encode(BASE64, blob.decode(IDENTITY, + req.http.pangram)); + + set resp.http.b64hobbes = + blob.encode(BASE64, blob.decode(IDENTITY, + req.http.hobbes)); + + set resp.http.b64all = + blob.encode(BASE64, blob.decode(HEX, req.http.hexall)); + + set resp.http.b64url = + blob.encode(BASE64URL, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64urlhobbes = + blob.encode(BASE64URL, + blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.b64urlall = + blob.encode(BASE64URL, blob.decode(HEX, req.http.hexall)); + + set resp.http.b64urlnopad = + blob.encode(BASE64URLNOPAD, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64nopadhobbes = + blob.encode(BASE64URLNOPAD, + blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.b64nopadall = + blob.encode(BASE64URLNOPAD, + blob.decode(HEX, req.http.hexall)); + + set resp.http.b64empty = + blob.encode(BASE64, blob.decode(IDENTITY, "")); + set resp.http.urlempty = + blob.encode(BASE64URL, blob.decode(IDENTITY, "")); + set resp.http.nopadempty = + blob.encode(BASE64URLNOPAD, blob.decode(IDENTITY, "")); + + set resp.http.b64param = + blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + encoding=BASE64); + + set resp.http.b64urlparam = + blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + encoding=BASE64URL); + + set resp.http.b64urlnopadparam = + blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + encoding=BASE64URLNOPAD); + + set resp.http.b64xcode = + blob.transcode(IDENTITY, BASE64, req.url + "Hello world" + + req.url); + + set resp.http.b64urlxcode = + blob.transcode(IDENTITY, BASE64URL, req.url + "Hello world" + + req.url); + + set resp.http.b64urlnopadxcode = + blob.transcode(IDENTITY, BASE64URLNOPAD, + req.url + "Hello world" + req.url); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.b64 == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" + expect resp.http.b64hobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" + expect resp.http.b64all == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.b64url == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" + expect resp.http.b64urlhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" + expect resp.http.b64urlall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.b64urlnopad == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + expect resp.http.b64nopadhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" + expect resp.http.b64nopadall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" + expect resp.http.b64empty == "" + expect resp.http.urlempty == "" + expect resp.http.nopadempty == "" + expect resp.http.b64urlparam == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" + expect resp.http.b64urlnopadparam == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + expect resp.http.b64xcode == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.b64urlxcode == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.b64urlnopadxcode == "L0hlbGxvIHdvcmxkLw" +} -run + +varnish v1 -vcl { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.foobarbazquux = "L0hlbGxvIHdvcmxkLw=="; + set req.http.pangram + = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="; + set req.http.hobbes = +{"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; + set req.http.hobbesnopad = regsuball(req.http.hobbes, "=", ""); + set req.http.all = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; + set req.http.allurl = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; + + set resp.http.dec = blob.encode(IDENTITY, + blob.decode(BASE64, req.http.foobarbazquux)); + + set resp.http.dec2 + = blob.encode(IDENTITY, + blob.decode(BASE64, req.http.pangram)); + + set resp.http.b64dechobbes = + blob.encode(IDENTITY, + blob.decode(BASE64, req.http.hobbes)); + + set resp.http.b64decall = + blob.encode(HEXLC, blob.decode(BASE64, req.http.all)); + + set resp.http.urldechobbes = + blob.encode(IDENTITY, blob.decode(BASE64URL, + req.http.hobbes)); + + set resp.http.urldecall = + blob.encode(HEXLC, + blob.decode(BASE64URL, req.http.allurl)); + + set resp.http.nopaddechobbes = + blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + req.http.hobbesnopad)); + + set resp.http.nopaddecall = + blob.encode(HEXLC, + blob.decode(BASE64URLNOPAD, req.http.allurl)); + + set resp.http.b64empty = + blob.encode(IDENTITY, blob.decode(BASE64, "")); + set resp.http.urlempty = + blob.encode(IDENTITY, blob.decode(BASE64URL, "")); + set resp.http.nopadempty = + blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, "")); + set resp.http.emptypieces = + blob.encode(IDENTITY, + blob.decode(BASE64, req.http.unset + "" + req.http.unset + + "" + req.http.unset + "")); + + set resp.http.decenc + = blob.encode(BASE64, + blob.decode(BASE64, req.http.foobarbazquux)); + + set resp.http.l = "L"; + set resp.http.dec2pieces + = blob.encode(IDENTITY, blob.decode(BASE64, + resp.http.l + "0hlbGxvIHdvcmxkLw==")); + + set resp.http.pad = "=="; + set resp.http.dec3pieces + = blob.encode(IDENTITY, blob.decode(BASE64, + resp.http.l + "0hlbGxvIHdvcmxkLw" + + resp.http.pad)); + + set resp.http.mid1 = "GxvI"; + set resp.http.mid2 = "dvcmx"; + set resp.http.dec7pieces + = blob.encode(IDENTITY, blob.decode(BASE64, + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw" + + resp.http.pad)); + + set resp.http.dec7param + = blob.encode(blob=blob.decode(encoded=resp.http.l + "0hlb" + + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + + resp.http.pad, decoding=BASE64), + encoding=IDENTITY); + + set resp.http.decnopad = blob.encode(IDENTITY, + blob.decode(BASE64URLNOPAD, + "L0hlbGxvIHdvcmxkLw")); + + set resp.http.decnopad2pieces + = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + resp.http.l + "0hlbGxvIHdvcmxkLw")); + + set resp.http.decnopad6pieces + = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw")); + + set resp.http.decnopadlong + = blob.encode(IDENTITY, + blob.decode(BASE64URLNOPAD, + "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + )); + + } +} + +client c1 { + txreq -url "/" + rxresp + expect resp.http.dec == "/Hello world/" + expect resp.http.dec2 == "The quick brown fox jumps over the lazy dog" + expect resp.http.b64dechobbes == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.b64decall == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.urldechobbes == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.urldecall == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.nopaddechobbes == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.nopaddecall == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.b64empty == "" + expect resp.http.urlempty == "" + expect resp.http.nopadempty == "" + expect resp.http.emptypieces == "" + expect resp.http.decenc == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.dec2pieces == "/Hello world/" + expect resp.http.dec3pieces == "/Hello world/" + expect resp.http.dec7pieces == "/Hello world/" + expect resp.http.dec7param == "/Hello world/" + expect resp.http.decnopad == "/Hello world/" + expect resp.http.decnopad2pieces == "/Hello world/" + expect resp.http.decnopad6pieces == "/Hello world/" + expect resp.http.decnopadlong == "The quick brown fox jumps over the lazy dog" +} -run + +# Decode failures + +server s1 -repeat 3 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + set req.http.foo = "AAA="; + if (req.url == "/base64") { + set resp.http.bad64 = blob.encode(IDENTITY, + blob.decode(BASE64, "-_-_" + req.http.foo)); + } + elsif (req.url == "/base64url") { + set resp.http.badurl = blob.encode(IDENTITY, + blob.decode(BASE64URL, "+/+/" + req.http.foo)); + } + elsif (req.url == "/base64urlnopad") { + set resp.http.badpad = blob.encode(IDENTITY, + blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); + } + } +} + +client c1 { + txreq -url /base64 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad64 == +} -run + +client c1 { + txreq -url /base64url + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.badurl == +} -run + +client c1 { + txreq -url /base64urlnopad + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.badpad == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "-_-_"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "././"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} +} -run diff --git a/bin/varnishtest/tests/m00038.vtc b/bin/varnishtest/tests/m00038.vtc new file mode 100644 index 0000000..99c7d69 --- /dev/null +++ b/bin/varnishtest/tests/m00038.vtc @@ -0,0 +1,229 @@ +varnishtest "VMOD blob base64 decode_n()" + +varnish v1 -vcl { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.foobarbazquux = "L0hlbGxvIHdvcmxkLw=="; + set req.http.pangram + = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="; + set req.http.hobbes = +{"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; + set req.http.hobbesnopad = regsuball(req.http.hobbes, "=", ""); + set req.http.all = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; + set req.http.allurl = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; + + set resp.http.dec + = blob.encode(IDENTITY, + blob.decode_n(8, BASE64, + req.http.foobarbazquux)); + + set resp.http.deceq + = blob.encode(IDENTITY, + blob.decode_n(20, BASE64, + req.http.foobarbazquux)); + + set resp.http.declong + = blob.encode(IDENTITY, + blob.decode_n(30, BASE64, + req.http.foobarbazquux)); + + set resp.http.dec2 + = blob.encode(IDENTITY, + blob.decode_n(12, BASE64, req.http.pangram)); + + set resp.http.b64dechobbes = + blob.encode(IDENTITY, + blob.decode_n(24, BASE64, req.http.hobbes)); + + set resp.http.b64decall = + blob.encode(HEXLC, blob.decode_n(128, BASE64, + req.http.all)); + + set resp.http.urldechobbes = + blob.encode(IDENTITY, blob.decode_n(180, BASE64URL, + req.http.hobbes)); + + set resp.http.urldecall = + blob.encode(HEXLC, + blob.decode_n(256, BASE64URL, + req.http.allurl)); + + set resp.http.nopaddechobbes = + blob.encode(IDENTITY, + blob.decode_n(500, BASE64URLNOPAD, + req.http.hobbesnopad)); + + set resp.http.nopaddecall = + blob.encode(HEXLC, + blob.decode_n(256, BASE64URLNOPAD, + req.http.allurl)); + + set resp.http.b64empty = + blob.encode(IDENTITY, blob.decode_n(0, BASE64, "")); + set resp.http.urlempty = + blob.encode(IDENTITY, blob.decode_n(1, BASE64URL, "")); + set resp.http.nopadempty = + blob.encode(IDENTITY, + blob.decode_n(0, BASE64URLNOPAD, "")); + set resp.http.emptypieces = + blob.encode(IDENTITY, + blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset + + "" + req.http.unset + "")); + + set resp.http.decenc + = blob.encode(BASE64, + blob.decode_n(20, BASE64, + req.http.foobarbazquux)); + + set resp.http.l = "L"; + set resp.http.dec2pieces + = blob.encode(IDENTITY, blob.decode_n(8, BASE64, + resp.http.l + "0hlbGxvIHdvcmxkLw==")); + + set resp.http.pad = "=="; + set resp.http.dec3pieces + = blob.encode(IDENTITY, blob.decode_n(12, BASE64, + resp.http.l + "0hlbGxvIHdvcmxkLw" + + resp.http.pad)); + + set resp.http.mid1 = "GxvI"; + set resp.http.mid2 = "dvcmx"; + set resp.http.dec7pieces + = blob.encode(IDENTITY, blob.decode_n(16, BASE64, + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw" + + resp.http.pad)); + + set resp.http.dec7param + = blob.encode(blob=blob.decode_n(encoded=resp.http.l + + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + + "kLw" + resp.http.pad, decoding=BASE64, n=20), + encoding=IDENTITY); + + set resp.http.decnopad = blob.encode(IDENTITY, + blob.decode_n(18, BASE64URLNOPAD, + "L0hlbGxvIHdvcmxkLw")); + + set resp.http.decnopad2pieces + = blob.encode(IDENTITY, blob.decode_n(19, BASE64URLNOPAD, + resp.http.l + "0hlbGxvIHdvcmxkLw")); + + set resp.http.decnopad6pieces + = blob.encode(IDENTITY, blob.decode_n(18, BASE64URLNOPAD, + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw")); + + set resp.http.decnopadlong + = blob.encode(IDENTITY, + blob.decode_n(60, BASE64URLNOPAD, + "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + )); + + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.dec == "/Hello" + expect resp.http.deceq == "/Hello world/" + expect resp.http.declong == "/Hello world/" + expect resp.http.dec2 == "The quick" + expect resp.http.b64dechobbes == "Man is distinguish" + expect resp.http.b64decall == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df" + expect resp.http.urldechobbes == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a p" + expect resp.http.urldecall == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.nopaddechobbes == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.nopaddecall == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.b64empty == "" + expect resp.http.urlempty == "" + expect resp.http.nopadempty == "" + expect resp.http.emptypieces == "" + expect resp.http.decenc == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.dec2pieces == "/Hello" + expect resp.http.dec3pieces == "/Hello wo" + expect resp.http.dec7pieces == "/Hello world" + expect resp.http.dec7param == "/Hello world/" + expect resp.http.decnopad == "/Hello world/" + expect resp.http.decnopad2pieces == "/Hello world/" + expect resp.http.decnopad6pieces == "/Hello world/" + expect resp.http.decnopadlong == "The quick brown fox jumps over the lazy dog" +} -run + +# Decode failures + +server s1 -repeat 3 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + set req.http.foo = "AAA="; + if (req.url == "/base64") { + set resp.http.bad64 = blob.encode(IDENTITY, + blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); + } + elsif (req.url == "/base64url") { + set resp.http.badurl = blob.encode(IDENTITY, + blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); + } + elsif (req.url == "/base64urlnopad") { + set resp.http.badpad = blob.encode(IDENTITY, + blob.decode_n(8, BASE64URLNOPAD, + "TWFu" + req.http.foo)); + } + } +} + +client c1 { + txreq -url /base64 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad64 == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "-_-_"$} +} -start + +logexpect l1 -wait + +client c1 { + txreq -url /base64url + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.badurl == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "././"$} +} -start + +logexpect l1 -wait + +client c1 { + txreq -url /base64urlnopad + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.badpad == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} +} -start + +logexpect l1 -wait diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc new file mode 100644 index 0000000..f5d4809 --- /dev/null +++ b/bin/varnishtest/tests/m00039.vtc @@ -0,0 +1,288 @@ +varnishtest "VMOD blob url encode and decode" + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.pangram = "The quick brown fox jumps over the lazy dog"; + set req.http.hobbes = +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; + set req.http.umlauts = "?bergr??entr?ger"; + set req.http.phkspeak = "sm?b?rnsp?dagog"; + set req.http.utf8 = "???"; + + # base64 encoding of all 256 byte values in ascending order + set req.http.b64all = +{"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; + + set resp.http.urllc = + blob.encode(URLLC, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.urluc = + blob.encode(URLUC, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.hobbeslc = + blob.encode(URLLC, blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.hobbesuc = + blob.encode(URLUC, blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.umlautslc = + blob.encode(URLLC, + blob.decode(IDENTITY, req.http.umlauts)); + + set resp.http.umlautsuc = + blob.encode(URLUC, + blob.decode(IDENTITY, req.http.umlauts)); + + set resp.http.phklc = + blob.encode(URLLC, + blob.decode(IDENTITY, req.http.phkspeak)); + + set resp.http.phkuc = + blob.encode(URLUC, + blob.decode(IDENTITY, req.http.phkspeak)); + + set resp.http.utf8lc = + blob.encode(URLLC, blob.decode(IDENTITY, req.http.utf8)); + + set resp.http.utf8uc = + blob.encode(URLUC, blob.decode(IDENTITY, req.http.utf8)); + + set resp.http.all-lc = + blob.encode(URLLC, blob.decode(BASE64, req.http.b64all)); + + set resp.http.all-uc = + blob.encode(URLUC, blob.decode(BASE64, req.http.b64all)); + + set resp.http.empty-lc = + blob.encode(URLLC, blob.decode(IDENTITY, "")); + + set resp.http.empty-uc = + blob.encode(URLUC, blob.decode(IDENTITY, "")); + + set resp.http.urllcparam = + blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + encoding=URLLC); + + set resp.http.urlucparam = + blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + encoding=URLUC); + + set req.http.urllcfoobar = "foo%3abar%3abaz%3aquux"; + set req.http.urlucfoobar = "foo%3Abar%3Abaz%3Aquux"; + set req.http.urlmixedfoobar = "foo%3Abar%3abaz%3Aquux"; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urllcumlauts = "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger"; + set req.http.urlucumlauts = "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger"; + set req.http.urllcphk = "sm%c3%a5b%c3%b8rnsp%c3%a6dagog"; + set req.http.urlucphk = "sm%C3%A5b%C3%B8rnsp%C3%A6dagog"; + set req.http.urllcutf8 = "%e6%97%a5%e6%89%bc%e8%aa%9e"; + set req.http.urlucutf8 = "%E6%97%A5%E6%89%BC%E8%AA%9E"; + set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlalllc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; + + set resp.http.decuc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urlucfoobar)); + + set resp.http.declc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urllcfoobar)); + + set resp.http.decmixed = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urlmixedfoobar)); + + set resp.http.dechobbesuc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urlhobbesuc)); + + set resp.http.dechobbeslc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urlhobbeslc)); + + set resp.http.decumlautsuc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urlucumlauts)); + + set resp.http.decumlautslc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urllcumlauts)); + + set resp.http.decphkuc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urlucphk)); + + set resp.http.decphklc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urllcphk)); + + set resp.http.decutf8uc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urlucutf8)); + + set resp.http.decutf8lc = + blob.encode(IDENTITY, + blob.decode(URL, req.http.urllcutf8)); + + set resp.http.decalluc = + blob.encode(BASE64, blob.decode(URL, req.http.urlalluc)); + + set resp.http.decalllc = + blob.encode(BASE64, blob.decode(URL, req.http.urlalllc)); + + set resp.http.decempty = + blob.encode(IDENTITY, blob.decode(URL, "")); + + set resp.http.decemptybyte = + blob.encode(IDENTITY, blob.decode(URL, "%00")); + + set resp.http.decemptypieces = + blob.encode(IDENTITY, + blob.decode(URL, req.http.unset + "" + + req.http.unset + "")); + + set req.http.part1 = "foo%"; + set resp.http.dec2pieces = + blob.encode(IDENTITY, blob.decode(URL, req.http.part1 + + "20bar%20baz%20quux")); + + set req.http.part2 = "0quux"; + set resp.http.dec3param = + blob.encode(blob=blob.decode(encoded=req.http.part1 + + "20bar%20baz%2" + req.http.part2, + decoding=URL), + encoding=IDENTITY); + + set resp.http.dec3pieces = + blob.encode(IDENTITY, blob.decode(URL, req.http.part1 + + "20bar%20baz%2" + req.http.part2)); + + set resp.http.decmanypieces = + blob.encode(IDENTITY, blob.decode(URL, "" + req.http.unset + + req.http.part1 + req.http.unset + "" + + req.http.unset + "" + "20bar%20baz%2" + + "" + req.http.unset + req.http.part2 + + req.http.unset + "" + req.http.unset)); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.urllc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.urluc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.hobbeslc == "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." + expect resp.http.hobbesuc == "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." + expect resp.http.umlautslc == "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger" + expect resp.http.umlautsuc == "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger" + expect resp.http.phklc == "sm%c3%a5b%c3%b8rnsp%c3%a6dagog" + expect resp.http.phkuc == "sm%C3%A5b%C3%B8rnsp%C3%A6dagog" + expect resp.http.utf8lc == "%e6%97%a5%e6%89%bc%e8%aa%9e" + expect resp.http.utf8uc == "%E6%97%A5%E6%89%BC%E8%AA%9E" + expect resp.http.all-lc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.all-uc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" + expect resp.http.empty-uc == "" + expect resp.http.empty-lc == "" + expect resp.http.urllcparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.urlucparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.decuc == "foo:bar:baz:quux" + expect resp.http.declc == "foo:bar:baz:quux" + expect resp.http.decmixed == "foo:bar:baz:quux" + expect resp.http.dechobbesuc == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.dechobbeslc == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.decumlautsuc == "?bergr??entr?ger" + expect resp.http.decumlautslc == "?bergr??entr?ger" + expect resp.http.decphkuc == "sm?b?rnsp?dagog" + expect resp.http.decphklc == "sm?b?rnsp?dagog" + expect resp.http.decutf8uc == "???" + expect resp.http.decutf8lc == "???" + expect resp.http.decalluc == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.decalllc == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.decempty == "" + expect resp.http.decemptybyte == "" + expect resp.http.decemptypieces == "" + expect resp.http.dec2pieces == "foo bar baz quux" + expect resp.http.dec3pieces == "foo bar baz quux" + expect resp.http.dec3param == "foo bar baz quux" + expect resp.http.decmanypieces == "foo bar baz quux" +} -run + +# Decode failures + +server s1 -repeat 4 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + if (req.url == "/percent") { + set resp.http.bad + = blob.encode(URLUC, blob.decode(URL, "%")); + } + elsif (req.url == "/percent-two") { + set resp.http.bad = blob.encode(URLUC, + blob.decode(URL, "%2")); + } + elsif (req.url == "/percent-q") { + set resp.http.bad = blob.encode(URLUC, + blob.decode(URL, "%q")); + } + elsif (req.url == "/percent-two-q") { + set resp.http.bad = blob.encode(URLUC, + blob.decode(URL, "%2q")); + } + } +} + +client c1 { + txreq -url /percent + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /percent-two + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /percent-q + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /percent-two-q + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%q\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2q\"$" +} -run diff --git a/bin/varnishtest/tests/m00040.vtc b/bin/varnishtest/tests/m00040.vtc new file mode 100644 index 0000000..b93a3c5 --- /dev/null +++ b/bin/varnishtest/tests/m00040.vtc @@ -0,0 +1,197 @@ +varnishtest "VMOD blob decode_n() with URL" + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.urllcfoobar = "foo%3abar%3abaz%3aquux"; + set req.http.urlucfoobar = "foo%3Abar%3Abaz%3Aquux"; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urllcumlauts = "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger"; + set req.http.urlucumlauts = "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger"; + set req.http.urllcphk = "sm%c3%a5b%c3%b8rnsp%c3%a6dagog"; + set req.http.urlucphk = "sm%C3%A5b%C3%B8rnsp%C3%A6dagog"; + set req.http.urllcutf8 = "%e6%97%a5%e6%89%bc%e8%aa%9e"; + set req.http.urlucutf8 = "%E6%97%A5%E6%89%BC%E8%AA%9E"; + set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlalllc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; + + set resp.http.decuc = + blob.encode(IDENTITY, + blob.decode_n(9, URL, req.http.urlucfoobar)); + + set resp.http.declc = + blob.encode(IDENTITY, + blob.decode_n(12, URL, req.http.urllcfoobar)); + + set resp.http.dechobbesuc = + blob.encode(IDENTITY, + blob.decode_n(27, URL, req.http.urlhobbesuc)); + + set resp.http.dechobbeslc = + blob.encode(IDENTITY, + blob.decode_n(27, URL, req.http.urlhobbeslc)); + + set resp.http.decumlautsuc = + blob.encode(IDENTITY, + blob.decode_n(17, URL, + req.http.urlucumlauts)); + + set resp.http.decumlautslc = + blob.encode(IDENTITY, + blob.decode_n(25, URL, + req.http.urllcumlauts)); + + set resp.http.decphkuc = + blob.encode(IDENTITY, + blob.decode_n(18, URL, req.http.urlucphk)); + + set resp.http.decphklc = + blob.encode(IDENTITY, + blob.decode_n(30, URL, req.http.urllcphk)); + + set resp.http.decutf8uc = + blob.encode(IDENTITY, + blob.decode_n(9, URL, req.http.urlucutf8)); + + set resp.http.decutf8lc = + blob.encode(IDENTITY, + blob.decode_n(18, URL, req.http.urllcutf8)); + + set resp.http.decalluc = + blob.encode(HEXLC, + blob.decode_n(252, URL, req.http.urlalluc)); + + set resp.http.decalllc = + blob.encode(HEXUC, + blob.decode_n(252, URL, req.http.urlalllc)); + + set resp.http.decempty = + blob.encode(IDENTITY, blob.decode_n(10, URL, "")); + + set resp.http.decemptybyte = + blob.encode(IDENTITY, blob.decode_n(3, URL, "%00")); + + set resp.http.decemptypieces = + blob.encode(IDENTITY, + blob.decode_n(1, URL, req.http.unset + "" + + req.http.unset + "")); + + set req.http.part1 = "foo%"; + set resp.http.dec2pieces = + blob.encode(IDENTITY, + blob.decode_n(6, URL, req.http.part1 + + "20bar%20baz%20quux")); + + set req.http.part2 = "0quux"; + set resp.http.dec3param = + blob.encode(blob=blob.decode_n(encoded=req.http.part1 + + "20bar%20baz%2" + req.http.part2, + decoding=URL, n=12), + encoding=IDENTITY); + + set resp.http.dec3pieces = + blob.encode(IDENTITY, + blob.decode_n(18, URL, req.http.part1 + + "20bar%20baz%2" + + req.http.part2)); + + set resp.http.decmanypieces = + blob.encode(IDENTITY, + blob.decode_n(24, URL, "" + req.http.unset + + req.http.part1 + req.http.unset + "" + + req.http.unset + "" + "20bar%20baz%2" + + "" + req.http.unset + req.http.part2 + + req.http.unset + "" + req.http.unset)); + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.decuc == "foo:bar" + expect resp.http.declc == "foo:bar:" + expect resp.http.dechobbesuc == "Man is distinguished," + expect resp.http.dechobbeslc == "Man is distinguished," + expect resp.http.decumlautsuc == "?bergr?" + expect resp.http.decumlautslc == "?bergr??en" + expect resp.http.decphkuc == "sm?b?rns" + expect resp.http.decphklc == "sm?b?rnsp?dagog" + expect resp.http.decutf8uc == "?" + expect resp.http.decutf8lc == "??" + expect resp.http.decalluc == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f" + expect resp.http.decalllc == "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F" + expect resp.http.decempty == "" + expect resp.http.decemptybyte == "" + expect resp.http.decemptypieces == "" + expect resp.http.dec2pieces == "foo " + expect resp.http.dec3pieces == "foo bar baz " + expect resp.http.dec3param == "foo bar " + expect resp.http.decmanypieces == "foo bar baz quux" +} -run + +# Decode failures + +server s1 -repeat 4 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + if (req.url == "/percent") { + set resp.http.bad = blob.encode(URLUC, + blob.decode_n(1, URL, "%20")); + } + elsif (req.url == "/percent-two") { + set resp.http.bad = blob.encode(URLUC, + blob.decode_n(2, URL, "%20")); + } + elsif (req.url == "/comma") { + set resp.http.good = blob.encode(IDENTITY, + blob.decode_n(3, URL, "%2c%q")); + } + elsif (req.url == "/colon") { + set resp.http.good = blob.encode(IDENTITY, + blob.decode_n(3, URL, "%3a%2q")); + } + } +} + +client c1 { + txreq -url /comma + rxresp + expect resp.status == 200 + expect resp.http.good == "," + txreq -url /colon + rxresp + expect resp.status == 200 + expect resp.http.good == ":" + txreq -url /percent + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /percent-two + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" +} -run diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc new file mode 100644 index 0000000..8ddd7c0 --- /dev/null +++ b/bin/varnishtest/tests/m00041.vtc @@ -0,0 +1,474 @@ +varnishtest "VMOD blob test transcode()" + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.foobar = "foo:bar:baz:quux"; + set req.http.hobbes = +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; + set req.http.hobbesb64 = +{"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; + set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexalldown = +{"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; + set req.http.hexallup = +{"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"}; + set req.http.b64all = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; + set req.http.b64allurl = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; + + set resp.http.id2id + = blob.transcode(encoded="Hello world"); + + set resp.http.id2b64 + = blob.transcode(encoded=req.http.hobbes, encoding=BASE64); + + set resp.http.id2b64nopad + = blob.transcode(IDENTITY, BASE64URLNOPAD, req.http.hobbes); + + set resp.http.id2hexuc + = blob.transcode(IDENTITY, HEXUC, req.http.hobbes); + + set resp.http.id2hexlc + = blob.transcode(IDENTITY, HEXLC, req.http.hobbes); + + set resp.http.id2urluc + = blob.transcode(IDENTITY, URLUC, req.http.foobar); + + set resp.http.id2urllc + = blob.transcode(IDENTITY, URLLC, req.http.foobar); + + set resp.http.b642id + = blob.transcode(BASE64, IDENTITY, req.http.hobbesb64); + + set resp.http.hex2id + = blob.transcode(HEX, IDENTITY, req.http.hexhobbes); + + set resp.http.hexalldown2b64 + = blob.transcode(HEX, BASE64, req.http.hexalldown); + + set resp.http.hexalldown2b64url + = blob.transcode(HEX, BASE64URL, req.http.hexalldown); + + set resp.http.hexalldown2b64nopad + = blob.transcode(HEX, BASE64URLNOPAD, req.http.hexalldown); + + set resp.http.hexallup2b64 + = blob.transcode(HEX, BASE64, req.http.hexallup); + + set resp.http.hexallup2b64url + = blob.transcode(HEX, BASE64URL, req.http.hexallup); + + set resp.http.hexallup2b64nopad + = blob.transcode(HEX, BASE64URLNOPAD, req.http.hexallup); + + set resp.http.hexalldown2urluc + = blob.transcode(HEX, URLUC, req.http.hexalldown); + + set resp.http.hexalldown2urllc + = blob.transcode(HEX, URLLC, req.http.hexalldown); + + set resp.http.hexallup2urluc + = blob.transcode(HEX, URLUC, req.http.hexallup); + + set resp.http.hexallup2urllc + = blob.transcode(HEX, URLLC, req.http.hexallup); + + set resp.http.b64all2hexuc + = blob.transcode(BASE64, HEXUC, req.http.b64all); + + set resp.http.b64all2hexlc + = blob.transcode(BASE64, HEXLC, req.http.b64all); + + set resp.http.b64allurl2hexuc + = blob.transcode(BASE64URL, HEXUC, req.http.b64allurl); + + set resp.http.b64allurl2hexlc + = blob.transcode(BASE64URL, HEXLC, req.http.b64allurl); + + set resp.http.b64all2urluc + = blob.transcode(BASE64, URLUC, req.http.b64all); + + set resp.http.b64all2urllc + = blob.transcode(BASE64, URLLC, req.http.b64all); + + set resp.http.b64allurl2urluc + = blob.transcode(BASE64URL, URLUC, req.http.b64allurl); + + set resp.http.b64allurl2urllc + = blob.transcode(BASE64URL, URLLC, req.http.b64allurl); + + set resp.http.hexuc2hexuc + = blob.transcode(HEX, HEXUC, "0123456789ABCDEF"); + + set resp.http.hexlc2hexlc + = blob.transcode(HEX, HEXLC, "0123456789abcdef"); + + set resp.http.hexuc2hexlc + = blob.transcode(HEX, HEXLC, "0123456789ABCDEF"); + + set resp.http.hexlc2hexuc + = blob.transcode(HEX, HEXUC, "0123456789abcdef"); + + set resp.http.hexmix2hexuc + = blob.transcode(HEX, HEXUC, "0123456789ABCdef"); + + set resp.http.hexmix2hexlc + = blob.transcode(HEX, HEXLC, "0123456789abcDEF"); + + set req.http.hexpart1 = "01234567"; + set req.http.hexpart2 = "89abcdef"; + set resp.http.hexparam + = blob.transcode(encoded="" + req.http.unset + "" + + req.http.unset + "" + req.http.hexpart1 + + "" + req.http.unset + "" + req.http.unset + + req.http.hexpart2, decoding=HEX, + encoding=HEXUC); + + set resp.http.b642b64 + = blob.transcode(BASE64, BASE64, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789+/"); + + set resp.http.b64url2b64url = + blob.transcode(BASE64URL, BASE64URL, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789-_"); + + set resp.http.b64urlnopad2b64urlnopad = + blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789-_"); + + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.id2id == "Hello world" + expect resp.http.id2b64 == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" + expect resp.http.id2b64nopad == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" + expect resp.http.id2hexuc == "4D616E2069732064697374696E677569736865642C206E6F74206F6E6C792062792068697320726561736F6E2C2062757420627920746869732073696E67756C61722070617373696F6E2066726F6D206F7468657220616E696D616C732C2077686963682069732061206C757374206F6620746865206D696E642C20746861742062792061207065727365766572616E6365206F662064656C6967687420696E2074686520636F6E74696E75656420616E6420696E6465666174696761626C652067656E65726174696F6E206F66206B6E6F776C656467652C2065786365656473207468652073686F727420766568656D656E6365206F6620616E79206361726E616C20706C6561737572652E" + expect resp.http.id2hexlc == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" + expect resp.http.id2urluc == "foo%3Abar%3Abaz%3Aquux" + expect resp.http.id2urllc == "foo%3abar%3abaz%3aquux" + expect resp.http.b642id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.hex2id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.hexalldown2b64 == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.hexalldown2b64url == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.hexalldown2b64nopad == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" + expect resp.http.hexallup2b64 == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.hexallup2b64url == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w==" + expect resp.http.hexallup2b64nopad == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w" + expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" + expect resp.http.hexalldown2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" + expect resp.http.hexallup2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" + expect resp.http.hexallup2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.b64all2hexuc == "0000000410410820820C30C31041041451451861861C71C720820824924928A28A2CB2CB30C30C34D34D38E38E3CF3CF4104104514514924924D34D35145145555555965965D75D761861865965969A69A6DB6DB71C71C75D75D79E79E7DF7DF8208208618618A28A28E38E39249249659659A69A69E79E7A28A28A69A69AAAAAAAEBAEBB2CB2CB6DB6DBAEBAEBEFBEFC30C30C71C71CB2CB2CF3CF3D34D34D75D75DB6DB6DF7DF7E38E38E79E79EBAEBAEFBEFBF3CF3CF7DF7DFBEFBEFFFFFF" + expect resp.http.b64all2hexlc == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.b64allurl2hexuc == "0000000410410820820C30C31041041451451861861C71C720820824924928A28A2CB2CB30C30C34D34D38E38E3CF3CF4104104514514924924D34D35145145555555965965D75D761861865965969A69A6DB6DB71C71C75D75D79E79E7DF7DF8208208618618A28A28E38E39249249659659A69A69E79E7A28A28A69A69AAAAAAAEBAEBB2CB2CB6DB6DBAEBAEBEFBEFC30C30C71C71CB2CB2CF3CF3D34D34D75D75DB6DB6DF7DF7E38E38E79E79EBAEBAEFBEFBF3CF3CF7DF7DFBEFBEFFFFFF" + expect resp.http.b64allurl2hexlc == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.b64all2urluc == "%00%00%00%04%10A%08%20%82%0C0%C3%10A%04%14QE%18a%86%1Cq%C7%20%82%08%24%92I%28%A2%8A%2C%B2%CB0%C3%0C4%D3M8%E3%8E%3C%F3%CFA%04%10E%14QI%24%92M4%D3QE%14UUUYe%96%5Du%D7a%86%18e%96Yi%A6%9Am%B6%DBq%C7%1Cu%D7%5Dy%E7%9E%7D%F7%DF%82%08%20%86%18a%8A%28%A2%8E8%E3%92I%24%96Ye%9Ai%A6%9Ey%E7%A2%8A%28%A6%9Ai%AA%AA%AA%AE%BA%EB%B2%CB%2C%B6%DBm%BA%EB%AE%BE%FB%EF%C3%0C0%C7%1Cq%CB%2C%B2%CF%3C%F3%D3M4%D7%5Du%DBm%B6%DF%7D%F7%E3%8E8%E7%9Ey%EB%AE%BA%EF%BE%FB%F3%CF%3C%F7%DF%7D%FB%EF%BE%FF%FF%FF" + expect resp.http.b64all2urllc == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" + expect resp.http.b64allurl2urluc == "%00%00%00%04%10A%08%20%82%0C0%C3%10A%04%14QE%18a%86%1Cq%C7%20%82%08%24%92I%28%A2%8A%2C%B2%CB0%C3%0C4%D3M8%E3%8E%3C%F3%CFA%04%10E%14QI%24%92M4%D3QE%14UUUYe%96%5Du%D7a%86%18e%96Yi%A6%9Am%B6%DBq%C7%1Cu%D7%5Dy%E7%9E%7D%F7%DF%82%08%20%86%18a%8A%28%A2%8E8%E3%92I%24%96Ye%9Ai%A6%9Ey%E7%A2%8A%28%A6%9Ai%AA%AA%AA%AE%BA%EB%B2%CB%2C%B6%DBm%BA%EB%AE%BE%FB%EF%C3%0C0%C7%1Cq%CB%2C%B2%CF%3C%F3%D3M4%D7%5Du%DBm%B6%DF%7D%F7%E3%8E8%E7%9Ey%EB%AE%BA%EF%BE%FB%F3%CF%3C%F7%DF%7D%FB%EF%BE%FF%FF%FF" + expect resp.http.b64allurl2urllc == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" + expect resp.http.hexuc2hexuc == "0123456789ABCDEF" + expect resp.http.hexlc2hexlc == "0123456789abcdef" + expect resp.http.hexuc2hexlc == "0123456789abcdef" + expect resp.http.hexlc2hexuc == "0123456789ABCDEF" + expect resp.http.hexmix2hexuc == "0123456789ABCDEF" + expect resp.http.hexmix2hexlc == "0123456789abcdef" + expect resp.http.hexparam == "0123456789ABCDEF" + expect resp.http.b642b64 == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + expect resp.http.b64url2b64url == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" + expect resp.http.b64urlnopad2b64urlnopad == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" +} -run + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlalluplc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; + set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; + set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; + + set resp.http.urluc2id + = blob.transcode(URL, IDENTITY, req.http.urlhobbesuc); + + set resp.http.urllc2id + = blob.transcode(URL, IDENTITY, req.http.urlhobbeslc); + + set resp.http.urlalldownuc2b64 + = blob.transcode(URL, BASE64, req.http.urlalldownuc); + + set resp.http.urlalldownuc2b64url + = blob.transcode(URL, BASE64URL, req.http.urlalldownuc); + + set resp.http.urlalldownuc2b64nopad + = blob.transcode(URL, BASE64URLNOPAD, req.http.urlalldownuc); + + set resp.http.urlalldownlc2b64 + = blob.transcode(URL, BASE64, req.http.urlalldownlc); + + set resp.http.urlalldownlc2b64url + = blob.transcode(URL, BASE64URL, req.http.urlalldownlc); + + set resp.http.urlalldownlc2b64nopad + = blob.transcode(URL, BASE64URLNOPAD, req.http.urlalldownlc); + + set resp.http.urlallupuc2b64 + = blob.transcode(URL, BASE64, req.http.urlallupuc); + + set resp.http.urlallupuc2b64url + = blob.transcode(URL, BASE64URL, req.http.urlallupuc); + + set resp.http.urlallupuc2b64nopad + = blob.transcode(URL, BASE64URLNOPAD, req.http.urlallupuc); + + set resp.http.urlalluplc2b64 + = blob.transcode(URL, BASE64, req.http.urlalluplc); + + set resp.http.urlalluplc2b64url + = blob.transcode(URL, BASE64URL, req.http.urlalluplc); + + set resp.http.urlalluplc2b64nopad + = blob.transcode(URL, BASE64URLNOPAD, req.http.urlalluplc); + + set resp.http.urlalldownuc2urluc + = blob.transcode(URL, URLUC, req.http.urlalldownuc); + + set resp.http.urlalldownuc2urllc + = blob.transcode(URL, URLLC, req.http.urlalldownuc); + + set resp.http.urlalldownlc2urluc + = blob.transcode(URL, URLUC, req.http.urlalldownlc); + + set resp.http.urlalldownlc2urllc + = blob.transcode(URL, URLLC, req.http.urlalldownlc); + + set resp.http.urlallupuc2urluc + = blob.transcode(URL, URLUC, req.http.urlallupuc); + + set resp.http.urlallupuc2urllc + = blob.transcode(URL, URLLC, req.http.urlallupuc); + + set resp.http.urlalluplc2urluc + = blob.transcode(URL, URLUC, req.http.urlalluplc); + + set resp.http.urlalluplc2urllc + = blob.transcode(URL, URLLC, req.http.urlalluplc); + + } +} + +client c1 { + txreq + rxresp + expect resp.http.urluc2id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.urllc2id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.urlalldownuc2b64 == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.urlalldownuc2b64url == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.urlalldownuc2b64nopad == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" + expect resp.http.urlalldownlc2b64 == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.urlalldownlc2b64url == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.urlalldownlc2b64nopad == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" + expect resp.http.urlallupuc2b64 == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.urlallupuc2b64url == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w==" + expect resp.http.urlallupuc2b64nopad == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w" + expect resp.http.urlalluplc2b64 == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.urlalluplc2b64url == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w==" + expect resp.http.urlalluplc2b64nopad == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w" + expect resp.http.urlalldownuc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" + expect resp.http.urlalldownuc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" + expect resp.http.urlalldownlc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" + expect resp.http.urlalldownlc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" + expect resp.http.urlallupuc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" + expect resp.http.urlalluplc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" + expect resp.http.urlallupuc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.urlalluplc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" +} -run + +# Decode failures + +server s1 -repeat 11 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + set req.http.foo = "AAA="; + if (req.url == "/1") { + set resp.http.bad + = blob.transcode(HEX, IDENTITY, "0x123456"); + } + elsif (req.url == "/2") { + set resp.http.bad + = blob.transcode(BASE64, IDENTITY, + "-_-_" + req.http.foo); + } + elsif (req.url == "/3") { + set resp.http.bad + = blob.transcode(BASE64URL, IDENTITY, + "+/+/" + req.http.foo); + } + elsif (req.url == "/4") { + set resp.http.bad + = blob.transcode(BASE64URLNOPAD, IDENTITY, + "TWFu" + req.http.foo); + } + elsif (req.url == "/5") { + set resp.http.bad + = blob.transcode(BASE64, BASE64, + "_-_-" + req.http.foo); + } + elsif (req.url == "/6") { + set resp.http.bad + = blob.transcode(BASE64URL, BASE64URL, + "/+/+" + req.http.foo); + } + elsif (req.url == "/7") { + set resp.http.bad + = blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, + "Zm9v" + req.http.foo); + } + elsif (req.url == "/8") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%"); + } + elsif (req.url == "/9") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%2"); + } + elsif (req.url == "/10") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%q"); + } + elsif (req.url == "/11") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%2q"); + } + } +} + +client c1 { + txreq -url /1 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /2 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /3 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /4 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /5 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /6 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /7 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /8 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /9 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /10 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /11 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "0x123456"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "-_-_"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "\+/\+/"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "_-_-"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "/\+/\+"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "Zm9v"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%q"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2q"$} +} -run diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc new file mode 100644 index 0000000..a34f7d0 --- /dev/null +++ b/bin/varnishtest/tests/m00042.vtc @@ -0,0 +1,470 @@ +varnishtest "VMOD blob test transcode_n()" + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.foobar = "foo:bar:baz:quux"; + set req.http.hobbes = +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; + set req.http.hobbesb64 = +{"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; + set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexalldown = +{"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; + set req.http.hexallup = +{"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"}; + set req.http.b64all = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; + set req.http.b64allurl = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; + + set resp.http.id2id + = blob.transcode_n(5, IDENTITY, IDENTITY, "Hello world"); + + set resp.http.id2b64 + = blob.transcode_n(5, IDENTITY, BASE64, req.http.hobbes); + + set resp.http.id2b64nopad + = blob.transcode_n(5, IDENTITY, BASE64URLNOPAD, req.http.hobbes); + + set resp.http.id2hexuc + = blob.transcode_n(5, IDENTITY, HEXUC, req.http.hobbes); + + set resp.http.id2hexlc + = blob.transcode_n(5, IDENTITY, HEXLC, req.http.hobbes); + + set resp.http.id2urluc + = blob.transcode_n(5, IDENTITY, URLUC, req.http.foobar); + + set resp.http.id2urllc + = blob.transcode_n(5, IDENTITY, URLLC, req.http.foobar); + + set resp.http.b642id + = blob.transcode_n(8, BASE64, IDENTITY, req.http.hobbesb64); + + set resp.http.hex2id + = blob.transcode_n(12, HEX, IDENTITY, req.http.hexhobbes); + + set resp.http.hexalldown2b64 + = blob.transcode_n(12, HEX, BASE64, req.http.hexalldown); + + set resp.http.hexalldown2b64url + = blob.transcode_n(12, HEX, BASE64URL, req.http.hexalldown); + + set resp.http.hexalldown2b64nopad + = blob.transcode_n(10, HEX, BASE64URLNOPAD, req.http.hexalldown); + + set resp.http.hexallup2b64 + = blob.transcode_n(12, HEX, BASE64, req.http.hexallup); + + set resp.http.hexallup2b64url + = blob.transcode_n(10, HEX, BASE64URL, req.http.hexallup); + + set resp.http.hexallup2b64nopad + = blob.transcode_n(10, HEX, BASE64URLNOPAD, req.http.hexallup); + + set resp.http.hexalldown2urluc + = blob.transcode_n(12, HEX, URLUC, req.http.hexalldown); + + set resp.http.hexalldown2urllc + = blob.transcode_n(12, HEX, URLLC, req.http.hexalldown); + + set resp.http.hexallup2urluc + = blob.transcode_n(12, HEX, URLUC, req.http.hexallup); + + set resp.http.hexallup2urllc + = blob.transcode_n(12, HEX, URLLC, req.http.hexallup); + + set resp.http.b64all2hexuc + = blob.transcode_n(8, BASE64, HEXUC, req.http.b64all); + + set resp.http.b64all2hexlc + = blob.transcode_n(8, BASE64, HEXLC, req.http.b64all); + + set resp.http.b64allurl2hexuc + = blob.transcode_n(8, BASE64URL, HEXUC, req.http.b64allurl); + + set resp.http.b64allurl2hexlc + = blob.transcode_n(8, BASE64URL, HEXLC, req.http.b64allurl); + + set resp.http.b64all2urluc + = blob.transcode_n(8, BASE64, URLUC, req.http.b64all); + + set resp.http.b64all2urllc + = blob.transcode_n(8, BASE64, URLLC, req.http.b64all); + + set resp.http.b64allurl2urluc + = blob.transcode_n(8, BASE64URL, URLUC, req.http.b64allurl); + + set resp.http.b64allurl2urllc + = blob.transcode_n(8, BASE64URL, URLLC, req.http.b64allurl); + + set resp.http.hexuc2hexuc + = blob.transcode_n(10, HEX, HEXUC, "0123456789ABCDEF"); + + set resp.http.hexlc2hexlc + = blob.transcode_n(10, HEX, HEXLC, "0123456789abcdef"); + + set resp.http.hexuc2hexlc + = blob.transcode_n(9, HEX, HEXLC, "0123456789ABCDEF"); + + set resp.http.hexlc2hexuc + = blob.transcode_n(9, HEX, HEXUC, "0123456789abcdef"); + + set resp.http.hexmix2hexuc + = blob.transcode_n(15, HEX, HEXUC, "0123456789ABCdef"); + + set resp.http.hexmix2hexlc + = blob.transcode_n(13, HEX, HEXLC, "0123456789abcDEF"); + + set req.http.hexpart1 = "01234567"; + set req.http.hexpart2 = "89abcdef"; + set resp.http.hexparam + = blob.transcode_n(encoded="" + req.http.unset + "" + + req.http.unset + "" + req.http.hexpart1 + + "" + req.http.unset + "" + req.http.unset + + req.http.hexpart2, decoding=HEX, + encoding=HEXUC, n=10); + + set resp.http.b642b64 + = blob.transcode_n(36, BASE64, BASE64, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789+/"); + + set resp.http.b64url2b64url = + blob.transcode_n(34, BASE64URL, BASE64URL, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789-_"); + + set resp.http.b64urlnopad2b64urlnopad = + blob.transcode_n(34, BASE64URLNOPAD, BASE64URLNOPAD, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789-_"); + + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.id2id == "Hello" + expect resp.http.id2b64 == "TWFuIGk=" + expect resp.http.id2b64nopad == "TWFuIGk" + expect resp.http.id2hexuc == "4D616E2069" + expect resp.http.id2hexlc == "4d616e2069" + expect resp.http.id2urluc == "foo%3Ab" + expect resp.http.id2urllc == "foo%3ab" + expect resp.http.b642id == "Man is" + expect resp.http.hex2id == "Man is" + expect resp.http.hexalldown2b64 == "//79/Pv6" + expect resp.http.hexalldown2b64url == "__79_Pv6" + expect resp.http.hexalldown2b64nopad == "__79_Ps" + expect resp.http.hexallup2b64 == "AAECAwQF" + expect resp.http.hexallup2b64url == "AAECAwQ=" + expect resp.http.hexallup2b64nopad == "AAECAwQ" + expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA" + expect resp.http.hexalldown2urllc == "%ff%fe%fd%fc%fb%fa" + expect resp.http.hexallup2urluc == "%00%01%02%03%04%05" + expect resp.http.hexallup2urllc == "%00%01%02%03%04%05" + expect resp.http.b64all2hexuc == "000000041041" + expect resp.http.b64all2hexlc == "000000041041" + expect resp.http.b64allurl2hexuc == "000000041041" + expect resp.http.b64allurl2hexlc == "000000041041" + expect resp.http.b64all2urluc == "%00%00%00%04%10A" + expect resp.http.b64all2urllc == "%00%00%00%04%10A" + expect resp.http.b64allurl2urluc == "%00%00%00%04%10A" + expect resp.http.b64allurl2urllc == "%00%00%00%04%10A" + expect resp.http.hexuc2hexuc == "0123456789" + expect resp.http.hexlc2hexlc == "0123456789" + expect resp.http.hexuc2hexlc == "0012345678" + expect resp.http.hexlc2hexuc == "0012345678" + expect resp.http.hexmix2hexuc == "00123456789ABCDE" + expect resp.http.hexmix2hexlc == "00123456789abc" + expect resp.http.hexparam == "0123456789" + expect resp.http.b642b64 == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij" + expect resp.http.b64url2b64url == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefeQ==" + expect resp.http.b64urlnopad2b64urlnopad == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgg" +} -run + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlalluplc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; + set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; + set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; + + set resp.http.urluc2id + = blob.transcode_n(27, URL, IDENTITY, req.http.urlhobbesuc); + + set resp.http.urllc2id + = blob.transcode_n(63, URL, IDENTITY, req.http.urlhobbeslc); + + set resp.http.urlalldownuc2b64 + = blob.transcode_n(18, URL, BASE64, req.http.urlalldownuc); + + set resp.http.urlalldownuc2b64url + = blob.transcode_n(15, URL, BASE64URL, req.http.urlalldownuc); + + set resp.http.urlalldownuc2b64nopad + = blob.transcode_n(15, URL, BASE64URLNOPAD, + req.http.urlalldownuc); + + set resp.http.urlalldownlc2b64 + = blob.transcode_n(18, URL, BASE64, req.http.urlalldownlc); + + set resp.http.urlalldownlc2b64url + = blob.transcode_n(15, URL, BASE64URL, req.http.urlalldownlc); + + set resp.http.urlalldownlc2b64nopad + = blob.transcode_n(15, URL, BASE64URLNOPAD, + req.http.urlalldownlc); + + set resp.http.urlallupuc2b64 + = blob.transcode_n(36, URL, BASE64, req.http.urlallupuc); + + set resp.http.urlallupuc2b64url + = blob.transcode_n(33, URL, BASE64URL, req.http.urlallupuc); + + set resp.http.urlallupuc2b64nopad + = blob.transcode_n(33, URL, BASE64URLNOPAD, + req.http.urlallupuc); + + set resp.http.urlalluplc2b64 + = blob.transcode_n(36, URL, BASE64, req.http.urlalluplc); + + set resp.http.urlalluplc2b64url + = blob.transcode_n(33, URL, BASE64URL, req.http.urlalluplc); + + set resp.http.urlalluplc2b64nopad + = blob.transcode_n(33, URL, BASE64URLNOPAD, + req.http.urlalluplc); + + set resp.http.urlalldownuc2urluc + = blob.transcode_n(423, URL, URLUC, req.http.urlalldownuc); + + set resp.http.urlalldownuc2urllc + = blob.transcode_n(423, URL, URLLC, req.http.urlalldownuc); + + set resp.http.urlalldownlc2urluc + = blob.transcode_n(423, URL, URLUC, req.http.urlalldownlc); + + set resp.http.urlalldownlc2urllc + = blob.transcode_n(423, URL, URLLC, req.http.urlalldownlc); + + set resp.http.urlallupuc2urluc + = blob.transcode_n(197, URL, URLUC, req.http.urlallupuc); + + set resp.http.urlallupuc2urllc + = blob.transcode_n(197, URL, URLLC, req.http.urlallupuc); + + set resp.http.urlalluplc2urluc + = blob.transcode_n(197, URL, URLUC, req.http.urlalluplc); + + set resp.http.urlalluplc2urllc + = blob.transcode_n(197, URL, URLLC, req.http.urlalluplc); + + } +} + +client c1 { + txreq + rxresp + expect resp.http.urluc2id == "Man is distinguished," + expect resp.http.urllc2id == "Man is distinguished, not only by his reason," + expect resp.http.urlalldownuc2b64 == "//79/Pv6" + expect resp.http.urlalldownuc2b64url == "__79_Ps=" + expect resp.http.urlalldownuc2b64nopad == "__79_Ps" + expect resp.http.urlalldownlc2b64 == "//79/Pv6" + expect resp.http.urlalldownlc2b64url == "__79_Ps=" + expect resp.http.urlalldownlc2b64nopad == "__79_Ps" + expect resp.http.urlallupuc2b64 == "AAECAwQFBgcICQoL" + expect resp.http.urlallupuc2b64url == "AAECAwQFBgcICQo=" + expect resp.http.urlallupuc2b64nopad == "AAECAwQFBgcICQo" + expect resp.http.urlalluplc2b64 == "AAECAwQFBgcICQoL" + expect resp.http.urlalluplc2b64url == "AAECAwQFBgcICQo=" + expect resp.http.urlalluplc2b64nopad == "AAECAwQFBgcICQo" + expect resp.http.urlalldownuc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba" + expect resp.http.urlalldownuc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" + expect resp.http.urlalldownlc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba" + expect resp.http.urlalldownlc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" + expect resp.http.urlallupuc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" + expect resp.http.urlalluplc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" + expect resp.http.urlallupuc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" + expect resp.http.urlalluplc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" +} -run + +# Decode failures + +server s1 -repeat 11 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + set req.http.foo = "AAA="; + if (req.url == "/1") { + set resp.http.good + = blob.transcode_n(3, URL, IDENTITY, "%2c%q"); + } + elsif (req.url == "/2") { + set resp.http.good + = blob.transcode_n(3, URL, IDENTITY, "%3a%2q"); + } + elsif (req.url == "/3") { + set resp.http.bad + = blob.transcode_n(8, HEX, IDENTITY, + "0x123456"); + } + elsif (req.url == "/4") { + set resp.http.bad + = blob.transcode_n(4, BASE64, IDENTITY, + "-_-_" + req.http.foo); + } + elsif (req.url == "/5") { + set resp.http.bad + = blob.transcode_n(4, BASE64URL, IDENTITY, + "+/+/" + req.http.foo); + } + elsif (req.url == "/6") { + set resp.http.bad + = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, + "TWFu" + req.http.foo); + } + elsif (req.url == "/7") { + set resp.http.bad + = blob.transcode_n(4, BASE64, BASE64, + "_-_-" + req.http.foo); + } + elsif (req.url == "/8") { + set resp.http.bad + = blob.transcode_n(4, BASE64URL, BASE64URL, + "/+/+" + req.http.foo); + } + elsif (req.url == "/9") { + set resp.http.bad + = blob.transcode_n(8, BASE64URLNOPAD, + BASE64URLNOPAD, + "Zm9v" + req.http.foo); + } + elsif (req.url == "/10") { + set resp.http.bad + = blob.transcode_n(1, URL, IDENTITY, "%20"); + } + elsif (req.url == "/11") { + set resp.http.bad + = blob.transcode_n(2, URL, IDENTITY, "%20"); + } + } +} + +client c1 { + txreq -url /1 + rxresp + expect resp.status == 200 + expect resp.http.good == "," + txreq -url /2 + rxresp + expect resp.status == 200 + expect resp.http.good == ":" + txreq -url /3 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /4 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /5 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /6 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /7 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /8 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /9 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /10 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +client c1 { + txreq -url /11 + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.bad == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "0x123456"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "-_-_"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "\+/\+/"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "_-_-"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "/\+/\+"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "Zm9v"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%20"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%20"$} +} -run diff --git a/bin/varnishtest/tests/m00043.vtc b/bin/varnishtest/tests/m00043.vtc new file mode 100644 index 0000000..c12ac14 --- /dev/null +++ b/bin/varnishtest/tests/m00043.vtc @@ -0,0 +1,334 @@ +varnishtest "VMOD blob blob object interface" + +server s1 {} -start + +varnish v1 -arg "-i serverid" -vcl+backend { + import blob; + + sub vcl_init { + new id = blob.blob(IDENTITY, + "The quick brown fox jumps over the lazy dog"); + new idpieces + = blob.blob(IDENTITY, "" + server.identity + " " + + server.identity + ""); + new idempty = blob.blob(IDENTITY, ""); + new idparam + = blob.blob(encoded="" + server.identity + " " + server.identity + + "", decoding=IDENTITY); + + new hexuc = blob.blob(HEX, "666F6F206261722062617A2071757578"); + new hexlc = blob.blob(HEX, "666f6f206261722062617a2071757578"); + new hexmix = blob.blob(HEX, "666F6F206261722062617a2071757578"); + + new b64 = blob.blob(BASE64, "L0hlbGxvIHdvcmxkLw=="); + + new b64nopad = blob.blob(BASE64URLNOPAD, "L0hlbGxvIHdvcmxkLw"); + + new hexall = blob.blob(HEX, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"); + new b64all = blob.blob(BASE64, "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="); + } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.id = blob.encode(IDENTITY, id.get()); + set resp.http.idpieces = blob.encode(IDENTITY, idpieces.get()); + set resp.http.idparam = blob.encode(IDENTITY, idparam.get()); + set resp.http.idempty = blob.encode(IDENTITY, idempty.get()); + set resp.http.hexuc = blob.encode(IDENTITY, hexuc.get()); + set resp.http.hexlc = blob.encode(IDENTITY, hexlc.get()); + set resp.http.hexmix = blob.encode(IDENTITY, hexmix.get()); + set resp.http.b64 = blob.encode(IDENTITY, b64.get()); + set resp.http.b64nopad = blob.encode(IDENTITY, b64nopad.get()); + + set resp.http.allhex2b64func = blob.encode(BASE64, + hexall.get()); + set resp.http.allb642hexlcfunc = blob.encode(HEXLC, + b64all.get()); + set resp.http.allhex2b64meth = hexall.encode(BASE64); + set resp.http.allb642hexlcmeth = b64all.encode(HEXLC); + + set resp.http.id2id = id.encode(IDENTITY); + set resp.http.id2b64 = id.encode(BASE64); + set resp.http.id2b64url = id.encode(BASE64URL); + set resp.http.id2b64urlnopad = id.encode(BASE64URLNOPAD); + set resp.http.id2hexuc = id.encode(HEXUC); + set resp.http.id2hexlc = id.encode(HEXLC); + + set resp.http.emptyid = idempty.encode(IDENTITY); + set resp.http.emptyb64 = idempty.encode(BASE64); + set resp.http.emptyb64url = idempty.encode(BASE64URL); + set resp.http.emptyb64urlnopad = idempty.encode(BASE64URLNOPAD); + set resp.http.emptyhexuc = idempty.encode(HEXUC); + set resp.http.emptyhexlc = idempty.encode(HEXLC); + + set resp.http.hexuc2id = hexuc.encode(IDENTITY); + set resp.http.hexuc2b64 = hexuc.encode(BASE64); + set resp.http.hexuc2b64url = hexuc.encode(BASE64URL); + set resp.http.hexuc2b64nopad = hexuc.encode(BASE64URLNOPAD); + set resp.http.hexuc2hexuc = hexuc.encode(HEXUC); + set resp.http.hexuc2hexlc = hexuc.encode(HEXLC); + + set resp.http.hexlc2id = hexlc.encode(IDENTITY); + set resp.http.hexlc2b64 = hexlc.encode(BASE64); + set resp.http.hexlc2b64url = hexlc.encode(BASE64URL); + set resp.http.hexlc2b64nopad = hexlc.encode(BASE64URLNOPAD); + set resp.http.hexlc2hexuc = hexlc.encode(HEXUC); + set resp.http.hexlc2hexlc = hexlc.encode(HEXLC); + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.id == "The quick brown fox jumps over the lazy dog" + expect resp.http.idpieces == "serverid serverid" + expect resp.http.idparam == "serverid serverid" + expect resp.http.idempty == "" + expect resp.http.hexuc == "foo bar baz quux" + expect resp.http.hexlc == "foo bar baz quux" + expect resp.http.hexmix == "foo bar baz quux" + expect resp.http.b64 == "/Hello world/" + expect resp.http.b64nopad == "/Hello world/" + + expect resp.http.allhex2b64func == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.allb642hexlcfunc == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + expect resp.http.allhex2b64meth == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.allb642hexlcmeth == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + + expect resp.http.id2id == "The quick brown fox jumps over the lazy dog" + expect resp.http.id2b64 == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" + expect resp.http.id2b64url == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" + expect resp.http.id2b64urlnopad == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + expect resp.http.id2hexuc == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67" + expect resp.http.id2hexlc == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" + + expect resp.http.emptyid == "" + expect resp.http.emptyb64 == "" + expect resp.http.emptyb64url == "" + expect resp.http.emptyb64urlnopad == "" + expect resp.http.emptyhexuc == "" + expect resp.http.emptyhexlc == "" + + expect resp.http.hexuc2id == "foo bar baz quux" + expect resp.http.hexuc2b64 == "Zm9vIGJhciBiYXogcXV1eA==" + expect resp.http.hexuc2b64url == "Zm9vIGJhciBiYXogcXV1eA==" + expect resp.http.hexuc2b64nopad == "Zm9vIGJhciBiYXogcXV1eA" + expect resp.http.hexuc2hexuc == "666F6F206261722062617A2071757578" + expect resp.http.hexuc2hexlc == "666f6f206261722062617a2071757578" + + expect resp.http.hexlc2id == "foo bar baz quux" + expect resp.http.hexlc2b64 == "Zm9vIGJhciBiYXogcXV1eA==" + expect resp.http.hexlc2b64url == "Zm9vIGJhciBiYXogcXV1eA==" + expect resp.http.hexlc2b64nopad == "Zm9vIGJhciBiYXogcXV1eA" + expect resp.http.hexlc2hexuc == "666F6F206261722062617A2071757578" + expect resp.http.hexlc2hexlc == "666f6f206261722062617a2071757578" +} -run + +# run twice to test retrieving cached encodings +client c1 -run + +varnish v1 -vcl+backend { + import blob; + + sub vcl_init { + new b64 = blob.blob(BASE64, "L0hlbGxvIHdvcmxkLw=="); + new b64url = blob.blob(BASE64URL, "L0hlbGxvIHdvcmxkLw=="); + new b64nopad = blob.blob(BASE64URLNOPAD, "L0hlbGxvIHdvcmxkLw"); + } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.b642id = b64.encode(IDENTITY); + set resp.http.b642b64 = b64.encode(BASE64); + set resp.http.b642b64url = b64.encode(BASE64URL); + set resp.http.b642b64nopad = b64.encode(BASE64URLNOPAD); + set resp.http.b642hexuc = b64.encode(HEXUC); + set resp.http.b642hexlc = b64.encode(HEXLC); + set resp.http.b642urluc = b64.encode(URLUC); + set resp.http.b642urllc = b64.encode(URLLC); + + set resp.http.b64url2id = b64url.encode(IDENTITY); + set resp.http.b64url2b64 = b64url.encode(BASE64); + set resp.http.b64url2b64url = b64url.encode(BASE64URL); + set resp.http.b64url2b64nopad = b64url.encode(BASE64URLNOPAD); + set resp.http.b64url2hexuc = b64url.encode(HEXUC); + set resp.http.b64url2hexlc = b64url.encode(HEXLC); + set resp.http.b64url2urluc = b64url.encode(URLUC); + set resp.http.b64url2urllc = b64url.encode(URLLC); + + set resp.http.b64nopad2id = b64nopad.encode(IDENTITY); + set resp.http.b64nopad2b64 = b64nopad.encode(BASE64); + set resp.http.b64nopad2b64url = b64nopad.encode(BASE64URL); + set resp.http.b64nopad2b64nopad = b64nopad.encode(BASE64URLNOPAD); + set resp.http.b64nopad2hexuc = b64nopad.encode(HEXUC); + set resp.http.b64nopad2hexlc = b64nopad.encode(HEXLC); + set resp.http.b64nopad2urluc = b64nopad.encode(URLUC); + set resp.http.b64nopad2urllc = b64nopad.encode(URLLC); + } +} + +client c2 { + txreq + rxresp + expect resp.http.b642id == "/Hello world/" + expect resp.http.b642b64 == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.b642b64url == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.b642b64nopad == "L0hlbGxvIHdvcmxkLw" + expect resp.http.b642hexuc == "2F48656C6C6F20776F726C642F" + expect resp.http.b642hexlc == "2f48656c6c6f20776f726c642f" + expect resp.http.b642urluc == "%2FHello%20world%2F" + expect resp.http.b642urllc == "%2fHello%20world%2f" + + expect resp.http.b64url2id == "/Hello world/" + expect resp.http.b64url2b64 == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.b64url2b64url == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.b64url2b64nopad == "L0hlbGxvIHdvcmxkLw" + expect resp.http.b64url2hexuc == "2F48656C6C6F20776F726C642F" + expect resp.http.b64url2hexlc == "2f48656c6c6f20776f726c642f" + expect resp.http.b64url2urluc == "%2FHello%20world%2F" + expect resp.http.b64url2urllc == "%2fHello%20world%2f" + + expect resp.http.b64nopad2id == "/Hello world/" + expect resp.http.b64nopad2b64 == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.b64nopad2b64url == "L0hlbGxvIHdvcmxkLw==" + expect resp.http.b64nopad2b64nopad == "L0hlbGxvIHdvcmxkLw" + expect resp.http.b64nopad2hexuc == "2F48656C6C6F20776F726C642F" + expect resp.http.b64nopad2hexlc == "2f48656c6c6f20776f726c642f" + expect resp.http.b64nopad2urluc == "%2FHello%20world%2F" + expect resp.http.b64nopad2urllc == "%2fHello%20world%2f" +} -run + +# run twice +client c2 -run + +varnish v1 -vcl+backend { + import blob; + + sub vcl_init { + new id = blob.blob(IDENTITY, + "The quick brown fox jumps over the lazy dog"); + new url = blob.blob(URL, "foo%3Abar%3abaz%3Aquux"); + new idempty = blob.blob(IDENTITY, ""); + new hexuc = blob.blob(HEX, "666F6F206261722062617A2071757578"); + new hexlc = blob.blob(HEX, "666f6f206261722062617a2071757578"); + } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.id2urluc = id.encode(URLUC); + set resp.http.id2urllc = id.encode(URLLC); + set resp.http.emptyurluc = idempty.encode(URLUC); + set resp.http.emptyurllc = idempty.encode(URLLC); + set resp.http.url = blob.encode(IDENTITY, url.get()); + set resp.http.hexuc2urluc = hexuc.encode(URLUC); + set resp.http.hexuc2urllc = hexuc.encode(URLLC); + set resp.http.hexlc2urluc = hexlc.encode(URLUC); + set resp.http.hexlc2urllc = hexlc.encode(URLLC); + set resp.http.url2id = url.encode(IDENTITY); + set resp.http.url2b64 = url.encode(BASE64); + set resp.http.url2b64url = url.encode(BASE64URL); + set resp.http.url2b64nopad = url.encode(BASE64URLNOPAD); + set resp.http.url2hexuc = url.encode(HEXUC); + set resp.http.url2hexlc = url.encode(HEXLC); + set resp.http.url2urluc = url.encode(URLUC); + set resp.http.url2urllc = url.encode(URLLC); + } +} + +client c3 { + txreq + rxresp + expect resp.http.id2urluc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.id2urllc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.emptyurluc == "" + expect resp.http.emptyurllc == "" + expect resp.http.hexuc2urluc == "foo%20bar%20baz%20quux" + expect resp.http.hexuc2urllc == "foo%20bar%20baz%20quux" + expect resp.http.hexlc2urluc == "foo%20bar%20baz%20quux" + expect resp.http.hexlc2urllc == "foo%20bar%20baz%20quux" + expect resp.http.url == "foo:bar:baz:quux" + expect resp.http.url2id == "foo:bar:baz:quux" + expect resp.http.url2b64 == "Zm9vOmJhcjpiYXo6cXV1eA==" + expect resp.http.url2b64url == "Zm9vOmJhcjpiYXo6cXV1eA==" + expect resp.http.url2b64nopad == "Zm9vOmJhcjpiYXo6cXV1eA" + expect resp.http.url2hexuc == "666F6F3A6261723A62617A3A71757578" + expect resp.http.url2hexlc == "666f6f3a6261723a62617a3a71757578" + expect resp.http.url2urluc == "foo%3Abar%3Abaz%3Aquux" + expect resp.http.url2urllc == "foo%3abar%3abaz%3aquux" +} -run + +# run twice +client c3 -run + +varnish v1 -errvcl {vmod blob error: cannot create blob err, illegal encoding beginning with "g"} { + import blob; + backend b { .host="${bad_ip}"; } + sub vcl_init { + new err = blob.blob(HEX, "g"); + } +} + +varnish v1 -errvcl {vmod blob error: cannot create blob bad64, illegal encoding beginning with "-_-_"} { + import blob; + backend b { .host="${bad_ip}"; } + sub vcl_init { + new bad64 = blob.blob(BASE64, "-_-_"); + } +} + +varnish v1 -errvcl {vmod blob error: cannot create blob badurl, illegal encoding beginning with "+/+/"} { + import blob; + backend b { .host="${bad_ip}"; } + sub vcl_init { + new badurl = blob.blob(BASE64URL, "+/+/"); + } +} + +varnish v1 -errvcl {vmod blob error: cannot create blob badpad, illegal encoding beginning with "YWI="} { + import blob; + backend b { .host="${bad_ip}"; } + sub vcl_init { + new badpad = blob.blob(BASE64URLNOPAD, "YWI="); + } +} + +varnish v1 -errvcl {vmod blob error: cannot create blob badurl, illegal encoding beginning with "%"} { + import blob; + backend b { .host="${bad_ip}"; } + sub vcl_init { + new badurl = blob.blob(URL, "%"); + } +} + +varnish v1 -errvcl {vmod blob error: cannot create blob badurl, illegal encoding beginning with "%2"} { + import blob; + backend b { .host="${bad_ip}"; } + sub vcl_init { + new badurl = blob.blob(URL, "%2"); + } +} + +varnish v1 -errvcl {vmod blob error: cannot create blob badurl, illegal encoding beginning with "%q"} { + import blob; + backend b { .host="${bad_ip}"; } + sub vcl_init { + new badurl = blob.blob(URL, "%q"); + } +} + +varnish v1 -errvcl {vmod blob error: cannot create blob badurl, illegal encoding beginning with "%2q"} { + import blob; + backend b { .host="${bad_ip}"; } + sub vcl_init { + new badurl = blob.blob(URL, "%2q"); + } +} diff --git a/bin/varnishtest/tests/m00044.vtc b/bin/varnishtest/tests/m00044.vtc new file mode 100644 index 0000000..20b6b51 --- /dev/null +++ b/bin/varnishtest/tests/m00044.vtc @@ -0,0 +1,164 @@ +varnishtest "VMOD blob test all examples from the vcc/rst" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { + import blob; + import std; + + ############################################################ + # top Usage section + sub vcl_init { + # Create blob objects from encodings such as base64 or hex. + new myblob = blob.blob(BASE64, "Zm9vYmFy"); + new yourblob = blob.blob(encoded="666F6F", decoding=HEX); + } + + sub vcl_deliver { + # The .get() method retrieves the BLOB from an object. + set resp.http.MyBlob-As-Hex + = blob.encode(blob=myblob.get(), encoding=HEXLC); + + # The .encode() method efficiently retrieves an encoding. + set resp.http.YourBlob-As-Base64 = yourblob.encode(BASE64); + + # decode() and encode() functions convert blobs to text and + # vice versa at runtime. + set resp.http.Base64-Encoded + = blob.encode(BASE64, + blob.decode(HEX, req.http.Hex-Encoded)); + } + + sub vcl_recv { + # transcode() converts from one encoding to another. + set req.http.Hex-Encoded + = blob.transcode(decoding=BASE64, encoding=HEXUC, encoded="YmF6"); + + # transcode() can replace other specific encoding/deconding + # vmods - e.g. vmod_urlcode + set req.url = blob.transcode(encoded=req.url, decoding=URL); + set req.http.url_urlcoded + = blob.transcode(encoded=req.url, encoding=URLLC); + } + # get output from recv + sub vcl_deliver { + set resp.http.url_urlcoded = req.http.url_urlcoded; + } + + ############################################################ + # IDENTITY + sub vcl_deliver { + set resp.http.Trunced-Foo1 + = blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + set resp.http.Trunced-Foo2 + = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); + } + + ############################################################ + # HEX + sub vcl_deliver { + set resp.http.First = "abc"; + set resp.http.Second = "def0"; + set resp.http.Hex-Decoded = blob.encode( + HEXLC, + blob.decode(HEX, resp.http.First + resp.http.Second)); + } + + ############################################################ + # encode - also contains decode examples + sub vcl_deliver { + set resp.http.encode1 + = blob.encode(HEXLC, blob.decode(BASE64, "Zm9vYmFyYmF6")); + + # same with named parameters + set resp.http.encode2 + = blob.encode(blob=blob.decode(encoded="Zm9vYmFyYmF6", + decoding=BASE64), + encoding=HEXLC); + + # convert blob to string + set resp.http.encode3 + = blob.encode(blob=blob.decode(encoded="foo")); + } + + ############################################################ + # transcode + sub vcl_deliver { + set resp.http.Hex2Base64-1 = blob.transcode(HEX, BASE64, "666f6f"); + + # same with named parameters + set resp.http.Hex2Base64-2 + = blob.transcode(encoded="666f6f", + encoding=BASE64, decoding=HEX); + + # replacement for urlcode.decode("foo%20bar") + set resp.http.urldecoded + = blob.transcode(encoded="foo%20bar", decoding=URL); + + # replacement for urlcode.encode("foo bar") + set resp.http.urlencoded + = blob.transcode(encoded="foo bar", encoding=URLLC); + } + + ############################################################ + # blob init + .get + .encode + sub vcl_init { + new theblob1 = blob.blob(BASE64, "YmxvYg=="); + + # same with named arguments + new theblob2 = blob.blob(encoded="YmxvYg==", decoding=BASE64); + + # string as a blob + new stringblob = blob.blob(encoded="bazz"); + } + sub vcl_deliver { + # .get + set resp.http.The-Blob1 = + blob.encode(blob=theblob1.get()); + + set resp.http.The-Blob2 = + blob.encode(blob=theblob2.get()); + + set resp.http.The-Stringblob = + blob.encode(blob=stringblob.get()); + + # .encode + + # blob as text + set resp.http.The-Blob = theblob1.encode(); + + # blob as base64 + set resp.http.The-Blob-b64 = theblob1.encode(BASE64); + } + +} -start + +client c1 { + txreq -url "/foo%20bar" + rxresp + expect resp.status == 200 + expect resp.http.MyBlob-As-Hex == "666f6f626172" + expect resp.http.YourBlob-As-Base64 == "Zm9v" + expect resp.http.Base64-Encoded == "YmF6" + expect resp.http.url_urlcoded == "%2ffoo%20bar" + expect resp.http.Trunced-Foo1 == "foo" + expect resp.http.Trunced-Foo2 == "foo" + expect resp.http.First == "abc" + expect resp.http.Second == "def0" + expect resp.http.Hex-Decoded == "0abcdef0" + expect resp.http.encode1 == "666f6f62617262617a" + expect resp.http.encode2 == "666f6f62617262617a" + expect resp.http.encode3 == "foo" + expect resp.http.Hex2Base64-1 == "Zm9v" + expect resp.http.Hex2Base64-2 == "Zm9v" + expect resp.http.urldecoded == "foo bar" + expect resp.http.urlencoded == "foo%20bar" + expect resp.http.The-Blob1 == "blob" + expect resp.http.The-Blob2 == "blob" + expect resp.http.The-Stringblob == "bazz" + expect resp.http.The-Blob == "blob" + expect resp.http.The-Blob-b64 == "YmxvYg==" +} -run diff --git a/bin/varnishtest/vmods.h b/bin/varnishtest/vmods.h index a994bef..e732468 100644 --- a/bin/varnishtest/vmods.h +++ b/bin/varnishtest/vmods.h @@ -32,3 +32,4 @@ VTC_VMOD(debug) VTC_VMOD(directors) VTC_VMOD(purge) VTC_VMOD(vtc) +VTC_VMOD(blob) diff --git a/configure.ac b/configure.ac index 2743139..c3a0984 100644 --- a/configure.ac +++ b/configure.ac @@ -734,6 +734,7 @@ AC_CONFIG_FILES([ lib/libvmod_directors/Makefile lib/libvmod_purge/Makefile lib/libvmod_vtc/Makefile + lib/libvmod_blob/Makefile man/Makefile varnishapi.pc varnishapi-uninstalled.pc diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 0de2f28..2d68243 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -213,6 +213,10 @@ reference/vmod_vtc.generated.rst: reference $(top_builddir)/lib/libvmod_vtc/vmod cp $(top_builddir)/lib/libvmod_vtc/vmod_vtc.rst $@ || true BUILT_SOURCES += reference/vmod_vtc.generated.rst +reference/vmod_blob.generated.rst: reference $(top_builddir)/lib/libvmod_blob/vmod_blob.rst + cp $(top_builddir)/lib/libvmod_blob/vmod_blob.rst $@ || true +BUILT_SOURCES += reference/vmod_blob.generated.rst + EXTRA_DIST += $(BUILT_SOURCES) MAINTAINERCLEANFILES = $(EXTRA_DIST) diff --git a/doc/sphinx/reference/index.rst b/doc/sphinx/reference/index.rst index e1164f8..39ccb81 100644 --- a/doc/sphinx/reference/index.rst +++ b/doc/sphinx/reference/index.rst @@ -24,6 +24,7 @@ The Varnish Reference Manual vmod_directors.generated.rst vmod_vtc.generated.rst vmod_purge.generated.rst + vmod_blob.generated.rst directors.rst varnish-counters.rst vsl.rst diff --git a/lib/Makefile.am b/lib/Makefile.am index 8981c65..4afd3d0 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -9,4 +9,5 @@ SUBDIRS = \ libvmod_std \ libvmod_directors \ libvmod_purge \ - libvmod_vtc + libvmod_vtc \ + libvmod_blob diff --git a/lib/libvmod_blob/Makefile.am b/lib/libvmod_blob/Makefile.am new file mode 100644 index 0000000..b0de15f --- /dev/null +++ b/lib/libvmod_blob/Makefile.am @@ -0,0 +1,53 @@ +# +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmod_srcdir = $(top_srcdir)/lib/libvmod_blob +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict +vmod_LTLIBRARIES = libvmod_blob.la + +libvmod_blob_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_blob_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ + @SAN_LDFLAGS@ + +libvmod_blob_la_SOURCES = \ + vmod_blob.c \ + vmod_blob.h \ + id.c \ + base64.h \ + base64.c \ + hex.h \ + hex.c \ + url.c \ + wb.h \ + wb.c \ + parse_encoding.h \ + parse_encoding.c + +nodist_libvmod_blob_la_SOURCES = \ + vcc_if.c \ + vcc_if.h + +# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build +$(libvmod_blob_la_OBJECTS):vcc_if.h + +vcc_if.h vmod_blob.rst vmod_blob.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc + +base64.o: base64.c base64.h + +EXTRA_DIST = vmod.vcc + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_blob.rst \ + $(builddir)/vmod_blob.man.rst diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c new file mode 100644 index 0000000..d06e323 --- /dev/null +++ b/lib/libvmod_blob/base64.c @@ -0,0 +1,192 @@ +/*- + * Copyright 2015-2016 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Authors: Nils Goroll + * Geoffrey Simmons + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "config.h" +#include +#include + +#include "base64.h" + +#include "vdef.h" +#include "vrt.h" +#include "vas.h" + +#define base64_l(l) (((l) << 2) / 3) + +size_t +base64nopad_encode_l(size_t l) +{ + return base64_l(l) + 4; +} + +size_t +base64_encode_l(size_t l) +{ + return (((base64_l(l)) + 3) & ~3) + 1; +} + +size_t +base64_decode_l(size_t l) +{ + return ((l) * 3) >> 2; +} + +static inline int +decode(char *restrict *restrict dest, char *restrict const buf, + const size_t buflen, unsigned u, const int n) +{ + char *d; + + if (n <= 1) { + errno = EINVAL; + return -1; + } + d = *dest; + for (int i = 0; i < n - 1; i++) { + if (d == buf + buflen) { + errno = ENOMEM; + return -1; + } + *d++ = (u >> 16) & 0xff; + u <<= 8; + } + *dest += d - *dest; + return 1; +} + +ssize_t +base64_encode(const enum encoding enc, char *restrict const buf, + const size_t buflen, const char *restrict const inbuf, + const size_t inlength) +{ + const struct b64_alphabet *alpha = &b64_alphabet[enc]; + char *p = buf; + const uint8_t *in = (const uint8_t *)inbuf; + const uint8_t * const end = in + inlength; + + AN(buf); + AN(alpha); + if (in == NULL || inlength == 0) + return 0; + + if ((enc == BASE64URLNOPAD && + buflen < base64nopad_encode_l(inlength)) || + (enc != BASE64URLNOPAD && + buflen < base64_encode_l(inlength))) { + errno = ENOMEM; + return -1; + } + + while (end - in >= 3) { + *p++ = alpha->b64[(in[0] >> 2) & 0x3f]; + *p++ = alpha->b64[((in[0] << 4) | (in[1] >> 4)) & 0x3f]; + *p++ = alpha->b64[((in[1] << 2) | (in[2] >> 6)) & 0x3f]; + *p++ = alpha->b64[in[2] & 0x3f]; + in += 3; + } + if (end - in > 0) { + *p++ = alpha->b64[(in[0] >> 2) & 0x3f]; + if (end - in == 1) { + *p++ = alpha->b64[(in[0] << 4) & 0x3f]; + if (alpha->padding) { + *p++ = alpha->padding; + *p++ = alpha->padding; + } + } + else { + *p++ = alpha->b64[((in[0] << 4) | (in[1] >> 4)) & 0x3f]; + *p++ = alpha->b64[(in[1] << 2) & 0x3f]; + if (alpha->padding) { + *p++ = alpha->padding; + } + } + } + assert(p >= buf && p - buf <= buflen); + return p - buf; +} + +ssize_t +base64_decode(const enum encoding dec, char *restrict const buf, + const size_t buflen, ssize_t inlen, + const char *const p, va_list ap) +{ + const struct b64_alphabet *alpha = &b64_alphabet[dec]; + char *dest = buf; + unsigned u = 0, term = 0; + int n = 0; + size_t len = SIZE_MAX; + + AN(buf); + AN(alpha); + + if (inlen >= 0) + len = inlen; + + for (const char *s = p; len > 0 && s != vrt_magic_string_end; + s = va_arg(ap, const char *)) { + if (s == NULL) + continue; + if (*s && term) { + errno = EINVAL; + return -1; + } + while (*s && len) { + while (n < 4) { + char b = alpha->i64[(unsigned) *s++]; + u <<= 6; + if (b == ILL) { + errno = EINVAL; + return -1; + } + n++; + if (b == PAD) { + term++; + continue; + } + u |= (unsigned) b; + if (--len == 0) + break; + if (!*s) + break; + } + if (n == 4) { + if (decode(&dest, buf, buflen, u, n-term) < 0) + return -1; + n = 0; + } + } + } + if (n) { + if (!alpha->padding) + u <<= 6 * (4 - n); + if (decode(&dest, buf, buflen, u, n-term) < 0) + return -1; + } + + return dest - buf; +} diff --git a/lib/libvmod_blob/base64.h b/lib/libvmod_blob/base64.h new file mode 100644 index 0000000..e5318bd --- /dev/null +++ b/lib/libvmod_blob/base64.h @@ -0,0 +1,156 @@ +/*- + * Copyright 2015-2016 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Authors: Nils Goroll + * Geoffrey Simmons + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "vmod_blob.h" + +#define ILL -1 +#define PAD -2 + +static const struct b64_alphabet { + const char b64[64]; + const int8_t i64[256]; + const int padding; +} b64_alphabet[] = { + [BASE64] = { + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789+/", + { + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, 62, ILL, ILL, ILL, 63, /* +, - */ + 52, 53, 54, 55, 56, 57, 58, 59, /* 0 - 7 */ + 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ + ILL, 0, 1, 2, 3, 4, 5, 6, /* A - G */ + 7, 8, 9, 10, 11, 12, 13, 14, /* H - O */ + 15, 16, 17, 18, 19, 20, 21, 22, /* P - W */ + 23, 24, 25, ILL, ILL, ILL, ILL, ILL, /* X, Y, Z */ + ILL, 26, 27, 28, 29, 30, 31, 32, /* a - g */ + 33, 34, 35, 36, 37, 38, 39, 40, /* h - o */ + 41, 42, 43, 44, 45, 46, 47, 48, /* p - w */ + 49, 50, 51, ILL, ILL, ILL, ILL, ILL, /* x, y, z */ + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + }, + '=' + }, + [BASE64URL] = { + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_", + { + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, 62, ILL, ILL, /* - */ + 52, 53, 54, 55, 56, 57, 58, 59, /* 0 - 7 */ + 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ + ILL, 0, 1, 2, 3, 4, 5, 6, /* A - G */ + 7, 8, 9, 10, 11, 12, 13, 14, /* H - O */ + 15, 16, 17, 18, 19, 20, 21, 22, /* P - W */ + 23, 24, 25, ILL, ILL, ILL, ILL, 63, /* X-Z, _ */ + ILL, 26, 27, 28, 29, 30, 31, 32, /* a - g */ + 33, 34, 35, 36, 37, 38, 39, 40, /* h - o */ + 41, 42, 43, 44, 45, 46, 47, 48, /* p - w */ + 49, 50, 51, ILL, ILL, ILL, ILL, ILL, /* x, y, z */ + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + }, + '=' + }, + [BASE64URLNOPAD] = { + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_", + { + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, 62, ILL, ILL, /* - */ + 52, 53, 54, 55, 56, 57, 58, 59, /* 0 - 7 */ + 60, 61, ILL, ILL, ILL, ILL, ILL, ILL, /* 8, 9 */ + ILL, 0, 1, 2, 3, 4, 5, 6, /* A - G */ + 7, 8, 9, 10, 11, 12, 13, 14, /* H - O */ + 15, 16, 17, 18, 19, 20, 21, 22, /* P - W */ + 23, 24, 25, ILL, ILL, ILL, ILL, 63, /* X-Z, _ */ + ILL, 26, 27, 28, 29, 30, 31, 32, /* a - g */ + 33, 34, 35, 36, 37, 38, 39, 40, /* h - o */ + 41, 42, 43, 44, 45, 46, 47, 48, /* p - w */ + 49, 50, 51, ILL, ILL, ILL, ILL, ILL, /* x, y, z */ + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + }, + 0 + }, +}; diff --git a/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c new file mode 100644 index 0000000..0195123 --- /dev/null +++ b/lib/libvmod_blob/hex.c @@ -0,0 +1,167 @@ +/*- + * Copyright 2016 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Authors: Nils Goroll + * Geoffrey Simmons + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "config.h" +#include +#include + +#include "vmod_blob.h" +#include "hex.h" + +#include "vdef.h" +#include "vrt.h" +#include "vas.h" + +const char hex_alphabet[][16] = { + "0123456789abcdef", + "0123456789ABCDEF" +}; + +/* + * Shift the ASCII table over so that it begins at '0', and replace the + * hex digits with their binary values. This fits all of the hex digits + * into 55 bytes (cacheline friendly). + */ +const uint8_t nibble[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, 10, 11, 12, + 13, 14, 15, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 10, + 11, 12, 13, 14, 15 +}; + +size_t +hex_encode_l(size_t l) +{ + return ((l) << 1) + 1; +} + +size_t +hex_decode_l(size_t l) +{ + return ((l) + 1) >> 1; +} + +static inline char +hex2byte(const unsigned char hi, const unsigned char lo) +{ + return (nibble[hi - '0'] << 4) | nibble[lo - '0']; +} + +ssize_t +hex_encode(const enum encoding enc, char *restrict const buf, + const size_t buflen, const char *restrict const in, + const size_t inlen) +{ + char *p = buf; + const char *alphabet = hex_alphabet[0]; + + AN(buf); + assert(enc == HEXUC || enc == HEXLC); + if (in == NULL || inlen == 0) + return 0; + if (buflen < hex_encode_l(inlen)) + return -1; + + if (enc != HEXLC) + alphabet = hex_alphabet[1]; + + for (int i = 0; i < inlen; i++) { + *p++ = alphabet[(in[i] & 0xf0) >> 4]; + *p++ = alphabet[in[i] & 0x0f]; + } + + return p - buf; +} + +ssize_t +hex_decode(const enum encoding dec, char *restrict const buf, + const size_t buflen, ssize_t n, + const char *restrict const p, va_list ap) +{ + char *dest = buf; + unsigned char extranib = 0; + ssize_t len = 0; + va_list ap2; + + AN(buf); + assert(dec == HEX); + + va_copy(ap2, ap); + for (const char *s = p; s != vrt_magic_string_end; + s = va_arg(ap2, const char *)) { + const char *b = s; + if (s != NULL) + while (*s) + if (!isxdigit(*s++)) { + len = -1; + break; + } + if (len == -1) + break; + len += s - b; + } + va_end(ap2); + + if (len == 0) + return 0; + if (len == -1) { + errno = EINVAL; + return -1; + } + if (n != -1 && len > n) + len = n; + + if ((len+1) >> 1 > buflen) { + errno = ENOMEM; + return -1; + } + if (len & 1) { + extranib = '0'; + len++; + } + + for (const char *s = p; len > 0 && s != vrt_magic_string_end; + s = va_arg(ap, const char *)) { + if (s == NULL || *s == '\0') + continue; + if (extranib) { + *dest++ = hex2byte(extranib, *s++); + len -= 2; + } + while (len >= 2 && *s && *(s+1)) { + *dest++ = hex2byte(*s, *(s+1)); + s += 2; + len -= 2; + } + extranib = *s; + } + assert(dest <= buf + buflen); + return dest - buf; +} diff --git a/lib/libvmod_blob/hex.h b/lib/libvmod_blob/hex.h new file mode 100644 index 0000000..9c0e344 --- /dev/null +++ b/lib/libvmod_blob/hex.h @@ -0,0 +1,37 @@ +/*- + * Copyright 2016 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Authors: Nils Goroll + * Geoffrey Simmons + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#define ILL (0xff) + +/* These are defined in hex.c */ + +extern const char hex_alphabet[][16]; + +extern const uint8_t nibble[]; diff --git a/lib/libvmod_blob/id.c b/lib/libvmod_blob/id.c new file mode 100644 index 0000000..3a32061 --- /dev/null +++ b/lib/libvmod_blob/id.c @@ -0,0 +1,102 @@ +/*- + * Copyright 2015-2016 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Authors: Nils Goroll + * Geoffrey Simmons + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "config.h" +#include +#include +#include + +#include "vmod_blob.h" + +#include "vdef.h" +#include "vrt.h" +#include "vas.h" + +size_t +id_encode_l(size_t l) +{ + return l + 1; +} + +size_t +id_decode_l(size_t l) +{ + return l; +} + +ssize_t +id_encode(const enum encoding enc, char *restrict const buf, + const size_t buflen, const char *restrict const in, + const size_t inlen) +{ + (void) enc; + AN(buf); + + if (buflen < inlen + 1) + return -1; + if (in == NULL || inlen == 0) + return 0; + + memcpy(buf, in, inlen); + return inlen; +} + +ssize_t +id_decode(const enum encoding enc, + char *restrict const buf, const size_t buflen, + ssize_t n, const char *restrict const p, va_list ap) +{ + char *dest = buf; + size_t outlen = 0, c = SIZE_MAX; + + (void) enc; + AN(buf); + + if (n >= 0) + c = n; + + for (const char *s = p; c > 0 && s != vrt_magic_string_end; + s = va_arg(ap, const char *)) { + size_t len; + + if (s == NULL || *s == '\0') + continue; + len = strlen(s); + if (len > c) + len = c; + c -= len; + if ((outlen += len) > buflen) { + errno = ENOMEM; + return -1; + } + memcpy(dest, s, len); + dest += len; + } + + return outlen; +} diff --git a/lib/libvmod_blob/parse_encoding.c b/lib/libvmod_blob/parse_encoding.c new file mode 100644 index 0000000..ec64b28 --- /dev/null +++ b/lib/libvmod_blob/parse_encoding.c @@ -0,0 +1,179 @@ +/* + * for the time being, this code is auto-generated outside the varnishd source + * tree, see + * https://code.uplex.de/uplex-varnish/libvmod-blobcode/blob/master/src/gen_enum_parse.pl + * + * TODO: integrate in vmodtool.py or replace with something else + * cf. the same TODO for the shard director in libvmod_directors + */ + +#include "parse_encoding.h" +#define term(c) ((c) == '\0') + +enum encoding +parse_encoding (const char *m) { + int p; + enum encoding r; + + switch (m[0]) { + case 'B': goto _0B; // BASE64, BASE64URL, BASE64URLNOPAD + case 'H': goto _0H; // HEX, HEXLC, HEXUC + case 'I': goto _0I; // IDENTITY + case 'U': goto _0U; // URL, URLLC, URLUC + default: goto invalid; + } + _0B: + switch (m[1]) { + case 'A': goto _1BA; // BASE64, BASE64URL, BASE64URLNOPAD + default: goto invalid; + } + _1BA: + switch (m[2]) { + case 'S': goto _2BAS; // BASE64, BASE64URL, BASE64URLNOPAD + default: goto invalid; + } + _2BAS: + switch (m[3]) { + case 'E': goto _3BASE; // BASE64, BASE64URL, BASE64URLNOPAD + default: goto invalid; + } + _3BASE: + switch (m[4]) { + case '6': goto _4BASE6; // BASE64, BASE64URL, BASE64URLNOPAD + default: goto invalid; + } + _4BASE6: + switch (m[5]) { + case '4': goto _5BASE64; // BASE64, BASE64URL, BASE64URLNOPAD + default: goto invalid; + } + _5BASE64: + //BASE64 + if (term(m[6])) { + r = BASE64; + p = 6; + goto ok; + } + switch (m[6]) { + case 'U': goto _6BASE64U; // BASE64URL, BASE64URLNOPAD + default: goto invalid; + } + _6BASE64U: + switch (m[7]) { + case 'R': goto _7BASE64UR; // BASE64URL, BASE64URLNOPAD + default: goto invalid; + } + _7BASE64UR: + switch (m[8]) { + case 'L': goto _8BASE64URL; // BASE64URL, BASE64URLNOPAD + default: goto invalid; + } + _8BASE64URL: + //BASE64URL + if (term(m[9])) { + r = BASE64URL; + p = 9; + goto ok; + } + switch (m[9]) { + case 'N': goto _9BASE64URLN; // BASE64URLNOPAD + default: goto invalid; + } + _9BASE64URLN: + //BASE64URLNOPAD + if ((m[10] == 'O') && (m[11] == 'P') && (m[12] == 'A') && (m[13] == 'D') && (term(m[14]))) { + r = BASE64URLNOPAD; + p = 14; + goto ok; + } + goto invalid; + _0H: + switch (m[1]) { + case 'E': goto _1HE; // HEX, HEXLC, HEXUC + default: goto invalid; + } + _1HE: + switch (m[2]) { + case 'X': goto _2HEX; // HEX, HEXLC, HEXUC + default: goto invalid; + } + _2HEX: + //HEX + if (term(m[3])) { + r = HEX; + p = 3; + goto ok; + } + switch (m[3]) { + case 'L': goto _3HEXL; // HEXLC + case 'U': goto _3HEXU; // HEXUC + default: goto invalid; + } + _3HEXL: + //HEXLC + if ((m[4] == 'C') && (term(m[5]))) { + r = HEXLC; + p = 5; + goto ok; + } + goto invalid; + _3HEXU: + //HEXUC + if ((m[4] == 'C') && (term(m[5]))) { + r = HEXUC; + p = 5; + goto ok; + } + goto invalid; + _0I: + //IDENTITY + if ((m[1] == 'D') && (m[2] == 'E') && (m[3] == 'N') && (m[4] == 'T') && (m[5] == 'I') && (m[6] == 'T') && (m[7] == 'Y') && (term(m[8]))) { + r = IDENTITY; + p = 8; + goto ok; + } + goto invalid; + _0U: + switch (m[1]) { + case 'R': goto _1UR; // URL, URLLC, URLUC + default: goto invalid; + } + _1UR: + switch (m[2]) { + case 'L': goto _2URL; // URL, URLLC, URLUC + default: goto invalid; + } + _2URL: + //URL + if (term(m[3])) { + r = URL; + p = 3; + goto ok; + } + switch (m[3]) { + case 'L': goto _3URLL; // URLLC + case 'U': goto _3URLU; // URLUC + default: goto invalid; + } + _3URLL: + //URLLC + if ((m[4] == 'C') && (term(m[5]))) { + r = URLLC; + p = 5; + goto ok; + } + goto invalid; + _3URLU: + //URLUC + if ((m[4] == 'C') && (term(m[5]))) { + r = URLUC; + p = 5; + goto ok; + } + goto invalid; + ok: + return r; + invalid: + return _INVALID; + (void)p; +} diff --git a/lib/libvmod_blob/parse_encoding.h b/lib/libvmod_blob/parse_encoding.h new file mode 100644 index 0000000..6d6068b --- /dev/null +++ b/lib/libvmod_blob/parse_encoding.h @@ -0,0 +1,26 @@ +/* + * for the time being, this code is auto-generated outside the varnishd source + * tree, see + * https://code.uplex.de/uplex-varnish/libvmod-blobcode/blob/master/src/gen_enum_parse.pl + * + * TODO: integrate in vmodtool.py or replace with something else + * cf. the same TODO for the shard director in libvmod_directors + */ + +enum encoding { + _INVALID = 0, + IDENTITY, + BASE64, + BASE64URL, + BASE64URLNOPAD, + HEX, + HEXUC, + HEXLC, + URL, + URLLC, + URLUC, + __MAX_ENCODING +}; + +enum encoding parse_encoding (const char *); + diff --git a/lib/libvmod_blob/url.c b/lib/libvmod_blob/url.c new file mode 100644 index 0000000..7368030 --- /dev/null +++ b/lib/libvmod_blob/url.c @@ -0,0 +1,187 @@ +/*- + * Copyright 2015-2016 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Authors: Nils Goroll + * Geoffrey Simmons + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "config.h" +#include + +#include "vmod_blob.h" +#include "hex.h" + +#include "vdef.h" +#include "vrt.h" +#include "vas.h" + +/* Decoder states */ +enum state_e { + NORMAL, + PERCENT, /* just read '%' */ + FIRSTNIB, /* just read the first nibble after '%' */ +}; + +size_t +url_encode_l(size_t l) +{ + return (l * 3) + 1; +} + +size_t +url_decode_l(size_t l) +{ + return l; +} + +/* + * Bitmap of unreserved characters according to RFC 3986 section 2.3 + * (locale-independent and cacheline friendly) + */ +static const uint8_t unreserved[] = { + 0x0, 0x0, 0x0, 0x0, 0x0, 0x60, 0xff, 0x3, + 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 +}; + +static inline int +isunreserved(const uint8_t c) +{ + return (unreserved[c >> 3] & (1 << (c & 7))); +} + +static inline int +isoutofrange(const uint8_t c) +{ + return (c < '0' || c > 'f'); +} + +ssize_t +url_encode(const enum encoding enc, char *restrict const buf, + const size_t buflen, const char *restrict const in, + const size_t inlen) +{ + char *p = buf; + const char * const end = buf + buflen; + const char *alphabet = hex_alphabet[0]; + + AN(buf); + assert(enc == URLUC || enc == URLLC); + if (in == NULL || inlen == 0) + return 0; + + if (enc != URLLC) + alphabet = hex_alphabet[1]; + + for (int i = 0; i < inlen; i++) { + if (isunreserved(in[i])) { + if (p == end) + return -1; + *p++ = in[i]; + } + else { + if (p + 3 > end) + return -1; + *p++ = '%'; + *p++ = alphabet[(in[i] & 0xf0) >> 4]; + *p++ = alphabet[in[i] & 0x0f]; + } + } + + return p - buf; +} + +ssize_t +url_decode(const enum encoding dec, char *restrict const buf, + const size_t buflen, ssize_t n, const char *restrict const p, + va_list ap) +{ + char *dest = buf; + const char * const end = buf + buflen; + size_t len = SIZE_MAX; + uint8_t nib = 0; + enum state_e state = NORMAL; + + AN(buf); + assert(dec == URL); + + if (n >= 0 && n < len) + len = n; + + for (const char *s = p; len > 0 && s != vrt_magic_string_end; + s = va_arg(ap, const char *)) { + if (s == NULL || *s == '\0') + continue; + while (*s && len) { + uint8_t nib2; + + switch(state) { + case NORMAL: + if (*s == '%') + state = PERCENT; + else { + if (dest == end) { + errno = ENOMEM; + return -1; + } + *dest++ = *s; + } + break; + case PERCENT: + if (isoutofrange(*s) + || (nib = nibble[*s - '0']) == ILL) { + errno = EINVAL; + return -1; + } + state = FIRSTNIB; + break; + case FIRSTNIB: + if (dest == end) { + errno = ENOMEM; + return -1; + } + if (isoutofrange(*s) + || (nib2 = nibble[*s - '0']) == ILL) { + errno = EINVAL; + return -1; + } + *dest++ = (nib << 4) | nib2; + nib = 0; + state = NORMAL; + break; + default: + WRONG("illegal URL decode state"); + } + s++; + len--; + } + } + if (state != NORMAL) { + errno = EINVAL; + return -1; + } + assert(dest <= end); + return dest - buf; +} diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc new file mode 100644 index 0000000..826a6c9 --- /dev/null +++ b/lib/libvmod_blob/vmod.vcc @@ -0,0 +1,376 @@ +#- +# This document is licensed under the same conditions as Varnish itself. +# See LICENSE for details. +# +# Authors: Nils Goroll +# Geoffrey Simmons +# + +$Module blob 3 utilities for the VCL blob type + +:: + + STRING blob.encode(ENUM encoding, BLOB blob) + BLOB blob.decode(ENUM decoding, STRING_LIST encoded) + BLOB blob.decode_n(INT n, ENUM decoding, STRING_LIST encoded) + STRING blob.transcode(ENUM decoding, ENUM encoding, + STRING_LIST encoded) + STRING blob.transcode_n(INT n, ENUM decoding, ENUM encoding, + STRING_LIST encoded) + + new OBJ = blob.blob(ENUM decoding, STRING_LIST encoded) + BLOB .get() + STRING .encode(ENUM encoding) + +DESCRIPTION +=========== + +This VMOD provides utility functions and an object for the VCL data +type BLOB, which may contain arbitrary data of any length. + +Examples:: + + sub vcl_init { + # Create blob objects from encodings such as base64 or hex. + new myblob = blob.blob(BASE64, "Zm9vYmFy"); + new yourblob = blob.blob(encoded="666F6F", decoding=HEX); + } + + sub vcl_deliver { + # The .get() method retrieves the BLOB from an object. + set resp.http.MyBlob-As-Hex + = blob.encode(blob=myblob.get(), encoding=HEXLC); + + # The .encode() method efficiently retrieves an encoding. + set resp.http.YourBlob-As-Base64 = yourblob.encode(BASE64); + + # decode() and encode() functions convert blobs to text and + # vice versa at runtime. + set resp.http.Base64-Encoded + = blob.encode(BASE64, + blob.decode(HEX, req.http.Hex-Encoded)); + } + + sub vcl_recv { + # transcode() converts from one encoding to another. + set req.http.Hex-Encoded + = blob.transcode(decoding=BASE64, encoding=HEXUC, + encoded="YmF6"); + + # transcode() from URL to IDENTITY effects a URL decode. + set req.url = blob.transcode(encoded=req.url, decoding=URL); + + # transcode() from IDENTITY to URL effects a URL encode. + set req.http.url_urlcoded + = blob.transcode(encoded=req.url, encoding=URLLC); + } + +ENCODING SCHEMES +================ + +Binary-to-text encoding schemes are specified by ENUMs in the VMOD's +constructor, methods and functions. Decodings convert a (possibly +concatenated) string into a blob, while encodings convert a blob into +a string. + +ENUM values for a decoding can be one of: + +* ``IDENTITY`` +* ``BASE64`` +* ``BASE64URL`` +* ``BASE64URLNOPAD`` +* ``HEX`` +* ``URL`` + +An encoding can be one of: + +* ``IDENTITY`` +* ``BASE64`` +* ``BASE64URL`` +* ``BASE64URLNOPAD`` +* ``HEXUC`` +* ``HEXLC`` +* ``URLUC`` +* ``URLLC`` + +Empty strings are decoded into a "null blob" (of length 0), +and conversely a null blob is encoded as the empty string. + +IDENTITY +-------- + +The simplest encoding converts between the BLOB and STRING data types, +leaving the contents byte-identical. + +Note that a BLOB may contain a null byte at any position before its +end; if such a BLOB is decoded with IDENTITY, the resulting STRING +will have a null byte at that position. Since VCL strings, like C +strings, are represented with a terminating null byte, the string will +be truncated, appearing to contain less data than the original +blob. For example:: + + # Decode from the hex encoding for "foo\0bar". + # The header will be seen as "foo". + set resp.http.Trunced-Foo1 + = blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + +IDENTITY is the default encoding and decoding. So the above can also +be written as:: + + # Decode from the hex encoding for "foo\0bar". + # The header will be seen as "foo". + set resp.http.Trunced-Foo2 + = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); + +BASE64* +------- + +The base64 encoding schemes use 4 characters to encode 3 bytes. There +are no newlines or maximal line lengths -- whitespace is not +permitted. + +The ``BASE64`` encoding uses the alphanumeric characters, ``+`` and +``/``; and encoded strings are padded with the ``=`` character so that +their length is always a multiple of four. + +The ``BASE64URL`` encoding also uses the alphanumeric characters, but +``-`` and ``_`` instead of ``+`` and ``/``, so that an encoded string +can be used safely in a URL. This scheme also uses the padding +character ``=``. + +The ``BASE64URLNOPAD`` encoding uses the same alphabet as +``BASE6URL``, but leaves out the padding. Thus the length of an +encoding with this scheme is not necessarily a mutltiple of four. + +HEX* +---- + +The ``HEX`` decoding converts a hex string, which may contain upper- +or lowercase characters for hex digits ``A`` through ``f``, into a +blob. The ``HEXUC`` or ``HEXLC`` encodings convert a blob into a hex +string with upper- and lowercase digits, respectively. A prefix such +as ``0x`` is not used for any of these schemes. + +If a hex string to be decoded has an odd number of digits, it is +decoded as if a ``0`` is prepended to it; that is, the first digit is +interpreted as representing the least significant nibble of the first +byte. For example:: + + # The concatenated string is "abcdef0", and is decoded as "0abcdef0". + set resp.http.First = "abc"; + set resp.http.Second = "def0"; + set resp.http.Hex-Decoded + = blob.encode(HEXLC, blob.decode(HEX, + resp.http.First + resp.http.Second)); + +URL* +---- + +The ``URL`` decoding replaces any ``%<2-hex-digits>`` substrings with +the binary value of the hexadecimal number after the % sign. + +The ``URLLC`` and ``URLUC`` encodings implement "percent encoding" as per +RFC3986, the hexadecimal characters A-F being output in lower- and +uppercase, respectively. + +$Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEX, URL} decoding="IDENTITY", STRING_LIST encoded) + +Returns the BLOB derived from the string ``encoded`` according to the +scheme specified by ``decoding``. + +``decoding`` defaults to IDENTITY + +Example:: + + blob.decode(BASE64, "Zm9vYmFyYmF6"); + + # same with named parameters + blob.decode(encoded="Zm9vYmFyYmF6", decoding=BASE64); + + # convert string to blob + blob.decode(encoded="foo"); + +$Function BLOB decode_n(INT n, + ENUM {IDENTITY, BASE64, BASE64URL, + BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", + STRING_LIST encoded) + +Same as ``decode()``, but only decode the first ``n`` characters of +the encoded string. If ``n`` is greater than the length of the string, +then return the same result as ``decode()``. + +$Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + BLOB blob) + +Returns a string representation of the BLOB ``blob`` as specifed by +``encoding``. + +``encoding`` defaults to IDENTITY + +Example:: + + set resp.http.encode1 + = blob.encode(HEXLC, blob.decode(BASE64, "Zm9vYmFyYmF6")); + + # same with named parameters + set resp.http.encode2 + = blob.encode(blob=blob.decode(encoded="Zm9vYmFyYmF6", + decoding=BASE64), + encoding=HEXLC); + + # convert blob to string + set resp.http.encode3 + = blob.encode(blob=blob.decode(encoded="foo")); + +$Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEX, URL} decoding="IDENTITY", + ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + STRING_LIST encoded) + +Translates from one encoding to another, by first decoding the string +``encoded`` according to the scheme ``decoding``, and then returning +the encoding of the resulting blob according to the scheme +``encoding``. + +``decoding`` and ``encoding`` default to IDENTITY + +Example:: + + set resp.http.Hex2Base64-1 = blob.transcode(HEX, BASE64, "666f6f"); + + # same with named parameters + set resp.http.Hex2Base64-2 + = blob.transcode(encoded="666f6f", + encoding=BASE64, decoding=HEX); + + # URL decode -- recall that IDENTITY is the default encoding. + set resp.http.urldecoded + = blob.transcode(encoded="foo%20bar", decoding=URLLC); + + # URL encode + set resp.http.urlencoded + = blob.transcode(encoded="foo bar", encoding=URL); + +$Function STRING transcode_n(INT n, + ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEX, URL} decoding="IDENTITY", + ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + STRING_LIST encoded) + +Same as ``transcode()``, but only from the first ``n`` characters of +the encoded string. + +$Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, + URL} decoding="IDENTITY", + STRING_LIST encoded) + +Creates an object that contains the BLOB derived from the string +``encoded`` according to the scheme ``decoding``. + +Example:: + + new theblob1 = blob.blob(BASE64, "YmxvYg=="); + + # same with named arguments + new theblob2 = blob.blob(encoded="YmxvYg==", decoding=BASE64); + + # string as a blob + new stringblob = blob.blob(encoded="bazz"); + +$Method BLOB .get() + +Returns the BLOB created by the constructor. + +Example:: + + set resp.http.The-Blob1 = + blob.encode(blob=theblob1.get()); + + set resp.http.The-Blob2 = + blob.encode(blob=theblob2.get()); + + set resp.http.The-Stringblob = + blob.encode(blob=stringblob.get()); + +$Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXUC, + HEXLC, URLUC, URLLC} encoding="IDENTITY") + +Returns an encoding of BLOB created by the constructor, according to +the scheme ``encoding``. + +Example:: + + # blob as text + set resp.http.The-Blob = theblob1.encode(); + + # blob as base64 + set resp.http.The-Blob-b64 = theblob1.encode(BASE64); + +For any ``blob`` object and encoding ``ENC``, encodings via the ``.encode()`` +method and the ``encode()`` function are equal:: + + # Always true: + blob.encode(ENC, blob.get()) == blob.encode(ENC) + +But the object method is more efficient -- the encoding is computed +once and cached (with allocation in heap memory), and the cached +encoding is retrieved on every subsequent call. The ``encode()`` +function computes the encoding on every call, allocating space for the +string in Varnish workspaces. + +So if the data in a BLOB are fixed at VCL initialization time, so that +its encodings will always be the same, it is better to create a +``blob`` object. The VMOD's functions should be used for data that are +not known until runtime. + +ERRORS +====== + +The encoders and decoders may fail if there is insufficient space to +create the new blob or string. Decoders may also fail if the encoded +string is an illegal format for the decoding scheme. + +If any of the VMOD's methods, functions or constructor fail, then VCL +failure is invoked, just as if ``return(fail)`` had been called in the +VCL source. This means that: + +* If the ``blob`` object constructor fails, or if any methods or + functions fail during ``vcl_init``, then the VCL program will fail + to load, and the VCC compiler will emit an error message. + +* If a method or function fails in any other VCL subroutine besides + ``vcl_synth``, then control is directed to ``vcl_synth``. The + response status is set to 503 with the reason string ``"VCL + failed"``, and an error message will be written to the Varnish log + using the tag ``VCL_Error``. + +* If the failure occurs during ``vcl_synth``, then ``vcl_synth`` is + aborted. The response line ``"503 VCL failed"`` is returned, and + the ``VCL_Error`` message is written to the log. + +LIMITATIONS +=========== + +The VMOD allocates memory in various ways for new blobs and +strings. The ``blob`` object and its methods allocate memory from the +heap, and hence they are only limited by available virtual memory. + +The ``encode()``, ``decode()`` and ``transcode()`` functions allocate +Varnish workspace. If these functions are failing, as indicated by +"out of space" messages in the Varnish log (with the ``VCL_Error`` +tag), then you will need to increase the varnishd parameters +``workspace_client`` and/or ``workspace_backend``. + +The ``transcode()`` function also allocates space on the stack for a +temporary BLOB. If this function causes stack overflow, you may need +to increase the varnishd parameter ``thread_pool_stack``. + +SEE ALSO +======== + +* :ref:`varnishd(1)` +* :ref:`vcl(7)` diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c new file mode 100644 index 0000000..7d0ad92 --- /dev/null +++ b/lib/libvmod_blob/vmod_blob.c @@ -0,0 +1,609 @@ +/*- + * Copyright 2015-2017 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Authors: Nils Goroll + * Geoffrey Simmons + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "config.h" +#include +#include + +#include "vcl.h" +#include "vdef.h" +#include "vrt.h" + +#include "vcc_if.h" +#include "vmod_blob.h" +#include "wb.h" + +struct vmod_blob_blob { + unsigned magic; +#define VMOD_BLOB_MAGIC 0xfade4fa9 + struct vmod_priv blob; + const char *encoding[__MAX_ENCODING]; + pthread_mutex_t lock; +}; + +#define B64_FUNCS \ + .decode_l = base64_decode_l, \ + .decode = base64_decode, \ + .encode = base64_encode + +#define HEX_FUNCS \ + .decode_l = hex_decode_l, \ + .decode = hex_decode, \ + .encode_l = hex_encode_l, \ + .encode = hex_encode + +#define URL_FUNCS \ + .decode_l = url_decode_l, \ + .decode = url_decode, \ + .encode_l = url_encode_l, \ + .encode = url_encode + +static const struct vmod_blob_fptr { + len_f *const decode_l; + decode_f *const decode; + len_f *const encode_l; + encode_f *const encode; +} func[__MAX_ENCODING] = { + [_INVALID] = { + /* make implicit null init explicit for clarity */ + .decode_l = NULL, + .decode = NULL, + .encode_l = NULL, + .encode = NULL + }, + [IDENTITY] = { + .decode_l = id_decode_l, + .decode = id_decode, + .encode_l = id_encode_l, + .encode = id_encode + }, + [BASE64] = { + B64_FUNCS, + .encode_l = base64_encode_l + }, + [BASE64URL] = { + B64_FUNCS, + .encode_l = base64_encode_l + }, + [BASE64URLNOPAD] = { + B64_FUNCS, + .encode_l = base64nopad_encode_l + }, + [HEX] = { + HEX_FUNCS + }, + [HEXUC] = { + HEX_FUNCS + }, + [HEXLC] = { + HEX_FUNCS + }, + [URL] = { + URL_FUNCS + }, + [URLUC] = { + URL_FUNCS + }, + [URLLC] = { + URL_FUNCS + } +}; + +#undef B64_FUNCS +#undef HEX_FUNCS +#undef URL_FUNCS + +#define ERR(ctx, msg) \ + VRT_fail((ctx), "vmod blob error: " msg) + +#define VERR(ctx, fmt, ...) \ + VRT_fail((ctx), "vmod blob error: " fmt, __VA_ARGS__) + +#define ERRINVAL(ctx, enc) \ + VERR((ctx), "cannot decode, illegal encoding beginning with \"%s\"", \ + (enc)) + +#define VERRNOMEM(ctx, fmt, ...) \ + VERR((ctx), fmt ", out of space", __VA_ARGS__) + +#define ERRNOMEM(ctx, msg) \ + ERR((ctx), msg ", out of space") + +static char empty[1] = { '\0' }; + +static const struct vmod_priv null_blob[1] = +{ + { + .priv = empty, + .len = 0, + .free = NULL + } +}; + +static inline size_t +decode_l_va(enum encoding dec, const char * const p, va_list ap) +{ + size_t len = 0; + + AENC(dec); + + for (const char *s = p; s != vrt_magic_string_end; + s = va_arg(ap, const char *)) + if (s != NULL && *s != '\0') + len += strlen(s); + + return(func[dec].decode_l(len)); +} + +static void +err_decode(VRT_CTX, const char *enc) +{ + switch(errno) { + case EINVAL: + ERRINVAL(ctx, enc); + break; + case ENOMEM: + ERRNOMEM(ctx, "cannot decode"); + break; + default: + WRONG("invalid errno"); + } +} + +/* Objects */ + +VCL_VOID __match_proto__(td_blob_blob__init) +vmod_blob__init(VRT_CTX, struct vmod_blob_blob **blobp, const char *vcl_name, + VCL_ENUM decs, const char *p, ...) +{ + struct vmod_blob_blob *b; + enum encoding dec = parse_encoding(decs); + va_list ap; + ssize_t len; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(blobp); + AZ(*blobp); + AN(vcl_name); + AENC(dec); + + ALLOC_OBJ(b, VMOD_BLOB_MAGIC); + AN(b); + *blobp = b; + b->blob.free = NULL; + AZ(pthread_mutex_init(&b->lock, NULL)); + + va_start(ap, p); + len = decode_l_va(dec, p, ap); + va_end(ap); + if (len == 0) { + b->blob.len = 0; + b->blob.priv = NULL; + return; + } + assert(len > 0); + + b->blob.priv = malloc(len); + if (b->blob.priv == NULL) { + VERRNOMEM(ctx, "cannot create blob %s", vcl_name); + return; + } + + va_start(ap, p); + errno = 0; + len = func[dec].decode(dec, b->blob.priv, len, -1, p, ap); + va_end(ap); + + if (len == -1) { + assert(errno == EINVAL); + free(b->blob.priv); + b->blob.priv = NULL; + VERR(ctx, "cannot create blob %s, illegal encoding beginning " + "with \"%s\"", vcl_name, p); + return; + } + if (len == 0) { + b->blob.len = 0; + free(b->blob.priv); + b->blob.priv = NULL; + return; + } + b->blob.len = len; +} + +VCL_BLOB __match_proto__(td_blob_blob_get) +vmod_blob_get(VRT_CTX, struct vmod_blob_blob *b) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(b, VMOD_BLOB_MAGIC); + return &b->blob; +} + +VCL_STRING +vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs) +{ + enum encoding enc = parse_encoding(encs); + AENC(enc); + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(b, VMOD_BLOB_MAGIC); + + if (b->blob.len == 0) + return ""; + + if (b->encoding[enc] == NULL) { + AZ(pthread_mutex_lock(&b->lock)); + if (b->encoding[enc] == NULL) { + ssize_t len = func[enc].encode_l(b->blob.len); + + assert(len >= 0); + if (len == 0) + b->encoding[enc] = ""; + else { + b->encoding[enc] = malloc(len); + if (b->encoding[enc] == NULL) + ERRNOMEM(ctx, "cannot encode"); + else { + const char *s = b->encoding[enc]; + len = + func[enc].encode( + enc, (void *) s, len, + b->blob.priv, + b->blob.len); + assert(len >= 0); + if (len == 0) { + free((void *) s); + b->encoding[enc] = ""; + } + else + *((char *)s + len) = '\0'; + } + } + } + AZ(pthread_mutex_unlock(&b->lock)); + } + return b->encoding[enc]; +} + +VCL_VOID __match_proto__(td_blob_blob__fini) +vmod_blob__fini(struct vmod_blob_blob **blobp) +{ + struct vmod_blob_blob *b; + + if (blobp == NULL || *blobp == NULL) + return; + + b = *blobp; + *blobp = NULL; + CHECK_OBJ(b, VMOD_BLOB_MAGIC); + if (b->blob.priv != NULL) { + free(b->blob.priv); + b->blob.priv = NULL; + } + for (int i = 0; i < __MAX_ENCODING; i++) + if (b->encoding[i] != NULL && b->encoding[i][0] != '\0') { + free((void *) b->encoding[i]); + b->encoding[i] = NULL; + } + AZ(pthread_mutex_destroy(&b->lock)); + FREE_OBJ(b); +} + +/* Functions */ + +static inline const char * +find_nonempty_va(const char *restrict *p, va_list ap) +{ + const char *q; + + /* find first non-empty vararg */ + for (; *p == vrt_magic_string_end || *p == NULL || **p == '\0'; + *p = va_arg(ap, const char *)) + if (*p == vrt_magic_string_end) + return (vrt_magic_string_end); + + /* find next non-empty vararg */ + for (q = va_arg(ap, const char *); + q != vrt_magic_string_end && (q == NULL || *q == '\0'); + q = va_arg(ap, const char *)) + ; + + return (q); +} + +/* + * special case: we can avoid copying for identity decode if we need to + * deal with a single vararg only - in which case we just have the blob + * point to the input string + */ +static VCL_BLOB +decode_id_inplace(struct vmod_priv *b, VCL_INT n, const char *restrict p, + va_list ap) { + const char *q; + int l; + + if (n == 0) + return null_blob; + + q = find_nonempty_va(&p, ap); + + if (p == vrt_magic_string_end) + return null_blob; + + if (q == vrt_magic_string_end) { + /* can use in-place decode */ + l = strlen(p); + if (n > 0 && n < l) + l = n; + b->priv = (char *)p; + b->len = l; + b->free = NULL; + return (b); + } + + if (n == -1) + return NULL; + l = strlen(p); + if (n > l) + return NULL; + b->priv = (char *)p; + b->len = n; + b->free = NULL; + + return (b); +} + +static VCL_BLOB +decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, + const char *restrict const p, va_list ap) { + enum encoding dec = parse_encoding(decs); + struct wb_s wb; + struct vmod_priv *b; + char *buf; + uintptr_t snap; + ssize_t len; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AENC(dec); + CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC); + + snap = WS_Snapshot(ctx->ws); + if ((b = WS_Alloc(ctx->ws, sizeof(struct vmod_priv))) == NULL) { + ERRNOMEM(ctx, "cannot decode"); + return NULL; + } + + if (dec == IDENTITY) { + va_list aq; + va_copy(aq, ap); + const struct vmod_priv *bb = decode_id_inplace(b, n, p, aq); + va_end(aq); + if (bb == null_blob) + WS_Reset(ctx->ws, snap); + if (bb == b) + return bb; + } + + if (wb_create(ctx->ws, &wb) == NULL) { + WS_Reset(ctx->ws, snap); + ERRNOMEM(ctx, "cannot decode"); + return NULL; + } + buf = wb_buf(&wb); + + errno = 0; + len = func[dec].decode(dec, buf, wb_space(&wb), n, p, ap); + + if (len == -1) { + err_decode(ctx, p); + wb_reset(&wb); + WS_Reset(ctx->ws, snap); + return NULL; + } + if (len == 0) { + wb_reset(&wb); + WS_Reset(ctx->ws, snap); + return null_blob; + } + wb_advance(&wb, len); + WS_ReleaseP(ctx->ws, wb_buf(&wb)); + b->priv = buf; + b->len = len; + b->free = NULL; + return b; +} + +VCL_BLOB __match_proto__(td_blob_decode) +vmod_decode(VRT_CTX, VCL_ENUM decs, const char *p, ...) +{ + va_list ap; + VCL_BLOB r; + + va_start(ap, p); + r = decode(ctx, -1, decs, p, ap); + va_end(ap); + + return (r); +} + +VCL_BLOB __match_proto__(td_blob_decode_n) +vmod_decode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *p, ...) +{ + va_list ap; + VCL_BLOB r; + + va_start(ap, p); + r = decode(ctx, n, decs, p, ap); + va_end(ap); + + return (r); +} + +static VCL_STRING +encode(VRT_CTX, enum encoding enc, VCL_BLOB b) +{ + struct wb_s wb; + ssize_t len; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AENC(enc); + + if (b == NULL) + return NULL; + + CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC); + if (wb_create(ctx->ws, &wb) == NULL) { + ERRNOMEM(ctx, "cannot encode"); + return NULL; + } + + len = func[enc].encode(enc, + wb_buf(&wb), wb_space(&wb), b->priv, b->len); + + if (len == -1) { + ERRNOMEM(ctx, "cannot encode"); + wb_reset(&wb); + return NULL; + } + if (len == 0) { + wb_reset(&wb); + return ""; + } + wb_advance(&wb, len); + return wb_finish(&wb, NULL); +} + +VCL_STRING __match_proto__(td_blob_encode) +vmod_encode(VRT_CTX, VCL_ENUM encs, VCL_BLOB b) +{ + enum encoding enc = parse_encoding(encs); + return encode(ctx, enc, b); +} + +static VCL_STRING +transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, + const char *restrict const p, va_list ap) +{ + enum encoding dec = parse_encoding(decs); + enum encoding enc = parse_encoding(encs); + va_list aq; + struct vmod_priv b; + VCL_STRING r; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC); + + AENC(dec); + AENC(enc); + + if (dec == IDENTITY) { + va_copy(aq, ap); + const struct vmod_priv *bb = decode_id_inplace(&b, n, p, aq); + va_end(aq); + if (bb != NULL) { + r = encode(ctx, enc, bb); + return (r); + } + } + + /* + * Allocate space for the decoded blob on the stack + * ignoring the limitation imposed by n + */ + va_copy(aq, ap); + size_t l = decode_l_va(dec, p, aq); + va_end(aq); + if (l == 0) + return ""; + /* XXX: handle stack overflow? */ + char buf[l]; + b.free = NULL; + b.priv = buf; + + errno = 0; + va_copy(aq, ap); + b.len = func[dec].decode(dec, buf, l, n, p, aq); + va_end(aq); + + if (b.len == -1) { + err_decode(ctx, p); + return NULL; + } + + /* + * If the encoding and decoding are the same, and the decoding was + * legal, just return the string, if there was only one in the + * STRING_LIST, or else the concatenated string. + */ + if (n == -1 && enc == dec) { + const char *q, *pp = p; + va_copy(aq, ap); + q = find_nonempty_va(&pp, ap); + va_end(aq); + + if (pp == vrt_magic_string_end) + return ""; + + if (q == vrt_magic_string_end) + return pp; + + r = VRT_String(ctx->ws, NULL, p, ap); + return r; + } + + r = encode(ctx, enc, &b); + return (r); +} + +VCL_STRING __match_proto__(td_blob_transcode) +vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, + const char *p, ...) +{ + va_list ap; + VCL_STRING r; + + va_start(ap, p); + r = transcode(ctx, -1, decs, encs, p, ap); + va_end(ap); + + return (r); +} + +VCL_STRING __match_proto__(td_blob_transcode_n) +vmod_transcode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, + const char *p, ...) +{ + va_list ap; + VCL_STRING r; + + va_start(ap, p); + r = transcode(ctx, n, decs, encs, p, ap); + va_end(ap); + + return (r); +} diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h new file mode 100644 index 0000000..1b809e1 --- /dev/null +++ b/lib/libvmod_blob/vmod_blob.h @@ -0,0 +1,127 @@ +/*- + * Copyright 2015-2016 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Authors: Nils Goroll + * Geoffrey Simmons + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include + +#include "parse_encoding.h" + +#define AENC(enc) assert((enc) > _INVALID && (enc) < __MAX_ENCODING) + +/* + * Length estimate interface + */ +typedef +size_t len_f(size_t); + +/* + * General interface for an encoder: encode the data at in of length inlen + * into a null-terminated string at buf, and return the length of the + * encoding. + * + * enc: encoding enum (from parse_encoding.h) + * buf: destination of the encoded string + * buflen: maximum length available at buf + * in: source of data to be encoded + * inlen: length of data to be encoded + * + * The regions pointed to by buf and in MUST NOT overlap (this is the + * contract imposed by restrict). + * An encoder SHALL NOT append the terminating null byte (this must + * be done by the caller). + * + * Returns: + * -1, if there is insufficient space at buf, *including* space for the + * terminating null byte + * 0, if the length of the encoding is 0 -- the caller should return + * the static constant empty string (literal "") + * otherwise, the number of bytes written (note that this does not + * include any terminating null byte) + */ +typedef +ssize_t encode_f(const enum encoding enc, char *restrict const buf, + const size_t buflen, const char *restrict const in, + const size_t inlen); + +/* + * General interface for a decoder: decode the concatenation of strings + * in p and ap (obtained from a STRING_LIST) into buf, and return the + * length of decoded data. + * + * dec: decoding enum (from parse_encoding.h) + * buf: destination of the decoded data + * buflen: maximum length available at buf + * inlen: maximum length to read or -1 to read up to \0 + * p, ap: strings obtained from a VCL STRING_LIST + * + * The regions pointed to by buf and any of the strings in p or ap MUST + * NOT overlap (per restrict). + * Note that the p,ap list is terminated by vrt_magic_string_end, and + * any member of the list may be NULL or empty. + * + * Returns: + * -1, if there is insufficient space at buf, or if the decoding is + * invalid; errno SHALL be set to ENOMEM or EINVALID, respectively + * 0, if the length of the decoding is 0 -- the caller should return + * a static constant empty BLOB + * otherwise, the number of bytes written + */ +typedef +ssize_t decode_f(const enum encoding dec, char *restrict const buf, + const size_t buflen, const ssize_t inlen, + const char *restrict const p, va_list ap); + +/* id.c */ +len_f id_encode_l; +len_f id_decode_l; + +encode_f id_encode; +decode_f id_decode; + +/* base64.c */ +len_f base64_decode_l; +len_f base64nopad_encode_l; +len_f base64_encode_l; + +encode_f base64_encode; +decode_f base64_decode; + + /* hex.c */ +len_f hex_encode_l; +len_f hex_decode_l; + +encode_f hex_encode; +decode_f hex_decode; + +/* url.c */ +len_f url_encode_l; +len_f url_decode_l; + +encode_f url_encode; +decode_f url_decode; diff --git a/lib/libvmod_blob/wb.c b/lib/libvmod_blob/wb.c new file mode 100644 index 0000000..343ca59 --- /dev/null +++ b/lib/libvmod_blob/wb.c @@ -0,0 +1,74 @@ +/*- + * Copyright 2015 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Authors: Nils Goroll + * + * 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. + * + * write buffer: utility functions to append-write on a varnish workspace + */ + +#include + +#include "wb.h" + +char * +wb_create(struct ws *ws, struct wb_s *wb) +{ + if (WS_Reserve(ws, 0) == 0) { + wb->w = NULL; + wb->ws = NULL; + return NULL; + } + wb->w = ws->f; + wb->ws = ws; + + return wb->w; +} + +void +wb_reset(struct wb_s *wb) +{ + WS_Release(wb->ws, 0); + memset(wb, 0, sizeof(*wb)); +} + +/* + * release varnish workspace + * + * return start of buffer + */ +char * +wb_finish(struct wb_s *wb, ssize_t *l) +{ + char *r = wb->ws->f; + assert(wb->ws->r - wb->w > 0); + if (l) + *l = wb_len(wb); + + *wb->w = '\0'; + wb->w++; + + /* amount of space used */ + WS_ReleaseP(wb->ws, wb->w); + + return r; +} diff --git a/lib/libvmod_blob/wb.h b/lib/libvmod_blob/wb.h new file mode 100644 index 0000000..7bd1cbf --- /dev/null +++ b/lib/libvmod_blob/wb.h @@ -0,0 +1,70 @@ +/*- + * Copyright 2015-2016 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Author: Nils Goroll + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "cache/cache.h" + +struct wb_s { + struct ws *ws; // varnish workspace + char *w; // current write position +}; + +/* return one byte less for the final zero byte */ +static inline const char* +wb_end(struct wb_s *wb) { + return wb->ws->r - 1; +} + +/* return the write position */ +static inline char* +wb_buf(struct wb_s *wb) { + return wb->w; +} + +/* return one byte less for the final zero byte */ +static inline ssize_t +wb_space(struct wb_s *wb) { + ssize_t f = wb->ws->r - wb->w; + assert(f > 0); + return f - 1; +} + +static inline ssize_t +wb_len(struct wb_s *wb) { + ssize_t l = wb->w - wb->ws->f; + assert(l >= 0); + return l; +} + +static inline void +wb_advance(struct wb_s *wb, ssize_t l) { + wb->w += l; // final byte + assert(wb->w < wb_end(wb)); +} + +char *wb_create(struct ws *ws, struct wb_s *wb); +void wb_reset(struct wb_s *wb); +char *wb_finish(struct wb_s *wb, ssize_t *l); diff --git a/man/Makefile.am b/man/Makefile.am index 73f6049..2187ff9 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -18,7 +18,8 @@ dist_man_MANS = \ vmod_directors.3 \ vmod_purge.3 \ vmod_std.3 \ - vmod_vtc.3 + vmod_vtc.3 \ + vmod_blob.3 CLEANFILES = $(dist_man_MANS) @@ -97,4 +98,7 @@ vmod_std.3: $(top_builddir)/lib/libvmod_std/vmod_std.man.rst vmod_vtc.3: $(top_builddir)/lib/libvmod_vtc/vmod_vtc.man.rst ${RST2MAN} $(RST2ANY_FLAGS) $? $@ +vmod_blob.3: $(top_builddir)/lib/libvmod_blob/vmod_blob.man.rst + ${RST2MAN} $(RST2ANY_FLAGS) $? $@ + .NOPATH: $(dist_man_MANS) From geoff at uplex.de Mon Sep 4 12:59:11 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 04 Sep 2017 14:59:11 +0200 Subject: [master] 1adf442 Add VMOD blob same(), equal(), length() and subblob(). Message-ID: commit 1adf4429a7b934829632d529fa36c68b74e2c584 Author: Geoff Simmons Date: Fri Sep 1 13:30:02 2017 +0200 Add VMOD blob same(), equal(), length() and subblob(). diff --git a/bin/varnishtest/tests/m00045.vtc b/bin/varnishtest/tests/m00045.vtc new file mode 100644 index 0000000..654b16a --- /dev/null +++ b/bin/varnishtest/tests/m00045.vtc @@ -0,0 +1,323 @@ +varnishtest "VMOD blob same(), equal(), length() and subblob()" + +varnish v1 -vcl { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_init { + new foo1 = blob.blob(IDENTITY, "foobarbazquux"); + new foo2 = blob.blob(IDENTITY, "foobarbazquux"); + + new hobbes1 = blob.blob(IDENTITY, +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}); + new hobbes2 = blob.blob(IDENTITY, +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}); + + new empty1 = blob.blob(IDENTITY, ""); + new empty2 = blob.blob(IDENTITY, ""); + } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + if (blob.same(foo1.get(), foo1.get())) { + set resp.http.foo1same = "true"; + } + if (blob.same(foo2.get(), foo2.get())) { + set resp.http.foo2same = "true"; + } + if (blob.same(foo1.get(), foo2.get())) { + set resp.http.foo12same = "true"; + } + if (blob.same(foo2.get(), foo1.get())) { + set resp.http.foo21same = "true"; + } + if (blob.same(foo1.get(), hobbes1.get())) { + set resp.http.foohobbessame = "true"; + } + if (blob.same(foo1.get(), empty1.get())) { + set resp.http.fooemptysame = "true"; + } + + if (blob.equal(foo1.get(), foo1.get())) { + set resp.http.foo1equal = "true"; + } + if (blob.equal(foo1.get(), foo2.get())) { + set resp.http.foo12equal = "true"; + } + if (blob.equal(foo2.get(), foo1.get())) { + set resp.http.foo21equal = "true"; + } + if (blob.equal(foo1.get(), hobbes1.get())) { + set resp.http.foohobbesequal = "true"; + } + if (blob.equal(foo1.get(), empty1.get())) { + set resp.http.fooemptyequal = "true"; + } + + set resp.http.foo1len = blob.length(foo1.get()); + set resp.http.foo2len = blob.length(foo2.get()); + + if (blob.same(hobbes1.get(), hobbes1.get())) { + set resp.http.hobbes1same = "true"; + } + if (blob.same(hobbes2.get(), hobbes2.get())) { + set resp.http.hobbes2same = "true"; + } + if (blob.same(hobbes1.get(), hobbes2.get())) { + set resp.http.hobbes12same = "true"; + } + if (blob.same(hobbes2.get(), hobbes1.get())) { + set resp.http.hobbes21same = "true"; + } + if (blob.same(hobbes1.get(), empty1.get())) { + set resp.http.hobbesemptysame = "true"; + } + + if (blob.equal(hobbes1.get(), hobbes1.get())) { + set resp.http.hobbes1equal = "true"; + } + if (blob.equal(hobbes1.get(), hobbes2.get())) { + set resp.http.hobbes12equal = "true"; + } + if (blob.equal(hobbes2.get(), hobbes1.get())) { + set resp.http.hobbes21equal = "true"; + } + if (blob.equal(hobbes1.get(), empty1.get())) { + set resp.http.hobbesemptyequal = "true"; + } + + set resp.http.hobbes1len = blob.length(hobbes1.get()); + set resp.http.hobbes2len = blob.length(hobbes2.get()); + + if (blob.same(empty1.get(), empty1.get())) { + set resp.http.empty1same = "true"; + } + if (blob.same(empty2.get(), empty2.get())) { + set resp.http.empty2same = "true"; + } + if (blob.same(empty1.get(), empty2.get())) { + set resp.http.empty12same = "true"; + } + if (blob.same(empty2.get(), empty1.get())) { + set resp.http.empty21same = "true"; + } + + if (blob.equal(empty1.get(), empty1.get())) { + set resp.http.empty1equal = "true"; + } + if (blob.equal(empty1.get(), empty2.get())) { + set resp.http.empty12equal = "true"; + } + if (blob.equal(empty2.get(), empty1.get())) { + set resp.http.empty21equal = "true"; + } + + set resp.http.empty1len = blob.length(empty1.get()); + set resp.http.empty2len = blob.length(empty2.get()); + return(deliver); + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.http.foo1same == "true" + expect resp.http.foo2same == "true" + expect resp.http.foo12same == + expect resp.http.foo21same == + expect resp.http.foohobbessame == + expect resp.http.fooemptysame == + expect resp.http.foo1equal == "true" + expect resp.http.foo12equal == "true" + expect resp.http.foo21equal == "true" + expect resp.http.foohobbesequal == + expect resp.http.fooemptyequal == + expect resp.http.foo1len == "13" + expect resp.http.foo2len == "13" + expect resp.http.hobbes1same == "true" + expect resp.http.hobbes2same == "true" + expect resp.http.hobbes12same == + expect resp.http.hobbes21same == + expect resp.http.hobbesemptysame == + expect resp.http.hobbes1equal == "true" + expect resp.http.hobbes12equal == "true" + expect resp.http.hobbes21equal == "true" + expect resp.http.hobbesemptyequal == + expect resp.http.hobbes1len == "269" + expect resp.http.hobbes2len == "269" + expect resp.http.empty1same == "true" + expect resp.http.empty2same == "true" + + # VMOD blob uses a statically allocated empty blob for empty + # decodings. So the empty blobs from different objects + # evaluate as true for same(). + expect resp.http.empty12same == "true" + expect resp.http.empty21same == "true" + + expect resp.http.empty1equal == "true" + expect resp.http.empty12equal == "true" + expect resp.http.empty21equal == "true" + expect resp.http.empty1len == "0" + expect resp.http.empty2len == "0" +} -run + +# subblob() +varnish v1 -vcl { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_init { + # Byte values 0 up to 7 + new up07 = blob.blob(BASE64, "AAECAwQFBgc="); + # Byte values 7 down to 0 + new down07 = blob.blob(BASE64, "BwYFBAMCAQA="); + } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.up03 + = blob.encode(BASE64, blob.subblob(up07.get(), 4B)); + set resp.http.down07060504 + = blob.encode(BASE64, blob.subblob(down07.get(), 4B)); + set resp.http.up04050607 + = blob.encode(BASE64, blob.subblob(up07.get(), 4B, 4B)); + set resp.http.down03 + = blob.encode(BASE64, blob.subblob(down07.get(), 4B, 4B)); + set resp.http.up07 + = blob.encode(BASE64, blob.subblob(up07.get(), 8B)); + set resp.http.down07 + = blob.encode(BASE64, blob.subblob(down07.get(), 8B)); + set resp.http.zerobytes + = blob.encode(BASE64, blob.subblob(down07.get(), 0B)); + set resp.http.zerolen + = blob.length(blob.subblob(down07.get(), 0B)); + } +} + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.http.up03 == "AAECAw==" + expect resp.http.down07060504 == "BwYFBA==" + expect resp.http.up04050607 == "BAUGBw==" + expect resp.http.down03 == "AwIBAA==" + expect resp.http.up07 == "AAECAwQFBgc=" + expect resp.http.down07 == "BwYFBAMCAQA=" + expect resp.http.zerobytes == "" + expect resp.http.zerolen == "0" +} -run + +# subblob() failures +server s1 -repeat 3 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_init { + new up07 = blob.blob(BASE64, "AAECAwQFBgc="); + new empty = blob.blob(IDENTITY, ""); + } + + sub vcl_deliver { + if (req.url == "/empty") { + set resp.http.empty = blob.encode(BASE64, + blob.subblob(empty.get(), 1B)); + } + elsif (req.url == "/toolong") { + set resp.http.toolong + = blob.encode(BASE64, blob.subblob(up07.get(), 9B)); + } + elsif (req.url == "/badoffset") { + set resp.http.badoffset = blob.encode(BASE64, + blob.subblob(up07.get(), 4B, 5B)); + } + } +} + +logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" { + expect 0 * Begin req + expect * = VCL_Error "^vmod blob error: blob is empty in blob.subblob..$" + expect * = End +} -start + +client c1 { + txreq -url /empty + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.empty == +} -run + +logexpect l1 -wait + +client c1 { + txreq -url /toolong + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.toolong == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.subblob..$" +} -run + +client c1 { + txreq -url /badoffset + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.badoffset == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.subblob..$" +} -run + +# VCL load failures from subblob() +varnish v1 -errvcl {vmod blob error: blob is empty in blob.subblob()} { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_init { + new empty = blob.blob(IDENTITY, ""); + if (blob.same(empty.get(), blob.subblob(empty.get(), 0B))) { + new B = blob.blob(IDENTITY, "b"); + } + } +} + +varnish v1 -errvcl {vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.subblob()} { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_init { + new up07 = blob.blob(BASE64, "AAECAwQFBgc="); + if (blob.same(up07.get(), blob.subblob(up07.get(), 9B))) { + new B = blob.blob(IDENTITY, "b"); + } + } +} + +varnish v1 -errvcl {vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.subblob()} { + import blob; + backend b { .host = "${bad_ip}"; } + + sub vcl_init { + new up07 = blob.blob(BASE64, "AAECAwQFBgc="); + if (blob.same(up07.get(), blob.subblob(up07.get(), 4B, 5B))) { + new B = blob.blob(IDENTITY, "b"); + } + } +} diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 826a6c9..e1319a3 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -10,6 +10,7 @@ $Module blob 3 utilities for the VCL blob type :: + # binary-to-text encodings STRING blob.encode(ENUM encoding, BLOB blob) BLOB blob.decode(ENUM decoding, STRING_LIST encoded) BLOB blob.decode_n(INT n, ENUM decoding, STRING_LIST encoded) @@ -18,6 +19,13 @@ $Module blob 3 utilities for the VCL blob type STRING blob.transcode_n(INT n, ENUM decoding, ENUM encoding, STRING_LIST encoded) + # other utilities + BOOL blob.same(BLOB, BLOB) + BOOL blob.equal(BLOB, BLOB) + INT blob.length(BLOB) + BLOB blob.subblob(BLOB, BYTES length [, BYTES offset]) + + # blob object new OBJ = blob.blob(ENUM decoding, STRING_LIST encoded) BLOB .get() STRING .encode(ENUM encoding) @@ -264,6 +272,38 @@ $Function STRING transcode_n(INT n, Same as ``transcode()``, but only from the first ``n`` characters of the encoded string. +$Function BOOL same(BLOB, BLOB) + +Returns true if and only if the two BLOB arguments are the same +object, i.e. they specify exactly the same region of memory. + +If the BLOBs are both empty (length is 0 and/or the internal pointer +is NULL), then ``same()`` returns ``true``. If any non-empty BLOB +is compared to an empty BLOB, then ``same()`` returns ``false``. + +$Function BOOL equal(BLOB, BLOB) + +Returns true if and only if the two BLOB arguments have equal contents +(possibly in different memory regions). + +As with ``same()``: If the BLOBs are both empty, then ``equal()`` +returns ``true``. If any non-empty BLOB is compared to an empty BLOB, +then ``equal()`` returns ``false``. + +$Function INT length(BLOB) + +Returns the length of the BLOB. + +$Function BLOB subblob(BLOB, BYTES length, BYTES offset = 0) + +Returns a new BLOB formed from ``length`` bytes of the BLOB argument +starting at ``offset`` bytes from the start of its memory region. The +default value of ``offset`` is 0B. + +``subblob()`` fails and returns NULL if the BLOB argument is empty, or +if ``offset + length`` requires more bytes than are available in the +BLOB. + $Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", STRING_LIST encoded) @@ -330,9 +370,10 @@ not known until runtime. ERRORS ====== -The encoders and decoders may fail if there is insufficient space to -create the new blob or string. Decoders may also fail if the encoded -string is an illegal format for the decoding scheme. +The encoders, decoders and ``subblob()`` may fail if there is +insufficient space to create the new blob or string. Decoders may also +fail if the encoded string is an illegal format for the decoding +scheme. If any of the VMOD's methods, functions or constructor fail, then VCL failure is invoked, just as if ``return(fail)`` had been called in the @@ -360,10 +401,11 @@ strings. The ``blob`` object and its methods allocate memory from the heap, and hence they are only limited by available virtual memory. The ``encode()``, ``decode()`` and ``transcode()`` functions allocate -Varnish workspace. If these functions are failing, as indicated by -"out of space" messages in the Varnish log (with the ``VCL_Error`` -tag), then you will need to increase the varnishd parameters -``workspace_client`` and/or ``workspace_backend``. +Varnish workspace, as does ``subblob()`` for the newly created BLOB. +If these functions are failing, as indicated by "out of space" +messages in the Varnish log (with the ``VCL_Error`` tag), then you +will need to increase the varnishd parameters ``workspace_client`` +and/or ``workspace_backend``. The ``transcode()`` function also allocates space on the stack for a temporary BLOB. If this function causes stack overflow, you may need diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 7d0ad92..da105d9 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -244,7 +244,7 @@ vmod_blob_get(VRT_CTX, struct vmod_blob_blob *b) return &b->blob; } -VCL_STRING +VCL_STRING __match_proto__(td_blob_blob_encode) vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs) { enum encoding enc = parse_encoding(encs); @@ -607,3 +607,82 @@ vmod_transcode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, return (r); } + +VCL_BOOL __match_proto__(td_blob_same) +vmod_same(VRT_CTX, VCL_BLOB b1, VCL_BLOB b2) +{ + (void) ctx; + + if (b1 == NULL && b2 == NULL) + return 1; + if (b1 == NULL || b2 == NULL) + return 0; + return (b1->len == b2->len && b1->priv == b2->priv); +} + +VCL_BOOL __match_proto__(td_blob_equal) +vmod_equal(VRT_CTX, VCL_BLOB b1, VCL_BLOB b2) +{ + (void) ctx; + + if (b1 == NULL && b2 == NULL) + return 1; + if (b1 == NULL || b2 == NULL) + return 0; + if (b1->len != b2->len) + return 0; + if (b1->priv == b2->priv) + return 1; + if (b1->priv == NULL || b2->priv == NULL) + return 0; + return (memcmp(b1->priv, b2->priv, b1->len) == 0); +} + +VCL_INT __match_proto__(td_blob_length) +vmod_length(VRT_CTX, VCL_BLOB b) +{ + (void) ctx; + + if (b == NULL) + return 0; + return b->len; +} + +VCL_BLOB __match_proto__(td_blob_subblob) +vmod_subblob(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) +{ + uintptr_t snap; + struct vmod_priv *sub; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + assert(n >= 0); + assert(off >= 0); + + if (b == NULL || b->len == 0 || b->priv == NULL) { + ERR(ctx, "blob is empty in blob.subblob()"); + return NULL; + } + assert(b->len >= 0); + if (off + n > b->len) { + VERR(ctx, "size %lld from offset %lld requires more bytes than " + "blob length %d in blob.subblob()", n, off, b->len); + return NULL; + } + + if (n == 0) + return null_blob; + + snap = WS_Snapshot(ctx->ws); + if ((sub = WS_Alloc(ctx->ws, sizeof(*sub))) == NULL) { + ERRNOMEM(ctx, "Allocating BLOB result in blob.subblob()"); + return NULL; + } + if ((sub->priv = WS_Alloc(ctx->ws, n)) == NULL) { + VERRNOMEM(ctx, "Allocating %lld bytes in blob.subblob()", n); + WS_Reset(ctx->ws, snap); + return NULL; + } + memcpy(sub->priv, (char *)b->priv + off, n); + sub->len = n; + return sub; +} From geoff at uplex.de Mon Sep 4 12:59:11 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 04 Sep 2017 14:59:11 +0200 Subject: [master] c89bd1f VMOD blob: giving up on in-place decode, since it requires assigning a STRING (const char *) to vmod_priv->priv (void *) (const qualifier). Message-ID: commit c89bd1fbd43690c9828868d2e0516eb824fc5f3c Author: Geoff Simmons Date: Mon Sep 4 10:20:03 2017 +0200 VMOD blob: giving up on in-place decode, since it requires assigning a STRING (const char *) to vmod_priv->priv (void *) (const qualifier). diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index da105d9..e936944 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -42,7 +42,7 @@ struct vmod_blob_blob { unsigned magic; #define VMOD_BLOB_MAGIC 0xfade4fa9 struct vmod_priv blob; - const char *encoding[__MAX_ENCODING]; + char *encoding[__MAX_ENCODING]; pthread_mutex_t lock; }; @@ -263,25 +263,25 @@ vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs) assert(len >= 0); if (len == 0) - b->encoding[enc] = ""; + b->encoding[enc] = empty; else { b->encoding[enc] = malloc(len); if (b->encoding[enc] == NULL) ERRNOMEM(ctx, "cannot encode"); else { - const char *s = b->encoding[enc]; + char *s = b->encoding[enc]; len = func[enc].encode( - enc, (void *) s, len, + enc, s, len, b->blob.priv, b->blob.len); assert(len >= 0); if (len == 0) { - free((void *) s); - b->encoding[enc] = ""; + free(s); + b->encoding[enc] = empty; } else - *((char *)s + len) = '\0'; + s[len] = '\0'; } } } @@ -323,7 +323,7 @@ find_nonempty_va(const char *restrict *p, va_list ap) /* find first non-empty vararg */ for (; *p == vrt_magic_string_end || *p == NULL || **p == '\0'; - *p = va_arg(ap, const char *)) + *p = va_arg(ap, char *)) if (*p == vrt_magic_string_end) return (vrt_magic_string_end); @@ -336,51 +336,10 @@ find_nonempty_va(const char *restrict *p, va_list ap) return (q); } -/* - * special case: we can avoid copying for identity decode if we need to - * deal with a single vararg only - in which case we just have the blob - * point to the input string - */ -static VCL_BLOB -decode_id_inplace(struct vmod_priv *b, VCL_INT n, const char *restrict p, - va_list ap) { - const char *q; - int l; - - if (n == 0) - return null_blob; - - q = find_nonempty_va(&p, ap); - - if (p == vrt_magic_string_end) - return null_blob; - - if (q == vrt_magic_string_end) { - /* can use in-place decode */ - l = strlen(p); - if (n > 0 && n < l) - l = n; - b->priv = (char *)p; - b->len = l; - b->free = NULL; - return (b); - } - - if (n == -1) - return NULL; - l = strlen(p); - if (n > l) - return NULL; - b->priv = (char *)p; - b->len = n; - b->free = NULL; - - return (b); -} - static VCL_BLOB -decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, - const char *restrict const p, va_list ap) { +decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *restrict const p, + va_list ap) +{ enum encoding dec = parse_encoding(decs); struct wb_s wb; struct vmod_priv *b; @@ -398,17 +357,6 @@ decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, return NULL; } - if (dec == IDENTITY) { - va_list aq; - va_copy(aq, ap); - const struct vmod_priv *bb = decode_id_inplace(b, n, p, aq); - va_end(aq); - if (bb == null_blob) - WS_Reset(ctx->ws, snap); - if (bb == b) - return bb; - } - if (wb_create(ctx->ws, &wb) == NULL) { WS_Reset(ctx->ws, snap); ERRNOMEM(ctx, "cannot decode"); @@ -521,16 +469,6 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, AENC(dec); AENC(enc); - if (dec == IDENTITY) { - va_copy(aq, ap); - const struct vmod_priv *bb = decode_id_inplace(&b, n, p, aq); - va_end(aq); - if (bb != NULL) { - r = encode(ctx, enc, bb); - return (r); - } - } - /* * Allocate space for the decoded blob on the stack * ignoring the limitation imposed by n From geoff at uplex.de Mon Sep 4 13:02:11 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 04 Sep 2017 15:02:11 +0200 Subject: [master] 09aa86a Add VMOD blob to changes.rst. Message-ID: commit 09aa86a66cde67a8daf57c9e92b89f8507342a23 Author: Geoff Simmons Date: Mon Sep 4 15:00:58 2017 +0200 Add VMOD blob to changes.rst. Closes #2407 diff --git a/doc/changes.rst b/doc/changes.rst index ec24013..eccc094 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -29,6 +29,8 @@ VCL * Added ``bereq.is_bgfetch`` which is true for background fetches. +* Added VMOD blob (#2407) + C APIs (for vmod and utility authors) ------------------------------------- From fgsch at lodoss.net Mon Sep 4 14:46:10 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 04 Sep 2017 16:46:10 +0200 Subject: [master] eb34f7d Turn {be}req.hash into a BLOB Message-ID: commit eb34f7dd5b3afcb9ef9df002f63655180694dc5f Author: Federico G. Schwindt Date: Mon Sep 4 15:06:58 2017 +0100 Turn {be}req.hash into a BLOB Fixes #2402. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 42f93b6..243a814 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -768,34 +768,32 @@ VRT_BODY_L(resp) /*--------------------------------------------------------------------*/ -static const char * -vrt_hash(VRT_CTX, uint8_t *digest) -{ - char *p; - int i; - - p = WS_Alloc(ctx->ws, SHA256_LEN * 2 + 1); - if (p == NULL) - return (NULL); - for (i = 0; i < SHA256_LEN; i++) - sprintf(&p[i * 2], "%02x", digest[i]); +static struct vmod_priv * +vrt_do_blob(VRT_CTX, uint8_t *digest) +{ + struct vmod_priv *p; + p = (void *)WS_Alloc(ctx->ws, sizeof *p); + AN(p); + memset(p, 0, sizeof *p); + p->len = DIGEST_LEN; + p->priv = WS_Copy(ctx->ws, digest, DIGEST_LEN); return (p); } -const char * +VCL_BLOB VRT_r_req_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - return (vrt_hash(ctx, ctx->req->digest)); + return (vrt_do_blob(ctx, ctx->req->digest)); } -const char * +VCL_BLOB VRT_r_bereq_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - return (vrt_hash(ctx, ctx->bo->digest)); + return (vrt_do_blob(ctx, ctx->bo->digest)); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishtest/tests/b00051.vtc b/bin/varnishtest/tests/b00051.vtc index 1863850..1ec12a1 100644 --- a/bin/varnishtest/tests/b00051.vtc +++ b/bin/varnishtest/tests/b00051.vtc @@ -6,11 +6,12 @@ server s1 { } -start varnish v1 -vcl+backend { + import vtc; sub vcl_backend_response { - set beresp.http.bereq_hash = bereq.hash; + set beresp.http.bereq_hash = vtc.blob2hex(bereq.hash); } sub vcl_deliver { - set resp.http.req_hash = req.hash; + set resp.http.req_hash = vtc.blob2hex(req.hash); } } -start diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index b113669..77dcefa 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -220,15 +220,17 @@ varnish v1 -errvcl {Function returns VOID} { varnish v1 -errvcl {'req.hash': Not available in method 'vcl_recv'.} { backend b { .host = "127.0.0.1"; } + import vtc; sub vcl_recv { - set req.http.foo = req.hash; + set req.http.foo = vtc.blob2hex(req.hash); } } varnish v1 -errvcl {'req.hash': Not available in method 'vcl_hash'.} { backend b { .host = "127.0.0.1"; } + import vtc; sub vcl_hash { - set req.http.foo = req.hash; + set req.http.foo = vtc.blob2hex(req.hash); } } diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 8bbd1e6..64e2167 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -234,7 +234,7 @@ sp_variables = [ """ ), ('req.hash', - 'STRING', + 'BLOB', ('hit', 'miss', 'pass', 'purge', 'deliver', ), (), """ The hash key of this request. @@ -428,7 +428,7 @@ sp_variables = [ """ ), ('bereq.hash', - 'STRING', + 'BLOB', ('pipe', 'backend', ), (), """ The hash key of this request. From hermunn at varnish-software.com Mon Sep 4 14:56:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Mon, 04 Sep 2017 16:56:06 +0200 Subject: [master] 45f702f Make testcase 2372 work on SunOS Message-ID: commit 45f702f71a65c37023ace8d98ceb8472f2cd02fc Author: P?l Hermunn Johansen Date: Mon Sep 4 16:21:31 2017 +0200 Make testcase 2372 work on SunOS Since SunOS needs a litt bit more workspace_thread, this test case needs to be updated. The default buffer size for vtc (configurable with -b) had to be increased. diff --git a/bin/varnishtest/tests/r02372.vtc b/bin/varnishtest/tests/r02372.vtc index 649ccfe..c32d17b 100644 --- a/bin/varnishtest/tests/r02372.vtc +++ b/bin/varnishtest/tests/r02372.vtc @@ -1,11 +1,11 @@ varnishtest "Count purges when there are many variants" -server s1 -repeat 40 { +server s1 -repeat 72 { rxreq txresp -hdr "Vary: foo" } -start -varnish v1 -arg "-p workspace_thread=256" -vcl+backend { +varnish v1 -arg "-p workspace_thread=512" -vcl+backend { import std; sub vcl_recv { @@ -16,7 +16,7 @@ varnish v1 -arg "-p workspace_thread=256" -vcl+backend { } } -start -client c1 -repeat 40 { +client c1 -repeat 72 { txreq rxresp } -run @@ -29,4 +29,4 @@ client c2 { varnish v1 -expect n_lru_nuked == 0 varnish v1 -expect cache_hit == 0 varnish v1 -expect n_purges == 1 -varnish v1 -expect n_obj_purged == 40 +varnish v1 -expect n_obj_purged == 72 diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 611b41d..8b7765f 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -79,7 +79,7 @@ struct vtc_job { int iflg = 0; unsigned vtc_maxdur = 60; -static unsigned vtc_bufsiz = 512 * 1024; +static unsigned vtc_bufsiz = 1024 * 1024; static VTAILQ_HEAD(, vtc_tst) tst_head = VTAILQ_HEAD_INITIALIZER(tst_head); static struct vev_base *vb; From dridi.boukelmoune at gmail.com Mon Sep 4 14:58:11 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 04 Sep 2017 16:58:11 +0200 Subject: [master] a2f9d8f Changelog entries for vmod-purge and named addresses Message-ID: commit a2f9d8ff67bd0da753ed8507e9ea1dc9925ab492 Author: Dridi Boukelmoune Date: Mon Sep 4 16:53:01 2017 +0200 Changelog entries for vmod-purge and named addresses diff --git a/doc/changes.rst b/doc/changes.rst index eccc094..b988636 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -21,6 +21,9 @@ Usage ``MAIN.client_req``. VSM consumers should be changed to use the latter if necessary. +* A listen address can take a name in the -a argument. This name is used + in the logs and later will possibly be available in VCL. + VCL --- @@ -29,6 +32,8 @@ VCL * Added ``bereq.is_bgfetch`` which is true for background fetches. +* Added VMOD purge (#2404) + * Added VMOD blob (#2407) C APIs (for vmod and utility authors) From dridi.boukelmoune at gmail.com Mon Sep 4 15:04:11 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 04 Sep 2017 17:04:11 +0200 Subject: [master] f23bc34 Be more specific Message-ID: commit f23bc3466320c5c513caac9b835fbe12ecc8e52f Author: Dridi Boukelmoune Date: Mon Sep 4 17:02:17 2017 +0200 Be more specific diff --git a/doc/changes.rst b/doc/changes.rst index b988636..f390d7d 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -15,7 +15,7 @@ Usage * Where possible (on platforms with setproctitle(3)), the -i argument rather than the -n argument is used for process names -* varnishd honors ``vcl_path`` (#2342) +* varnishd -f honors ``vcl_path`` (#2342) * The ``MAIN.s_req`` statistic has been removed, as it was identical to ``MAIN.client_req``. VSM consumers should be changed to use the From hermunn at varnish-software.com Mon Sep 4 15:11:10 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Mon, 04 Sep 2017 17:11:10 +0200 Subject: [master] 5805714 Update the manual with new default Message-ID: commit 58057145d1941f8c3712cd8834db2d2921d35487 Author: P?l Hermunn Johansen Date: Mon Sep 4 17:10:29 2017 +0200 Update the manual with new default My previous patch did not update the manual and the usage message for varnishtest concerning the default internal buffer size. diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 8b7765f..0da7a4b 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -128,7 +128,7 @@ usage(void) fprintf(stderr, "usage: varnishtest [options] file ...\n"); #define FMT " %-28s # %s\n" fprintf(stderr, FMT, "-b size", - "Set internal buffer size (default: 512K)"); + "Set internal buffer size (default: 1M)"); fprintf(stderr, FMT, "-D name=val", "Define macro"); fprintf(stderr, FMT, "-i", "Find varnish binaries in build tree"); fprintf(stderr, FMT, "-j jobs", "Run this many tests in parallel"); diff --git a/doc/sphinx/reference/varnishtest.rst b/doc/sphinx/reference/varnishtest.rst index bb18f6c..495affc 100644 --- a/doc/sphinx/reference/varnishtest.rst +++ b/doc/sphinx/reference/varnishtest.rst @@ -30,7 +30,7 @@ simulate a transaction to provoke a specific behavior. The following options are available: --b size Set internal buffer size (default: 512K) +-b size Set internal buffer size (default: 1M) -D name=val Define macro for use in scripts From hermunn at varnish-software.com Mon Sep 4 15:57:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Mon, 04 Sep 2017 17:57:05 +0200 Subject: [5.2] 963ff64 Prepare for 5.2.0-rc1 release Message-ID: commit 963ff649d1fe17de1e6a9e2251bb76c1783fbee1 Author: P?l Hermunn Johansen Date: Mon Sep 4 17:49:04 2017 +0200 Prepare for 5.2.0-rc1 release diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index f6cb8e9..5837bd6 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -148,7 +148,7 @@ cnt_deliver(struct worker *wrk, struct req *req) http_PrintfHeader(req->resp, "Age: %.0f", floor(fmax(0., req->t_prev - req->objcore->t_origin))); - http_SetHeader(req->resp, "Via: 1.1 varnish (Varnish/5.1)"); + http_SetHeader(req->resp, "Via: 1.1 varnish (Varnish/5.2)"); if (cache_param->http_gzip_support && ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) && diff --git a/configure.ac b/configure.ac index c3a0984..09fefa5 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2017 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [trunk], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [5.2.0-rc1], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) From nils.goroll at uplex.de Mon Sep 4 18:01:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 04 Sep 2017 20:01:06 +0200 Subject: [master] 401a47e rename - this function is specific to the hash Message-ID: commit 401a47e9a8e54789e1ccf861f96797be412e9bfc Author: Nils Goroll Date: Mon Sep 4 19:07:52 2017 +0200 rename - this function is specific to the hash Ref: #2402 diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 243a814..de52389 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -769,7 +769,7 @@ VRT_BODY_L(resp) /*--------------------------------------------------------------------*/ static struct vmod_priv * -vrt_do_blob(VRT_CTX, uint8_t *digest) +vrt_hash_blob(VRT_CTX, uint8_t *digest) { struct vmod_priv *p; p = (void *)WS_Alloc(ctx->ws, sizeof *p); @@ -785,7 +785,7 @@ VRT_r_req_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - return (vrt_do_blob(ctx, ctx->req->digest)); + return (vrt_hash_blob(ctx, ctx->req->digest)); } VCL_BLOB @@ -793,7 +793,7 @@ VRT_r_bereq_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - return (vrt_do_blob(ctx, ctx->bo->digest)); + return (vrt_hash_blob(ctx, ctx->bo->digest)); } /*--------------------------------------------------------------------*/ From nils.goroll at uplex.de Mon Sep 4 18:01:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 04 Sep 2017 20:01:06 +0200 Subject: [master] 86caf8c vrt_hash_blob: fail gracefully for out-of-workspace conditions Message-ID: commit 86caf8ca5f34ab1a0b648f1f7c4394f07e81d2d3 Author: Nils Goroll Date: Mon Sep 4 19:21:12 2017 +0200 vrt_hash_blob: fail gracefully for out-of-workspace conditions No, we do not want to bring back panics for out-of-ws Ref: #2402 diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index de52389..0edf6d4 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -772,11 +772,17 @@ static struct vmod_priv * vrt_hash_blob(VRT_CTX, uint8_t *digest) { struct vmod_priv *p; + void *d; + p = (void *)WS_Alloc(ctx->ws, sizeof *p); - AN(p); + d = WS_Copy(ctx->ws, digest, DIGEST_LEN); + if (p == NULL || d == NULL) { + VRT_fail(ctx, "Workspace overflow ((be)req.hash)"); + return (NULL); + } memset(p, 0, sizeof *p); p->len = DIGEST_LEN; - p->priv = WS_Copy(ctx->ws, digest, DIGEST_LEN); + p->priv = d; return (p); } From nils.goroll at uplex.de Mon Sep 4 18:01:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 04 Sep 2017 20:01:06 +0200 Subject: [master] 6e6e7e7 set the sigaltstack for each thread - SunOS needs it Message-ID: commit 6e6e7e738d991ba5baf4d39b9b9f22836215622b Author: Nils Goroll Date: Mon Sep 4 19:48:26 2017 +0200 set the sigaltstack for each thread - SunOS needs it Ref: #2396 diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 41d2849..cf2948b 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -41,6 +41,11 @@ #include "hash/hash_slinger.h" +#ifdef HAVE_SIGALTSTACK +#include +extern stack_t altstack; +#endif + static void Pool_Work_Thread(struct pool *pp, struct worker *wrk); /*-------------------------------------------------------------------- @@ -401,6 +406,9 @@ pool_thread(void *priv) struct pool_info *pi; CAST_OBJ_NOTNULL(pi, priv, POOL_INFO_MAGIC); +#ifdef HAVE_SIGALTSTACK + AZ(sigaltstack(&altstack, NULL)); +#endif WRK_Thread(pi->qp, pi->stacksize, cache_param->workspace_thread); FREE_OBJ(pi); return (NULL); diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 2952a81..76103e2 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -84,6 +84,10 @@ static struct vlu *child_std_vlu; static struct vsb *child_panic = NULL; +#ifdef HAVE_SIGALTSTACK +stack_t altstack; +#endif + static void mgt_reap_child(void); /*===================================================================== @@ -365,15 +369,14 @@ mgt_launch_child(struct cli *cli) (void)sigaction(SIGABRT, &sa, NULL); #ifdef HAVE_SIGALTSTACK - stack_t ss; size_t sz = SIGSTKSZ + 4096; if (sz < mgt_param.wthread_stacksize) sz = mgt_param.wthread_stacksize; - ss.ss_sp = malloc(sz); - AN(ss.ss_sp); - ss.ss_size = sz; - ss.ss_flags = 0; - AZ(sigaltstack(&ss, NULL)); + altstack.ss_sp = malloc(sz); + AN(altstack.ss_sp); + altstack.ss_size = sz; + altstack.ss_flags = 0; + AZ(sigaltstack(&altstack, NULL)); sa.sa_flags |= SA_ONSTACK; #endif (void)sigaction(SIGSEGV, &sa, NULL); From nils.goroll at uplex.de Mon Sep 4 18:01:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 04 Sep 2017 20:01:06 +0200 Subject: [master] b7d42dd Use a separate segment for the sigaltstack Message-ID: commit b7d42dd543688436a3a594878380d92680a8f7f0 Author: Nils Goroll Date: Mon Sep 4 19:55:10 2017 +0200 Use a separate segment for the sigaltstack Having a stack on the heap just feels unclean, also this way we have a chance to get a red zone adjacent to the mapping just in case we manage to overflow the alt stack also. Ref: #2396 diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 76103e2..907df0d 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -85,6 +85,7 @@ static struct vlu *child_std_vlu; static struct vsb *child_panic = NULL; #ifdef HAVE_SIGALTSTACK +#include stack_t altstack; #endif @@ -372,7 +373,10 @@ mgt_launch_child(struct cli *cli) size_t sz = SIGSTKSZ + 4096; if (sz < mgt_param.wthread_stacksize) sz = mgt_param.wthread_stacksize; - altstack.ss_sp = malloc(sz); + altstack.ss_sp = mmap(NULL, sz, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0); + AN(altstack.ss_sp != MAP_FAILED); AN(altstack.ss_sp); altstack.ss_size = sz; altstack.ss_flags = 0; From nils.goroll at uplex.de Mon Sep 4 18:10:07 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 04 Sep 2017 20:10:07 +0200 Subject: [master] 95175e4 Make SunCC happy Message-ID: commit 95175e4c8d1930514a8a07619befa3f154cfe565 Author: Nils Goroll Date: Mon Sep 4 20:09:45 2017 +0200 Make SunCC happy diff --git a/lib/libvmod_blob/parse_encoding.c b/lib/libvmod_blob/parse_encoding.c index ec64b28..c156273 100644 --- a/lib/libvmod_blob/parse_encoding.c +++ b/lib/libvmod_blob/parse_encoding.c @@ -175,5 +175,4 @@ parse_encoding (const char *m) { return r; invalid: return _INVALID; - (void)p; } From geoff at uplex.de Mon Sep 4 18:17:16 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 04 Sep 2017 20:17:16 +0200 Subject: [master] 32e9634 VMOD blob: explicitly cast negative int8_t constants Message-ID: commit 32e9634cbc851fa73a714000f10ac24b9cb4fd90 Author: Geoff Simmons Date: Mon Sep 4 20:15:55 2017 +0200 VMOD blob: explicitly cast negative int8_t constants diff --git a/lib/libvmod_blob/base64.h b/lib/libvmod_blob/base64.h index e5318bd..708b588 100644 --- a/lib/libvmod_blob/base64.h +++ b/lib/libvmod_blob/base64.h @@ -28,8 +28,8 @@ #include "vmod_blob.h" -#define ILL -1 -#define PAD -2 +#define ILL ((int8_t) -1) +#define PAD ((int8_t) -2) static const struct b64_alphabet { const char b64[64]; From nils.goroll at uplex.de Mon Sep 4 18:21:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 04 Sep 2017 20:21:06 +0200 Subject: [master] 5adb58c remove unused variable from auto-generated code Message-ID: commit 5adb58cbf46571cf33adaf0bba45008dbe99f7fd Author: Nils Goroll Date: Mon Sep 4 20:20:46 2017 +0200 remove unused variable from auto-generated code diff --git a/lib/libvmod_blob/parse_encoding.c b/lib/libvmod_blob/parse_encoding.c index c156273..b18185f 100644 --- a/lib/libvmod_blob/parse_encoding.c +++ b/lib/libvmod_blob/parse_encoding.c @@ -5,6 +5,7 @@ * * TODO: integrate in vmodtool.py or replace with something else * cf. the same TODO for the shard director in libvmod_directors + * make generation of the offset-pointer p optional */ #include "parse_encoding.h" @@ -12,7 +13,6 @@ enum encoding parse_encoding (const char *m) { - int p; enum encoding r; switch (m[0]) { @@ -51,7 +51,6 @@ parse_encoding (const char *m) { //BASE64 if (term(m[6])) { r = BASE64; - p = 6; goto ok; } switch (m[6]) { @@ -72,7 +71,6 @@ parse_encoding (const char *m) { //BASE64URL if (term(m[9])) { r = BASE64URL; - p = 9; goto ok; } switch (m[9]) { @@ -83,7 +81,6 @@ parse_encoding (const char *m) { //BASE64URLNOPAD if ((m[10] == 'O') && (m[11] == 'P') && (m[12] == 'A') && (m[13] == 'D') && (term(m[14]))) { r = BASE64URLNOPAD; - p = 14; goto ok; } goto invalid; @@ -101,7 +98,6 @@ parse_encoding (const char *m) { //HEX if (term(m[3])) { r = HEX; - p = 3; goto ok; } switch (m[3]) { @@ -113,7 +109,6 @@ parse_encoding (const char *m) { //HEXLC if ((m[4] == 'C') && (term(m[5]))) { r = HEXLC; - p = 5; goto ok; } goto invalid; @@ -121,7 +116,6 @@ parse_encoding (const char *m) { //HEXUC if ((m[4] == 'C') && (term(m[5]))) { r = HEXUC; - p = 5; goto ok; } goto invalid; @@ -129,7 +123,6 @@ parse_encoding (const char *m) { //IDENTITY if ((m[1] == 'D') && (m[2] == 'E') && (m[3] == 'N') && (m[4] == 'T') && (m[5] == 'I') && (m[6] == 'T') && (m[7] == 'Y') && (term(m[8]))) { r = IDENTITY; - p = 8; goto ok; } goto invalid; @@ -147,7 +140,6 @@ parse_encoding (const char *m) { //URL if (term(m[3])) { r = URL; - p = 3; goto ok; } switch (m[3]) { @@ -159,7 +151,6 @@ parse_encoding (const char *m) { //URLLC if ((m[4] == 'C') && (term(m[5]))) { r = URLLC; - p = 5; goto ok; } goto invalid; @@ -167,7 +158,6 @@ parse_encoding (const char *m) { //URLUC if ((m[4] == 'C') && (term(m[5]))) { r = URLUC; - p = 5; goto ok; } goto invalid; From geoff at uplex.de Mon Sep 4 18:30:10 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 04 Sep 2017 20:30:10 +0200 Subject: [master] b7d5480 VMOD blob: increase workspace for a couple of vtc tests Message-ID: commit b7d548087cba07f8afc25f3079455f737bdd0b57 Author: Geoff Simmons Date: Mon Sep 4 20:28:45 2017 +0200 VMOD blob: increase workspace for a couple of vtc tests diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index c9210c7..2dca6f3 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -1,6 +1,7 @@ varnishtest "VMOD blob hex encode and decode" -varnish v1 -vcl { +# Some platforms need larger workspaces for this test +varnish v1 -arg "-p workspace_client=256k" -vcl { import blob; import std; backend b { .host = "${bad_ip}"; } diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index 8ddd7c0..b5cd490 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -1,6 +1,7 @@ varnishtest "VMOD blob test transcode()" -varnish v1 -vcl { +# Some platforms need larger workspaces for this test +varnish v1 -arg "-p workspace_client=256k" -vcl { import blob; import std; backend b { .host = "${bad_ip}"; } From geoff at uplex.de Mon Sep 4 18:41:11 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 04 Sep 2017 20:41:11 +0200 Subject: [master] 382c808 VMOD blob: use sentinel values that are strictly signed char in the decode table for base64. Message-ID: commit 382c8081b9de66e176c2797ff10b6fa1e1aed0eb Author: Geoff Simmons Date: Mon Sep 4 20:39:12 2017 +0200 VMOD blob: use sentinel values that are strictly signed char in the decode table for base64. diff --git a/lib/libvmod_blob/base64.h b/lib/libvmod_blob/base64.h index 708b588..bd83798 100644 --- a/lib/libvmod_blob/base64.h +++ b/lib/libvmod_blob/base64.h @@ -28,8 +28,8 @@ #include "vmod_blob.h" -#define ILL ((int8_t) -1) -#define PAD ((int8_t) -2) +#define ILL ((int8_t) 127) +#define PAD ((int8_t) 126) static const struct b64_alphabet { const char b64[64]; From dridi.boukelmoune at gmail.com Mon Sep 4 19:01:10 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 04 Sep 2017 21:01:10 +0200 Subject: [master] 3287799 Remove blob operations from vmod-vtc Message-ID: commit 32877991a478ee807ef0dd0f0742804ec89eb2cd Author: Dridi Boukelmoune Date: Mon Sep 4 20:41:33 2017 +0200 Remove blob operations from vmod-vtc They were inherited from vmod-debug, from a time when vmod-blob didn't exist in the source tree. Refs #2362 Refs #2402 Refs #2407 diff --git a/bin/varnishtest/tests/b00051.vtc b/bin/varnishtest/tests/b00051.vtc index 1ec12a1..ffa5bc5 100644 --- a/bin/varnishtest/tests/b00051.vtc +++ b/bin/varnishtest/tests/b00051.vtc @@ -6,12 +6,13 @@ server s1 { } -start varnish v1 -vcl+backend { - import vtc; + import blob; + sub vcl_backend_response { - set beresp.http.bereq_hash = vtc.blob2hex(bereq.hash); + set beresp.http.bereq_hash = blob.encode(HEXLC, bereq.hash); } sub vcl_deliver { - set resp.http.req_hash = vtc.blob2hex(req.hash); + set resp.http.req_hash = blob.encode(HEXLC, req.hash); } } -start diff --git a/bin/varnishtest/tests/m00012.vtc b/bin/varnishtest/tests/m00012.vtc index 276fa08..294458c 100644 --- a/bin/varnishtest/tests/m00012.vtc +++ b/bin/varnishtest/tests/m00012.vtc @@ -1,44 +1,21 @@ varnishtest "Test VMOD BLOBS" -server s1 { - rxreq - txresp -} -start - -varnish v1 -vcl+backend { - import vtc; - - sub vcl_deliver { - set resp.http.foo = vtc.blob2hex(vtc.str2blob("gunk")); - } -} -start - -client c1 { - txreq - rxresp - expect resp.http.foo == 67756e6b -} -run - -delay .1 - varnish v1 -errvcl {BLOBs can only be used as arguments to VMOD functions.} { - backend b1 {.host = "127.0.0.1";} - - import vtc; + backend b1 {.host = "${bad_backend}";} sub vcl_deliver { - set resp.http.foo = vtc.str2blob("gunk"); + set resp.http.foo = req.hash; } } varnish v1 -errvcl {Wrong argument type. Expected BLOB. Got STRING.} { - backend b1 {.host = "127.0.0.1";} + backend b1 {.host = "${bad_backend}";} - import vtc; + import blob; sub vcl_deliver { - set resp.http.foo = vtc.blob2hex("gunk"); + blob.encode(blob = "blob"); } } diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 77dcefa..ba2dd54 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -219,18 +219,18 @@ varnish v1 -errvcl {Function returns VOID} { } varnish v1 -errvcl {'req.hash': Not available in method 'vcl_recv'.} { + import blob; backend b { .host = "127.0.0.1"; } - import vtc; sub vcl_recv { - set req.http.foo = vtc.blob2hex(req.hash); + blob.encode(HEXLC, req.hash); } } varnish v1 -errvcl {'req.hash': Not available in method 'vcl_hash'.} { + import blob; backend b { .host = "127.0.0.1"; } - import vtc; sub vcl_hash { - set req.http.foo = vtc.blob2hex(req.hash); + blob.encode(HEXLC, req.hash); } } @@ -255,9 +255,9 @@ varnish v1 -errvcl {Expected 'from path ...'} { } varnish v1 -errvcl {INT * BLOB not possible.} { - import vtc; + import blob; sub vcl_deliver { - set resp.status = 100 * vtc.str2blob("a"); + set resp.status = 100 * blob.decode(HEX, "a"); } } diff --git a/lib/libvmod_vtc/vmod.vcc b/lib/libvmod_vtc/vmod.vcc index a616c30..b57a794 100644 --- a/lib/libvmod_vtc/vmod.vcc +++ b/lib/libvmod_vtc/vmod.vcc @@ -128,20 +128,6 @@ Returns the size in bytes of a collection of C-datatypes: This can be useful for VMOD authors in conjunction with workspace operations. -BLOBS -===== - -For VMODs dealing with BLOB arguments or return values, the following functions -offer convenience conversions to and from STRING. - -$Function BLOB str2blob(STRING src) - -Turn a string into a blob. - -$Function STRING blob2hex(BLOB src) - -Hexdump a blob. - SEE ALSO ======== diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c index c4e18cf..e1afcf8 100644 --- a/lib/libvmod_vtc/vmod_vtc.c +++ b/lib/libvmod_vtc/vmod_vtc.c @@ -221,42 +221,3 @@ vmod_typesize(VRT_CTX, VCL_STRING s) } return (i); } - -/*--------------------------------------------------------------------*/ - -VCL_BLOB __match_proto__(td_vtc_str2blob) -vmod_str2blob(VRT_CTX, VCL_STRING s) -{ - struct vmod_priv *p; - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - - p = WS_Alloc(ctx->ws, sizeof *p); - AN(p); - memset(p, 0, sizeof *p); - p->len = strlen(s); - p->priv = WS_Copy(ctx->ws, s, -1); - return (p); -} - -VCL_STRING __match_proto__(td_vtc_blob2hex) -vmod_blob2hex(VRT_CTX, VCL_BLOB b) -{ - char *s, *p; - uint8_t *q; - int i; - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - - s = WS_Alloc(ctx->ws, b->len * 2 + 2); - AN(s); - p = s; - q = b->priv; - for (i = 0; i < b->len; i++) { - assert(snprintf(p, 3, "%02x", *q) == 2); - p += 2; - q += 1; - } - VRT_priv_fini(b); - return (s); -} From fgsch at lodoss.net Mon Sep 4 20:52:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 04 Sep 2017 22:52:06 +0200 Subject: [master] c6422b5 Whitespace Message-ID: commit c6422b5c1bfb91e515a34ca74849f977286584f5 Author: Federico G. Schwindt Date: Mon Sep 4 18:55:35 2017 +0100 Whitespace diff --git a/lib/libvmod_blob/base64.h b/lib/libvmod_blob/base64.h index bd83798..962ae22 100644 --- a/lib/libvmod_blob/base64.h +++ b/lib/libvmod_blob/base64.h @@ -47,7 +47,7 @@ static const struct b64_alphabet { ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 62, ILL, ILL, ILL, 63, /* +, - */ 52, 53, 54, 55, 56, 57, 58, 59, /* 0 - 7 */ - 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ + 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ ILL, 0, 1, 2, 3, 4, 5, 6, /* A - G */ 7, 8, 9, 10, 11, 12, 13, 14, /* H - O */ 15, 16, 17, 18, 19, 20, 21, 22, /* P - W */ @@ -86,7 +86,7 @@ static const struct b64_alphabet { ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 62, ILL, ILL, /* - */ 52, 53, 54, 55, 56, 57, 58, 59, /* 0 - 7 */ - 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ + 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ ILL, 0, 1, 2, 3, 4, 5, 6, /* A - G */ 7, 8, 9, 10, 11, 12, 13, 14, /* H - O */ 15, 16, 17, 18, 19, 20, 21, 22, /* P - W */ @@ -125,7 +125,7 @@ static const struct b64_alphabet { ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 62, ILL, ILL, /* - */ 52, 53, 54, 55, 56, 57, 58, 59, /* 0 - 7 */ - 60, 61, ILL, ILL, ILL, ILL, ILL, ILL, /* 8, 9 */ + 60, 61, ILL, ILL, ILL, ILL, ILL, ILL, /* 8, 9 */ ILL, 0, 1, 2, 3, 4, 5, 6, /* A - G */ 7, 8, 9, 10, 11, 12, 13, 14, /* H - O */ 15, 16, 17, 18, 19, 20, 21, 22, /* P - W */ diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h index 1b809e1..3953035 100644 --- a/lib/libvmod_blob/vmod_blob.h +++ b/lib/libvmod_blob/vmod_blob.h @@ -64,7 +64,7 @@ size_t len_f(size_t); * otherwise, the number of bytes written (note that this does not * include any terminating null byte) */ -typedef +typedef ssize_t encode_f(const enum encoding enc, char *restrict const buf, const size_t buflen, const char *restrict const in, const size_t inlen); From fgsch at lodoss.net Mon Sep 4 20:52:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 04 Sep 2017 22:52:06 +0200 Subject: [master] a4d3479 Polish Message-ID: commit a4d347943a0826ee87e6982083f862127deab32a Author: Federico G. Schwindt Date: Mon Sep 4 21:40:12 2017 +0100 Polish diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 0edf6d4..8c22e1a 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -769,19 +769,19 @@ VRT_BODY_L(resp) /*--------------------------------------------------------------------*/ static struct vmod_priv * -vrt_hash_blob(VRT_CTX, uint8_t *digest) +vrt_do_blob(VRT_CTX, const char *err, uint8_t *src, size_t len) { struct vmod_priv *p; void *d; p = (void *)WS_Alloc(ctx->ws, sizeof *p); - d = WS_Copy(ctx->ws, digest, DIGEST_LEN); + d = WS_Copy(ctx->ws, src, len); if (p == NULL || d == NULL) { - VRT_fail(ctx, "Workspace overflow ((be)req.hash)"); + VRT_fail(ctx, "Workspace overflow (%s)", err); return (NULL); } memset(p, 0, sizeof *p); - p->len = DIGEST_LEN; + p->len = len; p->priv = d; return (p); } @@ -791,7 +791,8 @@ VRT_r_req_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - return (vrt_hash_blob(ctx, ctx->req->digest)); + return (vrt_do_blob(ctx, "req.hash", ctx->req->digest, + DIGEST_LEN)); } VCL_BLOB @@ -799,7 +800,8 @@ VRT_r_bereq_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - return (vrt_hash_blob(ctx, ctx->bo->digest)); + return (vrt_do_blob(ctx, "bereq.hash", ctx->bo->digest, + DIGEST_LEN)); } /*--------------------------------------------------------------------*/ From fgsch at lodoss.net Mon Sep 4 22:15:07 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 05 Sep 2017 00:15:07 +0200 Subject: [master] c36fcf8 Add missing changelogs Message-ID: commit c36fcf83a26dace6274f5474b7b8a31d6eb04811 Author: Federico G. Schwindt Date: Mon Sep 4 23:03:59 2017 +0100 Add missing changelogs Fixes #2408. diff --git a/doc/changes.rst b/doc/changes.rst index f390d7d..9003c32 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -367,6 +367,103 @@ News for Vmod Authors * PRIV_* now also work for object methods with unchanged scope. +================================ +Varnish Cache 4.1.8 (2017-08-02) +================================ + +Changes since 4.1.7: + +* Update in the documentation of timestamps + +Bugs fixed +---------- + +* 2379_ - Correctly handle bogusly large chunk sizes (VSV00001) + +.. _2379: https://github.com/varnishcache/varnish-cache/issues/2379 + +================================ +Varnish Cache 4.1.7 (2017-06-28) +================================ + +Changes since 4.1.7-beta1: + +* Add extra locking to protect the pools list and refcounts +* Don't panic on a null ban + +Bugs fixed +---------- + +* 2321_ - Prevent storage backends name collisions + +.. _2321: https://github.com/varnishcache/varnish-cache/issues/2321 + +====================================== +Varnish Cache 4.1.7-beta1 (2017-06-15) +====================================== + +Changes since 4.1.6: + +* Add -vsl_catchup to varnishtest +* Add record-prefix support to varnishncsa + +Bugs fixed +---------- +* 1764_ - Correctly honor nuke_limit parameter +* 2022_ - varnishstat -1 -f field inclusion glob doesn't allow VBE + backend fields +* 2069_ - Health probes fail when HTTP response does not contain + reason phrase +* 2118_ - "varnishstat -f MAIN.sess_conn -1" produces empty output +* 2219_ - Remember to reset workspace +* 2320_ - Rework and fix varnishstat counter filtering +* 2329_ - Docfix: Only root can jail + +.. _1764: https://github.com/varnishcache/varnish-cache/issues/1764 +.. _2022: https://github.com/varnishcache/varnish-cache/issues/2022 +.. _2069: https://github.com/varnishcache/varnish-cache/issues/2069 +.. _2118: https://github.com/varnishcache/varnish-cache/issues/2118 +.. _2219: https://github.com/varnishcache/varnish-cache/issues/2219 +.. _2320: https://github.com/varnishcache/varnish-cache/issues/2320 +.. _2329: https://github.com/varnishcache/varnish-cache/issues/2329 + +================================ +Varnish Cache 4.1.6 (2017-04-26) +================================ + +* Introduce a vxid left hand side for VSL queries. This allows + matching on records matching a known vxid. +* Environment variables are now available in the stdandard VMOD; + std.getenv() +* Add setenv command to varnishtest + + +Bugs fixed +---------- +* 2200_ - Dramatically simplify VEV, fix assert in vev.c +* 2216_ - Make sure Age is always less than max-age +* 2233_ - Correct check when parsing the query string +* 2241_ - VSL fails to get hold of SHM +* 2270_ - Newly loaded auto VCLs don't get their go_cold timer set +* 2273_ - Master cooling problem +* 2275_ - If the client workspace is almost, but not quite exhaused, we may + not be able to get enough iovec's to do Chunked transmission. +* 2295_ - Spinning loop in VBE_Poll causes master to kill child on + CLI timeout +* 2301_ - Don't attempt to check if varnishd is still running if we have + already failed. +* 2313_ - Cannot link to varnishapi, symbols missing + +.. _2200: https://github.com/varnishcache/varnish-cache/issues/2200 +.. _2216: https://github.com/varnishcache/varnish-cache/pull/2216 +.. _2233: https://github.com/varnishcache/varnish-cache/issues/2233 +.. _2241: https://github.com/varnishcache/varnish-cache/issues/2241 +.. _2270: https://github.com/varnishcache/varnish-cache/issues/2270 +.. _2273: https://github.com/varnishcache/varnish-cache/pull/2273 +.. _2275: https://github.com/varnishcache/varnish-cache/issues/2275 +.. _2295: https://github.com/varnishcache/varnish-cache/issues/2295 +.. _2301: https://github.com/varnishcache/varnish-cache/issues/2301 +.. _2313: https://github.com/varnishcache/varnish-cache/issues/2313 ================================ Varnish Cache 4.1.5 (2017-02-09) @@ -493,7 +590,7 @@ Bugs fixed * 2024_ - panic vmod_rr_resolve() round_robin.c line 75 (be) != NULL * 2011_ - VBE.*.conn (concurrent connections to backend) not working as expected * 2008_ - Assert error in VBE_Delete() -* 2007_ - Update documentation part about CLI/management port authentication paramater +* 2007_ - Update documentation part about CLI/management port authentication parameter * 1881_ - std.cache_req_body() w/ return(pipe) is broken .. _2027: https://github.com/varnishcache/varnish-cache/issues/2027 From fgsch at lodoss.net Mon Sep 4 23:56:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 05 Sep 2017 01:56:06 +0200 Subject: [master] 21030ab Correct function names on diagnostic messages Message-ID: commit 21030ab457fd8e1f6a1ca17ded12b86c8988ee98 Author: Federico G. Schwindt Date: Tue Sep 5 00:38:39 2017 +0100 Correct function names on diagnostic messages diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index cf7456b..ebca6f2 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -427,7 +427,8 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) p = e + 1; if (av[0] != NULL || ac < 4 || ac > 5) { - (void)(vsm_diag(vd, "VSM_Open: bad index (%d/%s)", + (void)(vsm_diag(vd, + "vsm_refresh_set2: bad index (%d/%s)", ac, av[0])); VAV_Free(av); break; @@ -506,7 +507,8 @@ VSM_Status(struct vsm *vd) if (vd->dfd < 0) { vd->dfd = open(vd->dname, O_RDONLY); if (vd->dfd < 0) - (void)vsm_diag(vd, "VSM_Open: Cannot open workdir"); + (void)vsm_diag(vd, + "VSM_Status: Cannot open workdir"); else AZ(fstat(vd->dfd, &vd->dst)); } @@ -710,7 +712,7 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf) AN(vf->b); vg = vsm_findseg(vd, vf); if (vg == NULL) - return (vsm_diag(vd, "VSM_Map: bad fantom")); + return (vsm_diag(vd, "VSM_Unmap: bad fantom")); assert(vg->refs > 0); vg->refs--; vf->b = NULL; From fgsch at lodoss.net Mon Sep 4 23:56:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 05 Sep 2017 01:56:06 +0200 Subject: [master] ffdeafe Always initialise vd->dname Message-ID: commit ffdeafe345670b8e213a4b4a68f0674ee519264d Author: Federico G. Schwindt Date: Tue Sep 5 00:40:53 2017 +0100 Always initialise vd->dname This was lost in commit 74328de8eeb2703591fe59190f73fcabf057adbe. Fixes #2412. diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index ebca6f2..235c9e0 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -531,7 +531,7 @@ VSM_Attach(struct vsm *vd, int progress) { double t0; unsigned u; - int n = 0; + int i, n = 0; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); @@ -540,6 +540,14 @@ VSM_Attach(struct vsm *vd, int progress) else t0 = VTIM_mono() + vd->patience; + if (vd->dname == NULL) { + /* Use default (hostname) */ + i = VSM_Arg(vd, 'n', ""); + if (i < 0) + return (i); + AN(vd->dname); + } + AZ(vd->attached); while (1) { u = VSM_Status(vd); From dridi.boukelmoune at gmail.com Tue Sep 5 10:00:11 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 05 Sep 2017 12:00:11 +0200 Subject: [master] 83a93b0 Accept a negative TTL with purge.soft Message-ID: commit 83a93b0bd12cabed7cf3b1c0aaba71ff701b6800 Author: Dridi Boukelmoune Date: Tue Sep 5 09:57:32 2017 +0200 Accept a negative TTL with purge.soft diff --git a/lib/libvmod_purge/vmod.vcc b/lib/libvmod_purge/vmod.vcc index a935732..1e9259e 100644 --- a/lib/libvmod_purge/vmod.vcc +++ b/lib/libvmod_purge/vmod.vcc @@ -93,8 +93,8 @@ $Function INT soft(DURATION ttl = 0, DURATION grace = -1, DURATION keep = -1) Description Sets the TTL, grace and keep. By default, TTL is set to 0 with grace - and keep periods left untouched. Setting a negative value for any of - the parameters leaves them untouched. Setting all three parameters to + and keep periods left untouched. Setting a negative value for grace or + keep periods leaves them untouched. Setting all three parameters to 0 is equivalent to a hard purge. It can only be called from ``vcl_hit`` or ``vcl_miss``. It returns the number of soft-purged objects. diff --git a/lib/libvmod_purge/vmod_purge.c b/lib/libvmod_purge/vmod_purge.c index 7fba6b2..4ba039b 100644 --- a/lib/libvmod_purge/vmod_purge.c +++ b/lib/libvmod_purge/vmod_purge.c @@ -49,8 +49,6 @@ vmod_soft(VRT_CTX, VCL_DURATION ttl, VCL_DURATION grace, VCL_DURATION keep) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (ttl < 0) - ttl = NAN; if (grace < 0) grace = NAN; if (keep < 0) From dridi.boukelmoune at gmail.com Tue Sep 5 10:00:11 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 05 Sep 2017 12:00:11 +0200 Subject: [master] 75966f9 Polish Message-ID: commit 75966f92f7bf280af6d86df5ebebd4fdb8b9abc9 Author: Dridi Boukelmoune Date: Tue Sep 5 11:39:44 2017 +0200 Polish diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 3657376..313ed52 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -397,10 +397,7 @@ VGZ_Destroy(struct vgz **vgp) enum vgzret_e vr; int i; - vg = *vgp; - CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - *vgp = NULL; - + TAKE_OBJ_NOTNULL(vg, vgp, VGZ_MAGIC); AN(vg->id); VSLb(vg->vsl, SLT_Gzip, "%s %jd %jd %jd %jd %jd", vg->id, diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c index e80d1b7..cb40ea9 100644 --- a/lib/libvarnish/vcli_serve.c +++ b/lib/libvarnish/vcli_serve.c @@ -607,9 +607,7 @@ VCLS_Destroy(struct VCLS **csp) struct VCLS_fd *cfd, *cfd2; struct cli_proto *clp; - cs = *csp; - *csp = NULL; - CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); + TAKE_OBJ_NOTNULL(cs, csp, VCLS_MAGIC); VTAILQ_FOREACH_SAFE(cfd, &cs->fds, list, cfd2) cls_close_fd(cs, cfd); diff --git a/lib/libvarnish/vsmw.c b/lib/libvarnish/vsmw.c index ee9fa3e..a5c7e3f 100644 --- a/lib/libvarnish/vsmw.c +++ b/lib/libvarnish/vsmw.c @@ -301,11 +301,7 @@ VSMW_Destroy(struct vsmw **pp) struct vsmw *vsmw; struct vsmwseg *seg, *s2; - AN(pp); - AN(*pp); - vsmw = *pp; - *pp = NULL; - CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC); + TAKE_OBJ_NOTNULL(vsmw, pp, VSMW_MAGIC); AZ(unlinkat(vsmw->vdirfd, vsmw->idx, 0)); REPLACE(vsmw->idx, NULL); VTAILQ_FOREACH_SAFE(seg, &vsmw->segs, list, s2) diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 235c9e0..bbdc8ab 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -237,11 +237,7 @@ VSM_Destroy(struct vsm **vdp) { struct vsm *vd; - AN(vdp); - vd = *vdp; - *vdp = NULL; - - CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); + TAKE_OBJ_NOTNULL(vd, vdp, VSM_MAGIC); if (vd->vsc != NULL) VSC_Delete(vd->vsc); From phk at FreeBSD.org Tue Sep 5 10:49:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Sep 2017 12:49:06 +0200 Subject: [master] 7e48c02 Whitespace OCD Message-ID: commit 7e48c02115a114507463da80986ffd68d78be7f0 Author: Poul-Henning Kamp Date: Tue Sep 5 10:48:40 2017 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index 11f36e6..cb15b5e 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -51,7 +51,7 @@ varnish v1 -vcl { decoding=IDENTITY)); set resp.http.truncated = - blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); } } -start diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index 2dca6f3..b26d151 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -19,26 +19,26 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.hexlc = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode(IDENTITY, req.http.pangram)); set resp.http.hexuc = - blob.encode(HEXUC, + blob.encode(HEXUC, blob.decode(IDENTITY, req.http.pangram)); - set resp.http.hobbeslc = + set resp.http.hobbeslc = blob.encode(HEXLC, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEXUC, blob.decode(IDENTITY, req.http.hobbes)); - set resp.http.all-lc = + set resp.http.all-lc = blob.encode(HEXLC, blob.decode(BASE64, req.http.b64all)); set resp.http.all-uc = blob.encode(HEXUC, blob.decode(BASE64, req.http.b64all)); - set resp.http.empty-lc = + set resp.http.empty-lc = blob.encode(HEXLC, blob.decode(IDENTITY, "")); set resp.http.empty-uc = @@ -55,41 +55,41 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); # Hobbes quotation in hex - set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; set req.http.hexhobbesuc = std.toupper(req.http.hexhobbeslc); - set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; + set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; set req.http.hexalllc = std.tolower(req.http.hexalluc); - set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); - set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); + set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); + set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); set resp.http.decuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.hexucfoobar)); set resp.http.declc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.hexlcfoobar)); set resp.http.dechobbesuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.hexhobbesuc)); set resp.http.dechobbeslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode(HEX, req.http.hexalluc)); + blob.encode(BASE64, blob.decode(HEX, req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode(HEX, req.http.hexalllc)); + blob.encode(BASE64, blob.decode(HEX, req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob.decode(HEX, + blob.encode(BASE64, blob.decode(HEX, req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob.decode(HEX, + blob.encode(BASE64, blob.decode(HEX, req.http.hexalllcodd)); set resp.http.decempty = @@ -102,7 +102,7 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { blob.encode(IDENTITY, blob.decode(HEX, "0")); set resp.http.decemptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.unset + "" + req.http.unset + "")); @@ -123,7 +123,7 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode(HEX, "" + req.http.unset + blob.encode(IDENTITY, blob.decode(HEX, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -188,8 +188,8 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect 0 * Begin req - expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" + expect 0 * Begin req + expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" #" expect * = End } -start diff --git a/bin/varnishtest/tests/m00036.vtc b/bin/varnishtest/tests/m00036.vtc index 88f869a..21ff627 100644 --- a/bin/varnishtest/tests/m00036.vtc +++ b/bin/varnishtest/tests/m00036.vtc @@ -18,26 +18,26 @@ varnish v1 -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.hexlc = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode_n(5, IDENTITY, req.http.pangram)); set resp.http.hexuc = - blob.encode(HEXUC, + blob.encode(HEXUC, blob.decode_n(5, IDENTITY, req.http.pangram)); - set resp.http.hobbeslc = + set resp.http.hobbeslc = blob.encode(HEXLC, blob.decode_n(5, IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEXUC, blob.decode_n(5, IDENTITY, req.http.hobbes)); - set resp.http.all-lc = + set resp.http.all-lc = blob.encode(HEXLC, blob.decode_n(8, BASE64, req.http.b64all)); set resp.http.all-uc = blob.encode(HEXUC, blob.decode_n(8, BASE64, req.http.b64all)); - set resp.http.empty-lc = + set resp.http.empty-lc = blob.encode(HEXLC, blob.decode_n(5, IDENTITY, "")); set resp.http.empty-uc = @@ -54,41 +54,41 @@ varnish v1 -vcl { set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); # Hobbes quotation in hex - set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; set req.http.hexhobbesuc = std.toupper(req.http.hexhobbeslc); - set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; + set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; set req.http.hexalllc = std.tolower(req.http.hexalluc); - set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); - set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); + set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); + set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); set resp.http.decuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(10, HEX, req.http.hexucfoobar)); set resp.http.declc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(10, HEX, req.http.hexlcfoobar)); set resp.http.dechobbesuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(12, HEX, req.http.hexhobbesuc)); set resp.http.dechobbeslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(12, HEX, req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalluc)); + blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalllc)); + blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob.decode_n(11, HEX, + blob.encode(BASE64, blob.decode_n(11, HEX, req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob.decode_n(11, HEX, + blob.encode(BASE64, blob.decode_n(11, HEX, req.http.hexalllcodd)); set resp.http.decempty = @@ -101,7 +101,7 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob.decode_n(2, HEX, "0")); set resp.http.decemptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(5, HEX, req.http.unset + "" + req.http.unset + "")); @@ -122,7 +122,7 @@ varnish v1 -vcl { "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode_n(20, HEX, "" + req.http.unset + blob.encode(IDENTITY, blob.decode_n(20, HEX, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -187,8 +187,8 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect 0 * Begin req - expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" + expect 0 * Begin req + expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" #" expect * = End } -start diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index 29bde50..13dc2d5 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -18,37 +18,37 @@ varnish v1 -vcl { {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set resp.http.b64 = - blob.encode(BASE64, blob.decode(IDENTITY, + blob.encode(BASE64, blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64hobbes = - blob.encode(BASE64, blob.decode(IDENTITY, + blob.encode(BASE64, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64all = blob.encode(BASE64, blob.decode(HEX, req.http.hexall)); set resp.http.b64url = - blob.encode(BASE64URL, + blob.encode(BASE64URL, blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64urlhobbes = - blob.encode(BASE64URL, + blob.encode(BASE64URL, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64urlall = blob.encode(BASE64URL, blob.decode(HEX, req.http.hexall)); set resp.http.b64urlnopad = - blob.encode(BASE64URLNOPAD, + blob.encode(BASE64URLNOPAD, blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64nopadhobbes = - blob.encode(BASE64URLNOPAD, + blob.encode(BASE64URLNOPAD, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64nopadall = - blob.encode(BASE64URLNOPAD, + blob.encode(BASE64URLNOPAD, blob.decode(HEX, req.http.hexall)); set resp.http.b64empty = @@ -134,26 +134,26 @@ varnish v1 -vcl { blob.decode(BASE64, req.http.pangram)); set resp.http.b64dechobbes = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(BASE64, req.http.hobbes)); set resp.http.b64decall = blob.encode(HEXLC, blob.decode(BASE64, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob.decode(BASE64URL, + blob.encode(IDENTITY, blob.decode(BASE64URL, req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode(BASE64URL, req.http.allurl)); set resp.http.nopaddechobbes = - blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, req.http.hobbesnopad)); set resp.http.nopaddecall = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode(BASE64URLNOPAD, req.http.allurl)); set resp.http.b64empty = @@ -167,34 +167,34 @@ varnish v1 -vcl { blob.decode(BASE64, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); - set resp.http.decenc + set resp.http.decenc = blob.encode(BASE64, blob.decode(BASE64, req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob.decode(BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw==")); + resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces = blob.encode(IDENTITY, blob.decode(BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw" - + resp.http.pad)); + resp.http.l + "0hlbGxvIHdvcmxkLw" + + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces = blob.encode(IDENTITY, blob.decode(BASE64, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw" - + resp.http.pad)); + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw" + + resp.http.pad)); set resp.http.dec7param = blob.encode(blob=blob.decode(encoded=resp.http.l + "0hlb" - + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" - + resp.http.pad, decoding=BASE64), - encoding=IDENTITY); + + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + + resp.http.pad, decoding=BASE64), + encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, @@ -202,17 +202,17 @@ varnish v1 -vcl { set resp.http.decnopad2pieces = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, - resp.http.l + "0hlbGxvIHdvcmxkLw")); + resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw")); + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, - "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); } @@ -255,19 +255,19 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - set req.http.foo = "AAA="; - if (req.url == "/base64") { - set resp.http.bad64 = blob.encode(IDENTITY, - blob.decode(BASE64, "-_-_" + req.http.foo)); - } - elsif (req.url == "/base64url") { - set resp.http.badurl = blob.encode(IDENTITY, - blob.decode(BASE64URL, "+/+/" + req.http.foo)); - } - elsif (req.url == "/base64urlnopad") { - set resp.http.badpad = blob.encode(IDENTITY, - blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); - } + set req.http.foo = "AAA="; + if (req.url == "/base64") { + set resp.http.bad64 = blob.encode(IDENTITY, + blob.decode(BASE64, "-_-_" + req.http.foo)); + } + elsif (req.url == "/base64url") { + set resp.http.badurl = blob.encode(IDENTITY, + blob.decode(BASE64URL, "+/+/" + req.http.foo)); + } + elsif (req.url == "/base64urlnopad") { + set resp.http.badpad = blob.encode(IDENTITY, + blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); + } } } diff --git a/bin/varnishtest/tests/m00038.vtc b/bin/varnishtest/tests/m00038.vtc index 99c7d69..f69bd58 100644 --- a/bin/varnishtest/tests/m00038.vtc +++ b/bin/varnishtest/tests/m00038.vtc @@ -21,17 +21,17 @@ varnish v1 -vcl { {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; set resp.http.dec - = blob.encode(IDENTITY, + = blob.encode(IDENTITY, blob.decode_n(8, BASE64, req.http.foobarbazquux)); set resp.http.deceq - = blob.encode(IDENTITY, + = blob.encode(IDENTITY, blob.decode_n(20, BASE64, req.http.foobarbazquux)); set resp.http.declong - = blob.encode(IDENTITY, + = blob.encode(IDENTITY, blob.decode_n(30, BASE64, req.http.foobarbazquux)); @@ -40,25 +40,25 @@ varnish v1 -vcl { blob.decode_n(12, BASE64, req.http.pangram)); set resp.http.b64dechobbes = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(24, BASE64, req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEXLC, blob.decode_n(128, BASE64, + blob.encode(HEXLC, blob.decode_n(128, BASE64, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob.decode_n(180, BASE64URL, + blob.encode(IDENTITY, blob.decode_n(180, BASE64URL, req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode_n(256, BASE64URL, req.http.allurl)); set resp.http.nopaddechobbes = blob.encode(IDENTITY, - blob.decode_n(500, BASE64URLNOPAD, + blob.decode_n(500, BASE64URLNOPAD, req.http.hobbesnopad)); set resp.http.nopaddecall = @@ -71,14 +71,14 @@ varnish v1 -vcl { set resp.http.urlempty = blob.encode(IDENTITY, blob.decode_n(1, BASE64URL, "")); set resp.http.nopadempty = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(0, BASE64URLNOPAD, "")); set resp.http.emptypieces = blob.encode(IDENTITY, blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); - set resp.http.decenc + set resp.http.decenc = blob.encode(BASE64, blob.decode_n(20, BASE64, req.http.foobarbazquux)); @@ -86,27 +86,27 @@ varnish v1 -vcl { set resp.http.l = "L"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob.decode_n(8, BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw==")); + resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces = blob.encode(IDENTITY, blob.decode_n(12, BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw" - + resp.http.pad)); + resp.http.l + "0hlbGxvIHdvcmxkLw" + + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces = blob.encode(IDENTITY, blob.decode_n(16, BASE64, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw" - + resp.http.pad)); + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw" + + resp.http.pad)); set resp.http.dec7param = blob.encode(blob=blob.decode_n(encoded=resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad, decoding=BASE64, n=20), - encoding=IDENTITY); + encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, blob.decode_n(18, BASE64URLNOPAD, @@ -114,17 +114,17 @@ varnish v1 -vcl { set resp.http.decnopad2pieces = blob.encode(IDENTITY, blob.decode_n(19, BASE64URLNOPAD, - resp.http.l + "0hlbGxvIHdvcmxkLw")); + resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces = blob.encode(IDENTITY, blob.decode_n(18, BASE64URLNOPAD, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw")); + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, blob.decode_n(60, BASE64URLNOPAD, - "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); } @@ -169,20 +169,20 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - set req.http.foo = "AAA="; - if (req.url == "/base64") { - set resp.http.bad64 = blob.encode(IDENTITY, - blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); - } - elsif (req.url == "/base64url") { - set resp.http.badurl = blob.encode(IDENTITY, - blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); - } - elsif (req.url == "/base64urlnopad") { - set resp.http.badpad = blob.encode(IDENTITY, - blob.decode_n(8, BASE64URLNOPAD, + set req.http.foo = "AAA="; + if (req.url == "/base64") { + set resp.http.bad64 = blob.encode(IDENTITY, + blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); + } + elsif (req.url == "/base64url") { + set resp.http.badurl = blob.encode(IDENTITY, + blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); + } + elsif (req.url == "/base64urlnopad") { + set resp.http.badpad = blob.encode(IDENTITY, + blob.decode_n(8, BASE64URLNOPAD, "TWFu" + req.http.foo)); - } + } } } diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index f5d4809..77fb240 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -22,48 +22,48 @@ varnish v1 -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.urllc = - blob.encode(URLLC, + blob.encode(URLLC, blob.decode(IDENTITY, req.http.pangram)); set resp.http.urluc = - blob.encode(URLUC, + blob.encode(URLUC, blob.decode(IDENTITY, req.http.pangram)); - set resp.http.hobbeslc = + set resp.http.hobbeslc = blob.encode(URLLC, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = blob.encode(URLUC, blob.decode(IDENTITY, req.http.hobbes)); - set resp.http.umlautslc = + set resp.http.umlautslc = blob.encode(URLLC, - blob.decode(IDENTITY, req.http.umlauts)); + blob.decode(IDENTITY, req.http.umlauts)); - set resp.http.umlautsuc = + set resp.http.umlautsuc = blob.encode(URLUC, - blob.decode(IDENTITY, req.http.umlauts)); + blob.decode(IDENTITY, req.http.umlauts)); - set resp.http.phklc = + set resp.http.phklc = blob.encode(URLLC, - blob.decode(IDENTITY, req.http.phkspeak)); + blob.decode(IDENTITY, req.http.phkspeak)); - set resp.http.phkuc = + set resp.http.phkuc = blob.encode(URLUC, - blob.decode(IDENTITY, req.http.phkspeak)); + blob.decode(IDENTITY, req.http.phkspeak)); - set resp.http.utf8lc = + set resp.http.utf8lc = blob.encode(URLLC, blob.decode(IDENTITY, req.http.utf8)); - set resp.http.utf8uc = + set resp.http.utf8uc = blob.encode(URLUC, blob.decode(IDENTITY, req.http.utf8)); - set resp.http.all-lc = + set resp.http.all-lc = blob.encode(URLLC, blob.decode(BASE64, req.http.b64all)); set resp.http.all-uc = blob.encode(URLUC, blob.decode(BASE64, req.http.b64all)); - set resp.http.empty-lc = + set resp.http.empty-lc = blob.encode(URLLC, blob.decode(IDENTITY, "")); set resp.http.empty-uc = @@ -80,7 +80,7 @@ varnish v1 -vcl { set req.http.urllcfoobar = "foo%3abar%3abaz%3aquux"; set req.http.urlucfoobar = "foo%3Abar%3Abaz%3Aquux"; set req.http.urlmixedfoobar = "foo%3Abar%3abaz%3Aquux"; - set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urllcumlauts = "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger"; set req.http.urlucumlauts = "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger"; @@ -88,58 +88,58 @@ varnish v1 -vcl { set req.http.urlucphk = "sm%C3%A5b%C3%B8rnsp%C3%A6dagog"; set req.http.urllcutf8 = "%e6%97%a5%e6%89%bc%e8%aa%9e"; set req.http.urlucutf8 = "%E6%97%A5%E6%89%BC%E8%AA%9E"; - set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; set req.http.urlalllc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; set resp.http.decuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlucfoobar)); set resp.http.declc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urllcfoobar)); set resp.http.decmixed = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlmixedfoobar)); set resp.http.dechobbesuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlhobbesuc)); set resp.http.dechobbeslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlhobbeslc)); set resp.http.decumlautsuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlucumlauts)); set resp.http.decumlautslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urllcumlauts)); set resp.http.decphkuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlucphk)); set resp.http.decphklc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urllcphk)); set resp.http.decutf8uc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlucutf8)); set resp.http.decutf8lc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode(URL, req.http.urlalluc)); + blob.encode(BASE64, blob.decode(URL, req.http.urlalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode(URL, req.http.urlalllc)); + blob.encode(BASE64, blob.decode(URL, req.http.urlalllc)); set resp.http.decempty = blob.encode(IDENTITY, blob.decode(URL, "")); @@ -148,7 +148,7 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob.decode(URL, "%00")); set resp.http.decemptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.unset + "" + req.http.unset + "")); @@ -169,7 +169,7 @@ varnish v1 -vcl { "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode(URL, "" + req.http.unset + blob.encode(IDENTITY, blob.decode(URL, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -229,22 +229,22 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - if (req.url == "/percent") { - set resp.http.bad - = blob.encode(URLUC, blob.decode(URL, "%")); - } - elsif (req.url == "/percent-two") { - set resp.http.bad = blob.encode(URLUC, - blob.decode(URL, "%2")); - } - elsif (req.url == "/percent-q") { - set resp.http.bad = blob.encode(URLUC, - blob.decode(URL, "%q")); - } - elsif (req.url == "/percent-two-q") { - set resp.http.bad = blob.encode(URLUC, + if (req.url == "/percent") { + set resp.http.bad + = blob.encode(URLUC, blob.decode(URL, "%")); + } + elsif (req.url == "/percent-two") { + set resp.http.bad = blob.encode(URLUC, + blob.decode(URL, "%2")); + } + elsif (req.url == "/percent-q") { + set resp.http.bad = blob.encode(URLUC, + blob.decode(URL, "%q")); + } + elsif (req.url == "/percent-two-q") { + set resp.http.bad = blob.encode(URLUC, blob.decode(URL, "%2q")); - } + } } } @@ -281,8 +281,8 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%\"$" - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2\"$" - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%q\"$" - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2q\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%q\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2q\"$" } -run diff --git a/bin/varnishtest/tests/m00040.vtc b/bin/varnishtest/tests/m00040.vtc index b93a3c5..0ec8842 100644 --- a/bin/varnishtest/tests/m00040.vtc +++ b/bin/varnishtest/tests/m00040.vtc @@ -12,7 +12,7 @@ varnish v1 -vcl { sub vcl_synth { set req.http.urllcfoobar = "foo%3abar%3abaz%3aquux"; set req.http.urlucfoobar = "foo%3Abar%3Abaz%3Aquux"; - set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urllcumlauts = "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger"; set req.http.urlucumlauts = "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger"; @@ -20,57 +20,57 @@ varnish v1 -vcl { set req.http.urlucphk = "sm%C3%A5b%C3%B8rnsp%C3%A6dagog"; set req.http.urllcutf8 = "%e6%97%a5%e6%89%bc%e8%aa%9e"; set req.http.urlucutf8 = "%E6%97%A5%E6%89%BC%E8%AA%9E"; - set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; set req.http.urlalllc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; set resp.http.decuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(9, URL, req.http.urlucfoobar)); set resp.http.declc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(12, URL, req.http.urllcfoobar)); set resp.http.dechobbesuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(27, URL, req.http.urlhobbesuc)); set resp.http.dechobbeslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(27, URL, req.http.urlhobbeslc)); set resp.http.decumlautsuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(17, URL, req.http.urlucumlauts)); set resp.http.decumlautslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(25, URL, req.http.urllcumlauts)); set resp.http.decphkuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(18, URL, req.http.urlucphk)); set resp.http.decphklc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(30, URL, req.http.urllcphk)); set resp.http.decutf8uc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(9, URL, req.http.urlucutf8)); set resp.http.decutf8lc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(18, URL, req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode_n(252, URL, req.http.urlalluc)); set resp.http.decalllc = - blob.encode(HEXUC, + blob.encode(HEXUC, blob.decode_n(252, URL, req.http.urlalllc)); set resp.http.decempty = @@ -80,7 +80,7 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob.decode_n(3, URL, "%00")); set resp.http.decemptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(1, URL, req.http.unset + "" + req.http.unset + "")); @@ -88,7 +88,7 @@ varnish v1 -vcl { set resp.http.dec2pieces = blob.encode(IDENTITY, blob.decode_n(6, URL, req.http.part1 + - "20bar%20baz%20quux")); + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = @@ -104,7 +104,7 @@ varnish v1 -vcl { + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(24, URL, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" @@ -148,22 +148,22 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - if (req.url == "/percent") { - set resp.http.bad = blob.encode(URLUC, - blob.decode_n(1, URL, "%20")); - } - elsif (req.url == "/percent-two") { - set resp.http.bad = blob.encode(URLUC, - blob.decode_n(2, URL, "%20")); - } - elsif (req.url == "/comma") { - set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%2c%q")); - } - elsif (req.url == "/colon") { - set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%3a%2q")); - } + if (req.url == "/percent") { + set resp.http.bad = blob.encode(URLUC, + blob.decode_n(1, URL, "%20")); + } + elsif (req.url == "/percent-two") { + set resp.http.bad = blob.encode(URLUC, + blob.decode_n(2, URL, "%20")); + } + elsif (req.url == "/comma") { + set resp.http.good = blob.encode(IDENTITY, + blob.decode_n(3, URL, "%2c%q")); + } + elsif (req.url == "/colon") { + set resp.http.good = blob.encode(IDENTITY, + blob.decode_n(3, URL, "%3a%2q")); + } } } @@ -192,6 +192,6 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" } -run diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index b5cd490..811d814 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -16,7 +16,7 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; set req.http.hobbesb64 = {"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; - set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; set req.http.hexalldown = {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set req.http.hexallup = @@ -204,11 +204,11 @@ varnish v1 -vcl { } sub vcl_synth { - set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; - set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; set req.http.urlalluplc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; - set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; + set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id @@ -318,57 +318,57 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - set req.http.foo = "AAA="; - if (req.url == "/1") { - set resp.http.bad - = blob.transcode(HEX, IDENTITY, "0x123456"); - } - elsif (req.url == "/2") { - set resp.http.bad - = blob.transcode(BASE64, IDENTITY, + set req.http.foo = "AAA="; + if (req.url == "/1") { + set resp.http.bad + = blob.transcode(HEX, IDENTITY, "0x123456"); + } + elsif (req.url == "/2") { + set resp.http.bad + = blob.transcode(BASE64, IDENTITY, "-_-_" + req.http.foo); - } - elsif (req.url == "/3") { - set resp.http.bad - = blob.transcode(BASE64URL, IDENTITY, + } + elsif (req.url == "/3") { + set resp.http.bad + = blob.transcode(BASE64URL, IDENTITY, "+/+/" + req.http.foo); - } - elsif (req.url == "/4") { - set resp.http.bad - = blob.transcode(BASE64URLNOPAD, IDENTITY, + } + elsif (req.url == "/4") { + set resp.http.bad + = blob.transcode(BASE64URLNOPAD, IDENTITY, "TWFu" + req.http.foo); - } - elsif (req.url == "/5") { - set resp.http.bad - = blob.transcode(BASE64, BASE64, + } + elsif (req.url == "/5") { + set resp.http.bad + = blob.transcode(BASE64, BASE64, "_-_-" + req.http.foo); - } - elsif (req.url == "/6") { - set resp.http.bad - = blob.transcode(BASE64URL, BASE64URL, - "/+/+" + req.http.foo); - } - elsif (req.url == "/7") { - set resp.http.bad - = blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, - "Zm9v" + req.http.foo); - } - elsif (req.url == "/8") { - set resp.http.bad - = blob.transcode(URL, IDENTITY, "%"); - } - elsif (req.url == "/9") { - set resp.http.bad - = blob.transcode(URL, IDENTITY, "%2"); - } - elsif (req.url == "/10") { - set resp.http.bad - = blob.transcode(URL, IDENTITY, "%q"); - } - elsif (req.url == "/11") { - set resp.http.bad - = blob.transcode(URL, IDENTITY, "%2q"); - } + } + elsif (req.url == "/6") { + set resp.http.bad + = blob.transcode(BASE64URL, BASE64URL, + "/+/+" + req.http.foo); + } + elsif (req.url == "/7") { + set resp.http.bad + = blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, + "Zm9v" + req.http.foo); + } + elsif (req.url == "/8") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%"); + } + elsif (req.url == "/9") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%2"); + } + elsif (req.url == "/10") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%q"); + } + elsif (req.url == "/11") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%2q"); + } } } @@ -461,15 +461,15 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "0x123456"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "-_-_"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "\+/\+/"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "_-_-"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "/\+/\+"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "Zm9v"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%q"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2q"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "0x123456"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "-_-_"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "\+/\+/"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "_-_-"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "/\+/\+"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "Zm9v"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%q"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2q"$} } -run diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index a34f7d0..164846a 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -15,7 +15,7 @@ varnish v1 -vcl { {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; set req.http.hobbesb64 = {"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; - set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; set req.http.hexalldown = {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set req.http.hexallup = @@ -25,7 +25,7 @@ varnish v1 -vcl { set req.http.b64allurl = {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; - set resp.http.id2id + set resp.http.id2id = blob.transcode_n(5, IDENTITY, IDENTITY, "Hello world"); set resp.http.id2b64 @@ -140,13 +140,13 @@ varnish v1 -vcl { set resp.http.b64url2b64url = blob.transcode_n(34, BASE64URL, BASE64URL, - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" - + "ghijklmnopqrstuvwxyz0123456789-_"); + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789-_"); set resp.http.b64urlnopad2b64urlnopad = blob.transcode_n(34, BASE64URLNOPAD, BASE64URLNOPAD, - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" - + "ghijklmnopqrstuvwxyz0123456789-_"); + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789-_"); } } -start @@ -203,11 +203,11 @@ varnish v1 -vcl { } sub vcl_synth { - set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; - set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; set req.http.urlalluplc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; - set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; + set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id @@ -321,59 +321,59 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - set req.http.foo = "AAA="; - if (req.url == "/1") { - set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, "%2c%q"); - } - elsif (req.url == "/2") { - set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, "%3a%2q"); - } - elsif (req.url == "/3") { - set resp.http.bad - = blob.transcode_n(8, HEX, IDENTITY, - "0x123456"); - } - elsif (req.url == "/4") { - set resp.http.bad - = blob.transcode_n(4, BASE64, IDENTITY, - "-_-_" + req.http.foo); - } - elsif (req.url == "/5") { - set resp.http.bad - = blob.transcode_n(4, BASE64URL, IDENTITY, - "+/+/" + req.http.foo); - } - elsif (req.url == "/6") { - set resp.http.bad - = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, - "TWFu" + req.http.foo); - } - elsif (req.url == "/7") { - set resp.http.bad - = blob.transcode_n(4, BASE64, BASE64, - "_-_-" + req.http.foo); - } - elsif (req.url == "/8") { - set resp.http.bad - = blob.transcode_n(4, BASE64URL, BASE64URL, - "/+/+" + req.http.foo); - } - elsif (req.url == "/9") { - set resp.http.bad - = blob.transcode_n(8, BASE64URLNOPAD, - BASE64URLNOPAD, + set req.http.foo = "AAA="; + if (req.url == "/1") { + set resp.http.good + = blob.transcode_n(3, URL, IDENTITY, "%2c%q"); + } + elsif (req.url == "/2") { + set resp.http.good + = blob.transcode_n(3, URL, IDENTITY, "%3a%2q"); + } + elsif (req.url == "/3") { + set resp.http.bad + = blob.transcode_n(8, HEX, IDENTITY, + "0x123456"); + } + elsif (req.url == "/4") { + set resp.http.bad + = blob.transcode_n(4, BASE64, IDENTITY, + "-_-_" + req.http.foo); + } + elsif (req.url == "/5") { + set resp.http.bad + = blob.transcode_n(4, BASE64URL, IDENTITY, + "+/+/" + req.http.foo); + } + elsif (req.url == "/6") { + set resp.http.bad + = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, + "TWFu" + req.http.foo); + } + elsif (req.url == "/7") { + set resp.http.bad + = blob.transcode_n(4, BASE64, BASE64, + "_-_-" + req.http.foo); + } + elsif (req.url == "/8") { + set resp.http.bad + = blob.transcode_n(4, BASE64URL, BASE64URL, + "/+/+" + req.http.foo); + } + elsif (req.url == "/9") { + set resp.http.bad + = blob.transcode_n(8, BASE64URLNOPAD, + BASE64URLNOPAD, "Zm9v" + req.http.foo); - } - elsif (req.url == "/10") { - set resp.http.bad - = blob.transcode_n(1, URL, IDENTITY, "%20"); - } - elsif (req.url == "/11") { - set resp.http.bad - = blob.transcode_n(2, URL, IDENTITY, "%20"); - } + } + elsif (req.url == "/10") { + set resp.http.bad + = blob.transcode_n(1, URL, IDENTITY, "%20"); + } + elsif (req.url == "/11") { + set resp.http.bad + = blob.transcode_n(2, URL, IDENTITY, "%20"); + } } } diff --git a/bin/varnishtest/tests/m00043.vtc b/bin/varnishtest/tests/m00043.vtc index c12ac14..74763b5 100644 --- a/bin/varnishtest/tests/m00043.vtc +++ b/bin/varnishtest/tests/m00043.vtc @@ -10,7 +10,7 @@ varnish v1 -arg "-i serverid" -vcl+backend { "The quick brown fox jumps over the lazy dog"); new idpieces = blob.blob(IDENTITY, "" + server.identity + " " - + server.identity + ""); + + server.identity + ""); new idempty = blob.blob(IDENTITY, ""); new idparam = blob.blob(encoded="" + server.identity + " " + server.identity diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index e1319a3..aa88db4 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -15,9 +15,9 @@ $Module blob 3 utilities for the VCL blob type BLOB blob.decode(ENUM decoding, STRING_LIST encoded) BLOB blob.decode_n(INT n, ENUM decoding, STRING_LIST encoded) STRING blob.transcode(ENUM decoding, ENUM encoding, - STRING_LIST encoded) + STRING_LIST encoded) STRING blob.transcode_n(INT n, ENUM decoding, ENUM encoding, - STRING_LIST encoded) + STRING_LIST encoded) # other utilities BOOL blob.same(BLOB, BLOB) @@ -47,7 +47,7 @@ Examples:: sub vcl_deliver { # The .get() method retrieves the BLOB from an object. set resp.http.MyBlob-As-Hex - = blob.encode(blob=myblob.get(), encoding=HEXLC); + = blob.encode(blob=myblob.get(), encoding=HEXLC); # The .encode() method efficiently retrieves an encoding. set resp.http.YourBlob-As-Base64 = yourblob.encode(BASE64); @@ -55,22 +55,22 @@ Examples:: # decode() and encode() functions convert blobs to text and # vice versa at runtime. set resp.http.Base64-Encoded - = blob.encode(BASE64, - blob.decode(HEX, req.http.Hex-Encoded)); + = blob.encode(BASE64, + blob.decode(HEX, req.http.Hex-Encoded)); } sub vcl_recv { # transcode() converts from one encoding to another. set req.http.Hex-Encoded - = blob.transcode(decoding=BASE64, encoding=HEXUC, - encoded="YmF6"); + = blob.transcode(decoding=BASE64, encoding=HEXUC, + encoded="YmF6"); # transcode() from URL to IDENTITY effects a URL decode. set req.url = blob.transcode(encoded=req.url, decoding=URL); # transcode() from IDENTITY to URL effects a URL encode. set req.http.url_urlcoded - = blob.transcode(encoded=req.url, encoding=URLLC); + = blob.transcode(encoded=req.url, encoding=URLLC); } ENCODING SCHEMES @@ -169,7 +169,7 @@ byte. For example:: set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode(HEXLC, blob.decode(HEX, - resp.http.First + resp.http.Second)); + resp.http.First + resp.http.Second)); URL* ---- @@ -182,7 +182,7 @@ RFC3986, the hexadecimal characters A-F being output in lower- and uppercase, respectively. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", STRING_LIST encoded) Returns the BLOB derived from the string ``encoded`` according to the scheme specified by ``decoding``. @@ -209,7 +209,7 @@ the encoded string. If ``n`` is greater than the length of the string, then return the same result as ``decode()``. $Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", BLOB blob) Returns a string representation of the BLOB ``blob`` as specifed by @@ -233,10 +233,10 @@ Example:: = blob.encode(blob=blob.decode(encoded="foo")); $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", - ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", - STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", + ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + STRING_LIST encoded) Translates from one encoding to another, by first decoding the string ``encoded`` according to the scheme ``decoding``, and then returning @@ -264,10 +264,10 @@ Example:: $Function STRING transcode_n(INT n, ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", - ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", - STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", + ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + STRING_LIST encoded) Same as ``transcode()``, but only from the first ``n`` characters of the encoded string. @@ -305,8 +305,8 @@ if ``offset + length`` requires more bytes than are available in the BLOB. $Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, - URL} decoding="IDENTITY", - STRING_LIST encoded) + URL} decoding="IDENTITY", + STRING_LIST encoded) Creates an object that contains the BLOB derived from the string ``encoded`` according to the scheme ``decoding``. @@ -337,7 +337,7 @@ Example:: blob.encode(blob=stringblob.get()); $Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXUC, - HEXLC, URLUC, URLLC} encoding="IDENTITY") + HEXLC, URLUC, URLLC} encoding="IDENTITY") Returns an encoding of BLOB created by the constructor, according to the scheme ``encoding``. diff --git a/lib/libvmod_purge/vmod.vcc b/lib/libvmod_purge/vmod.vcc index 1e9259e..25a9cb8 100644 --- a/lib/libvmod_purge/vmod.vcc +++ b/lib/libvmod_purge/vmod.vcc @@ -42,61 +42,61 @@ EXAMPLE :: sub vcl_recv { - if (req.method == "PURGE") { - if (client.ip !~ purge_acl) { - return (synth(405)); - } - return (hash); - } + if (req.method == "PURGE") { + if (client.ip !~ purge_acl) { + return (synth(405)); + } + return (hash); + } } sub my_purge { - set req.http.purged = purge.hard(); - if (req.http.purged == "0") { - return (synth(404)); - } - else { - return (synth(200)); - } + set req.http.purged = purge.hard(); + if (req.http.purged == "0") { + return (synth(404)); + } + else { + return (synth(200)); + } } sub vcl_hit { - if (req.method == "PURGE") { - call my_purge; - } + if (req.method == "PURGE") { + call my_purge; + } } sub vcl_miss { - if (req.method == "PURGE") { - call my_purge; - } + if (req.method == "PURGE") { + call my_purge; + } } sub vcl_synth { - if (req.method == "PURGE") { - if (req.http.purged) { - set resp.http.purged = req.http.purged; - } - return (deliver); - } + if (req.method == "PURGE") { + if (req.http.purged) { + set resp.http.purged = req.http.purged; + } + return (deliver); + } } $Function INT hard() Description This is equivalent to ``return(purge)`` but explicitly called from - ``vcl_hit`` and ``vcl_miss``. It returns the number of purged objects. + ``vcl_hit`` and ``vcl_miss``. It returns the number of purged objects. Example set req.http.purged = purge.hard(); $Function INT soft(DURATION ttl = 0, DURATION grace = -1, DURATION keep = -1) Description - Sets the TTL, grace and keep. By default, TTL is set to 0 with grace - and keep periods left untouched. Setting a negative value for grace or - keep periods leaves them untouched. Setting all three parameters to - 0 is equivalent to a hard purge. It can only be called from ``vcl_hit`` - or ``vcl_miss``. It returns the number of soft-purged objects. + Sets the TTL, grace and keep. By default, TTL is set to 0 with grace + and keep periods left untouched. Setting a negative value for grace or + keep periods leaves them untouched. Setting all three parameters to + 0 is equivalent to a hard purge. It can only be called from ``vcl_hit`` + or ``vcl_miss``. It returns the number of soft-purged objects. SEE ALSO ======== From phk at FreeBSD.org Wed Sep 6 20:56:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Sep 2017 20:56:05 +0000 (UTC) Subject: [master] 6340ce0 Drop the incestous relationship between VSM and VSC, and stack VSC neatly on top of VSM. Message-ID: <20170906205605.61B9290C02@lists.varnish-cache.org> commit 6340ce0eb63327d61e1ec4266922c9cbf8871d5d Author: Poul-Henning Kamp Date: Wed Sep 6 20:54:50 2017 +0000 Drop the incestous relationship between VSM and VSC, and stack VSC neatly on top of VSM. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index c9270cf..1f24b25 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -74,7 +74,7 @@ do_xml_cb(void *priv, const struct VSC_point * const pt) } static void -do_xml(struct vsm *vd) +do_xml(struct vsc *vsc) { char time_stamp[20]; time_t now; @@ -83,7 +83,7 @@ do_xml(struct vsm *vd) now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf("\n", time_stamp); - (void)VSC_Iter(vd, NULL, do_xml_cb, NULL); + (void)VSC_Iter(vsc, NULL, do_xml_cb, NULL); printf("\n"); } @@ -124,7 +124,7 @@ do_json_cb(void *priv, const struct VSC_point * const pt) } static void -do_json(struct vsm *vd) +do_json(struct vsc *vsc) { char time_stamp[20]; time_t now; @@ -137,7 +137,7 @@ do_json(struct vsm *vd) (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf(" \"timestamp\": \"%s\",\n", time_stamp); - (void)VSC_Iter(vd, NULL, do_json_cb, &jp); + (void)VSC_Iter(vsc, NULL, do_json_cb, &jp); printf("\n}\n"); } @@ -194,15 +194,15 @@ do_once_cb(void *priv, const struct VSC_point * const pt) } static void -do_once(struct vsm *vd) +do_once(struct vsc *vsc) { struct once_priv op; memset(&op, 0, sizeof op); op.pad = 18; - (void)VSC_Iter(vd, NULL, do_once_cb_first, &op); - (void)VSC_Iter(vd, NULL, do_once_cb, &op); + (void)VSC_Iter(vsc, NULL, do_once_cb_first, &op); + (void)VSC_Iter(vsc, NULL, do_once_cb, &op); } /*--------------------------------------------------------------------*/ @@ -226,13 +226,13 @@ do_list_cb(void *priv, const struct VSC_point * const pt) } static void -list_fields(struct vsm *vd) +list_fields(struct vsc *vsc) { printf("Varnishstat -f option fields:\n"); printf("Field name Description\n"); printf("---------- -----------\n"); - (void)VSC_Iter(vd, NULL, do_list_cb, NULL); + (void)VSC_Iter(vsc, NULL, do_list_cb, NULL); } /*--------------------------------------------------------------------*/ @@ -256,10 +256,13 @@ main(int argc, char * const *argv) int once = 0, xml = 0, json = 0, f_list = 0, curses = 0; signed char opt; int i; + struct vsc *vsc; VUT_Init(progname, argc, argv, &vopt_spec); vd = VSM_New(); AN(vd); + vsc = VSC_New(vd); + AN(vsc); while ((opt = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { switch (opt) { @@ -282,7 +285,7 @@ main(int argc, char * const *argv) json = 1; break; default: - i = VSC_Arg(vd, opt, optarg); + i = VSC_Arg(vsc, opt, optarg); if (i < 0) VUT_Error(1, "%s", VSM_Error(vd)); if (!i) @@ -300,15 +303,15 @@ main(int argc, char * const *argv) VUT_Error(1, "%s", VSM_Error(vd)); if (curses) - do_curses(vd, 1.0); + do_curses(vd, vsc, 1.0); else if (xml) - do_xml(vd); + do_xml(vsc); else if (json) - do_json(vd); + do_json(vsc); else if (once) - do_once(vd); + do_once(vsc); else if (f_list) - list_fields(vd); + list_fields(vsc); else assert(0); diff --git a/bin/varnishstat/varnishstat.h b/bin/varnishstat/varnishstat.h index 54fd0ba..6a73ef2 100644 --- a/bin/varnishstat/varnishstat.h +++ b/bin/varnishstat/varnishstat.h @@ -35,4 +35,4 @@ #include "vas.h" #include "vcs.h" -void do_curses(struct vsm *vd, double delay); +void do_curses(struct vsm *, struct vsc *, double); diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 7d99c7e..104af2b 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -313,7 +313,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) } static void -build_pt_list(struct vsm *vd, struct vsm_fantom *fantom) +build_pt_list(struct vsc *vsc, struct vsm_fantom *fantom) { struct pt_priv pt_priv; int i; @@ -334,7 +334,7 @@ build_pt_list(struct vsm *vd, struct vsm_fantom *fantom) main_cache_hit = NULL; main_cache_miss = NULL; - (void)VSC_Iter(vd, fantom, build_pt_list_cb, &pt_priv); + (void)VSC_Iter(vsc, fantom, build_pt_list_cb, &pt_priv); delete_pt_list(); AN(VTAILQ_EMPTY(&ptlist)); AZ(n_ptlist); @@ -1044,7 +1044,7 @@ handle_keypress(int ch) } void -do_curses(struct vsm *vd, double delay) +do_curses(struct vsm *vd, struct vsc *vsc, double delay) { struct pollfd pollfd; long t; @@ -1073,7 +1073,7 @@ do_curses(struct vsm *vd, double delay) (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED))) { init_hitrate(); delete_pt_list(); - build_pt_list(vd, &f_iter); + build_pt_list(vsc, &f_iter); initial = 0; } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 7a10731..45218bc 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -78,6 +78,7 @@ struct varnish { struct vsm *vsm_vsl; struct vsm *vsm_vsc; + struct vsc *vsc; int has_a_arg; unsigned vsl_tag_count[256]; @@ -521,7 +522,10 @@ varnish_launch(struct varnish *v) free(r); v->vsm_vsc = VSM_New(); - (void)VSM_Arg(v->vsm_vsc, 'n', v->workdir); + AN(v->vsm_vsc); + v->vsc = VSC_New(v->vsm_vsc); + AN(v->vsc); + (void)VSC_Arg(v->vsc, 'n', v->workdir); AZ(VSM_Attach(v->vsm_vsc, -1)); v->vsm_vsl = VSM_New(); @@ -846,7 +850,7 @@ varnish_vsc(const struct varnish *v, const char *arg) dp.arg = arg; (void)VSM_Status(v->vsm_vsc); - (void)VSC_Iter(v->vsm_vsc, NULL, do_stat_dump_cb, &dp); + (void)VSC_Iter(v->vsc, NULL, do_stat_dump_cb, &dp); } /********************************************************************** @@ -912,7 +916,7 @@ varnish_expect(const struct varnish *v, char * const *av) for (i = 0; i < 50; i++, (void)usleep(100000)) { (void)VSM_Status(v->vsm_vsc); - good = VSC_Iter(v->vsm_vsc, NULL, do_expect_cb, &sp); + good = VSC_Iter(v->vsc, NULL, do_expect_cb, &sp); if (!good) { good = -2; continue; diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 7a87f70..97c85e1 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -38,13 +38,17 @@ #include "vapi/vsc_int.h" struct vsm; +struct vsc; struct vsm_fantom; /*--------------------------------------------------------------------- * VSC level access functions */ -int VSC_Arg(struct vsm *vd, char arg, const char *opt); +struct vsc *VSC_New(struct vsm *); +void VSC_Destroy(struct vsc **); + +int VSC_Arg(struct vsc *, char arg, const char *opt); /* * Handle standard stat-presenter arguments * Return: @@ -80,8 +84,7 @@ void VSC_Destroy_Point(struct VSC_point **); typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt); -int VSC_Iter(struct vsm *vd, struct vsm_fantom *fantom, VSC_iter_f *func, - void *priv); +int VSC_Iter(struct vsc *, struct vsm_fantom *, VSC_iter_f *func, void *priv); /* * Iterate over all statistics counters, calling "func" for * each counter not suppressed by any "-f" arguments. diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am index fbd4014..d0e8b64 100644 --- a/lib/libvarnishapi/Makefile.am +++ b/lib/libvarnishapi/Makefile.am @@ -14,7 +14,6 @@ libvarnishapi_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:6:0 libvarnishapi_la_SOURCES = \ vjsn.c \ vjsn.h \ - vsc_priv.h \ vsl_api.h \ vxp.h \ vxp_tokens.h \ diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 6a7cab2..b5d1b00 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -193,4 +193,6 @@ LIBVARNISHAPI_1.7 { VSM_Status; VSM_Arg; VSM_Dup; + VSC_New; + VSC_Destroy; } LIBVARNISHAPI_1.0; diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index cd933ad..de998cf 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -51,8 +51,6 @@ #include "vapi/vsc.h" #include "vapi/vsm.h" -#include "vsc_priv.h" - struct vsc_sf { unsigned magic; #define VSC_SF_MAGIC 0x558478dd @@ -65,6 +63,7 @@ struct vsc { unsigned magic; #define VSC_MAGIC 0x3373554a + struct vsm *vsm; struct vsc_sf_head sf_list_include; struct vsc_sf_head sf_list_exclude; }; @@ -116,20 +115,18 @@ VSC_Destroy_Point(struct VSC_point **p) /*--------------------------------------------------------------------*/ -static struct vsc * -vsc_setup(struct vsm *vd) +struct vsc * +VSC_New(struct vsm *vsm) { struct vsc *vsc; - vsc = VSM_GetVSC(vd); - if (vsc == NULL) { - ALLOC_OBJ(vsc, VSC_MAGIC); - AN(vsc); - VTAILQ_INIT(&vsc->sf_list_include); - VTAILQ_INIT(&vsc->sf_list_exclude); - VSM_SetVSC(vd, vsc); - } - CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + AN(vsm); + ALLOC_OBJ(vsc, VSC_MAGIC); + if (vsc == NULL) + return (vsc); + vsc->vsm = vsm; + VTAILQ_INIT(&vsc->sf_list_include); + VTAILQ_INIT(&vsc->sf_list_exclude); return (vsc); } @@ -150,10 +147,11 @@ vsc_delete_sf_list(struct vsc_sf_head *head) } void -VSC_Delete(struct vsc *vsc) +VSC_Destroy(struct vsc **vscp) { + struct vsc *vsc; - CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + TAKE_OBJ_NOTNULL(vsc, vscp, VSC_MAGIC); vsc_delete_sf_list(&vsc->sf_list_include); vsc_delete_sf_list(&vsc->sf_list_exclude); FREE_OBJ(vsc); @@ -162,13 +160,11 @@ VSC_Delete(struct vsc *vsc) /*--------------------------------------------------------------------*/ static int -vsc_f_arg(struct vsm *vd, const char *opt) +vsc_f_arg(struct vsc *vsc, const char *opt) { - struct vsc *vsc = vsc_setup(vd); struct vsc_sf *sf; unsigned exclude = 0; - AN(vd); AN(opt); ALLOC_OBJ(sf, VSC_SF_MAGIC); @@ -193,14 +189,16 @@ vsc_f_arg(struct vsm *vd, const char *opt) /*--------------------------------------------------------------------*/ int -VSC_Arg(struct vsm *vd, char arg, const char *opt) +VSC_Arg(struct vsc *vsc, char arg, const char *opt) { + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + switch (arg) { - case 'f': return (vsc_f_arg(vd, opt)); + case 'f': return (vsc_f_arg(vsc, opt)); case 'n': case 't': - return (VSM_Arg(vd, arg, opt)); + return (VSM_Arg(vsc->vsm, arg, opt)); default: return (0); } @@ -210,11 +208,11 @@ VSC_Arg(struct vsm *vd, char arg, const char *opt) */ static int -vsc_filter(struct vsm *vd, const char *nm) +vsc_filter(const struct vsc *vsc, const char *nm) { - struct vsc *vsc = vsc_setup(vd); struct vsc_sf *sf; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); VTAILQ_FOREACH(sf, &vsc->sf_list_exclude, list) if (!fnmatch(sf->pattern, nm, 0)) return (1); @@ -230,12 +228,13 @@ vsc_filter(struct vsm *vd, const char *nm) */ static int -vsc_iter_elem(struct vsm *vd, const struct vsm_fantom *fantom, +vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, const struct vjsn_val *vv, struct vsb *vsb, VSC_iter_f *func, void *priv) { struct VSC_point point; struct vjsn_val *vt; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); memset(&point, 0, sizeof point); vt = vjsn_child(vv, "name"); @@ -246,7 +245,7 @@ vsc_iter_elem(struct vsm *vd, const struct vsm_fantom *fantom, VSB_printf(vsb, "%s.%s", fantom->ident, vt->value); AZ(VSB_finish(vsb)); - if (vsc_filter(vd, VSB_data(vsb))) + if (vsc_filter(vsc, VSB_data(vsb))) return (0); point.name = VSB_data(vsb); @@ -315,7 +314,7 @@ vsc_iter_elem(struct vsm *vd, const struct vsm_fantom *fantom, } static int -vsc_iter_fantom(struct vsm *vd, const struct vsm_fantom *fantom, +vsc_iter_fantom(const struct vsc *vsc, const struct vsm_fantom *fantom, struct vsb *vsb, VSC_iter_f *func, void *priv) { int i = 0; @@ -324,6 +323,8 @@ vsc_iter_fantom(struct vsm *vd, const struct vsm_fantom *fantom, struct vjsn *vj; struct vjsn_val *vv, *vve; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + p = (char*)fantom->b + 8 + vbe64dec(fantom->b); assert (p < (char*)fantom->e); vj = vjsn_parse(p, &e); @@ -332,7 +333,7 @@ vsc_iter_fantom(struct vsm *vd, const struct vsm_fantom *fantom, vve = vjsn_child(vj->value, "elem"); AN(vve); VTAILQ_FOREACH(vv, &vve->children, list) { - i = vsc_iter_elem(vd, fantom, vv, vsb, func, priv); + i = vsc_iter_elem(vsc, fantom, vv, vsb, func, priv); if (i) break; } @@ -343,21 +344,21 @@ vsc_iter_fantom(struct vsm *vd, const struct vsm_fantom *fantom, /*-------------------------------------------------------------------- */ -int -VSC_Iter(struct vsm *vd, struct vsm_fantom *fantom, VSC_iter_f *func, - void *priv) +int __match_proto__() // We don't want vsc to be const +VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv) { struct vsm_fantom ifantom; uint64_t u; int i = 0; struct vsb *vsb; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); vsb = VSB_new_auto(); AN(vsb); - VSM_FOREACH(&ifantom, vd) { + VSM_FOREACH(&ifantom, vsc->vsm) { if (strcmp(ifantom.class, VSC_CLASS)) continue; - AZ(VSM_Map(vd, &ifantom)); + AZ(VSM_Map(vsc->vsm, &ifantom)); u = vbe64dec(ifantom.b); if (u == 0) { VRMB(); @@ -365,11 +366,12 @@ VSC_Iter(struct vsm *vd, struct vsm_fantom *fantom, VSC_iter_f *func, u = vbe64dec(ifantom.b); } assert(u > 0); - if (fantom != NULL) - *fantom = ifantom; - i = vsc_iter_fantom(vd, &ifantom, vsb, func, priv); - if (fantom == NULL) - AZ(VSM_Unmap(vd, &ifantom)); + i = vsc_iter_fantom(vsc, &ifantom, vsb, func, priv); + if (f != NULL) { + *f = ifantom; + } else { + AZ(VSM_Unmap(vsc->vsm, &ifantom)); + } if (i) break; } diff --git a/lib/libvarnishapi/vsc_priv.h b/lib/libvarnishapi/vsc_priv.h deleted file mode 100644 index 48e24c6..0000000 --- a/lib/libvarnishapi/vsc_priv.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2015 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. - * - */ - -struct vsc; -struct vsm; - -void VSM_SetVSC(struct vsm *, struct vsc *); -struct vsc *VSM_GetVSC(const struct vsm *); -void VSC_Delete(struct vsc *); diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index bbdc8ab..96c171b 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -52,7 +52,6 @@ #include "vin.h" #include "vsb.h" #include "vsm_priv.h" -#include "vsc_priv.h" #include "vqueue.h" #include "vtim.h" @@ -115,7 +114,6 @@ struct vsm { struct stat dst; char *dname; - struct vsc *vsc; struct vsm_set *mgt; struct vsm_set *child; @@ -239,8 +237,6 @@ VSM_Destroy(struct vsm **vdp) TAKE_OBJ_NOTNULL(vd, vdp, VSM_MAGIC); - if (vd->vsc != NULL) - VSC_Delete(vd->vsc); VSM_ResetError(vd); free(vd->dname); vsm_delset(&vd->mgt); @@ -252,24 +248,6 @@ VSM_Destroy(struct vsm **vdp) /*--------------------------------------------------------------------*/ -void -VSM_SetVSC(struct vsm *vd, struct vsc *vsc) -{ - CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - - vd->vsc = vsc; -} - -struct vsc * -VSM_GetVSC(const struct vsm *vd) -{ - CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - - return (vd->vsc); -} - -/*--------------------------------------------------------------------*/ - const char * VSM_Error(const struct vsm *vd) { From phk at FreeBSD.org Wed Sep 6 21:02:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Sep 2017 21:02:04 +0000 (UTC) Subject: [master] e7565c5 Whitespace OCD Message-ID: <20170906210205.03D0D90F4A@lists.varnish-cache.org> commit e7565c536e2e08cfa1b22015029f6f7e73c44d66 Author: Poul-Henning Kamp Date: Wed Sep 6 21:01:00 2017 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/m00038.vtc b/bin/varnishtest/tests/m00038.vtc index f69bd58..894618d 100644 --- a/bin/varnishtest/tests/m00038.vtc +++ b/bin/varnishtest/tests/m00038.vtc @@ -45,11 +45,11 @@ varnish v1 -vcl { set resp.http.b64decall = blob.encode(HEXLC, blob.decode_n(128, BASE64, - req.http.all)); + req.http.all)); set resp.http.urldechobbes = blob.encode(IDENTITY, blob.decode_n(180, BASE64URL, - req.http.hobbes)); + req.http.hobbes)); set resp.http.urldecall = blob.encode(HEXLC, @@ -76,7 +76,7 @@ varnish v1 -vcl { set resp.http.emptypieces = blob.encode(IDENTITY, blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset - + "" + req.http.unset + "")); + + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index 77fb240..8048ccf 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -150,7 +150,7 @@ varnish v1 -vcl { set resp.http.decemptypieces = blob.encode(IDENTITY, blob.decode(URL, req.http.unset + "" - + req.http.unset + "")); + + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = @@ -235,11 +235,11 @@ varnish v1 -vcl+backend { } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URLUC, - blob.decode(URL, "%2")); + blob.decode(URL, "%2")); } elsif (req.url == "/percent-q") { set resp.http.bad = blob.encode(URLUC, - blob.decode(URL, "%q")); + blob.decode(URL, "%q")); } elsif (req.url == "/percent-two-q") { set resp.http.bad = blob.encode(URLUC, diff --git a/bin/varnishtest/tests/m00040.vtc b/bin/varnishtest/tests/m00040.vtc index 0ec8842..b3c87b3 100644 --- a/bin/varnishtest/tests/m00040.vtc +++ b/bin/varnishtest/tests/m00040.vtc @@ -82,13 +82,13 @@ varnish v1 -vcl { set resp.http.decemptypieces = blob.encode(IDENTITY, blob.decode_n(1, URL, req.http.unset + "" - + req.http.unset + "")); + + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob.decode_n(6, URL, req.http.part1 + - "20bar%20baz%20quux")); + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = @@ -150,19 +150,19 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { set resp.http.bad = blob.encode(URLUC, - blob.decode_n(1, URL, "%20")); + blob.decode_n(1, URL, "%20")); } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URLUC, - blob.decode_n(2, URL, "%20")); + blob.decode_n(2, URL, "%20")); } elsif (req.url == "/comma") { set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%2c%q")); + blob.decode_n(3, URL, "%2c%q")); } elsif (req.url == "/colon") { set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%3a%2q")); + blob.decode_n(3, URL, "%3a%2q")); } } } diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index 811d814..c350ee1 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -346,12 +346,12 @@ varnish v1 -vcl+backend { elsif (req.url == "/6") { set resp.http.bad = blob.transcode(BASE64URL, BASE64URL, - "/+/+" + req.http.foo); + "/+/+" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad = blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, - "Zm9v" + req.http.foo); + "Zm9v" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index 164846a..37ed285 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -333,38 +333,38 @@ varnish v1 -vcl+backend { elsif (req.url == "/3") { set resp.http.bad = blob.transcode_n(8, HEX, IDENTITY, - "0x123456"); + "0x123456"); } elsif (req.url == "/4") { set resp.http.bad = blob.transcode_n(4, BASE64, IDENTITY, - "-_-_" + req.http.foo); + "-_-_" + req.http.foo); } elsif (req.url == "/5") { set resp.http.bad = blob.transcode_n(4, BASE64URL, IDENTITY, - "+/+/" + req.http.foo); + "+/+/" + req.http.foo); } elsif (req.url == "/6") { set resp.http.bad = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, - "TWFu" + req.http.foo); + "TWFu" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad = blob.transcode_n(4, BASE64, BASE64, - "_-_-" + req.http.foo); + "_-_-" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad = blob.transcode_n(4, BASE64URL, BASE64URL, - "/+/+" + req.http.foo); + "/+/+" + req.http.foo); } elsif (req.url == "/9") { set resp.http.bad = blob.transcode_n(8, BASE64URLNOPAD, - BASE64URLNOPAD, - "Zm9v" + req.http.foo); + BASE64URLNOPAD, + "Zm9v" + req.http.foo); } elsif (req.url == "/10") { set resp.http.bad From hermunn at varnish-software.com Thu Sep 7 06:59:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:05 +0000 (UTC) Subject: [5.2] 32ab4ba rename - this function is specific to the hash Message-ID: <20170907065905.8210B91CBD@lists.varnish-cache.org> commit 32ab4baeb3a766c74cc73431f5bfd16e353f45a6 Author: Nils Goroll Date: Mon Sep 4 19:07:52 2017 +0200 rename - this function is specific to the hash Ref: #2402 diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 243a814..de52389 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -769,7 +769,7 @@ VRT_BODY_L(resp) /*--------------------------------------------------------------------*/ static struct vmod_priv * -vrt_do_blob(VRT_CTX, uint8_t *digest) +vrt_hash_blob(VRT_CTX, uint8_t *digest) { struct vmod_priv *p; p = (void *)WS_Alloc(ctx->ws, sizeof *p); @@ -785,7 +785,7 @@ VRT_r_req_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - return (vrt_do_blob(ctx, ctx->req->digest)); + return (vrt_hash_blob(ctx, ctx->req->digest)); } VCL_BLOB @@ -793,7 +793,7 @@ VRT_r_bereq_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - return (vrt_do_blob(ctx, ctx->bo->digest)); + return (vrt_hash_blob(ctx, ctx->bo->digest)); } /*--------------------------------------------------------------------*/ From hermunn at varnish-software.com Thu Sep 7 06:59:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:05 +0000 (UTC) Subject: [5.2] 6568a2a vrt_hash_blob: fail gracefully for out-of-workspace conditions Message-ID: <20170907065905.9D5C191CC0@lists.varnish-cache.org> commit 6568a2a632493666ef2cad01b80fe8167e5d9f7f Author: Nils Goroll Date: Mon Sep 4 19:21:12 2017 +0200 vrt_hash_blob: fail gracefully for out-of-workspace conditions No, we do not want to bring back panics for out-of-ws Ref: #2402 diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index de52389..0edf6d4 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -772,11 +772,17 @@ static struct vmod_priv * vrt_hash_blob(VRT_CTX, uint8_t *digest) { struct vmod_priv *p; + void *d; + p = (void *)WS_Alloc(ctx->ws, sizeof *p); - AN(p); + d = WS_Copy(ctx->ws, digest, DIGEST_LEN); + if (p == NULL || d == NULL) { + VRT_fail(ctx, "Workspace overflow ((be)req.hash)"); + return (NULL); + } memset(p, 0, sizeof *p); p->len = DIGEST_LEN; - p->priv = WS_Copy(ctx->ws, digest, DIGEST_LEN); + p->priv = d; return (p); } From hermunn at varnish-software.com Thu Sep 7 06:59:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:05 +0000 (UTC) Subject: [5.2] 3ec5415 set the sigaltstack for each thread - SunOS needs it Message-ID: <20170907065905.B987091CC5@lists.varnish-cache.org> commit 3ec541550e89802f619551f53619fc36d6fe1dff Author: Nils Goroll Date: Mon Sep 4 19:48:26 2017 +0200 set the sigaltstack for each thread - SunOS needs it Ref: #2396 diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 41d2849..cf2948b 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -41,6 +41,11 @@ #include "hash/hash_slinger.h" +#ifdef HAVE_SIGALTSTACK +#include +extern stack_t altstack; +#endif + static void Pool_Work_Thread(struct pool *pp, struct worker *wrk); /*-------------------------------------------------------------------- @@ -401,6 +406,9 @@ pool_thread(void *priv) struct pool_info *pi; CAST_OBJ_NOTNULL(pi, priv, POOL_INFO_MAGIC); +#ifdef HAVE_SIGALTSTACK + AZ(sigaltstack(&altstack, NULL)); +#endif WRK_Thread(pi->qp, pi->stacksize, cache_param->workspace_thread); FREE_OBJ(pi); return (NULL); diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 2952a81..76103e2 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -84,6 +84,10 @@ static struct vlu *child_std_vlu; static struct vsb *child_panic = NULL; +#ifdef HAVE_SIGALTSTACK +stack_t altstack; +#endif + static void mgt_reap_child(void); /*===================================================================== @@ -365,15 +369,14 @@ mgt_launch_child(struct cli *cli) (void)sigaction(SIGABRT, &sa, NULL); #ifdef HAVE_SIGALTSTACK - stack_t ss; size_t sz = SIGSTKSZ + 4096; if (sz < mgt_param.wthread_stacksize) sz = mgt_param.wthread_stacksize; - ss.ss_sp = malloc(sz); - AN(ss.ss_sp); - ss.ss_size = sz; - ss.ss_flags = 0; - AZ(sigaltstack(&ss, NULL)); + altstack.ss_sp = malloc(sz); + AN(altstack.ss_sp); + altstack.ss_size = sz; + altstack.ss_flags = 0; + AZ(sigaltstack(&altstack, NULL)); sa.sa_flags |= SA_ONSTACK; #endif (void)sigaction(SIGSEGV, &sa, NULL); From hermunn at varnish-software.com Thu Sep 7 06:59:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:05 +0000 (UTC) Subject: [5.2] d7a7989 Use a separate segment for the sigaltstack Message-ID: <20170907065905.D8AF491CCA@lists.varnish-cache.org> commit d7a79894fdd226625e27da055fa0dac5c4f360db Author: Nils Goroll Date: Mon Sep 4 19:55:10 2017 +0200 Use a separate segment for the sigaltstack Having a stack on the heap just feels unclean, also this way we have a chance to get a red zone adjacent to the mapping just in case we manage to overflow the alt stack also. Ref: #2396 diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 76103e2..907df0d 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -85,6 +85,7 @@ static struct vlu *child_std_vlu; static struct vsb *child_panic = NULL; #ifdef HAVE_SIGALTSTACK +#include stack_t altstack; #endif @@ -372,7 +373,10 @@ mgt_launch_child(struct cli *cli) size_t sz = SIGSTKSZ + 4096; if (sz < mgt_param.wthread_stacksize) sz = mgt_param.wthread_stacksize; - altstack.ss_sp = malloc(sz); + altstack.ss_sp = mmap(NULL, sz, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0); + AN(altstack.ss_sp != MAP_FAILED); AN(altstack.ss_sp); altstack.ss_size = sz; altstack.ss_flags = 0; From hermunn at varnish-software.com Thu Sep 7 06:59:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:05 +0000 (UTC) Subject: [5.2] 299c326 Make SunCC happy Message-ID: <20170907065906.0154F91CD2@lists.varnish-cache.org> commit 299c3269cdcf343773e9bf95bdd51caafac7c997 Author: Nils Goroll Date: Mon Sep 4 20:09:45 2017 +0200 Make SunCC happy diff --git a/lib/libvmod_blob/parse_encoding.c b/lib/libvmod_blob/parse_encoding.c index ec64b28..c156273 100644 --- a/lib/libvmod_blob/parse_encoding.c +++ b/lib/libvmod_blob/parse_encoding.c @@ -175,5 +175,4 @@ parse_encoding (const char *m) { return r; invalid: return _INVALID; - (void)p; } From hermunn at varnish-software.com Thu Sep 7 06:59:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:06 +0000 (UTC) Subject: [5.2] f6d9a8e VMOD blob: explicitly cast negative int8_t constants Message-ID: <20170907065906.2372C91CE3@lists.varnish-cache.org> commit f6d9a8e4b7b4e2ed429e90dd1c679e3860eb18ae Author: Geoff Simmons Date: Mon Sep 4 20:15:55 2017 +0200 VMOD blob: explicitly cast negative int8_t constants diff --git a/lib/libvmod_blob/base64.h b/lib/libvmod_blob/base64.h index e5318bd..708b588 100644 --- a/lib/libvmod_blob/base64.h +++ b/lib/libvmod_blob/base64.h @@ -28,8 +28,8 @@ #include "vmod_blob.h" -#define ILL -1 -#define PAD -2 +#define ILL ((int8_t) -1) +#define PAD ((int8_t) -2) static const struct b64_alphabet { const char b64[64]; From hermunn at varnish-software.com Thu Sep 7 06:59:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:06 +0000 (UTC) Subject: [5.2] 46609bb remove unused variable from auto-generated code Message-ID: <20170907065906.44BBC91CF1@lists.varnish-cache.org> commit 46609bb1745f29525d0065f4c65811ac81f3320e Author: Nils Goroll Date: Mon Sep 4 20:20:46 2017 +0200 remove unused variable from auto-generated code diff --git a/lib/libvmod_blob/parse_encoding.c b/lib/libvmod_blob/parse_encoding.c index c156273..b18185f 100644 --- a/lib/libvmod_blob/parse_encoding.c +++ b/lib/libvmod_blob/parse_encoding.c @@ -5,6 +5,7 @@ * * TODO: integrate in vmodtool.py or replace with something else * cf. the same TODO for the shard director in libvmod_directors + * make generation of the offset-pointer p optional */ #include "parse_encoding.h" @@ -12,7 +13,6 @@ enum encoding parse_encoding (const char *m) { - int p; enum encoding r; switch (m[0]) { @@ -51,7 +51,6 @@ parse_encoding (const char *m) { //BASE64 if (term(m[6])) { r = BASE64; - p = 6; goto ok; } switch (m[6]) { @@ -72,7 +71,6 @@ parse_encoding (const char *m) { //BASE64URL if (term(m[9])) { r = BASE64URL; - p = 9; goto ok; } switch (m[9]) { @@ -83,7 +81,6 @@ parse_encoding (const char *m) { //BASE64URLNOPAD if ((m[10] == 'O') && (m[11] == 'P') && (m[12] == 'A') && (m[13] == 'D') && (term(m[14]))) { r = BASE64URLNOPAD; - p = 14; goto ok; } goto invalid; @@ -101,7 +98,6 @@ parse_encoding (const char *m) { //HEX if (term(m[3])) { r = HEX; - p = 3; goto ok; } switch (m[3]) { @@ -113,7 +109,6 @@ parse_encoding (const char *m) { //HEXLC if ((m[4] == 'C') && (term(m[5]))) { r = HEXLC; - p = 5; goto ok; } goto invalid; @@ -121,7 +116,6 @@ parse_encoding (const char *m) { //HEXUC if ((m[4] == 'C') && (term(m[5]))) { r = HEXUC; - p = 5; goto ok; } goto invalid; @@ -129,7 +123,6 @@ parse_encoding (const char *m) { //IDENTITY if ((m[1] == 'D') && (m[2] == 'E') && (m[3] == 'N') && (m[4] == 'T') && (m[5] == 'I') && (m[6] == 'T') && (m[7] == 'Y') && (term(m[8]))) { r = IDENTITY; - p = 8; goto ok; } goto invalid; @@ -147,7 +140,6 @@ parse_encoding (const char *m) { //URL if (term(m[3])) { r = URL; - p = 3; goto ok; } switch (m[3]) { @@ -159,7 +151,6 @@ parse_encoding (const char *m) { //URLLC if ((m[4] == 'C') && (term(m[5]))) { r = URLLC; - p = 5; goto ok; } goto invalid; @@ -167,7 +158,6 @@ parse_encoding (const char *m) { //URLUC if ((m[4] == 'C') && (term(m[5]))) { r = URLUC; - p = 5; goto ok; } goto invalid; From hermunn at varnish-software.com Thu Sep 7 06:59:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:06 +0000 (UTC) Subject: [5.2] 6b9b625 VMOD blob: increase workspace for a couple of vtc tests Message-ID: <20170907065906.6520691D0E@lists.varnish-cache.org> commit 6b9b625e5148e5342b0c37c016651470e9a2f96d Author: Geoff Simmons Date: Mon Sep 4 20:28:45 2017 +0200 VMOD blob: increase workspace for a couple of vtc tests diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index c9210c7..2dca6f3 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -1,6 +1,7 @@ varnishtest "VMOD blob hex encode and decode" -varnish v1 -vcl { +# Some platforms need larger workspaces for this test +varnish v1 -arg "-p workspace_client=256k" -vcl { import blob; import std; backend b { .host = "${bad_ip}"; } diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index 8ddd7c0..b5cd490 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -1,6 +1,7 @@ varnishtest "VMOD blob test transcode()" -varnish v1 -vcl { +# Some platforms need larger workspaces for this test +varnish v1 -arg "-p workspace_client=256k" -vcl { import blob; import std; backend b { .host = "${bad_ip}"; } From hermunn at varnish-software.com Thu Sep 7 06:59:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:06 +0000 (UTC) Subject: [5.2] 8d3e711 VMOD blob: use sentinel values that are strictly signed char in the decode table for base64. Message-ID: <20170907065906.83E1C91D20@lists.varnish-cache.org> commit 8d3e711eafad86d5742e1c9772d24b92adb548a8 Author: Geoff Simmons Date: Mon Sep 4 20:39:12 2017 +0200 VMOD blob: use sentinel values that are strictly signed char in the decode table for base64. diff --git a/lib/libvmod_blob/base64.h b/lib/libvmod_blob/base64.h index 708b588..bd83798 100644 --- a/lib/libvmod_blob/base64.h +++ b/lib/libvmod_blob/base64.h @@ -28,8 +28,8 @@ #include "vmod_blob.h" -#define ILL ((int8_t) -1) -#define PAD ((int8_t) -2) +#define ILL ((int8_t) 127) +#define PAD ((int8_t) 126) static const struct b64_alphabet { const char b64[64]; From hermunn at varnish-software.com Thu Sep 7 06:59:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:06 +0000 (UTC) Subject: [5.2] 7c24567 Remove blob operations from vmod-vtc Message-ID: <20170907065906.A67D291D2B@lists.varnish-cache.org> commit 7c24567d10cd3b15157e2c7e6a2eb11ea0102630 Author: Dridi Boukelmoune Date: Mon Sep 4 20:41:33 2017 +0200 Remove blob operations from vmod-vtc They were inherited from vmod-debug, from a time when vmod-blob didn't exist in the source tree. Refs #2362 Refs #2402 Refs #2407 diff --git a/bin/varnishtest/tests/b00051.vtc b/bin/varnishtest/tests/b00051.vtc index 1ec12a1..ffa5bc5 100644 --- a/bin/varnishtest/tests/b00051.vtc +++ b/bin/varnishtest/tests/b00051.vtc @@ -6,12 +6,13 @@ server s1 { } -start varnish v1 -vcl+backend { - import vtc; + import blob; + sub vcl_backend_response { - set beresp.http.bereq_hash = vtc.blob2hex(bereq.hash); + set beresp.http.bereq_hash = blob.encode(HEXLC, bereq.hash); } sub vcl_deliver { - set resp.http.req_hash = vtc.blob2hex(req.hash); + set resp.http.req_hash = blob.encode(HEXLC, req.hash); } } -start diff --git a/bin/varnishtest/tests/m00012.vtc b/bin/varnishtest/tests/m00012.vtc index 276fa08..294458c 100644 --- a/bin/varnishtest/tests/m00012.vtc +++ b/bin/varnishtest/tests/m00012.vtc @@ -1,44 +1,21 @@ varnishtest "Test VMOD BLOBS" -server s1 { - rxreq - txresp -} -start - -varnish v1 -vcl+backend { - import vtc; - - sub vcl_deliver { - set resp.http.foo = vtc.blob2hex(vtc.str2blob("gunk")); - } -} -start - -client c1 { - txreq - rxresp - expect resp.http.foo == 67756e6b -} -run - -delay .1 - varnish v1 -errvcl {BLOBs can only be used as arguments to VMOD functions.} { - backend b1 {.host = "127.0.0.1";} - - import vtc; + backend b1 {.host = "${bad_backend}";} sub vcl_deliver { - set resp.http.foo = vtc.str2blob("gunk"); + set resp.http.foo = req.hash; } } varnish v1 -errvcl {Wrong argument type. Expected BLOB. Got STRING.} { - backend b1 {.host = "127.0.0.1";} + backend b1 {.host = "${bad_backend}";} - import vtc; + import blob; sub vcl_deliver { - set resp.http.foo = vtc.blob2hex("gunk"); + blob.encode(blob = "blob"); } } diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 77dcefa..ba2dd54 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -219,18 +219,18 @@ varnish v1 -errvcl {Function returns VOID} { } varnish v1 -errvcl {'req.hash': Not available in method 'vcl_recv'.} { + import blob; backend b { .host = "127.0.0.1"; } - import vtc; sub vcl_recv { - set req.http.foo = vtc.blob2hex(req.hash); + blob.encode(HEXLC, req.hash); } } varnish v1 -errvcl {'req.hash': Not available in method 'vcl_hash'.} { + import blob; backend b { .host = "127.0.0.1"; } - import vtc; sub vcl_hash { - set req.http.foo = vtc.blob2hex(req.hash); + blob.encode(HEXLC, req.hash); } } @@ -255,9 +255,9 @@ varnish v1 -errvcl {Expected 'from path ...'} { } varnish v1 -errvcl {INT * BLOB not possible.} { - import vtc; + import blob; sub vcl_deliver { - set resp.status = 100 * vtc.str2blob("a"); + set resp.status = 100 * blob.decode(HEX, "a"); } } diff --git a/lib/libvmod_vtc/vmod.vcc b/lib/libvmod_vtc/vmod.vcc index a616c30..b57a794 100644 --- a/lib/libvmod_vtc/vmod.vcc +++ b/lib/libvmod_vtc/vmod.vcc @@ -128,20 +128,6 @@ Returns the size in bytes of a collection of C-datatypes: This can be useful for VMOD authors in conjunction with workspace operations. -BLOBS -===== - -For VMODs dealing with BLOB arguments or return values, the following functions -offer convenience conversions to and from STRING. - -$Function BLOB str2blob(STRING src) - -Turn a string into a blob. - -$Function STRING blob2hex(BLOB src) - -Hexdump a blob. - SEE ALSO ======== diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c index c4e18cf..e1afcf8 100644 --- a/lib/libvmod_vtc/vmod_vtc.c +++ b/lib/libvmod_vtc/vmod_vtc.c @@ -221,42 +221,3 @@ vmod_typesize(VRT_CTX, VCL_STRING s) } return (i); } - -/*--------------------------------------------------------------------*/ - -VCL_BLOB __match_proto__(td_vtc_str2blob) -vmod_str2blob(VRT_CTX, VCL_STRING s) -{ - struct vmod_priv *p; - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - - p = WS_Alloc(ctx->ws, sizeof *p); - AN(p); - memset(p, 0, sizeof *p); - p->len = strlen(s); - p->priv = WS_Copy(ctx->ws, s, -1); - return (p); -} - -VCL_STRING __match_proto__(td_vtc_blob2hex) -vmod_blob2hex(VRT_CTX, VCL_BLOB b) -{ - char *s, *p; - uint8_t *q; - int i; - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - - s = WS_Alloc(ctx->ws, b->len * 2 + 2); - AN(s); - p = s; - q = b->priv; - for (i = 0; i < b->len; i++) { - assert(snprintf(p, 3, "%02x", *q) == 2); - p += 2; - q += 1; - } - VRT_priv_fini(b); - return (s); -} From hermunn at varnish-software.com Thu Sep 7 06:59:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:06 +0000 (UTC) Subject: [5.2] 839869b Whitespace Message-ID: <20170907065906.C661891D3F@lists.varnish-cache.org> commit 839869ba4025fcaf3ece47c03be7a1271681e715 Author: Federico G. Schwindt Date: Mon Sep 4 18:55:35 2017 +0100 Whitespace diff --git a/lib/libvmod_blob/base64.h b/lib/libvmod_blob/base64.h index bd83798..962ae22 100644 --- a/lib/libvmod_blob/base64.h +++ b/lib/libvmod_blob/base64.h @@ -47,7 +47,7 @@ static const struct b64_alphabet { ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 62, ILL, ILL, ILL, 63, /* +, - */ 52, 53, 54, 55, 56, 57, 58, 59, /* 0 - 7 */ - 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ + 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ ILL, 0, 1, 2, 3, 4, 5, 6, /* A - G */ 7, 8, 9, 10, 11, 12, 13, 14, /* H - O */ 15, 16, 17, 18, 19, 20, 21, 22, /* P - W */ @@ -86,7 +86,7 @@ static const struct b64_alphabet { ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 62, ILL, ILL, /* - */ 52, 53, 54, 55, 56, 57, 58, 59, /* 0 - 7 */ - 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ + 60, 61, ILL, ILL, ILL, PAD, ILL, ILL, /* 8, 9, = */ ILL, 0, 1, 2, 3, 4, 5, 6, /* A - G */ 7, 8, 9, 10, 11, 12, 13, 14, /* H - O */ 15, 16, 17, 18, 19, 20, 21, 22, /* P - W */ @@ -125,7 +125,7 @@ static const struct b64_alphabet { ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 62, ILL, ILL, /* - */ 52, 53, 54, 55, 56, 57, 58, 59, /* 0 - 7 */ - 60, 61, ILL, ILL, ILL, ILL, ILL, ILL, /* 8, 9 */ + 60, 61, ILL, ILL, ILL, ILL, ILL, ILL, /* 8, 9 */ ILL, 0, 1, 2, 3, 4, 5, 6, /* A - G */ 7, 8, 9, 10, 11, 12, 13, 14, /* H - O */ 15, 16, 17, 18, 19, 20, 21, 22, /* P - W */ diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h index 1b809e1..3953035 100644 --- a/lib/libvmod_blob/vmod_blob.h +++ b/lib/libvmod_blob/vmod_blob.h @@ -64,7 +64,7 @@ size_t len_f(size_t); * otherwise, the number of bytes written (note that this does not * include any terminating null byte) */ -typedef +typedef ssize_t encode_f(const enum encoding enc, char *restrict const buf, const size_t buflen, const char *restrict const in, const size_t inlen); From hermunn at varnish-software.com Thu Sep 7 06:59:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:06 +0000 (UTC) Subject: [5.2] d753b96 Polish Message-ID: <20170907065906.E6D4E91D53@lists.varnish-cache.org> commit d753b96dd45d3634b955de4e82d49c77e8fb3e24 Author: Federico G. Schwindt Date: Mon Sep 4 21:40:12 2017 +0100 Polish diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 0edf6d4..8c22e1a 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -769,19 +769,19 @@ VRT_BODY_L(resp) /*--------------------------------------------------------------------*/ static struct vmod_priv * -vrt_hash_blob(VRT_CTX, uint8_t *digest) +vrt_do_blob(VRT_CTX, const char *err, uint8_t *src, size_t len) { struct vmod_priv *p; void *d; p = (void *)WS_Alloc(ctx->ws, sizeof *p); - d = WS_Copy(ctx->ws, digest, DIGEST_LEN); + d = WS_Copy(ctx->ws, src, len); if (p == NULL || d == NULL) { - VRT_fail(ctx, "Workspace overflow ((be)req.hash)"); + VRT_fail(ctx, "Workspace overflow (%s)", err); return (NULL); } memset(p, 0, sizeof *p); - p->len = DIGEST_LEN; + p->len = len; p->priv = d; return (p); } @@ -791,7 +791,8 @@ VRT_r_req_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - return (vrt_hash_blob(ctx, ctx->req->digest)); + return (vrt_do_blob(ctx, "req.hash", ctx->req->digest, + DIGEST_LEN)); } VCL_BLOB @@ -799,7 +800,8 @@ VRT_r_bereq_hash(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - return (vrt_hash_blob(ctx, ctx->bo->digest)); + return (vrt_do_blob(ctx, "bereq.hash", ctx->bo->digest, + DIGEST_LEN)); } /*--------------------------------------------------------------------*/ From hermunn at varnish-software.com Thu Sep 7 06:59:07 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:07 +0000 (UTC) Subject: [5.2] 5cb40a4 Add missing changelogs Message-ID: <20170907065907.140D491D60@lists.varnish-cache.org> commit 5cb40a4bf404bc8aa0c25585adee5f328a10ab30 Author: Federico G. Schwindt Date: Mon Sep 4 23:03:59 2017 +0100 Add missing changelogs Fixes #2408. diff --git a/doc/changes.rst b/doc/changes.rst index f390d7d..9003c32 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -367,6 +367,103 @@ News for Vmod Authors * PRIV_* now also work for object methods with unchanged scope. +================================ +Varnish Cache 4.1.8 (2017-08-02) +================================ + +Changes since 4.1.7: + +* Update in the documentation of timestamps + +Bugs fixed +---------- + +* 2379_ - Correctly handle bogusly large chunk sizes (VSV00001) + +.. _2379: https://github.com/varnishcache/varnish-cache/issues/2379 + +================================ +Varnish Cache 4.1.7 (2017-06-28) +================================ + +Changes since 4.1.7-beta1: + +* Add extra locking to protect the pools list and refcounts +* Don't panic on a null ban + +Bugs fixed +---------- + +* 2321_ - Prevent storage backends name collisions + +.. _2321: https://github.com/varnishcache/varnish-cache/issues/2321 + +====================================== +Varnish Cache 4.1.7-beta1 (2017-06-15) +====================================== + +Changes since 4.1.6: + +* Add -vsl_catchup to varnishtest +* Add record-prefix support to varnishncsa + +Bugs fixed +---------- +* 1764_ - Correctly honor nuke_limit parameter +* 2022_ - varnishstat -1 -f field inclusion glob doesn't allow VBE + backend fields +* 2069_ - Health probes fail when HTTP response does not contain + reason phrase +* 2118_ - "varnishstat -f MAIN.sess_conn -1" produces empty output +* 2219_ - Remember to reset workspace +* 2320_ - Rework and fix varnishstat counter filtering +* 2329_ - Docfix: Only root can jail + +.. _1764: https://github.com/varnishcache/varnish-cache/issues/1764 +.. _2022: https://github.com/varnishcache/varnish-cache/issues/2022 +.. _2069: https://github.com/varnishcache/varnish-cache/issues/2069 +.. _2118: https://github.com/varnishcache/varnish-cache/issues/2118 +.. _2219: https://github.com/varnishcache/varnish-cache/issues/2219 +.. _2320: https://github.com/varnishcache/varnish-cache/issues/2320 +.. _2329: https://github.com/varnishcache/varnish-cache/issues/2329 + +================================ +Varnish Cache 4.1.6 (2017-04-26) +================================ + +* Introduce a vxid left hand side for VSL queries. This allows + matching on records matching a known vxid. +* Environment variables are now available in the stdandard VMOD; + std.getenv() +* Add setenv command to varnishtest + + +Bugs fixed +---------- +* 2200_ - Dramatically simplify VEV, fix assert in vev.c +* 2216_ - Make sure Age is always less than max-age +* 2233_ - Correct check when parsing the query string +* 2241_ - VSL fails to get hold of SHM +* 2270_ - Newly loaded auto VCLs don't get their go_cold timer set +* 2273_ - Master cooling problem +* 2275_ - If the client workspace is almost, but not quite exhaused, we may + not be able to get enough iovec's to do Chunked transmission. +* 2295_ - Spinning loop in VBE_Poll causes master to kill child on + CLI timeout +* 2301_ - Don't attempt to check if varnishd is still running if we have + already failed. +* 2313_ - Cannot link to varnishapi, symbols missing + +.. _2200: https://github.com/varnishcache/varnish-cache/issues/2200 +.. _2216: https://github.com/varnishcache/varnish-cache/pull/2216 +.. _2233: https://github.com/varnishcache/varnish-cache/issues/2233 +.. _2241: https://github.com/varnishcache/varnish-cache/issues/2241 +.. _2270: https://github.com/varnishcache/varnish-cache/issues/2270 +.. _2273: https://github.com/varnishcache/varnish-cache/pull/2273 +.. _2275: https://github.com/varnishcache/varnish-cache/issues/2275 +.. _2295: https://github.com/varnishcache/varnish-cache/issues/2295 +.. _2301: https://github.com/varnishcache/varnish-cache/issues/2301 +.. _2313: https://github.com/varnishcache/varnish-cache/issues/2313 ================================ Varnish Cache 4.1.5 (2017-02-09) @@ -493,7 +590,7 @@ Bugs fixed * 2024_ - panic vmod_rr_resolve() round_robin.c line 75 (be) != NULL * 2011_ - VBE.*.conn (concurrent connections to backend) not working as expected * 2008_ - Assert error in VBE_Delete() -* 2007_ - Update documentation part about CLI/management port authentication paramater +* 2007_ - Update documentation part about CLI/management port authentication parameter * 1881_ - std.cache_req_body() w/ return(pipe) is broken .. _2027: https://github.com/varnishcache/varnish-cache/issues/2027 From hermunn at varnish-software.com Thu Sep 7 06:59:07 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:07 +0000 (UTC) Subject: [5.2] e840280 Correct function names on diagnostic messages Message-ID: <20170907065907.33D2D91D79@lists.varnish-cache.org> commit e84028060e960d6c985ce892e57bc953af5dbad4 Author: Federico G. Schwindt Date: Tue Sep 5 00:38:39 2017 +0100 Correct function names on diagnostic messages diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index cf7456b..ebca6f2 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -427,7 +427,8 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) p = e + 1; if (av[0] != NULL || ac < 4 || ac > 5) { - (void)(vsm_diag(vd, "VSM_Open: bad index (%d/%s)", + (void)(vsm_diag(vd, + "vsm_refresh_set2: bad index (%d/%s)", ac, av[0])); VAV_Free(av); break; @@ -506,7 +507,8 @@ VSM_Status(struct vsm *vd) if (vd->dfd < 0) { vd->dfd = open(vd->dname, O_RDONLY); if (vd->dfd < 0) - (void)vsm_diag(vd, "VSM_Open: Cannot open workdir"); + (void)vsm_diag(vd, + "VSM_Status: Cannot open workdir"); else AZ(fstat(vd->dfd, &vd->dst)); } @@ -710,7 +712,7 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf) AN(vf->b); vg = vsm_findseg(vd, vf); if (vg == NULL) - return (vsm_diag(vd, "VSM_Map: bad fantom")); + return (vsm_diag(vd, "VSM_Unmap: bad fantom")); assert(vg->refs > 0); vg->refs--; vf->b = NULL; From hermunn at varnish-software.com Thu Sep 7 06:59:07 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:07 +0000 (UTC) Subject: [5.2] 7d7fef6 Always initialise vd->dname Message-ID: <20170907065907.5268C91D8F@lists.varnish-cache.org> commit 7d7fef6371958580f601ce70f20e1a7c524727a4 Author: Federico G. Schwindt Date: Tue Sep 5 00:40:53 2017 +0100 Always initialise vd->dname This was lost in commit 74328de8eeb2703591fe59190f73fcabf057adbe. Fixes #2412. diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index ebca6f2..235c9e0 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -531,7 +531,7 @@ VSM_Attach(struct vsm *vd, int progress) { double t0; unsigned u; - int n = 0; + int i, n = 0; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); @@ -540,6 +540,14 @@ VSM_Attach(struct vsm *vd, int progress) else t0 = VTIM_mono() + vd->patience; + if (vd->dname == NULL) { + /* Use default (hostname) */ + i = VSM_Arg(vd, 'n', ""); + if (i < 0) + return (i); + AN(vd->dname); + } + AZ(vd->attached); while (1) { u = VSM_Status(vd); From hermunn at varnish-software.com Thu Sep 7 06:59:07 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:07 +0000 (UTC) Subject: [5.2] 38ef9b5 Accept a negative TTL with purge.soft Message-ID: <20170907065907.7016491DA3@lists.varnish-cache.org> commit 38ef9b56ca4f0c6841ac631a430eed7dab4984d6 Author: Dridi Boukelmoune Date: Tue Sep 5 09:57:32 2017 +0200 Accept a negative TTL with purge.soft diff --git a/lib/libvmod_purge/vmod.vcc b/lib/libvmod_purge/vmod.vcc index a935732..1e9259e 100644 --- a/lib/libvmod_purge/vmod.vcc +++ b/lib/libvmod_purge/vmod.vcc @@ -93,8 +93,8 @@ $Function INT soft(DURATION ttl = 0, DURATION grace = -1, DURATION keep = -1) Description Sets the TTL, grace and keep. By default, TTL is set to 0 with grace - and keep periods left untouched. Setting a negative value for any of - the parameters leaves them untouched. Setting all three parameters to + and keep periods left untouched. Setting a negative value for grace or + keep periods leaves them untouched. Setting all three parameters to 0 is equivalent to a hard purge. It can only be called from ``vcl_hit`` or ``vcl_miss``. It returns the number of soft-purged objects. diff --git a/lib/libvmod_purge/vmod_purge.c b/lib/libvmod_purge/vmod_purge.c index 7fba6b2..4ba039b 100644 --- a/lib/libvmod_purge/vmod_purge.c +++ b/lib/libvmod_purge/vmod_purge.c @@ -49,8 +49,6 @@ vmod_soft(VRT_CTX, VCL_DURATION ttl, VCL_DURATION grace, VCL_DURATION keep) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (ttl < 0) - ttl = NAN; if (grace < 0) grace = NAN; if (keep < 0) From hermunn at varnish-software.com Thu Sep 7 06:59:07 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:07 +0000 (UTC) Subject: [5.2] 65cccda Polish Message-ID: <20170907065907.91BC891DB9@lists.varnish-cache.org> commit 65cccdadc533c997c07a599878c14064c61a20cf Author: Dridi Boukelmoune Date: Tue Sep 5 11:39:44 2017 +0200 Polish diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 3657376..313ed52 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -397,10 +397,7 @@ VGZ_Destroy(struct vgz **vgp) enum vgzret_e vr; int i; - vg = *vgp; - CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - *vgp = NULL; - + TAKE_OBJ_NOTNULL(vg, vgp, VGZ_MAGIC); AN(vg->id); VSLb(vg->vsl, SLT_Gzip, "%s %jd %jd %jd %jd %jd", vg->id, diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c index e80d1b7..cb40ea9 100644 --- a/lib/libvarnish/vcli_serve.c +++ b/lib/libvarnish/vcli_serve.c @@ -607,9 +607,7 @@ VCLS_Destroy(struct VCLS **csp) struct VCLS_fd *cfd, *cfd2; struct cli_proto *clp; - cs = *csp; - *csp = NULL; - CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); + TAKE_OBJ_NOTNULL(cs, csp, VCLS_MAGIC); VTAILQ_FOREACH_SAFE(cfd, &cs->fds, list, cfd2) cls_close_fd(cs, cfd); diff --git a/lib/libvarnish/vsmw.c b/lib/libvarnish/vsmw.c index ee9fa3e..a5c7e3f 100644 --- a/lib/libvarnish/vsmw.c +++ b/lib/libvarnish/vsmw.c @@ -301,11 +301,7 @@ VSMW_Destroy(struct vsmw **pp) struct vsmw *vsmw; struct vsmwseg *seg, *s2; - AN(pp); - AN(*pp); - vsmw = *pp; - *pp = NULL; - CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC); + TAKE_OBJ_NOTNULL(vsmw, pp, VSMW_MAGIC); AZ(unlinkat(vsmw->vdirfd, vsmw->idx, 0)); REPLACE(vsmw->idx, NULL); VTAILQ_FOREACH_SAFE(seg, &vsmw->segs, list, s2) diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 235c9e0..bbdc8ab 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -237,11 +237,7 @@ VSM_Destroy(struct vsm **vdp) { struct vsm *vd; - AN(vdp); - vd = *vdp; - *vdp = NULL; - - CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); + TAKE_OBJ_NOTNULL(vd, vdp, VSM_MAGIC); if (vd->vsc != NULL) VSC_Delete(vd->vsc); From hermunn at varnish-software.com Thu Sep 7 06:59:07 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:07 +0000 (UTC) Subject: [5.2] 729f4b1 Whitespace OCD Message-ID: <20170907065907.C243191DCB@lists.varnish-cache.org> commit 729f4b152c42e38c6d6cdb33b2b515effb43c2c3 Author: Poul-Henning Kamp Date: Tue Sep 5 10:48:40 2017 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index 11f36e6..cb15b5e 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -51,7 +51,7 @@ varnish v1 -vcl { decoding=IDENTITY)); set resp.http.truncated = - blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); } } -start diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index 2dca6f3..b26d151 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -19,26 +19,26 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.hexlc = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode(IDENTITY, req.http.pangram)); set resp.http.hexuc = - blob.encode(HEXUC, + blob.encode(HEXUC, blob.decode(IDENTITY, req.http.pangram)); - set resp.http.hobbeslc = + set resp.http.hobbeslc = blob.encode(HEXLC, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEXUC, blob.decode(IDENTITY, req.http.hobbes)); - set resp.http.all-lc = + set resp.http.all-lc = blob.encode(HEXLC, blob.decode(BASE64, req.http.b64all)); set resp.http.all-uc = blob.encode(HEXUC, blob.decode(BASE64, req.http.b64all)); - set resp.http.empty-lc = + set resp.http.empty-lc = blob.encode(HEXLC, blob.decode(IDENTITY, "")); set resp.http.empty-uc = @@ -55,41 +55,41 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); # Hobbes quotation in hex - set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; set req.http.hexhobbesuc = std.toupper(req.http.hexhobbeslc); - set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; + set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; set req.http.hexalllc = std.tolower(req.http.hexalluc); - set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); - set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); + set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); + set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); set resp.http.decuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.hexucfoobar)); set resp.http.declc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.hexlcfoobar)); set resp.http.dechobbesuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.hexhobbesuc)); set resp.http.dechobbeslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode(HEX, req.http.hexalluc)); + blob.encode(BASE64, blob.decode(HEX, req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode(HEX, req.http.hexalllc)); + blob.encode(BASE64, blob.decode(HEX, req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob.decode(HEX, + blob.encode(BASE64, blob.decode(HEX, req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob.decode(HEX, + blob.encode(BASE64, blob.decode(HEX, req.http.hexalllcodd)); set resp.http.decempty = @@ -102,7 +102,7 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { blob.encode(IDENTITY, blob.decode(HEX, "0")); set resp.http.decemptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(HEX, req.http.unset + "" + req.http.unset + "")); @@ -123,7 +123,7 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode(HEX, "" + req.http.unset + blob.encode(IDENTITY, blob.decode(HEX, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -188,8 +188,8 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect 0 * Begin req - expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" + expect 0 * Begin req + expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" #" expect * = End } -start diff --git a/bin/varnishtest/tests/m00036.vtc b/bin/varnishtest/tests/m00036.vtc index 88f869a..21ff627 100644 --- a/bin/varnishtest/tests/m00036.vtc +++ b/bin/varnishtest/tests/m00036.vtc @@ -18,26 +18,26 @@ varnish v1 -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.hexlc = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode_n(5, IDENTITY, req.http.pangram)); set resp.http.hexuc = - blob.encode(HEXUC, + blob.encode(HEXUC, blob.decode_n(5, IDENTITY, req.http.pangram)); - set resp.http.hobbeslc = + set resp.http.hobbeslc = blob.encode(HEXLC, blob.decode_n(5, IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEXUC, blob.decode_n(5, IDENTITY, req.http.hobbes)); - set resp.http.all-lc = + set resp.http.all-lc = blob.encode(HEXLC, blob.decode_n(8, BASE64, req.http.b64all)); set resp.http.all-uc = blob.encode(HEXUC, blob.decode_n(8, BASE64, req.http.b64all)); - set resp.http.empty-lc = + set resp.http.empty-lc = blob.encode(HEXLC, blob.decode_n(5, IDENTITY, "")); set resp.http.empty-uc = @@ -54,41 +54,41 @@ varnish v1 -vcl { set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); # Hobbes quotation in hex - set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbeslc = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; set req.http.hexhobbesuc = std.toupper(req.http.hexhobbeslc); - set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; + set req.http.hexalluc = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; set req.http.hexalllc = std.tolower(req.http.hexalluc); - set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); - set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); + set req.http.hexallucodd = regsub(req.http.hexalluc, "^0", ""); + set req.http.hexalllcodd = regsub(req.http.hexalllc, "^0", ""); set resp.http.decuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(10, HEX, req.http.hexucfoobar)); set resp.http.declc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(10, HEX, req.http.hexlcfoobar)); set resp.http.dechobbesuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(12, HEX, req.http.hexhobbesuc)); set resp.http.dechobbeslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(12, HEX, req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalluc)); + blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalllc)); + blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob.decode_n(11, HEX, + blob.encode(BASE64, blob.decode_n(11, HEX, req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob.decode_n(11, HEX, + blob.encode(BASE64, blob.decode_n(11, HEX, req.http.hexalllcodd)); set resp.http.decempty = @@ -101,7 +101,7 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob.decode_n(2, HEX, "0")); set resp.http.decemptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(5, HEX, req.http.unset + "" + req.http.unset + "")); @@ -122,7 +122,7 @@ varnish v1 -vcl { "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode_n(20, HEX, "" + req.http.unset + blob.encode(IDENTITY, blob.decode_n(20, HEX, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -187,8 +187,8 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect 0 * Begin req - expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" + expect 0 * Begin req + expect * = VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"g\"$" #" expect * = End } -start diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index 29bde50..13dc2d5 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -18,37 +18,37 @@ varnish v1 -vcl { {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set resp.http.b64 = - blob.encode(BASE64, blob.decode(IDENTITY, + blob.encode(BASE64, blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64hobbes = - blob.encode(BASE64, blob.decode(IDENTITY, + blob.encode(BASE64, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64all = blob.encode(BASE64, blob.decode(HEX, req.http.hexall)); set resp.http.b64url = - blob.encode(BASE64URL, + blob.encode(BASE64URL, blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64urlhobbes = - blob.encode(BASE64URL, + blob.encode(BASE64URL, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64urlall = blob.encode(BASE64URL, blob.decode(HEX, req.http.hexall)); set resp.http.b64urlnopad = - blob.encode(BASE64URLNOPAD, + blob.encode(BASE64URLNOPAD, blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64nopadhobbes = - blob.encode(BASE64URLNOPAD, + blob.encode(BASE64URLNOPAD, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64nopadall = - blob.encode(BASE64URLNOPAD, + blob.encode(BASE64URLNOPAD, blob.decode(HEX, req.http.hexall)); set resp.http.b64empty = @@ -134,26 +134,26 @@ varnish v1 -vcl { blob.decode(BASE64, req.http.pangram)); set resp.http.b64dechobbes = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(BASE64, req.http.hobbes)); set resp.http.b64decall = blob.encode(HEXLC, blob.decode(BASE64, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob.decode(BASE64URL, + blob.encode(IDENTITY, blob.decode(BASE64URL, req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode(BASE64URL, req.http.allurl)); set resp.http.nopaddechobbes = - blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, req.http.hobbesnopad)); set resp.http.nopaddecall = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode(BASE64URLNOPAD, req.http.allurl)); set resp.http.b64empty = @@ -167,34 +167,34 @@ varnish v1 -vcl { blob.decode(BASE64, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); - set resp.http.decenc + set resp.http.decenc = blob.encode(BASE64, blob.decode(BASE64, req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob.decode(BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw==")); + resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces = blob.encode(IDENTITY, blob.decode(BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw" - + resp.http.pad)); + resp.http.l + "0hlbGxvIHdvcmxkLw" + + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces = blob.encode(IDENTITY, blob.decode(BASE64, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw" - + resp.http.pad)); + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw" + + resp.http.pad)); set resp.http.dec7param = blob.encode(blob=blob.decode(encoded=resp.http.l + "0hlb" - + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" - + resp.http.pad, decoding=BASE64), - encoding=IDENTITY); + + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + + resp.http.pad, decoding=BASE64), + encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, @@ -202,17 +202,17 @@ varnish v1 -vcl { set resp.http.decnopad2pieces = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, - resp.http.l + "0hlbGxvIHdvcmxkLw")); + resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw")); + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, - "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); } @@ -255,19 +255,19 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - set req.http.foo = "AAA="; - if (req.url == "/base64") { - set resp.http.bad64 = blob.encode(IDENTITY, - blob.decode(BASE64, "-_-_" + req.http.foo)); - } - elsif (req.url == "/base64url") { - set resp.http.badurl = blob.encode(IDENTITY, - blob.decode(BASE64URL, "+/+/" + req.http.foo)); - } - elsif (req.url == "/base64urlnopad") { - set resp.http.badpad = blob.encode(IDENTITY, - blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); - } + set req.http.foo = "AAA="; + if (req.url == "/base64") { + set resp.http.bad64 = blob.encode(IDENTITY, + blob.decode(BASE64, "-_-_" + req.http.foo)); + } + elsif (req.url == "/base64url") { + set resp.http.badurl = blob.encode(IDENTITY, + blob.decode(BASE64URL, "+/+/" + req.http.foo)); + } + elsif (req.url == "/base64urlnopad") { + set resp.http.badpad = blob.encode(IDENTITY, + blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); + } } } diff --git a/bin/varnishtest/tests/m00038.vtc b/bin/varnishtest/tests/m00038.vtc index 99c7d69..f69bd58 100644 --- a/bin/varnishtest/tests/m00038.vtc +++ b/bin/varnishtest/tests/m00038.vtc @@ -21,17 +21,17 @@ varnish v1 -vcl { {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; set resp.http.dec - = blob.encode(IDENTITY, + = blob.encode(IDENTITY, blob.decode_n(8, BASE64, req.http.foobarbazquux)); set resp.http.deceq - = blob.encode(IDENTITY, + = blob.encode(IDENTITY, blob.decode_n(20, BASE64, req.http.foobarbazquux)); set resp.http.declong - = blob.encode(IDENTITY, + = blob.encode(IDENTITY, blob.decode_n(30, BASE64, req.http.foobarbazquux)); @@ -40,25 +40,25 @@ varnish v1 -vcl { blob.decode_n(12, BASE64, req.http.pangram)); set resp.http.b64dechobbes = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(24, BASE64, req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEXLC, blob.decode_n(128, BASE64, + blob.encode(HEXLC, blob.decode_n(128, BASE64, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob.decode_n(180, BASE64URL, + blob.encode(IDENTITY, blob.decode_n(180, BASE64URL, req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode_n(256, BASE64URL, req.http.allurl)); set resp.http.nopaddechobbes = blob.encode(IDENTITY, - blob.decode_n(500, BASE64URLNOPAD, + blob.decode_n(500, BASE64URLNOPAD, req.http.hobbesnopad)); set resp.http.nopaddecall = @@ -71,14 +71,14 @@ varnish v1 -vcl { set resp.http.urlempty = blob.encode(IDENTITY, blob.decode_n(1, BASE64URL, "")); set resp.http.nopadempty = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(0, BASE64URLNOPAD, "")); set resp.http.emptypieces = blob.encode(IDENTITY, blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); - set resp.http.decenc + set resp.http.decenc = blob.encode(BASE64, blob.decode_n(20, BASE64, req.http.foobarbazquux)); @@ -86,27 +86,27 @@ varnish v1 -vcl { set resp.http.l = "L"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob.decode_n(8, BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw==")); + resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces = blob.encode(IDENTITY, blob.decode_n(12, BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw" - + resp.http.pad)); + resp.http.l + "0hlbGxvIHdvcmxkLw" + + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces = blob.encode(IDENTITY, blob.decode_n(16, BASE64, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw" - + resp.http.pad)); + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw" + + resp.http.pad)); set resp.http.dec7param = blob.encode(blob=blob.decode_n(encoded=resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad, decoding=BASE64, n=20), - encoding=IDENTITY); + encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, blob.decode_n(18, BASE64URLNOPAD, @@ -114,17 +114,17 @@ varnish v1 -vcl { set resp.http.decnopad2pieces = blob.encode(IDENTITY, blob.decode_n(19, BASE64URLNOPAD, - resp.http.l + "0hlbGxvIHdvcmxkLw")); + resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces = blob.encode(IDENTITY, blob.decode_n(18, BASE64URLNOPAD, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw")); + resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, blob.decode_n(60, BASE64URLNOPAD, - "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); } @@ -169,20 +169,20 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - set req.http.foo = "AAA="; - if (req.url == "/base64") { - set resp.http.bad64 = blob.encode(IDENTITY, - blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); - } - elsif (req.url == "/base64url") { - set resp.http.badurl = blob.encode(IDENTITY, - blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); - } - elsif (req.url == "/base64urlnopad") { - set resp.http.badpad = blob.encode(IDENTITY, - blob.decode_n(8, BASE64URLNOPAD, + set req.http.foo = "AAA="; + if (req.url == "/base64") { + set resp.http.bad64 = blob.encode(IDENTITY, + blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); + } + elsif (req.url == "/base64url") { + set resp.http.badurl = blob.encode(IDENTITY, + blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); + } + elsif (req.url == "/base64urlnopad") { + set resp.http.badpad = blob.encode(IDENTITY, + blob.decode_n(8, BASE64URLNOPAD, "TWFu" + req.http.foo)); - } + } } } diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index f5d4809..77fb240 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -22,48 +22,48 @@ varnish v1 -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.urllc = - blob.encode(URLLC, + blob.encode(URLLC, blob.decode(IDENTITY, req.http.pangram)); set resp.http.urluc = - blob.encode(URLUC, + blob.encode(URLUC, blob.decode(IDENTITY, req.http.pangram)); - set resp.http.hobbeslc = + set resp.http.hobbeslc = blob.encode(URLLC, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = blob.encode(URLUC, blob.decode(IDENTITY, req.http.hobbes)); - set resp.http.umlautslc = + set resp.http.umlautslc = blob.encode(URLLC, - blob.decode(IDENTITY, req.http.umlauts)); + blob.decode(IDENTITY, req.http.umlauts)); - set resp.http.umlautsuc = + set resp.http.umlautsuc = blob.encode(URLUC, - blob.decode(IDENTITY, req.http.umlauts)); + blob.decode(IDENTITY, req.http.umlauts)); - set resp.http.phklc = + set resp.http.phklc = blob.encode(URLLC, - blob.decode(IDENTITY, req.http.phkspeak)); + blob.decode(IDENTITY, req.http.phkspeak)); - set resp.http.phkuc = + set resp.http.phkuc = blob.encode(URLUC, - blob.decode(IDENTITY, req.http.phkspeak)); + blob.decode(IDENTITY, req.http.phkspeak)); - set resp.http.utf8lc = + set resp.http.utf8lc = blob.encode(URLLC, blob.decode(IDENTITY, req.http.utf8)); - set resp.http.utf8uc = + set resp.http.utf8uc = blob.encode(URLUC, blob.decode(IDENTITY, req.http.utf8)); - set resp.http.all-lc = + set resp.http.all-lc = blob.encode(URLLC, blob.decode(BASE64, req.http.b64all)); set resp.http.all-uc = blob.encode(URLUC, blob.decode(BASE64, req.http.b64all)); - set resp.http.empty-lc = + set resp.http.empty-lc = blob.encode(URLLC, blob.decode(IDENTITY, "")); set resp.http.empty-uc = @@ -80,7 +80,7 @@ varnish v1 -vcl { set req.http.urllcfoobar = "foo%3abar%3abaz%3aquux"; set req.http.urlucfoobar = "foo%3Abar%3Abaz%3Aquux"; set req.http.urlmixedfoobar = "foo%3Abar%3abaz%3Aquux"; - set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urllcumlauts = "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger"; set req.http.urlucumlauts = "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger"; @@ -88,58 +88,58 @@ varnish v1 -vcl { set req.http.urlucphk = "sm%C3%A5b%C3%B8rnsp%C3%A6dagog"; set req.http.urllcutf8 = "%e6%97%a5%e6%89%bc%e8%aa%9e"; set req.http.urlucutf8 = "%E6%97%A5%E6%89%BC%E8%AA%9E"; - set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; set req.http.urlalllc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; set resp.http.decuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlucfoobar)); set resp.http.declc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urllcfoobar)); set resp.http.decmixed = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlmixedfoobar)); set resp.http.dechobbesuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlhobbesuc)); set resp.http.dechobbeslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlhobbeslc)); set resp.http.decumlautsuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlucumlauts)); set resp.http.decumlautslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urllcumlauts)); set resp.http.decphkuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlucphk)); set resp.http.decphklc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urllcphk)); set resp.http.decutf8uc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urlucutf8)); set resp.http.decutf8lc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode(URL, req.http.urlalluc)); + blob.encode(BASE64, blob.decode(URL, req.http.urlalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode(URL, req.http.urlalllc)); + blob.encode(BASE64, blob.decode(URL, req.http.urlalllc)); set resp.http.decempty = blob.encode(IDENTITY, blob.decode(URL, "")); @@ -148,7 +148,7 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob.decode(URL, "%00")); set resp.http.decemptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode(URL, req.http.unset + "" + req.http.unset + "")); @@ -169,7 +169,7 @@ varnish v1 -vcl { "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode(URL, "" + req.http.unset + blob.encode(IDENTITY, blob.decode(URL, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -229,22 +229,22 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - if (req.url == "/percent") { - set resp.http.bad - = blob.encode(URLUC, blob.decode(URL, "%")); - } - elsif (req.url == "/percent-two") { - set resp.http.bad = blob.encode(URLUC, - blob.decode(URL, "%2")); - } - elsif (req.url == "/percent-q") { - set resp.http.bad = blob.encode(URLUC, - blob.decode(URL, "%q")); - } - elsif (req.url == "/percent-two-q") { - set resp.http.bad = blob.encode(URLUC, + if (req.url == "/percent") { + set resp.http.bad + = blob.encode(URLUC, blob.decode(URL, "%")); + } + elsif (req.url == "/percent-two") { + set resp.http.bad = blob.encode(URLUC, + blob.decode(URL, "%2")); + } + elsif (req.url == "/percent-q") { + set resp.http.bad = blob.encode(URLUC, + blob.decode(URL, "%q")); + } + elsif (req.url == "/percent-two-q") { + set resp.http.bad = blob.encode(URLUC, blob.decode(URL, "%2q")); - } + } } } @@ -281,8 +281,8 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%\"$" - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2\"$" - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%q\"$" - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2q\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%q\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%2q\"$" } -run diff --git a/bin/varnishtest/tests/m00040.vtc b/bin/varnishtest/tests/m00040.vtc index b93a3c5..0ec8842 100644 --- a/bin/varnishtest/tests/m00040.vtc +++ b/bin/varnishtest/tests/m00040.vtc @@ -12,7 +12,7 @@ varnish v1 -vcl { sub vcl_synth { set req.http.urllcfoobar = "foo%3abar%3abaz%3aquux"; set req.http.urlucfoobar = "foo%3Abar%3Abaz%3Aquux"; - set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urllcumlauts = "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger"; set req.http.urlucumlauts = "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger"; @@ -20,57 +20,57 @@ varnish v1 -vcl { set req.http.urlucphk = "sm%C3%A5b%C3%B8rnsp%C3%A6dagog"; set req.http.urllcutf8 = "%e6%97%a5%e6%89%bc%e8%aa%9e"; set req.http.urlucutf8 = "%E6%97%A5%E6%89%BC%E8%AA%9E"; - set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlalluc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; set req.http.urlalllc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; set resp.http.decuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(9, URL, req.http.urlucfoobar)); set resp.http.declc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(12, URL, req.http.urllcfoobar)); set resp.http.dechobbesuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(27, URL, req.http.urlhobbesuc)); set resp.http.dechobbeslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(27, URL, req.http.urlhobbeslc)); set resp.http.decumlautsuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(17, URL, req.http.urlucumlauts)); set resp.http.decumlautslc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(25, URL, req.http.urllcumlauts)); set resp.http.decphkuc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(18, URL, req.http.urlucphk)); set resp.http.decphklc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(30, URL, req.http.urllcphk)); set resp.http.decutf8uc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(9, URL, req.http.urlucutf8)); set resp.http.decutf8lc = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(18, URL, req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(HEXLC, + blob.encode(HEXLC, blob.decode_n(252, URL, req.http.urlalluc)); set resp.http.decalllc = - blob.encode(HEXUC, + blob.encode(HEXUC, blob.decode_n(252, URL, req.http.urlalllc)); set resp.http.decempty = @@ -80,7 +80,7 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob.decode_n(3, URL, "%00")); set resp.http.decemptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(1, URL, req.http.unset + "" + req.http.unset + "")); @@ -88,7 +88,7 @@ varnish v1 -vcl { set resp.http.dec2pieces = blob.encode(IDENTITY, blob.decode_n(6, URL, req.http.part1 + - "20bar%20baz%20quux")); + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = @@ -104,7 +104,7 @@ varnish v1 -vcl { + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob.decode_n(24, URL, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" @@ -148,22 +148,22 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - if (req.url == "/percent") { - set resp.http.bad = blob.encode(URLUC, - blob.decode_n(1, URL, "%20")); - } - elsif (req.url == "/percent-two") { - set resp.http.bad = blob.encode(URLUC, - blob.decode_n(2, URL, "%20")); - } - elsif (req.url == "/comma") { - set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%2c%q")); - } - elsif (req.url == "/colon") { - set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%3a%2q")); - } + if (req.url == "/percent") { + set resp.http.bad = blob.encode(URLUC, + blob.decode_n(1, URL, "%20")); + } + elsif (req.url == "/percent-two") { + set resp.http.bad = blob.encode(URLUC, + blob.decode_n(2, URL, "%20")); + } + elsif (req.url == "/comma") { + set resp.http.good = blob.encode(IDENTITY, + blob.decode_n(3, URL, "%2c%q")); + } + elsif (req.url == "/colon") { + set resp.http.good = blob.encode(IDENTITY, + blob.decode_n(3, URL, "%3a%2q")); + } } } @@ -192,6 +192,6 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" - expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" + expect * * VCL_Error "^vmod blob error: cannot decode, illegal encoding beginning with \"%20\"$" } -run diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index b5cd490..811d814 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -16,7 +16,7 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; set req.http.hobbesb64 = {"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; - set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; set req.http.hexalldown = {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set req.http.hexallup = @@ -204,11 +204,11 @@ varnish v1 -vcl { } sub vcl_synth { - set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; - set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; set req.http.urlalluplc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; - set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; + set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id @@ -318,57 +318,57 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - set req.http.foo = "AAA="; - if (req.url == "/1") { - set resp.http.bad - = blob.transcode(HEX, IDENTITY, "0x123456"); - } - elsif (req.url == "/2") { - set resp.http.bad - = blob.transcode(BASE64, IDENTITY, + set req.http.foo = "AAA="; + if (req.url == "/1") { + set resp.http.bad + = blob.transcode(HEX, IDENTITY, "0x123456"); + } + elsif (req.url == "/2") { + set resp.http.bad + = blob.transcode(BASE64, IDENTITY, "-_-_" + req.http.foo); - } - elsif (req.url == "/3") { - set resp.http.bad - = blob.transcode(BASE64URL, IDENTITY, + } + elsif (req.url == "/3") { + set resp.http.bad + = blob.transcode(BASE64URL, IDENTITY, "+/+/" + req.http.foo); - } - elsif (req.url == "/4") { - set resp.http.bad - = blob.transcode(BASE64URLNOPAD, IDENTITY, + } + elsif (req.url == "/4") { + set resp.http.bad + = blob.transcode(BASE64URLNOPAD, IDENTITY, "TWFu" + req.http.foo); - } - elsif (req.url == "/5") { - set resp.http.bad - = blob.transcode(BASE64, BASE64, + } + elsif (req.url == "/5") { + set resp.http.bad + = blob.transcode(BASE64, BASE64, "_-_-" + req.http.foo); - } - elsif (req.url == "/6") { - set resp.http.bad - = blob.transcode(BASE64URL, BASE64URL, - "/+/+" + req.http.foo); - } - elsif (req.url == "/7") { - set resp.http.bad - = blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, - "Zm9v" + req.http.foo); - } - elsif (req.url == "/8") { - set resp.http.bad - = blob.transcode(URL, IDENTITY, "%"); - } - elsif (req.url == "/9") { - set resp.http.bad - = blob.transcode(URL, IDENTITY, "%2"); - } - elsif (req.url == "/10") { - set resp.http.bad - = blob.transcode(URL, IDENTITY, "%q"); - } - elsif (req.url == "/11") { - set resp.http.bad - = blob.transcode(URL, IDENTITY, "%2q"); - } + } + elsif (req.url == "/6") { + set resp.http.bad + = blob.transcode(BASE64URL, BASE64URL, + "/+/+" + req.http.foo); + } + elsif (req.url == "/7") { + set resp.http.bad + = blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, + "Zm9v" + req.http.foo); + } + elsif (req.url == "/8") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%"); + } + elsif (req.url == "/9") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%2"); + } + elsif (req.url == "/10") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%q"); + } + elsif (req.url == "/11") { + set resp.http.bad + = blob.transcode(URL, IDENTITY, "%2q"); + } } } @@ -461,15 +461,15 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "0x123456"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "-_-_"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "\+/\+/"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "_-_-"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "/\+/\+"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "Zm9v"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%q"$} - expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2q"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "0x123456"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "-_-_"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "\+/\+/"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "_-_-"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "/\+/\+"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "Zm9v"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%q"$} + expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "%2q"$} } -run diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index a34f7d0..164846a 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -15,7 +15,7 @@ varnish v1 -vcl { {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; set req.http.hobbesb64 = {"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; - set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; set req.http.hexalldown = {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set req.http.hexallup = @@ -25,7 +25,7 @@ varnish v1 -vcl { set req.http.b64allurl = {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; - set resp.http.id2id + set resp.http.id2id = blob.transcode_n(5, IDENTITY, IDENTITY, "Hello world"); set resp.http.id2b64 @@ -140,13 +140,13 @@ varnish v1 -vcl { set resp.http.b64url2b64url = blob.transcode_n(34, BASE64URL, BASE64URL, - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" - + "ghijklmnopqrstuvwxyz0123456789-_"); + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789-_"); set resp.http.b64urlnopad2b64urlnopad = blob.transcode_n(34, BASE64URLNOPAD, BASE64URLNOPAD, - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" - + "ghijklmnopqrstuvwxyz0123456789-_"); + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + + "ghijklmnopqrstuvwxyz0123456789-_"); } } -start @@ -203,11 +203,11 @@ varnish v1 -vcl { } sub vcl_synth { - set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; + set req.http.urlhobbeslc = "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; set req.http.urlhobbesuc = "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure."; - set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; + set req.http.urlallupuc = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"; set req.http.urlalluplc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"; - set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; + set req.http.urlalldownuc = "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00"; set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id @@ -321,59 +321,59 @@ varnish v1 -vcl+backend { import blob; sub vcl_deliver { - set req.http.foo = "AAA="; - if (req.url == "/1") { - set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, "%2c%q"); - } - elsif (req.url == "/2") { - set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, "%3a%2q"); - } - elsif (req.url == "/3") { - set resp.http.bad - = blob.transcode_n(8, HEX, IDENTITY, - "0x123456"); - } - elsif (req.url == "/4") { - set resp.http.bad - = blob.transcode_n(4, BASE64, IDENTITY, - "-_-_" + req.http.foo); - } - elsif (req.url == "/5") { - set resp.http.bad - = blob.transcode_n(4, BASE64URL, IDENTITY, - "+/+/" + req.http.foo); - } - elsif (req.url == "/6") { - set resp.http.bad - = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, - "TWFu" + req.http.foo); - } - elsif (req.url == "/7") { - set resp.http.bad - = blob.transcode_n(4, BASE64, BASE64, - "_-_-" + req.http.foo); - } - elsif (req.url == "/8") { - set resp.http.bad - = blob.transcode_n(4, BASE64URL, BASE64URL, - "/+/+" + req.http.foo); - } - elsif (req.url == "/9") { - set resp.http.bad - = blob.transcode_n(8, BASE64URLNOPAD, - BASE64URLNOPAD, + set req.http.foo = "AAA="; + if (req.url == "/1") { + set resp.http.good + = blob.transcode_n(3, URL, IDENTITY, "%2c%q"); + } + elsif (req.url == "/2") { + set resp.http.good + = blob.transcode_n(3, URL, IDENTITY, "%3a%2q"); + } + elsif (req.url == "/3") { + set resp.http.bad + = blob.transcode_n(8, HEX, IDENTITY, + "0x123456"); + } + elsif (req.url == "/4") { + set resp.http.bad + = blob.transcode_n(4, BASE64, IDENTITY, + "-_-_" + req.http.foo); + } + elsif (req.url == "/5") { + set resp.http.bad + = blob.transcode_n(4, BASE64URL, IDENTITY, + "+/+/" + req.http.foo); + } + elsif (req.url == "/6") { + set resp.http.bad + = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, + "TWFu" + req.http.foo); + } + elsif (req.url == "/7") { + set resp.http.bad + = blob.transcode_n(4, BASE64, BASE64, + "_-_-" + req.http.foo); + } + elsif (req.url == "/8") { + set resp.http.bad + = blob.transcode_n(4, BASE64URL, BASE64URL, + "/+/+" + req.http.foo); + } + elsif (req.url == "/9") { + set resp.http.bad + = blob.transcode_n(8, BASE64URLNOPAD, + BASE64URLNOPAD, "Zm9v" + req.http.foo); - } - elsif (req.url == "/10") { - set resp.http.bad - = blob.transcode_n(1, URL, IDENTITY, "%20"); - } - elsif (req.url == "/11") { - set resp.http.bad - = blob.transcode_n(2, URL, IDENTITY, "%20"); - } + } + elsif (req.url == "/10") { + set resp.http.bad + = blob.transcode_n(1, URL, IDENTITY, "%20"); + } + elsif (req.url == "/11") { + set resp.http.bad + = blob.transcode_n(2, URL, IDENTITY, "%20"); + } } } diff --git a/bin/varnishtest/tests/m00043.vtc b/bin/varnishtest/tests/m00043.vtc index c12ac14..74763b5 100644 --- a/bin/varnishtest/tests/m00043.vtc +++ b/bin/varnishtest/tests/m00043.vtc @@ -10,7 +10,7 @@ varnish v1 -arg "-i serverid" -vcl+backend { "The quick brown fox jumps over the lazy dog"); new idpieces = blob.blob(IDENTITY, "" + server.identity + " " - + server.identity + ""); + + server.identity + ""); new idempty = blob.blob(IDENTITY, ""); new idparam = blob.blob(encoded="" + server.identity + " " + server.identity diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index e1319a3..aa88db4 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -15,9 +15,9 @@ $Module blob 3 utilities for the VCL blob type BLOB blob.decode(ENUM decoding, STRING_LIST encoded) BLOB blob.decode_n(INT n, ENUM decoding, STRING_LIST encoded) STRING blob.transcode(ENUM decoding, ENUM encoding, - STRING_LIST encoded) + STRING_LIST encoded) STRING blob.transcode_n(INT n, ENUM decoding, ENUM encoding, - STRING_LIST encoded) + STRING_LIST encoded) # other utilities BOOL blob.same(BLOB, BLOB) @@ -47,7 +47,7 @@ Examples:: sub vcl_deliver { # The .get() method retrieves the BLOB from an object. set resp.http.MyBlob-As-Hex - = blob.encode(blob=myblob.get(), encoding=HEXLC); + = blob.encode(blob=myblob.get(), encoding=HEXLC); # The .encode() method efficiently retrieves an encoding. set resp.http.YourBlob-As-Base64 = yourblob.encode(BASE64); @@ -55,22 +55,22 @@ Examples:: # decode() and encode() functions convert blobs to text and # vice versa at runtime. set resp.http.Base64-Encoded - = blob.encode(BASE64, - blob.decode(HEX, req.http.Hex-Encoded)); + = blob.encode(BASE64, + blob.decode(HEX, req.http.Hex-Encoded)); } sub vcl_recv { # transcode() converts from one encoding to another. set req.http.Hex-Encoded - = blob.transcode(decoding=BASE64, encoding=HEXUC, - encoded="YmF6"); + = blob.transcode(decoding=BASE64, encoding=HEXUC, + encoded="YmF6"); # transcode() from URL to IDENTITY effects a URL decode. set req.url = blob.transcode(encoded=req.url, decoding=URL); # transcode() from IDENTITY to URL effects a URL encode. set req.http.url_urlcoded - = blob.transcode(encoded=req.url, encoding=URLLC); + = blob.transcode(encoded=req.url, encoding=URLLC); } ENCODING SCHEMES @@ -169,7 +169,7 @@ byte. For example:: set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode(HEXLC, blob.decode(HEX, - resp.http.First + resp.http.Second)); + resp.http.First + resp.http.Second)); URL* ---- @@ -182,7 +182,7 @@ RFC3986, the hexadecimal characters A-F being output in lower- and uppercase, respectively. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", STRING_LIST encoded) Returns the BLOB derived from the string ``encoded`` according to the scheme specified by ``decoding``. @@ -209,7 +209,7 @@ the encoded string. If ``n`` is greater than the length of the string, then return the same result as ``decode()``. $Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", BLOB blob) Returns a string representation of the BLOB ``blob`` as specifed by @@ -233,10 +233,10 @@ Example:: = blob.encode(blob=blob.decode(encoded="foo")); $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", - ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", - STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", + ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + STRING_LIST encoded) Translates from one encoding to another, by first decoding the string ``encoded`` according to the scheme ``decoding``, and then returning @@ -264,10 +264,10 @@ Example:: $Function STRING transcode_n(INT n, ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", - ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", - STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", + ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, + HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + STRING_LIST encoded) Same as ``transcode()``, but only from the first ``n`` characters of the encoded string. @@ -305,8 +305,8 @@ if ``offset + length`` requires more bytes than are available in the BLOB. $Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, - URL} decoding="IDENTITY", - STRING_LIST encoded) + URL} decoding="IDENTITY", + STRING_LIST encoded) Creates an object that contains the BLOB derived from the string ``encoded`` according to the scheme ``decoding``. @@ -337,7 +337,7 @@ Example:: blob.encode(blob=stringblob.get()); $Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXUC, - HEXLC, URLUC, URLLC} encoding="IDENTITY") + HEXLC, URLUC, URLLC} encoding="IDENTITY") Returns an encoding of BLOB created by the constructor, according to the scheme ``encoding``. diff --git a/lib/libvmod_purge/vmod.vcc b/lib/libvmod_purge/vmod.vcc index 1e9259e..25a9cb8 100644 --- a/lib/libvmod_purge/vmod.vcc +++ b/lib/libvmod_purge/vmod.vcc @@ -42,61 +42,61 @@ EXAMPLE :: sub vcl_recv { - if (req.method == "PURGE") { - if (client.ip !~ purge_acl) { - return (synth(405)); - } - return (hash); - } + if (req.method == "PURGE") { + if (client.ip !~ purge_acl) { + return (synth(405)); + } + return (hash); + } } sub my_purge { - set req.http.purged = purge.hard(); - if (req.http.purged == "0") { - return (synth(404)); - } - else { - return (synth(200)); - } + set req.http.purged = purge.hard(); + if (req.http.purged == "0") { + return (synth(404)); + } + else { + return (synth(200)); + } } sub vcl_hit { - if (req.method == "PURGE") { - call my_purge; - } + if (req.method == "PURGE") { + call my_purge; + } } sub vcl_miss { - if (req.method == "PURGE") { - call my_purge; - } + if (req.method == "PURGE") { + call my_purge; + } } sub vcl_synth { - if (req.method == "PURGE") { - if (req.http.purged) { - set resp.http.purged = req.http.purged; - } - return (deliver); - } + if (req.method == "PURGE") { + if (req.http.purged) { + set resp.http.purged = req.http.purged; + } + return (deliver); + } } $Function INT hard() Description This is equivalent to ``return(purge)`` but explicitly called from - ``vcl_hit`` and ``vcl_miss``. It returns the number of purged objects. + ``vcl_hit`` and ``vcl_miss``. It returns the number of purged objects. Example set req.http.purged = purge.hard(); $Function INT soft(DURATION ttl = 0, DURATION grace = -1, DURATION keep = -1) Description - Sets the TTL, grace and keep. By default, TTL is set to 0 with grace - and keep periods left untouched. Setting a negative value for grace or - keep periods leaves them untouched. Setting all three parameters to - 0 is equivalent to a hard purge. It can only be called from ``vcl_hit`` - or ``vcl_miss``. It returns the number of soft-purged objects. + Sets the TTL, grace and keep. By default, TTL is set to 0 with grace + and keep periods left untouched. Setting a negative value for grace or + keep periods leaves them untouched. Setting all three parameters to + 0 is equivalent to a hard purge. It can only be called from ``vcl_hit`` + or ``vcl_miss``. It returns the number of soft-purged objects. SEE ALSO ======== From hermunn at varnish-software.com Thu Sep 7 06:59:07 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:07 +0000 (UTC) Subject: [5.2] 6ca3781 Minor flexelintery Message-ID: <20170907065907.E05B091DD5@lists.varnish-cache.org> commit 6ca378105ee37c41b6db2d0e0fca31e43daf4907 Author: Poul-Henning Kamp Date: Tue Sep 5 20:43:50 2017 +0000 Minor flexelintery diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b8066a1..fe3fdae 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -1084,7 +1084,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, bo = NULL; /* ref transferred to fetch thread */ if (mode == VBF_BACKGROUND) { ObjWaitState(oc, BOS_REQ_DONE); - VRB_Ignore(req); + (void)VRB_Ignore(req); } else { ObjWaitState(oc, BOS_STREAM); if (oc->boc->state == BOS_FAILED) { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 5837bd6..0b56b80 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -922,7 +922,7 @@ cnt_purge(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(boc, OBJCORE_MAGIC); VRY_Finish(req, DISCARD); - HSH_Purge(wrk, boc->objhead, 0, 0, 0); + (void)HSH_Purge(wrk, boc->objhead, 0, 0, 0); AZ(HSH_DerefObjCore(wrk, &boc, 1)); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 8c22e1a..1cdb983 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -38,7 +38,6 @@ #include "cache_director.h" #include "vrt.h" #include "vrt_obj.h" -#include "vsha256.h" static char vrt_hostname[255] = ""; @@ -769,7 +768,7 @@ VRT_BODY_L(resp) /*--------------------------------------------------------------------*/ static struct vmod_priv * -vrt_do_blob(VRT_CTX, const char *err, uint8_t *src, size_t len) +vrt_do_blob(VRT_CTX, const char *err, const uint8_t *src, size_t len) { struct vmod_priv *p; void *d; From hermunn at varnish-software.com Thu Sep 7 06:59:08 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 06:59:08 +0000 (UTC) Subject: [5.2] 97c02d2 Accommodate older python version Message-ID: <20170907065908.0E35691DDE@lists.varnish-cache.org> commit 97c02d22e03cb9d5ca2c462920399a0b60d50c82 Author: Federico G. Schwindt Date: Tue Sep 5 22:43:41 2017 +0100 Accommodate older python version I'm looking at you, EL6. diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py index 2d39f7b..d21e06b 100644 --- a/lib/libvcc/vsctool.py +++ b/lib/libvcc/vsctool.py @@ -39,6 +39,7 @@ import sys import gzip import StringIO import collections +import struct TYPES = [ "counter", "gauge", "bitmap" ] CTYPES = [ "uint64_t" ] @@ -55,7 +56,9 @@ PARAMS = { def gzip_str(s): out = StringIO.StringIO() - gzip.GzipFile(fileobj=out, mode="w", mtime=0x12bfd58).write(s) + gzip.GzipFile(fileobj=out, mode="w").write(s) + out.seek(4) + out.write(struct.pack(" commit 23333e3c60e8803b9b17a70694ba4cc833a93530 Author: Dridi Boukelmoune Date: Tue Sep 5 19:39:38 2017 +0200 Remove irrelevant limits that were caused by VSC Closes #2406 Refs #2157 diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index f6ce78e..4d04728 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -143,11 +143,11 @@ stv_check_ident(const char *spec, const char *ident) void STV_Config(const char *spec) { - char **av; + char **av, buf[8]; const char *name; struct stevedore *stv; const struct stevedore *stv2; - int ac, l; + int ac; static unsigned seq = 0; av = MGT_NamedArg(spec, &name, "-s"); @@ -174,16 +174,13 @@ STV_Config(const char *spec) *stv = *stv2; AN(stv->name); - if (name == NULL) - bprintf(stv->ident, "s%u", seq++); - else { - /* XXX: no need for truncation once VSM ident becomes dynamic */ - l = strlen(name); - if (l > sizeof stv->ident - 1) - l = sizeof stv->ident - 1; - bprintf(stv->ident, "%.*s", l, name); + if (name == NULL) { + bprintf(buf, "s%u", seq++); + name = buf; } + stv->ident = strdup(name); + AN(stv->ident); stv_check_ident(spec, stv->ident); if (stv->init != NULL) diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 8b78326..0a61d8d 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -119,7 +119,7 @@ struct stevedore { void *priv; VTAILQ_ENTRY(stevedore) list; - char ident[16]; /* XXX: match VSM_chunk.ident */ + char *ident; char *vclname; }; diff --git a/bin/varnishtest/tests/r02406.vtc b/bin/varnishtest/tests/r02406.vtc new file mode 100644 index 0000000..3f3d018 --- /dev/null +++ b/bin/varnishtest/tests/r02406.vtc @@ -0,0 +1,12 @@ +varnishtest "Long backend and storage names" + +varnish v1 -arg "-s acme_example_com_static_assets_malloc_storage=malloc" + +varnish v1 -vcl { + backend be_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789 { + .host = "${bad_backend}"; + } +} -start + +varnish v1 -expect SMA.acme_example_com_static_assets_malloc_storage.c_req == 0 +varnish v1 -expect VBE.vcl1.be_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789.req == 0 diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index bc0c096..54458d8 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -469,16 +469,6 @@ vcc_ParseBackend(struct vcc *tl) vcc_ExpectVid(tl, "backend"); /* ID: name */ ERRCHK(tl); - /* XXX: lift this limit once VSM ident becomes dynamic */ - if (tl->t->e - tl->t->b > MAX_BACKEND_NAME) { - VSB_printf(tl->sb, - "Name of %.*s too long (max %d, is %zu):\n", - PF(t_first), MAX_BACKEND_NAME, - (size_t)(tl->t->e - tl->t->b)); - vcc_ErrWhere(tl, tl->t); - return; - } - t_be = tl->t; vcc_NextToken(tl); diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 547b2bc..79f9a02 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -234,7 +234,6 @@ void vcc_Acl_Hack(struct vcc *tl, char *b, size_t bl); int vcc_ParseAction(struct vcc *tl); /* vcc_backend.c */ -#define MAX_BACKEND_NAME 64 struct fld_spec; void vcc_ParseProbe(struct vcc *tl); From phk at FreeBSD.org Thu Sep 7 07:57:03 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 07:57:03 +0000 (UTC) Subject: [master] e249ab4 Don't fail at jailing if vcache user does not exist Message-ID: <20170907075703.CBF4592BE1@lists.varnish-cache.org> commit e249ab46878e7ae5014852265f3bedb2f7e7b2d6 Author: Poul-Henning Kamp Date: Thu Sep 7 07:55:59 2017 +0000 Don't fail at jailing if vcache user does not exist Fixes #2417 diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index 6513f44..d39a3d6 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -167,8 +167,10 @@ vju_init(char **args) vju_mgr_gid = getgid(); - if (vju_wrkuser == NULL) - (void)vju_getwrkuid(VCACHE_USER); + if (vju_wrkuser == NULL && vju_getwrkuid(VCACHE_USER)) { + vju_wrkuid = vju_uid; + vju_wrkgid = vju_gid; + } if (vju_wrkuser != NULL && vju_wrkgid != vju_gid) ARGV_ERR("Unix jail: user %s and %s have " @@ -257,7 +259,7 @@ vju_vsm_dir(int fd) /* Called under JAIL_MASTER_FILE */ AZ(fchmod(fd, 0750)); - AZ(fchown(fd, vju_wrkuid, vju_gid)); + AZ(fchown(fd, vju_wrkuid, vju_wrkgid)); } static void __match_proto__(jail_fixfile_f) From hermunn at varnish-software.com Thu Sep 7 08:35:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 08:35:05 +0000 (UTC) Subject: [5.2] 12ddc91 Drop the incestous relationship between VSM and VSC, and stack VSC neatly on top of VSM. Message-ID: <20170907083505.9774492892@lists.varnish-cache.org> commit 12ddc91b02f94ea57e597772f8d3cd68e9a560dc Author: Poul-Henning Kamp Date: Wed Sep 6 20:54:50 2017 +0000 Drop the incestous relationship between VSM and VSC, and stack VSC neatly on top of VSM. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index c9270cf..1f24b25 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -74,7 +74,7 @@ do_xml_cb(void *priv, const struct VSC_point * const pt) } static void -do_xml(struct vsm *vd) +do_xml(struct vsc *vsc) { char time_stamp[20]; time_t now; @@ -83,7 +83,7 @@ do_xml(struct vsm *vd) now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf("\n", time_stamp); - (void)VSC_Iter(vd, NULL, do_xml_cb, NULL); + (void)VSC_Iter(vsc, NULL, do_xml_cb, NULL); printf("\n"); } @@ -124,7 +124,7 @@ do_json_cb(void *priv, const struct VSC_point * const pt) } static void -do_json(struct vsm *vd) +do_json(struct vsc *vsc) { char time_stamp[20]; time_t now; @@ -137,7 +137,7 @@ do_json(struct vsm *vd) (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf(" \"timestamp\": \"%s\",\n", time_stamp); - (void)VSC_Iter(vd, NULL, do_json_cb, &jp); + (void)VSC_Iter(vsc, NULL, do_json_cb, &jp); printf("\n}\n"); } @@ -194,15 +194,15 @@ do_once_cb(void *priv, const struct VSC_point * const pt) } static void -do_once(struct vsm *vd) +do_once(struct vsc *vsc) { struct once_priv op; memset(&op, 0, sizeof op); op.pad = 18; - (void)VSC_Iter(vd, NULL, do_once_cb_first, &op); - (void)VSC_Iter(vd, NULL, do_once_cb, &op); + (void)VSC_Iter(vsc, NULL, do_once_cb_first, &op); + (void)VSC_Iter(vsc, NULL, do_once_cb, &op); } /*--------------------------------------------------------------------*/ @@ -226,13 +226,13 @@ do_list_cb(void *priv, const struct VSC_point * const pt) } static void -list_fields(struct vsm *vd) +list_fields(struct vsc *vsc) { printf("Varnishstat -f option fields:\n"); printf("Field name Description\n"); printf("---------- -----------\n"); - (void)VSC_Iter(vd, NULL, do_list_cb, NULL); + (void)VSC_Iter(vsc, NULL, do_list_cb, NULL); } /*--------------------------------------------------------------------*/ @@ -256,10 +256,13 @@ main(int argc, char * const *argv) int once = 0, xml = 0, json = 0, f_list = 0, curses = 0; signed char opt; int i; + struct vsc *vsc; VUT_Init(progname, argc, argv, &vopt_spec); vd = VSM_New(); AN(vd); + vsc = VSC_New(vd); + AN(vsc); while ((opt = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { switch (opt) { @@ -282,7 +285,7 @@ main(int argc, char * const *argv) json = 1; break; default: - i = VSC_Arg(vd, opt, optarg); + i = VSC_Arg(vsc, opt, optarg); if (i < 0) VUT_Error(1, "%s", VSM_Error(vd)); if (!i) @@ -300,15 +303,15 @@ main(int argc, char * const *argv) VUT_Error(1, "%s", VSM_Error(vd)); if (curses) - do_curses(vd, 1.0); + do_curses(vd, vsc, 1.0); else if (xml) - do_xml(vd); + do_xml(vsc); else if (json) - do_json(vd); + do_json(vsc); else if (once) - do_once(vd); + do_once(vsc); else if (f_list) - list_fields(vd); + list_fields(vsc); else assert(0); diff --git a/bin/varnishstat/varnishstat.h b/bin/varnishstat/varnishstat.h index 54fd0ba..6a73ef2 100644 --- a/bin/varnishstat/varnishstat.h +++ b/bin/varnishstat/varnishstat.h @@ -35,4 +35,4 @@ #include "vas.h" #include "vcs.h" -void do_curses(struct vsm *vd, double delay); +void do_curses(struct vsm *, struct vsc *, double); diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 7d99c7e..104af2b 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -313,7 +313,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) } static void -build_pt_list(struct vsm *vd, struct vsm_fantom *fantom) +build_pt_list(struct vsc *vsc, struct vsm_fantom *fantom) { struct pt_priv pt_priv; int i; @@ -334,7 +334,7 @@ build_pt_list(struct vsm *vd, struct vsm_fantom *fantom) main_cache_hit = NULL; main_cache_miss = NULL; - (void)VSC_Iter(vd, fantom, build_pt_list_cb, &pt_priv); + (void)VSC_Iter(vsc, fantom, build_pt_list_cb, &pt_priv); delete_pt_list(); AN(VTAILQ_EMPTY(&ptlist)); AZ(n_ptlist); @@ -1044,7 +1044,7 @@ handle_keypress(int ch) } void -do_curses(struct vsm *vd, double delay) +do_curses(struct vsm *vd, struct vsc *vsc, double delay) { struct pollfd pollfd; long t; @@ -1073,7 +1073,7 @@ do_curses(struct vsm *vd, double delay) (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED))) { init_hitrate(); delete_pt_list(); - build_pt_list(vd, &f_iter); + build_pt_list(vsc, &f_iter); initial = 0; } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 7a10731..45218bc 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -78,6 +78,7 @@ struct varnish { struct vsm *vsm_vsl; struct vsm *vsm_vsc; + struct vsc *vsc; int has_a_arg; unsigned vsl_tag_count[256]; @@ -521,7 +522,10 @@ varnish_launch(struct varnish *v) free(r); v->vsm_vsc = VSM_New(); - (void)VSM_Arg(v->vsm_vsc, 'n', v->workdir); + AN(v->vsm_vsc); + v->vsc = VSC_New(v->vsm_vsc); + AN(v->vsc); + (void)VSC_Arg(v->vsc, 'n', v->workdir); AZ(VSM_Attach(v->vsm_vsc, -1)); v->vsm_vsl = VSM_New(); @@ -846,7 +850,7 @@ varnish_vsc(const struct varnish *v, const char *arg) dp.arg = arg; (void)VSM_Status(v->vsm_vsc); - (void)VSC_Iter(v->vsm_vsc, NULL, do_stat_dump_cb, &dp); + (void)VSC_Iter(v->vsc, NULL, do_stat_dump_cb, &dp); } /********************************************************************** @@ -912,7 +916,7 @@ varnish_expect(const struct varnish *v, char * const *av) for (i = 0; i < 50; i++, (void)usleep(100000)) { (void)VSM_Status(v->vsm_vsc); - good = VSC_Iter(v->vsm_vsc, NULL, do_expect_cb, &sp); + good = VSC_Iter(v->vsc, NULL, do_expect_cb, &sp); if (!good) { good = -2; continue; diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 7a87f70..97c85e1 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -38,13 +38,17 @@ #include "vapi/vsc_int.h" struct vsm; +struct vsc; struct vsm_fantom; /*--------------------------------------------------------------------- * VSC level access functions */ -int VSC_Arg(struct vsm *vd, char arg, const char *opt); +struct vsc *VSC_New(struct vsm *); +void VSC_Destroy(struct vsc **); + +int VSC_Arg(struct vsc *, char arg, const char *opt); /* * Handle standard stat-presenter arguments * Return: @@ -80,8 +84,7 @@ void VSC_Destroy_Point(struct VSC_point **); typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt); -int VSC_Iter(struct vsm *vd, struct vsm_fantom *fantom, VSC_iter_f *func, - void *priv); +int VSC_Iter(struct vsc *, struct vsm_fantom *, VSC_iter_f *func, void *priv); /* * Iterate over all statistics counters, calling "func" for * each counter not suppressed by any "-f" arguments. diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am index fbd4014..d0e8b64 100644 --- a/lib/libvarnishapi/Makefile.am +++ b/lib/libvarnishapi/Makefile.am @@ -14,7 +14,6 @@ libvarnishapi_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:6:0 libvarnishapi_la_SOURCES = \ vjsn.c \ vjsn.h \ - vsc_priv.h \ vsl_api.h \ vxp.h \ vxp_tokens.h \ diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 6a7cab2..b5d1b00 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -193,4 +193,6 @@ LIBVARNISHAPI_1.7 { VSM_Status; VSM_Arg; VSM_Dup; + VSC_New; + VSC_Destroy; } LIBVARNISHAPI_1.0; diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index cd933ad..de998cf 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -51,8 +51,6 @@ #include "vapi/vsc.h" #include "vapi/vsm.h" -#include "vsc_priv.h" - struct vsc_sf { unsigned magic; #define VSC_SF_MAGIC 0x558478dd @@ -65,6 +63,7 @@ struct vsc { unsigned magic; #define VSC_MAGIC 0x3373554a + struct vsm *vsm; struct vsc_sf_head sf_list_include; struct vsc_sf_head sf_list_exclude; }; @@ -116,20 +115,18 @@ VSC_Destroy_Point(struct VSC_point **p) /*--------------------------------------------------------------------*/ -static struct vsc * -vsc_setup(struct vsm *vd) +struct vsc * +VSC_New(struct vsm *vsm) { struct vsc *vsc; - vsc = VSM_GetVSC(vd); - if (vsc == NULL) { - ALLOC_OBJ(vsc, VSC_MAGIC); - AN(vsc); - VTAILQ_INIT(&vsc->sf_list_include); - VTAILQ_INIT(&vsc->sf_list_exclude); - VSM_SetVSC(vd, vsc); - } - CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + AN(vsm); + ALLOC_OBJ(vsc, VSC_MAGIC); + if (vsc == NULL) + return (vsc); + vsc->vsm = vsm; + VTAILQ_INIT(&vsc->sf_list_include); + VTAILQ_INIT(&vsc->sf_list_exclude); return (vsc); } @@ -150,10 +147,11 @@ vsc_delete_sf_list(struct vsc_sf_head *head) } void -VSC_Delete(struct vsc *vsc) +VSC_Destroy(struct vsc **vscp) { + struct vsc *vsc; - CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + TAKE_OBJ_NOTNULL(vsc, vscp, VSC_MAGIC); vsc_delete_sf_list(&vsc->sf_list_include); vsc_delete_sf_list(&vsc->sf_list_exclude); FREE_OBJ(vsc); @@ -162,13 +160,11 @@ VSC_Delete(struct vsc *vsc) /*--------------------------------------------------------------------*/ static int -vsc_f_arg(struct vsm *vd, const char *opt) +vsc_f_arg(struct vsc *vsc, const char *opt) { - struct vsc *vsc = vsc_setup(vd); struct vsc_sf *sf; unsigned exclude = 0; - AN(vd); AN(opt); ALLOC_OBJ(sf, VSC_SF_MAGIC); @@ -193,14 +189,16 @@ vsc_f_arg(struct vsm *vd, const char *opt) /*--------------------------------------------------------------------*/ int -VSC_Arg(struct vsm *vd, char arg, const char *opt) +VSC_Arg(struct vsc *vsc, char arg, const char *opt) { + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + switch (arg) { - case 'f': return (vsc_f_arg(vd, opt)); + case 'f': return (vsc_f_arg(vsc, opt)); case 'n': case 't': - return (VSM_Arg(vd, arg, opt)); + return (VSM_Arg(vsc->vsm, arg, opt)); default: return (0); } @@ -210,11 +208,11 @@ VSC_Arg(struct vsm *vd, char arg, const char *opt) */ static int -vsc_filter(struct vsm *vd, const char *nm) +vsc_filter(const struct vsc *vsc, const char *nm) { - struct vsc *vsc = vsc_setup(vd); struct vsc_sf *sf; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); VTAILQ_FOREACH(sf, &vsc->sf_list_exclude, list) if (!fnmatch(sf->pattern, nm, 0)) return (1); @@ -230,12 +228,13 @@ vsc_filter(struct vsm *vd, const char *nm) */ static int -vsc_iter_elem(struct vsm *vd, const struct vsm_fantom *fantom, +vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, const struct vjsn_val *vv, struct vsb *vsb, VSC_iter_f *func, void *priv) { struct VSC_point point; struct vjsn_val *vt; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); memset(&point, 0, sizeof point); vt = vjsn_child(vv, "name"); @@ -246,7 +245,7 @@ vsc_iter_elem(struct vsm *vd, const struct vsm_fantom *fantom, VSB_printf(vsb, "%s.%s", fantom->ident, vt->value); AZ(VSB_finish(vsb)); - if (vsc_filter(vd, VSB_data(vsb))) + if (vsc_filter(vsc, VSB_data(vsb))) return (0); point.name = VSB_data(vsb); @@ -315,7 +314,7 @@ vsc_iter_elem(struct vsm *vd, const struct vsm_fantom *fantom, } static int -vsc_iter_fantom(struct vsm *vd, const struct vsm_fantom *fantom, +vsc_iter_fantom(const struct vsc *vsc, const struct vsm_fantom *fantom, struct vsb *vsb, VSC_iter_f *func, void *priv) { int i = 0; @@ -324,6 +323,8 @@ vsc_iter_fantom(struct vsm *vd, const struct vsm_fantom *fantom, struct vjsn *vj; struct vjsn_val *vv, *vve; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + p = (char*)fantom->b + 8 + vbe64dec(fantom->b); assert (p < (char*)fantom->e); vj = vjsn_parse(p, &e); @@ -332,7 +333,7 @@ vsc_iter_fantom(struct vsm *vd, const struct vsm_fantom *fantom, vve = vjsn_child(vj->value, "elem"); AN(vve); VTAILQ_FOREACH(vv, &vve->children, list) { - i = vsc_iter_elem(vd, fantom, vv, vsb, func, priv); + i = vsc_iter_elem(vsc, fantom, vv, vsb, func, priv); if (i) break; } @@ -343,21 +344,21 @@ vsc_iter_fantom(struct vsm *vd, const struct vsm_fantom *fantom, /*-------------------------------------------------------------------- */ -int -VSC_Iter(struct vsm *vd, struct vsm_fantom *fantom, VSC_iter_f *func, - void *priv) +int __match_proto__() // We don't want vsc to be const +VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv) { struct vsm_fantom ifantom; uint64_t u; int i = 0; struct vsb *vsb; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); vsb = VSB_new_auto(); AN(vsb); - VSM_FOREACH(&ifantom, vd) { + VSM_FOREACH(&ifantom, vsc->vsm) { if (strcmp(ifantom.class, VSC_CLASS)) continue; - AZ(VSM_Map(vd, &ifantom)); + AZ(VSM_Map(vsc->vsm, &ifantom)); u = vbe64dec(ifantom.b); if (u == 0) { VRMB(); @@ -365,11 +366,12 @@ VSC_Iter(struct vsm *vd, struct vsm_fantom *fantom, VSC_iter_f *func, u = vbe64dec(ifantom.b); } assert(u > 0); - if (fantom != NULL) - *fantom = ifantom; - i = vsc_iter_fantom(vd, &ifantom, vsb, func, priv); - if (fantom == NULL) - AZ(VSM_Unmap(vd, &ifantom)); + i = vsc_iter_fantom(vsc, &ifantom, vsb, func, priv); + if (f != NULL) { + *f = ifantom; + } else { + AZ(VSM_Unmap(vsc->vsm, &ifantom)); + } if (i) break; } diff --git a/lib/libvarnishapi/vsc_priv.h b/lib/libvarnishapi/vsc_priv.h deleted file mode 100644 index 48e24c6..0000000 --- a/lib/libvarnishapi/vsc_priv.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2015 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. - * - */ - -struct vsc; -struct vsm; - -void VSM_SetVSC(struct vsm *, struct vsc *); -struct vsc *VSM_GetVSC(const struct vsm *); -void VSC_Delete(struct vsc *); diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index bbdc8ab..96c171b 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -52,7 +52,6 @@ #include "vin.h" #include "vsb.h" #include "vsm_priv.h" -#include "vsc_priv.h" #include "vqueue.h" #include "vtim.h" @@ -115,7 +114,6 @@ struct vsm { struct stat dst; char *dname; - struct vsc *vsc; struct vsm_set *mgt; struct vsm_set *child; @@ -239,8 +237,6 @@ VSM_Destroy(struct vsm **vdp) TAKE_OBJ_NOTNULL(vd, vdp, VSM_MAGIC); - if (vd->vsc != NULL) - VSC_Delete(vd->vsc); VSM_ResetError(vd); free(vd->dname); vsm_delset(&vd->mgt); @@ -252,24 +248,6 @@ VSM_Destroy(struct vsm **vdp) /*--------------------------------------------------------------------*/ -void -VSM_SetVSC(struct vsm *vd, struct vsc *vsc) -{ - CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - - vd->vsc = vsc; -} - -struct vsc * -VSM_GetVSC(const struct vsm *vd) -{ - CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - - return (vd->vsc); -} - -/*--------------------------------------------------------------------*/ - const char * VSM_Error(const struct vsm *vd) { From hermunn at varnish-software.com Thu Sep 7 08:35:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 08:35:05 +0000 (UTC) Subject: [5.2] f679045 Whitespace OCD Message-ID: <20170907083505.B05BA92895@lists.varnish-cache.org> commit f6790459151f8ac7604698ffd6f569b9b0ac211d Author: Poul-Henning Kamp Date: Wed Sep 6 21:01:00 2017 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/m00038.vtc b/bin/varnishtest/tests/m00038.vtc index f69bd58..894618d 100644 --- a/bin/varnishtest/tests/m00038.vtc +++ b/bin/varnishtest/tests/m00038.vtc @@ -45,11 +45,11 @@ varnish v1 -vcl { set resp.http.b64decall = blob.encode(HEXLC, blob.decode_n(128, BASE64, - req.http.all)); + req.http.all)); set resp.http.urldechobbes = blob.encode(IDENTITY, blob.decode_n(180, BASE64URL, - req.http.hobbes)); + req.http.hobbes)); set resp.http.urldecall = blob.encode(HEXLC, @@ -76,7 +76,7 @@ varnish v1 -vcl { set resp.http.emptypieces = blob.encode(IDENTITY, blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset - + "" + req.http.unset + "")); + + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index 77fb240..8048ccf 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -150,7 +150,7 @@ varnish v1 -vcl { set resp.http.decemptypieces = blob.encode(IDENTITY, blob.decode(URL, req.http.unset + "" - + req.http.unset + "")); + + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = @@ -235,11 +235,11 @@ varnish v1 -vcl+backend { } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URLUC, - blob.decode(URL, "%2")); + blob.decode(URL, "%2")); } elsif (req.url == "/percent-q") { set resp.http.bad = blob.encode(URLUC, - blob.decode(URL, "%q")); + blob.decode(URL, "%q")); } elsif (req.url == "/percent-two-q") { set resp.http.bad = blob.encode(URLUC, diff --git a/bin/varnishtest/tests/m00040.vtc b/bin/varnishtest/tests/m00040.vtc index 0ec8842..b3c87b3 100644 --- a/bin/varnishtest/tests/m00040.vtc +++ b/bin/varnishtest/tests/m00040.vtc @@ -82,13 +82,13 @@ varnish v1 -vcl { set resp.http.decemptypieces = blob.encode(IDENTITY, blob.decode_n(1, URL, req.http.unset + "" - + req.http.unset + "")); + + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob.decode_n(6, URL, req.http.part1 + - "20bar%20baz%20quux")); + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = @@ -150,19 +150,19 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { set resp.http.bad = blob.encode(URLUC, - blob.decode_n(1, URL, "%20")); + blob.decode_n(1, URL, "%20")); } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URLUC, - blob.decode_n(2, URL, "%20")); + blob.decode_n(2, URL, "%20")); } elsif (req.url == "/comma") { set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%2c%q")); + blob.decode_n(3, URL, "%2c%q")); } elsif (req.url == "/colon") { set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%3a%2q")); + blob.decode_n(3, URL, "%3a%2q")); } } } diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index 811d814..c350ee1 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -346,12 +346,12 @@ varnish v1 -vcl+backend { elsif (req.url == "/6") { set resp.http.bad = blob.transcode(BASE64URL, BASE64URL, - "/+/+" + req.http.foo); + "/+/+" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad = blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, - "Zm9v" + req.http.foo); + "Zm9v" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index 164846a..37ed285 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -333,38 +333,38 @@ varnish v1 -vcl+backend { elsif (req.url == "/3") { set resp.http.bad = blob.transcode_n(8, HEX, IDENTITY, - "0x123456"); + "0x123456"); } elsif (req.url == "/4") { set resp.http.bad = blob.transcode_n(4, BASE64, IDENTITY, - "-_-_" + req.http.foo); + "-_-_" + req.http.foo); } elsif (req.url == "/5") { set resp.http.bad = blob.transcode_n(4, BASE64URL, IDENTITY, - "+/+/" + req.http.foo); + "+/+/" + req.http.foo); } elsif (req.url == "/6") { set resp.http.bad = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, - "TWFu" + req.http.foo); + "TWFu" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad = blob.transcode_n(4, BASE64, BASE64, - "_-_-" + req.http.foo); + "_-_-" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad = blob.transcode_n(4, BASE64URL, BASE64URL, - "/+/+" + req.http.foo); + "/+/+" + req.http.foo); } elsif (req.url == "/9") { set resp.http.bad = blob.transcode_n(8, BASE64URLNOPAD, - BASE64URLNOPAD, - "Zm9v" + req.http.foo); + BASE64URLNOPAD, + "Zm9v" + req.http.foo); } elsif (req.url == "/10") { set resp.http.bad From hermunn at varnish-software.com Thu Sep 7 08:35:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 08:35:05 +0000 (UTC) Subject: [5.2] 0174442 Don't fail at jailing if vcache user does not exist Message-ID: <20170907083505.CB6D39289B@lists.varnish-cache.org> commit 0174442d7398e01cb1bd1f5ce611ca3ce442313b Author: Poul-Henning Kamp Date: Thu Sep 7 07:55:59 2017 +0000 Don't fail at jailing if vcache user does not exist Fixes #2417 diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index 6513f44..d39a3d6 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -167,8 +167,10 @@ vju_init(char **args) vju_mgr_gid = getgid(); - if (vju_wrkuser == NULL) - (void)vju_getwrkuid(VCACHE_USER); + if (vju_wrkuser == NULL && vju_getwrkuid(VCACHE_USER)) { + vju_wrkuid = vju_uid; + vju_wrkgid = vju_gid; + } if (vju_wrkuser != NULL && vju_wrkgid != vju_gid) ARGV_ERR("Unix jail: user %s and %s have " @@ -257,7 +259,7 @@ vju_vsm_dir(int fd) /* Called under JAIL_MASTER_FILE */ AZ(fchmod(fd, 0750)); - AZ(fchown(fd, vju_wrkuid, vju_gid)); + AZ(fchown(fd, vju_wrkuid, vju_wrkgid)); } static void __match_proto__(jail_fixfile_f) From hermunn at varnish-software.com Thu Sep 7 09:07:04 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 7 Sep 2017 09:07:04 +0000 (UTC) Subject: [5.2] 92d0080 Prepare for 5.2.0-rc1 release Message-ID: <20170907090704.3877E9272E@lists.varnish-cache.org> commit 92d0080ec66e03f66a985fdedd76f27b1e0a505d Author: P?l Hermunn Johansen Date: Thu Sep 7 11:05:58 2017 +0200 Prepare for 5.2.0-rc1 release diff --git a/configure.ac b/configure.ac index 09fefa5..751af53 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2017 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [5.2.0-rc1], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [5.2.0-rc2], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) From phk at FreeBSD.org Thu Sep 7 09:44:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 09:44:05 +0000 (UTC) Subject: [master] 1f8d76c Remove unneeded #include Message-ID: <20170907094405.393999248D@lists.varnish-cache.org> commit 1f8d76c15457eafcf2861446d58cc26401d9a48b Author: Poul-Henning Kamp Date: Thu Sep 7 09:16:48 2017 +0000 Remove unneeded #include diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index cbbeb47..3d5a3ae 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -33,7 +33,6 @@ #endif #define COMMON_COMMON_H -#include #include #include From phk at FreeBSD.org Thu Sep 7 09:44:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 09:44:05 +0000 (UTC) Subject: [master] 344b83c Make VSC not own the VSM it operates on. Message-ID: <20170907094405.5425E92490@lists.varnish-cache.org> commit 344b83c7e7e32e85dfc45632f94c9a46d38d8999 Author: Poul-Henning Kamp Date: Thu Sep 7 09:38:54 2017 +0000 Make VSC not own the VSM it operates on. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 1f24b25..88d2c66 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -74,7 +74,7 @@ do_xml_cb(void *priv, const struct VSC_point * const pt) } static void -do_xml(struct vsc *vsc) +do_xml(struct vsm *vsm, struct vsc *vsc) { char time_stamp[20]; time_t now; @@ -83,7 +83,7 @@ do_xml(struct vsc *vsc) now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf("\n", time_stamp); - (void)VSC_Iter(vsc, NULL, do_xml_cb, NULL); + (void)VSC_Iter(vsc, vsm, NULL, do_xml_cb, NULL); printf("\n"); } @@ -124,7 +124,7 @@ do_json_cb(void *priv, const struct VSC_point * const pt) } static void -do_json(struct vsc *vsc) +do_json(struct vsm *vsm, struct vsc *vsc) { char time_stamp[20]; time_t now; @@ -137,7 +137,7 @@ do_json(struct vsc *vsc) (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf(" \"timestamp\": \"%s\",\n", time_stamp); - (void)VSC_Iter(vsc, NULL, do_json_cb, &jp); + (void)VSC_Iter(vsc, vsm, NULL, do_json_cb, &jp); printf("\n}\n"); } @@ -194,15 +194,15 @@ do_once_cb(void *priv, const struct VSC_point * const pt) } static void -do_once(struct vsc *vsc) +do_once(struct vsm *vsm, struct vsc *vsc) { struct once_priv op; memset(&op, 0, sizeof op); op.pad = 18; - (void)VSC_Iter(vsc, NULL, do_once_cb_first, &op); - (void)VSC_Iter(vsc, NULL, do_once_cb, &op); + (void)VSC_Iter(vsc, vsm, NULL, do_once_cb_first, &op); + (void)VSC_Iter(vsc, vsm, NULL, do_once_cb, &op); } /*--------------------------------------------------------------------*/ @@ -226,13 +226,13 @@ do_list_cb(void *priv, const struct VSC_point * const pt) } static void -list_fields(struct vsc *vsc) +list_fields(struct vsm *vsm, struct vsc *vsc) { printf("Varnishstat -f option fields:\n"); printf("Field name Description\n"); printf("---------- -----------\n"); - (void)VSC_Iter(vsc, NULL, do_list_cb, NULL); + (void)VSC_Iter(vsc, vsm, NULL, do_list_cb, NULL); } /*--------------------------------------------------------------------*/ @@ -261,7 +261,7 @@ main(int argc, char * const *argv) VUT_Init(progname, argc, argv, &vopt_spec); vd = VSM_New(); AN(vd); - vsc = VSC_New(vd); + vsc = VSC_New(); AN(vsc); while ((opt = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { @@ -284,8 +284,11 @@ main(int argc, char * const *argv) case 'j': json = 1; break; + case 'f': + AN(VSC_Arg(vsc, opt, optarg)); + break; default: - i = VSC_Arg(vsc, opt, optarg); + i = VSM_Arg(vd, opt, optarg); if (i < 0) VUT_Error(1, "%s", VSM_Error(vd)); if (!i) @@ -305,13 +308,13 @@ main(int argc, char * const *argv) if (curses) do_curses(vd, vsc, 1.0); else if (xml) - do_xml(vsc); + do_xml(vd, vsc); else if (json) - do_json(vsc); + do_json(vd, vsc); else if (once) - do_once(vsc); + do_once(vd, vsc); else if (f_list) - list_fields(vsc); + list_fields(vd, vsc); else assert(0); diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 104af2b..f2e34bd 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -313,7 +313,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) } static void -build_pt_list(struct vsc *vsc, struct vsm_fantom *fantom) +build_pt_list(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *fantom) { struct pt_priv pt_priv; int i; @@ -334,7 +334,7 @@ build_pt_list(struct vsc *vsc, struct vsm_fantom *fantom) main_cache_hit = NULL; main_cache_miss = NULL; - (void)VSC_Iter(vsc, fantom, build_pt_list_cb, &pt_priv); + (void)VSC_Iter(vsc, vsm, fantom, build_pt_list_cb, &pt_priv); delete_pt_list(); AN(VTAILQ_EMPTY(&ptlist)); AZ(n_ptlist); @@ -1073,7 +1073,7 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED))) { init_hitrate(); delete_pt_list(); - build_pt_list(vsc, &f_iter); + build_pt_list(vsc, vd, &f_iter); initial = 0; } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 45218bc..e81c054 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -523,13 +523,13 @@ varnish_launch(struct varnish *v) v->vsm_vsc = VSM_New(); AN(v->vsm_vsc); - v->vsc = VSC_New(v->vsm_vsc); + v->vsc = VSC_New(); AN(v->vsc); - (void)VSC_Arg(v->vsc, 'n', v->workdir); + assert(VSM_Arg(v->vsm_vsc, 'n', v->workdir) > 0); AZ(VSM_Attach(v->vsm_vsc, -1)); v->vsm_vsl = VSM_New(); - (void)VSM_Arg(v->vsm_vsl, 'n', v->workdir); + assert(VSM_Arg(v->vsm_vsl, 'n', v->workdir) > 0); AZ(VSM_Attach(v->vsm_vsl, -1)); AZ(pthread_create(&v->tp_vsl, NULL, varnishlog_thread, v)); @@ -850,7 +850,7 @@ varnish_vsc(const struct varnish *v, const char *arg) dp.arg = arg; (void)VSM_Status(v->vsm_vsc); - (void)VSC_Iter(v->vsc, NULL, do_stat_dump_cb, &dp); + (void)VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_stat_dump_cb, &dp); } /********************************************************************** @@ -916,7 +916,7 @@ varnish_expect(const struct varnish *v, char * const *av) for (i = 0; i < 50; i++, (void)usleep(100000)) { (void)VSM_Status(v->vsm_vsc); - good = VSC_Iter(v->vsc, NULL, do_expect_cb, &sp); + good = VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_expect_cb, &sp); if (!good) { good = -2; continue; diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 97c85e1..986259b 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -45,7 +45,7 @@ struct vsm_fantom; * VSC level access functions */ -struct vsc *VSC_New(struct vsm *); +struct vsc *VSC_New(void); void VSC_Destroy(struct vsc **); int VSC_Arg(struct vsc *, char arg, const char *opt); @@ -84,7 +84,8 @@ void VSC_Destroy_Point(struct VSC_point **); typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt); -int VSC_Iter(struct vsc *, struct vsm_fantom *, VSC_iter_f *func, void *priv); +int VSC_Iter(struct vsc *, struct vsm *, struct vsm_fantom *, + VSC_iter_f *func, void *priv); /* * Iterate over all statistics counters, calling "func" for * each counter not suppressed by any "-f" arguments. diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index de998cf..47a5ccd 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -63,7 +63,6 @@ struct vsc { unsigned magic; #define VSC_MAGIC 0x3373554a - struct vsm *vsm; struct vsc_sf_head sf_list_include; struct vsc_sf_head sf_list_exclude; }; @@ -116,15 +115,13 @@ VSC_Destroy_Point(struct VSC_point **p) /*--------------------------------------------------------------------*/ struct vsc * -VSC_New(struct vsm *vsm) +VSC_New(void) { struct vsc *vsc; - AN(vsm); ALLOC_OBJ(vsc, VSC_MAGIC); if (vsc == NULL) return (vsc); - vsc->vsm = vsm; VTAILQ_INIT(&vsc->sf_list_include); VTAILQ_INIT(&vsc->sf_list_exclude); return (vsc); @@ -196,11 +193,7 @@ VSC_Arg(struct vsc *vsc, char arg, const char *opt) switch (arg) { case 'f': return (vsc_f_arg(vsc, opt)); - case 'n': - case 't': - return (VSM_Arg(vsc->vsm, arg, opt)); - default: - return (0); + default: return (0); } } @@ -345,7 +338,8 @@ vsc_iter_fantom(const struct vsc *vsc, const struct vsm_fantom *fantom, */ int __match_proto__() // We don't want vsc to be const -VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv) +VSC_Iter(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *f, + VSC_iter_f *func, void *priv) { struct vsm_fantom ifantom; uint64_t u; @@ -353,12 +347,13 @@ VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv) struct vsb *vsb; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + AN(vsm); vsb = VSB_new_auto(); AN(vsb); - VSM_FOREACH(&ifantom, vsc->vsm) { + VSM_FOREACH(&ifantom, vsm) { if (strcmp(ifantom.class, VSC_CLASS)) continue; - AZ(VSM_Map(vsc->vsm, &ifantom)); + AZ(VSM_Map(vsm, &ifantom)); u = vbe64dec(ifantom.b); if (u == 0) { VRMB(); @@ -370,7 +365,7 @@ VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv) if (f != NULL) { *f = ifantom; } else { - AZ(VSM_Unmap(vsc->vsm, &ifantom)); + AZ(VSM_Unmap(vsm, &ifantom)); } if (i) break; From phk at FreeBSD.org Thu Sep 7 09:47:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 09:47:04 +0000 (UTC) Subject: [master] 35a2193 No quoting needed. Message-ID: <20170907094704.4687C927EC@lists.varnish-cache.org> commit 35a21932d8974b798e1f24d2968e34891f0794da Author: Poul-Henning Kamp Date: Thu Sep 7 09:45:51 2017 +0000 No quoting needed. diff --git a/bin/varnishd/flint.sh b/bin/varnishd/flint.sh index 569fbbe..1de11ce 100755 --- a/bin/varnishd/flint.sh +++ b/bin/varnishd/flint.sh @@ -3,9 +3,9 @@ FLOPS=' -I../../lib/libvgz -DVARNISHD_IS_NOT_A_VMOD - -DVARNISH_STATE_DIR=\"foo\" - -DVARNISH_VMOD_DIR=\"foo\" - -DVARNISH_VCL_DIR=\"foo\" + -DVARNISH_STATE_DIR="foo" + -DVARNISH_VMOD_DIR="foo" + -DVARNISH_VCL_DIR="foo" cache/*.c common/*.c hash/*.c From phk at FreeBSD.org Thu Sep 7 10:06:03 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 10:06:03 +0000 (UTC) Subject: [master] 9f281a2 Yeah, so I forgot: <> includes in .h files is still a bad idea. Message-ID: <20170907100603.8965992F7B@lists.varnish-cache.org> commit 9f281a25b9d063228c0dfdc7e4ed4643d1e27755 Author: Poul-Henning Kamp Date: Thu Sep 7 10:04:33 2017 +0000 Yeah, so I forgot: <> includes in .h files is still a bad idea. diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 766201e..8695803 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -33,8 +33,6 @@ #endif #define MGT_MGT_H -#include - #include "common/common.h" #include "common/com_params.h" diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index 9284bd0..fa40577 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 907df0d..41456fd 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index f6aa212..d982511 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c index 3b7df19..ea5fff2 100644 --- a/bin/varnishd/mgt/mgt_jail.c +++ b/bin/varnishd/mgt/mgt_jail.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index d39a3d6..f4097d0 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index ac35a7e..74bec16 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 7615228..bba58b3 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 431e937..2bd7bb9 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -29,6 +29,8 @@ #include "config.h" +#include + #include "mgt/mgt.h" #include "mgt/mgt_param.h" diff --git a/bin/varnishd/mgt/mgt_param_tcp.c b/bin/varnishd/mgt/mgt_param_tcp.c index 1519d9d..70ababc 100644 --- a/bin/varnishd/mgt/mgt_param_tcp.c +++ b/bin/varnishd/mgt/mgt_param_tcp.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 49b9b5e..14bceac 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -42,6 +42,8 @@ #include "config.h" +#include + #include "mgt/mgt.h" #include "mgt/mgt_param.h" diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index fdd1d53..d5d5193 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_util.c b/bin/varnishd/mgt/mgt_util.c index 2431532..de31fda 100644 --- a/bin/varnishd/mgt/mgt_util.c +++ b/bin/varnishd/mgt/mgt_util.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 83887c2..641131a 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index afe8532..f8579c0 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index 4d04728..c4b0285 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -33,6 +33,7 @@ #include "config.h" +#include #include #include #include diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index d6ea9a4..5ee2ada 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include From phk at FreeBSD.org Thu Sep 7 10:13:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 10:13:04 +0000 (UTC) Subject: [master] 8d4b1ec Spell __FreeBSD_version correctly Message-ID: <20170907101304.87B2E9229F@lists.varnish-cache.org> commit 8d4b1eca3f66c883cf3f989571f44b8f7adca40d Author: Poul-Henning Kamp Date: Thu Sep 7 10:12:37 2017 +0000 Spell __FreeBSD_version correctly diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index d6c8921..3624c28 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -191,7 +191,7 @@ static struct cli_proto debug_cmds[] = { * XXX: Think more about which order we start things */ -#if defined(__FreeBSD__) && __FreeBSD__version >= 1000000 +#if defined(__FreeBSD__) && __FreeBSD_version >= 1000000 static void child_malloc_fail(void *p, const char *s) { @@ -208,7 +208,7 @@ child_main(void) setbuf(stdout, NULL); setbuf(stderr, NULL); printf("Child starts\n"); -#if defined(__FreeBSD__) && __FreeBSD__version >= 1000000 +#if defined(__FreeBSD__) && __FreeBSD_version >= 1000000 malloc_message = child_malloc_fail; #endif From phk at FreeBSD.org Thu Sep 7 10:54:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 10:54:05 +0000 (UTC) Subject: [master] cbff1d8 Argument constification polishing Message-ID: <20170907105405.647BE92201@lists.varnish-cache.org> commit cbff1d80f45623d7156cf0abdda7ff66c3986902 Author: Poul-Henning Kamp Date: Thu Sep 7 10:52:41 2017 +0000 Argument constification polishing Helped by: PC-Lint-Plus-RC2 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 3f517e4..e3bc4d4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -849,7 +849,7 @@ void Lck_DestroyClass(struct VSC_lck **vsclck); #include "tbl/locks.h" /* cache_mempool.c */ -void MPL_AssertSane(void *item); +void MPL_AssertSane(const void *item); struct mempool * MPL_New(const char *name, volatile struct poolparam *pp, volatile unsigned *cur_size); void MPL_Destroy(struct mempool **mpp); diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index f86f648..91f5c08 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -517,7 +517,7 @@ VCA_DestroyPool(struct pool *pp) /*--------------------------------------------------------------------*/ -static void * +static void * __match_proto__() vca_acct(void *arg) { struct listen_sock *ls; @@ -573,7 +573,7 @@ vca_acct(void *arg) /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) ccf_start(struct cli *cli, const char * const *av, void *priv) { @@ -586,7 +586,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) ccf_listen_address(struct cli *cli, const char * const *av, void *priv) { struct listen_sock *ls; diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 1ec9ef5..64154f4 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -366,7 +366,7 @@ do_list(struct cli *cli, struct backend *b, void *priv) return (0); } -static void +static void __match_proto__(cli_func_t) cli_backend_list(struct cli *cli, const char * const *av, void *priv) { int probes = 0; @@ -412,7 +412,7 @@ do_set_health(struct cli *cli, struct backend *b, void *priv) return (0); } -static void +static void __match_proto__() cli_backend_set_health(struct cli *cli, const char * const *av, void *priv) { const char *ah; diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 55932e8..39cb394 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -616,7 +616,7 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) * CLI functions to add bans */ -static void +static void __match_proto__(cli_func_t) ccf_ban(struct cli *cli, const char * const *av, void *priv) { int narg, i; @@ -705,7 +705,7 @@ ban_render(struct cli *cli, const uint8_t *bs) } } -static void +static void __match_proto__(cli_func_t) ccf_ban_list(struct cli *cli, const char * const *av, void *priv) { struct ban *b, *bl; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index afa8959..9a2af88 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -223,7 +223,7 @@ VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp, int top) * Debugging aids */ -static void +static void __match_proto__(cli_func_t) debug_fragfetch(struct cli *cli, const char * const *av, void *priv) { (void)priv; diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 3624c28..8602fcf 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -154,7 +154,7 @@ VXID_Get(struct worker *wrk, uint32_t mask) * Dumb down the VXID allocation to make it predictable for * varnishtest cases */ -static void +static void __match_proto__(cli_func_t) cli_debug_xid(struct cli *cli, const char * const *av, void *priv) { (void)priv; diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 45197e8..98c22f0 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -337,7 +337,7 @@ MPL_Free(struct mempool *mpl, void *item) } void -MPL_AssertSane(void *item) +MPL_AssertSane(const void *item) { struct memitem *mi; mi = (void*)((uintptr_t)item - sizeof(*mi)); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 03b3911..0bf34f2 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -178,7 +178,7 @@ pool_mkpool(unsigned pool_no) * NB: be maintained for params which require action. */ -static void * +static void * __match_proto__() pool_poolherder(void *priv) { unsigned nwq; diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index 719df9f..cb73247 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -202,7 +202,7 @@ VMOD_Panic(struct vsb *vsb) /*---------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) ccf_debug_vmod(struct cli *cli, const char * const *av, void *priv) { struct vmod *v; diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index f29a815..b84eee1 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -128,7 +128,7 @@ hcb_is_y(uintptr_t u) } static uintptr_t -hcb_r_node(struct objhead *n) +hcb_r_node(const struct objhead *n) { AZ((uintptr_t)n & (HCB_BIT_NODE | HCB_BIT_Y)); @@ -145,7 +145,7 @@ hcb_l_node(uintptr_t u) } static uintptr_t -hcb_r_y(struct hcb_y *y) +hcb_r_y(const struct hcb_y *y) { CHECK_OBJ_NOTNULL(y, HCB_Y_MAGIC); @@ -273,7 +273,7 @@ hcb_insert(struct worker *wrk, struct hcb_root *root, const uint8_t *digest, /*--------------------------------------------------------------------*/ static void -hcb_delete(struct hcb_root *r, struct objhead *oh) +hcb_delete(struct hcb_root *r, const struct objhead *oh) { struct hcb_y *y; volatile uintptr_t *p; diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 41456fd..125cc31 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -209,7 +209,7 @@ MCH_Fd_Inherit(int fd, const char *what) * Listen to stdout+stderr from the child */ -static int +static int __match_proto__(vlu_f) child_line(void *priv, const char *p) { (void)priv; @@ -686,7 +686,7 @@ mch_cli_server_stop(struct cli *cli, const char * const *av, void *priv) } } -static void +static void __match_proto__(cli_func_t) mch_cli_server_status(struct cli *cli, const char * const *av, void *priv) { (void)av; diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index d982511..e845c63 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -69,7 +69,7 @@ static const char *secret_file; /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) mcf_banner(struct cli *cli, const char *const *av, void *priv) { @@ -97,7 +97,7 @@ static struct cli_proto cli_proto[] = { /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) mcf_panic(struct cli *cli, const char * const *av, void *priv) { @@ -114,7 +114,7 @@ static struct cli_proto cli_debug[] = { /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) mcf_askchild(struct cli *cli, const char * const *av, void *priv) { int i; @@ -596,7 +596,7 @@ static double M_poll = 0.1; static VTAILQ_HEAD(,m_addr) m_addr_list = VTAILQ_HEAD_INITIALIZER(m_addr_list); -static void +static void __match_proto__(mgt_cli_close_f) Marg_closer(void *priv) { diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 74bec16..53db1ee 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -173,7 +173,7 @@ cli_check(const struct cli *cli) * This function is called when the CLI on stdin is closed. */ -static void +static void __match_proto__(mgt_cli_close_f) mgt_stdin_close(void *priv) { @@ -423,7 +423,7 @@ mgt_uptime(const struct vev *e, int what) /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(mgt_cli_close_f) mgt_I_close(void *priv) { (void)priv; diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index c4b0285..b1d0288 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -88,7 +88,7 @@ static struct cli_proto cli_stv[] = { /*-------------------------------------------------------------------- */ -static void +static void __match_proto__(storage_init_f) smp_fake_init(struct stevedore *parent, int ac, char * const *av) { diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index b4283f3..6c4d79e 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -72,7 +72,7 @@ static VTAILQ_HEAD(,smp_sc) silos = VTAILQ_HEAD_INITIALIZER(silos); */ static int -smp_appendban(struct smp_sc *sc, struct smp_signspace *spc, +smp_appendban(const struct smp_sc *sc, struct smp_signspace *spc, uint32_t len, const uint8_t *ban) { @@ -135,7 +135,7 @@ smp_banexport(const struct stevedore *stv, const uint8_t *bans, unsigned len) */ static int -smp_open_bans(struct smp_sc *sc, struct smp_signspace *spc) +smp_open_bans(const struct smp_sc *sc, struct smp_signspace *spc) { uint8_t *ptr, *pe; int i; @@ -630,7 +630,7 @@ debug_report_silo(struct cli *cli, const struct smp_sc *sc) } } -static void +static void __match_proto__(cli_func_t) debug_persistent(struct cli *cli, const char * const * av, void *priv) { struct smp_sc *sc; From phk at FreeBSD.org Thu Sep 7 10:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 10:59:05 +0000 (UTC) Subject: [master] f20f1d2 Add necessary include Message-ID: <20170907105905.0D18592586@lists.varnish-cache.org> commit f20f1d21cff3805fab2cac46500f88849144e6cd Author: Poul-Henning Kamp Date: Thu Sep 7 10:58:14 2017 +0000 Add necessary include diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c index eb40edf..bc8dabf 100644 --- a/bin/varnishd/common/common_vsc.c +++ b/bin/varnishd/common/common_vsc.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include #include From phk at FreeBSD.org Thu Sep 7 11:06:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 11:06:04 +0000 (UTC) Subject: [master] 53d312c Add necessary include Message-ID: <20170907110604.45A3F9294F@lists.varnish-cache.org> commit 53d312c455336444dbcc2e638ca4f52b3fbc927d Author: Poul-Henning Kamp Date: Thu Sep 7 11:05:03 2017 +0000 Add necessary include diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 125cc31..ebcaba5 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include From phk at FreeBSD.org Thu Sep 7 11:17:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 11:17:04 +0000 (UTC) Subject: [master] 451cf83 Remove old debug code Message-ID: <20170907111704.6771E92E94@lists.varnish-cache.org> commit 451cf83c34ba27dda892bd042d5b11ddeaa55de2 Author: Poul-Henning Kamp Date: Thu Sep 7 11:14:23 2017 +0000 Remove old debug code diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 4b3ffc4..ee70140 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -178,7 +178,6 @@ vwp_main(void *priv) if (vwp->pollfd[0].revents) v--; for (i = 1; i < vwp->hpoll;) { -VSL(SLT_Debug, vwp->pollfd[i].fd, "POLL loop i=%d revents=0x%x", i, vwp->pollfd[i].revents); assert(vwp->pollfd[i].fd != vwp->pipes[0]); wp = vwp->idx[i]; CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); From phk at FreeBSD.org Thu Sep 7 11:17:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 11:17:04 +0000 (UTC) Subject: [master] d1af7ce Add necessary #include Message-ID: <20170907111704.83A8492E97@lists.varnish-cache.org> commit d1af7ce114e2b719fd1fb2e2e5bfcc832f52f7fb Author: Poul-Henning Kamp Date: Thu Sep 7 11:16:23 2017 +0000 Add necessary #include diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index d5d5193..2b9741e 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include From phk at FreeBSD.org Thu Sep 7 19:57:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 19:57:06 +0000 (UTC) Subject: [master] 3d5241e decorate with prototypes Message-ID: <20170907195706.7B72C929EB@lists.varnish-cache.org> commit 3d5241e45d6be2c5f6d7fb39d6912e62f5dfb971 Author: Poul-Henning Kamp Date: Thu Sep 7 12:34:36 2017 +0000 decorate with prototypes diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 88d2c66..7138ba4 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -52,7 +52,7 @@ static const char progname[] = "varnishstat"; /*--------------------------------------------------------------------*/ -static int +static int __match_proto__(VSC_iter_f) do_xml_cb(void *priv, const struct VSC_point * const pt) { uint64_t val; @@ -90,7 +90,7 @@ do_xml(struct vsm *vsm, struct vsc *vsc) /*--------------------------------------------------------------------*/ -static int +static int __match_proto__(VSC_iter_f) do_json_cb(void *priv, const struct VSC_point * const pt) { uint64_t val; @@ -149,7 +149,7 @@ struct once_priv { int pad; }; -static int +static int __match_proto__(VSC_iter_f) do_once_cb_first(void *priv, const struct VSC_point * const pt) { struct once_priv *op; @@ -166,7 +166,7 @@ do_once_cb_first(void *priv, const struct VSC_point * const pt) return (1); } -static int +static int __match_proto__(VSC_iter_f) do_once_cb(void *priv, const struct VSC_point * const pt) { struct once_priv *op; @@ -207,7 +207,7 @@ do_once(struct vsm *vsm, struct vsc *vsc) /*--------------------------------------------------------------------*/ -static int +static int __match_proto__(VSC_iter_f) do_list_cb(void *priv, const struct VSC_point * const pt) { int i; diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index f2e34bd..e61d2f7 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -255,7 +255,7 @@ struct pt_priv { unsigned n_ptlist; }; -static int +static int __match_proto__(VSC_iter_f) build_pt_list_cb(void *priv, const struct VSC_point *vpt) { struct pt_priv *pt_priv; From phk at FreeBSD.org Thu Sep 7 19:57:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 19:57:06 +0000 (UTC) Subject: [master] 2aeca56 First part of VSC API rework to capitalize on VSM improvements. Message-ID: <20170907195706.939DB929EF@lists.varnish-cache.org> commit 2aeca565355fe148edd21e42bb32fc43e371b1d8 Author: Poul-Henning Kamp Date: Thu Sep 7 19:56:17 2017 +0000 First part of VSC API rework to capitalize on VSM improvements. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 7138ba4..c622cc7 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -42,8 +42,6 @@ #include "vapi/voptget.h" #include "vapi/vsl.h" #include "vdef.h" -#include "vnum.h" -#include "vtim.h" #include "vut.h" #include "varnishstat.h" @@ -83,7 +81,7 @@ do_xml(struct vsm *vsm, struct vsc *vsc) now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf("\n", time_stamp); - (void)VSC_Iter(vsc, vsm, NULL, do_xml_cb, NULL); + (void)VSC_Iter(vsc, vsm, NULL, do_xml_cb, NULL, NULL); printf("\n"); } @@ -137,7 +135,7 @@ do_json(struct vsm *vsm, struct vsc *vsc) (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf(" \"timestamp\": \"%s\",\n", time_stamp); - (void)VSC_Iter(vsc, vsm, NULL, do_json_cb, &jp); + (void)VSC_Iter(vsc, vsm, NULL, do_json_cb, NULL, &jp); printf("\n}\n"); } @@ -201,8 +199,8 @@ do_once(struct vsm *vsm, struct vsc *vsc) memset(&op, 0, sizeof op); op.pad = 18; - (void)VSC_Iter(vsc, vsm, NULL, do_once_cb_first, &op); - (void)VSC_Iter(vsc, vsm, NULL, do_once_cb, &op); + (void)VSC_Iter(vsc, vsm, NULL, do_once_cb_first, NULL, &op); + (void)VSC_Iter(vsc, vsm, NULL, do_once_cb, NULL, &op); } /*--------------------------------------------------------------------*/ @@ -232,7 +230,7 @@ list_fields(struct vsm *vsm, struct vsc *vsc) printf("Field name Description\n"); printf("---------- -----------\n"); - (void)VSC_Iter(vsc, vsm, NULL, do_list_cb, NULL); + (void)VSC_Iter(vsc, vsm, NULL, do_list_cb, NULL, NULL); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index e61d2f7..fcc96ef 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -31,7 +31,6 @@ * Statistics output program */ - #include "config.h" #include @@ -313,7 +312,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) } static void -build_pt_list(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *fantom) +build_pt_list(struct vsc *vsc, struct vsm *vsm) { struct pt_priv pt_priv; int i; @@ -334,7 +333,7 @@ build_pt_list(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *fantom) main_cache_hit = NULL; main_cache_miss = NULL; - (void)VSC_Iter(vsc, vsm, fantom, build_pt_list_cb, &pt_priv); + (void)VSC_Iter(vsc, vsm, NULL, build_pt_list_cb, NULL, &pt_priv); delete_pt_list(); AN(VTAILQ_EMPTY(&ptlist)); AZ(n_ptlist); @@ -1050,7 +1049,6 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) long t; int ch, initial = 1; double now; - struct vsm_fantom f_iter = VSM_FANTOM_NULL; interval = delay; @@ -1073,7 +1071,7 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED))) { init_hitrate(); delete_pt_list(); - build_pt_list(vsc, vd, &f_iter); + build_pt_list(vsc, vd); initial = 0; } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index e81c054..d63b37e 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -849,8 +849,7 @@ varnish_vsc(const struct varnish *v, const char *arg) dp.v = v; dp.arg = arg; (void)VSM_Status(v->vsm_vsc); - - (void)VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_stat_dump_cb, &dp); + (void)VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_stat_dump_cb, NULL, &dp); } /********************************************************************** @@ -915,8 +914,8 @@ varnish_expect(const struct varnish *v, char * const *av) good = 0; for (i = 0; i < 50; i++, (void)usleep(100000)) { (void)VSM_Status(v->vsm_vsc); - - good = VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_expect_cb, &sp); + good = VSC_Iter(v->vsc, v->vsm_vsc, + NULL, do_expect_cb, NULL, &sp); if (!good) { good = -2; continue; diff --git a/flint.lnt b/flint.lnt index f77c78b..3fa3bf4 100644 --- a/flint.lnt +++ b/flint.lnt @@ -27,6 +27,7 @@ /////////////////////////////////////////////////////////////////////// // General stylistic issues +-e663 // Suspicious array to pointer conversion -e574 // Signed-unsigned mix with relational -e641 // Converting enum '...' to int -e716 // while(1) ... diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 986259b..6f747f7 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -82,10 +82,11 @@ struct VSC_point *VSC_Clone_Point(const struct VSC_point * const); void VSC_Destroy_Point(struct VSC_point **); +typedef void *VSC_new_f(void *priv, const struct VSC_point *const pt); typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt); +typedef int VSC_destroy_f(void *priv, const struct VSC_point *const pt); -int VSC_Iter(struct vsc *, struct vsm *, struct vsm_fantom *, - VSC_iter_f *func, void *priv); +int VSC_Iter(struct vsc *, struct vsm *, VSC_new_f *, VSC_iter_f *, VSC_destroy_f *, void *priv); /* * Iterate over all statistics counters, calling "func" for * each counter not suppressed by any "-f" arguments. diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index b5d1b00..b89c90c 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -195,4 +195,5 @@ LIBVARNISHAPI_1.7 { VSM_Dup; VSC_New; VSC_Destroy; + VSC_Iter2; } LIBVARNISHAPI_1.0; diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 47a5ccd..6ccbc9d 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -59,12 +59,28 @@ struct vsc_sf { }; VTAILQ_HEAD(vsc_sf_head, vsc_sf); +struct vsc_pt { + struct VSC_point point; + char *name; +}; + +struct vsc_seg { + unsigned magic; +#define VSC_SEG_MAGIC 0x801177d4 + VTAILQ_ENTRY(vsc_seg) list; + struct vsm_fantom fantom[1]; + struct vjsn *vj; + unsigned npoints; + struct vsc_pt *points; +}; + struct vsc { unsigned magic; #define VSC_MAGIC 0x3373554a struct vsc_sf_head sf_list_include; struct vsc_sf_head sf_list_exclude; + VTAILQ_HEAD(,vsc_seg) segs; }; /*-------------------------------------------------------------------- @@ -81,8 +97,7 @@ static const struct VSC_level_desc * const levels[] = { #undef VSC_LEVEL_F }; -static const size_t nlevels = - sizeof(levels)/sizeof(*levels); +static const size_t nlevels = sizeof(levels)/sizeof(*levels); /*--------------------------------------------------------------------*/ @@ -124,6 +139,7 @@ VSC_New(void) return (vsc); VTAILQ_INIT(&vsc->sf_list_include); VTAILQ_INIT(&vsc->sf_list_exclude); + VTAILQ_INIT(&vsc->segs); return (vsc); } @@ -220,15 +236,20 @@ vsc_filter(const struct vsc *vsc, const char *nm) /*-------------------------------------------------------------------- */ +static void +vsc_clean_point(struct vsc_pt *point) +{ + REPLACE(point->name, NULL); +} + static int -vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, - const struct vjsn_val *vv, struct vsb *vsb, VSC_iter_f *func, void *priv) +vsc_fill_point(const struct vsc *vsc, const struct vsm_fantom *fantom, + const struct vjsn_val *vv, struct vsb *vsb, struct vsc_pt *point) { - struct VSC_point point; struct vjsn_val *vt; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); - memset(&point, 0, sizeof point); + memset(point, 0, sizeof *point); vt = vjsn_child(vv, "name"); AN(vt); @@ -241,13 +262,15 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, if (vsc_filter(vsc, VSB_data(vsb))) return (0); - point.name = VSB_data(vsb); + point->name = strdup(VSB_data(vsb)); + AN(point->name); + point->point.name = point->name; #define DOF(n, k) \ vt = vjsn_child(vv, k); \ AN(vt); \ assert(vt->type == VJSN_STRING); \ - point.n = vt->value; + point->point.n = vt->value; DOF(ctype, "ctype"); DOF(sdesc, "oneliner"); @@ -258,13 +281,13 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, assert(vt->type == VJSN_STRING); if (!strcmp(vt->value, "counter")) { - point.semantics = 'c'; + point->point.semantics = 'c'; } else if (!strcmp(vt->value, "gauge")) { - point.semantics = 'g'; + point->point.semantics = 'g'; } else if (!strcmp(vt->value, "bitmap")) { - point.semantics = 'b'; + point->point.semantics = 'b'; } else { - point.semantics = '?'; + point->point.semantics = '?'; } vt = vjsn_child(vv, "format"); @@ -272,15 +295,15 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, assert(vt->type == VJSN_STRING); if (!strcmp(vt->value, "integer")) { - point.format = 'i'; + point->point.format = 'i'; } else if (!strcmp(vt->value, "bytes")) { - point.format = 'B'; + point->point.format = 'B'; } else if (!strcmp(vt->value, "bitmap")) { - point.format = 'b'; + point->point.format = 'b'; } else if (!strcmp(vt->value, "duration")) { - point.format = 'd'; + point->point.format = 'd'; } else { - point.format = '?'; + point->point.format = '?'; } vt = vjsn_child(vv, "level"); @@ -288,11 +311,11 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, assert(vt->type == VJSN_STRING); if (!strcmp(vt->value, "info")) { - point.level = &level_info; + point->point.level = &level_info; } else if (!strcmp(vt->value, "diag")) { - point.level = &level_diag; + point->point.level = &level_diag; } else if (!strcmp(vt->value, "debug")) { - point.level = &level_debug; + point->point.level = &level_debug; } else { WRONG("Illegal level"); } @@ -300,80 +323,131 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, vt = vjsn_child(vv, "index"); AN(vt); - point.ptr = (volatile void*) + point->point.ptr = (volatile void*) ((volatile char*)fantom->b + atoi(vt->value)); + return (1); +} + +static void +vsc_del_seg(struct vsm *vsm, struct vsc_seg *sp) +{ + unsigned u; - return (func(priv, &point)); + AN(vsm); + CHECK_OBJ_NOTNULL(sp, VSC_SEG_MAGIC); + AZ(VSM_Unmap(vsm, sp->fantom)); + vjsn_delete(&sp->vj); + for(u = 0; u < sp->npoints; u++) + vsc_clean_point(&sp->points[u]); + free(sp->points); + FREE_OBJ(sp); } -static int -vsc_iter_fantom(const struct vsc *vsc, const struct vsm_fantom *fantom, - struct vsb *vsb, VSC_iter_f *func, void *priv) +static struct vsc_seg * +vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp) { - int i = 0; + struct vsc_seg *sp; + uint64_t u; + unsigned j; const char *p; const char *e; - struct vjsn *vj; struct vjsn_val *vv, *vve; + struct vsb *vsb; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + AN(vsm); + + ALLOC_OBJ(sp, VSC_SEG_MAGIC); + AN(sp); + *sp->fantom = *fp; + AZ(VSM_Map(vsm, sp->fantom)); - p = (char*)fantom->b + 8 + vbe64dec(fantom->b); - assert (p < (char*)fantom->e); - vj = vjsn_parse(p, &e); + u = vbe64dec(sp->fantom->b); + if (u == 0) { + VRMB(); + usleep(100000); + u = vbe64dec(sp->fantom->b); + } + assert(u > 0); + p = (char*)sp->fantom->b + 8 + u; + assert (p < (char*)sp->fantom->e); + sp->vj = vjsn_parse(p, &e); XXXAZ(e); - AN(vj); - vve = vjsn_child(vj->value, "elem"); + vve = vjsn_child(sp->vj->value, "elements"); AN(vve); - VTAILQ_FOREACH(vv, &vve->children, list) { - i = vsc_iter_elem(vsc, fantom, vv, vsb, func, priv); - if (i) - break; + sp->npoints = strtoul(vve->value, NULL, 0); + sp->points = calloc(sp->npoints, sizeof *sp->points); + AN(sp->points); + vsb = VSB_new_auto(); + AN(vsb); + j = 0; + vve = vjsn_child(sp->vj->value, "elem"); + AN(vve); + VTAILQ_FOREACH(vv, &vve->children, list) + (void)vsc_fill_point(vsc, sp->fantom, vv, vsb, sp->points + j++); + VSB_destroy(&vsb); + AN(sp->vj); + return (sp); +} + +static int +vsc_iter_seg(const struct vsc_seg *sp, VSC_iter_f *fiter, void *priv) +{ + unsigned u; + int i = 0; + + CHECK_OBJ_NOTNULL(sp, VSC_SEG_MAGIC); + AN(fiter); + for(u = 0; u < sp->npoints; u++) { + if (sp->points[u].name != NULL) { + i = fiter(priv, &sp->points[u].point); + if (i) + break; + } } - vjsn_delete(&vj); return (i); } -/*-------------------------------------------------------------------- - */ - -int __match_proto__() // We don't want vsc to be const -VSC_Iter(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *f, - VSC_iter_f *func, void *priv) +int +VSC_Iter(struct vsc *vsc, struct vsm *vsm, + VSC_new_f *fnew, VSC_iter_f *fiter, VSC_destroy_f *fdestroy, void *priv) { - struct vsm_fantom ifantom; - uint64_t u; + struct vsm_fantom ifantom; + struct vsc_seg *sp, *sp2; int i = 0; - struct vsb *vsb; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); AN(vsm); - vsb = VSB_new_auto(); - AN(vsb); + (void)fnew; + (void)fdestroy; + sp = VTAILQ_FIRST(&vsc->segs); VSM_FOREACH(&ifantom, vsm) { if (strcmp(ifantom.class, VSC_CLASS)) continue; - AZ(VSM_Map(vsm, &ifantom)); - u = vbe64dec(ifantom.b); - if (u == 0) { - VRMB(); - usleep(100000); - u = vbe64dec(ifantom.b); + while (sp != NULL && + (strcmp(ifantom.ident, sp->fantom->ident) || + VSM_StillValid(vsm, sp->fantom) != VSM_valid)) { + sp2 = sp; + sp = VTAILQ_NEXT(sp, list); + VTAILQ_REMOVE(&vsc->segs, sp2, list); + vsc_del_seg(vsm, sp2); } - assert(u > 0); - i = vsc_iter_fantom(vsc, &ifantom, vsb, func, priv); - if (f != NULL) { - *f = ifantom; + if (sp != NULL) { + i = vsc_iter_seg(sp, fiter, priv); + sp = VTAILQ_NEXT(sp, list); } else { - AZ(VSM_Unmap(vsm, &ifantom)); + sp = vsc_add_seg(vsc, vsm, &ifantom); + VTAILQ_INSERT_TAIL(&vsc->segs, sp, list); + i = vsc_iter_seg(sp, fiter, priv); + sp = NULL; } if (i) break; } - VSB_destroy(&vsb); return (i); } + /*-------------------------------------------------------------------- */ @@ -397,4 +471,3 @@ VSC_ChangeLevel(const struct VSC_level_desc *old, int chg) i = 0; return (levels[i]); } - From phk at FreeBSD.org Thu Sep 7 22:07:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Sep 2017 22:07:05 +0000 (UTC) Subject: [master] 770d369 Try to get the VSM ownership right. Message-ID: <20170907220705.3374C9367E@lists.varnish-cache.org> commit 770d3699cdea2cec2a29122349f683b44efdfcd6 Author: Poul-Henning Kamp Date: Thu Sep 7 22:05:41 2017 +0000 Try to get the VSM ownership right. The general rule is that if varnishd is started as root, you need to be root or in group "varnish" to access the shared memory. Fixes #2419 diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 8695803..ad6abe7 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -166,7 +166,6 @@ void mgt_SHM_static_alloc(const void *, ssize_t size, void mgt_SHM_Create(void); void mgt_SHM_Destroy(int keep); -extern struct vsmw *mgt_vsmw; void mgt_SHM_ChildNew(void); void mgt_SHM_ChildDestroy(void); diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index e845c63..d7fa6a6 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -504,9 +504,9 @@ mgt_cli_secret(const char *S_arg) char buf[BUFSIZ]; /* Save in shmem */ - VJ_master(JAIL_MASTER_FILE); mgt_SHM_static_alloc(S_arg, strlen(S_arg) + 1L, "Arg", "-S"); + VJ_master(JAIL_MASTER_FILE); fd = open(S_arg, O_RDONLY); if (fd < 0) { fprintf(stderr, "Can not open secret-file \"%s\"\n", S_arg); @@ -574,9 +574,7 @@ mgt_cli_telnet(const char *T_arg) if (VSB_len(vsb) == 0) ARGV_ERR("-T %s could not be listened on.\n", T_arg); /* Save in shmem */ - VJ_master(JAIL_MASTER_FILE); mgt_SHM_static_alloc(VSB_data(vsb), VSB_len(vsb) + 1, "Arg", "-T"); - VJ_master(JAIL_MASTER_LOW); VSB_destroy(&vsb); } diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 53db1ee..67492d6 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -839,10 +839,8 @@ main(int argc, char * const *argv) mgt_SHM_Init(); - VJ_master(JAIL_MASTER_FILE); mgt_SHM_static_alloc(i_arg, strlen(i_arg) + 1L, "Arg", "-i"); VSC_C_mgt = VSC_mgt_New(""); - VJ_master(JAIL_MASTER_LOW); if (M_arg != NULL) mgt_cli_master(M_arg); diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index 2b9741e..b81c8a5 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -47,7 +47,7 @@ #include "vsm_priv.h" #include "vsmw.h" -struct vsmw *mgt_vsmw; +static struct vsmw *mgt_vsmw; /*-------------------------------------------------------------------- */ @@ -90,13 +90,16 @@ mgt_shm_atexit(void) void mgt_SHM_Init(void) { + int fd; VJ_master(JAIL_MASTER_FILE); AZ(system("rm -rf " VSM_MGT_DIRNAME)); AZ(mkdir(VSM_MGT_DIRNAME, 0755)); - mgt_vsmw = VSMW_New(open(VSM_MGT_DIRNAME, O_RDONLY), 0640, "_.index"); - AN(mgt_vsmw); + fd = open(VSM_MGT_DIRNAME, O_RDONLY); + VJ_fix_vsm_dir(fd); VJ_master(JAIL_MASTER_LOW); + mgt_vsmw = VSMW_New(fd, 0640, "_.index"); + AN(mgt_vsmw); proc_vsmw = mgt_vsmw; @@ -119,7 +122,6 @@ mgt_SHM_ChildNew(void) MCH_Fd_Inherit(heritage.vsm_fd, "VSMW"); - VJ_master(JAIL_MASTER_FILE); heritage.param = VSMW_Allocf(mgt_vsmw, VSM_CLASS_PARAM, sizeof *heritage.param, ""); AN(heritage.param); @@ -129,7 +131,6 @@ mgt_SHM_ChildNew(void) heritage.panic_str = VSMW_Allocf(mgt_vsmw, "Panic", heritage.panic_str_len, ""); AN(heritage.panic_str); - VJ_master(JAIL_MASTER_LOW); } void From phk at FreeBSD.org Fri Sep 8 08:52:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Sep 2017 08:52:05 +0000 (UTC) Subject: [master] 0a5b5fc Rototill the last bit of the VSC-api and simplify varnishstat_curses accordingly. Message-ID: <20170908085205.D50BA938F6@lists.varnish-cache.org> commit 0a5b5fcd492e23ade603d37ab0b9caa2c0dbc9f4 Author: Poul-Henning Kamp Date: Fri Sep 8 08:50:44 2017 +0000 Rototill the last bit of the VSC-api and simplify varnishstat_curses accordingly. If somebody has time to push varnishstat in curses mode though the paces and check that everything works I'd appreciate it. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index c622cc7..d114281 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -81,7 +81,7 @@ do_xml(struct vsm *vsm, struct vsc *vsc) now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf("\n", time_stamp); - (void)VSC_Iter(vsc, vsm, NULL, do_xml_cb, NULL, NULL); + (void)VSC_Iter(vsc, vsm, do_xml_cb, NULL); printf("\n"); } @@ -135,7 +135,7 @@ do_json(struct vsm *vsm, struct vsc *vsc) (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf(" \"timestamp\": \"%s\",\n", time_stamp); - (void)VSC_Iter(vsc, vsm, NULL, do_json_cb, NULL, &jp); + (void)VSC_Iter(vsc, vsm, do_json_cb, &jp); printf("\n}\n"); } @@ -199,8 +199,8 @@ do_once(struct vsm *vsm, struct vsc *vsc) memset(&op, 0, sizeof op); op.pad = 18; - (void)VSC_Iter(vsc, vsm, NULL, do_once_cb_first, NULL, &op); - (void)VSC_Iter(vsc, vsm, NULL, do_once_cb, NULL, &op); + (void)VSC_Iter(vsc, vsm, do_once_cb_first, &op); + (void)VSC_Iter(vsc, vsm, do_once_cb, &op); } /*--------------------------------------------------------------------*/ @@ -230,7 +230,7 @@ list_fields(struct vsm *vsm, struct vsc *vsc) printf("Field name Description\n"); printf("---------- -----------\n"); - (void)VSC_Iter(vsc, vsm, NULL, do_list_cb, NULL, NULL); + (void)VSC_Iter(vsc, vsm, do_list_cb, NULL); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index fcc96ef..dec9c47 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -72,7 +72,7 @@ struct pt { #define PT_MAGIC 0x41698E4F VTAILQ_ENTRY(pt) list; - struct VSC_point *vpt; + const struct VSC_point *vpt; char seen; @@ -119,6 +119,7 @@ static int sample = 0; static int scale = 1; static double t_sample = 0.; static double interval = 1.; +static int vsm_status = 0; static void init_hitrate(void) @@ -226,130 +227,6 @@ build_pt_array(void) } static void -delete_pt_list(void) -{ - struct pt *pt; - unsigned i = 0; - - delete_pt_array(); - - while (!VTAILQ_EMPTY(&ptlist)) { - pt = VTAILQ_FIRST(&ptlist); - CHECK_OBJ_NOTNULL(pt, PT_MAGIC); - VTAILQ_REMOVE(&ptlist, pt, list); - VSC_Destroy_Point(&pt->vpt); - FREE_OBJ(pt); - i++; - } - assert(i == n_ptlist); - n_ptlist = 0; - - update_position(); -} - -struct pt_priv { - unsigned magic; -#define PT_PRIV_MAGIC 0x34ACBAD6 - VTAILQ_HEAD(, pt) ptlist; - unsigned n_ptlist; -}; - -static int __match_proto__(VSC_iter_f) -build_pt_list_cb(void *priv, const struct VSC_point *vpt) -{ - struct pt_priv *pt_priv; - struct pt *pt; - - if (vpt == NULL) - return (0); - - CAST_OBJ_NOTNULL(pt_priv, priv, PT_PRIV_MAGIC); - - AZ(strcmp(vpt->ctype, "uint64_t")); - - if (!strcmp(vpt->name, "MGT.uptime")) - mgt_uptime = vpt->ptr; - if (!strcmp(vpt->name, "MAIN.uptime")) - main_uptime = vpt->ptr; - if (!strcmp(vpt->name, "MAIN.cache_hit")) - main_cache_hit = vpt->ptr; - if (!strcmp(vpt->name, "MAIN.cache_miss")) - main_cache_miss = vpt->ptr; - - VTAILQ_FOREACH(pt, &ptlist, list) { - CHECK_OBJ_NOTNULL(pt, PT_MAGIC); - AN(pt->vpt->name); - if (strcmp(vpt->name, pt->vpt->name)) - continue; - VTAILQ_REMOVE(&ptlist, pt, list); - AN(n_ptlist); - n_ptlist--; - VSC_Destroy_Point(&pt->vpt); - pt->vpt = VSC_Clone_Point(vpt); - AN(pt->vpt); - VTAILQ_INSERT_TAIL(&pt_priv->ptlist, pt, list); - pt_priv->n_ptlist++; - return (0); - } - AZ(pt); - - ALLOC_OBJ(pt, PT_MAGIC); - AN(pt); - - pt->vpt = VSC_Clone_Point(vpt); - AN(pt->vpt); - - pt->last = *pt->vpt->ptr; - - pt->ma_10.nmax = 10; - pt->ma_100.nmax = 100; - pt->ma_1000.nmax = 1000; - - VTAILQ_INSERT_TAIL(&pt_priv->ptlist, pt, list); - pt_priv->n_ptlist++; - - return (0); -} - -static void -build_pt_list(struct vsc *vsc, struct vsm *vsm) -{ - struct pt_priv pt_priv; - int i; - struct pt *pt_current = NULL; - int current_line = 0; - - if (current < n_ptarray) { - pt_current = ptarray[current]; - current_line = current - page_start; - } - - pt_priv.magic = PT_PRIV_MAGIC; - VTAILQ_INIT(&pt_priv.ptlist); - pt_priv.n_ptlist = 0; - - mgt_uptime = NULL; - main_uptime = NULL; - main_cache_hit = NULL; - main_cache_miss = NULL; - - (void)VSC_Iter(vsc, vsm, NULL, build_pt_list_cb, NULL, &pt_priv); - delete_pt_list(); - AN(VTAILQ_EMPTY(&ptlist)); - AZ(n_ptlist); - VTAILQ_CONCAT(&ptlist, &pt_priv.ptlist, list); - n_ptlist = pt_priv.n_ptlist; - build_pt_array(); - - for (i = 0; pt_current != NULL && i < n_ptarray; i++) - if (ptarray[i] == pt_current) - break; - current = i; - page_start = current - current_line; - update_position(); -} - -static void sample_points(void) { struct pt *pt; @@ -528,11 +405,22 @@ print_duration(WINDOW *w, time_t t) } static void +running(WINDOW *w, time_t up, int flg) +{ + if (vsm_status & flg) { + print_duration(w_status, up); + } else { + wattron(w, A_STANDOUT); + wprintw(w, " Not Running"); + wattroff(w, A_STANDOUT); + } +} + +static void draw_status(void) { time_t up_mgt = 0; time_t up_chld = 0; - static const char discon[] = "*** DISCONNECTED ***"; AN(w_status); @@ -543,14 +431,12 @@ draw_status(void) if (main_uptime != NULL) up_chld = *main_uptime; - mvwprintw(w_status, 0, 0, "Uptime mgt: "); - print_duration(w_status, up_mgt); - mvwprintw(w_status, 1, 0, "Uptime child:"); - print_duration(w_status, up_chld); + mvwprintw(w_status, 0, 0, "Uptime mgt: "); + running(w_status, up_mgt, VSM_MGT_RUNNING); + mvwprintw(w_status, 1, 0, "Uptime child: "); + running(w_status, up_chld, VSM_WRK_RUNNING); - if (mgt_uptime == NULL) - mvwprintw(w_status, 0, COLS - strlen(discon), discon); - else if (COLS > 70) { + if (COLS > 70) { mvwprintw(w_status, 0, getmaxx(w_status) - 37, "Hitrate n: %8u %8u %8u", hitrate.hr_10.n, hitrate.hr_100.n, hitrate.hr_1000.n); @@ -1042,12 +928,62 @@ handle_keypress(int ch) redraw = 1; } +static void * __match_proto__(VSC_new_f) +newpt(void *priv, const struct VSC_point *const vpt) +{ + struct pt *pt; + + ALLOC_OBJ(pt, PT_MAGIC); + AN(pt); + AZ(priv); + pt->vpt = vpt; + pt->last = *pt->vpt->ptr; + pt->ma_10.nmax = 10; + pt->ma_100.nmax = 100; + pt->ma_1000.nmax = 1000; + + VTAILQ_INSERT_TAIL(&ptlist, pt, list); + n_ptlist++; + + AZ(strcmp(vpt->ctype, "uint64_t")); + + if (!strcmp(vpt->name, "MGT.uptime")) + mgt_uptime = vpt->ptr; + if (!strcmp(vpt->name, "MAIN.uptime")) + main_uptime = vpt->ptr; + if (!strcmp(vpt->name, "MAIN.cache_hit")) + main_cache_hit = vpt->ptr; + if (!strcmp(vpt->name, "MAIN.cache_miss")) + main_cache_miss = vpt->ptr; + return (pt); +} + +static void __match_proto__(VSC_destroy_f) +delpt(void *priv, const struct VSC_point *const vpt) +{ + struct pt *pt; + + AZ(priv); + CAST_OBJ_NOTNULL(pt, vpt->priv, PT_MAGIC); + VTAILQ_REMOVE(&ptlist, pt, list); + n_ptlist--; + FREE_OBJ(pt); + if (vpt->ptr == mgt_uptime) + mgt_uptime = NULL; + if (vpt->ptr == main_uptime) + main_uptime = NULL; + if (vpt->ptr == main_cache_hit) + main_cache_hit = NULL; + if (vpt->ptr == main_cache_miss) + main_cache_miss = NULL; +} + void -do_curses(struct vsm *vd, struct vsc *vsc, double delay) +do_curses(struct vsm *vsm, struct vsc *vsc, double delay) { struct pollfd pollfd; long t; - int ch, initial = 1; + int ch; double now; interval = delay; @@ -1066,13 +1002,17 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) make_windows(); doupdate(); + VSC_State(vsc, newpt, delpt, NULL); + + rebuild = 1; while (keep_running) { - if (initial || - (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED))) { + vsm_status = VSM_Status(vsm); + rebuild |= vsm_status & ~(VSM_MGT_RUNNING|VSM_WRK_RUNNING); + if (rebuild) { + (void)VSC_Iter(vsc, vsm, NULL, NULL); init_hitrate(); - delete_pt_list(); - build_pt_list(vsc, vd); - initial = 0; + build_pt_array(); + redraw = 1; } now = VTIM_mono(); @@ -1080,8 +1020,6 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) sample = 1; if (sample) sample_data(); - if (rebuild) - build_pt_array(); if (redraw) draw_screen(); @@ -1103,6 +1041,8 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) break; } } - VSM_Destroy(&vd); + VSC_Destroy(&vsc); + AN(VTAILQ_EMPTY(&ptlist)); + VSM_Destroy(&vsm); AZ(endwin()); } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index d63b37e..965931c 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -849,7 +849,7 @@ varnish_vsc(const struct varnish *v, const char *arg) dp.v = v; dp.arg = arg; (void)VSM_Status(v->vsm_vsc); - (void)VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_stat_dump_cb, NULL, &dp); + (void)VSC_Iter(v->vsc, v->vsm_vsc, do_stat_dump_cb, &dp); } /********************************************************************** @@ -914,8 +914,7 @@ varnish_expect(const struct varnish *v, char * const *av) good = 0; for (i = 0; i < 50; i++, (void)usleep(100000)) { (void)VSM_Status(v->vsm_vsc); - good = VSC_Iter(v->vsc, v->vsm_vsc, - NULL, do_expect_cb, NULL, &sp); + good = VSC_Iter(v->vsc, v->vsm_vsc, do_expect_cb, &sp); if (!good) { good = -2; continue; diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 6f747f7..969c243 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -41,25 +41,6 @@ struct vsm; struct vsc; struct vsm_fantom; -/*--------------------------------------------------------------------- - * VSC level access functions - */ - -struct vsc *VSC_New(void); -void VSC_Destroy(struct vsc **); - -int VSC_Arg(struct vsc *, char arg, const char *opt); - /* - * Handle standard stat-presenter arguments - * Return: - * -1 error, VSM_Error() returns diagnostic string - * 0 not handled - * 1 Handled. - */ - -struct VSC_level_desc; -struct VSC_point; - struct VSC_level_desc { const char *name; /* name */ const char *label; /* label */ @@ -71,50 +52,104 @@ struct VSC_point { const volatile uint64_t *ptr; /* field value */ const char *name; /* field name */ const char *ctype; /* C-type */ - int semantics; /* semantics */ - int format; /* display format */ + int semantics; /* semantics + * 'c' = Counter + * 'g' = Gauge + * 'b' = bitmap + * '?' = unknown + */ + int format; /* display format + * 'i' = integer + * 'B' = bytes + * 'b' = bitmap + * 'd' = duration + * '?' = unknown + */ const struct VSC_level_desc *level; /* verbosity level */ const char *sdesc; /* short description */ const char *ldesc; /* long description */ + void *priv; /* return val from VSC_new_f */ }; -struct VSC_point *VSC_Clone_Point(const struct VSC_point * const); - -void VSC_Destroy_Point(struct VSC_point **); +/*--------------------------------------------------------------------- + * Function pointers + */ typedef void *VSC_new_f(void *priv, const struct VSC_point *const pt); + /* + * priv is from VSC_State(). + * + * The return value is installed in pt->priv + */ + +typedef void VSC_destroy_f(void *priv, const struct VSC_point *const pt); + /* + * priv is from VSC_State(). + */ + typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt); -typedef int VSC_destroy_f(void *priv, const struct VSC_point *const pt); + /* + * priv is the argument to VSC_Iter() and not from VSC_State(). + * + * A non-zero return terminates the iteration + */ -int VSC_Iter(struct vsc *, struct vsm *, VSC_new_f *, VSC_iter_f *, VSC_destroy_f *, void *priv); +/*--------------------------------------------------------------------- + * VSC level access functions + */ + +struct vsc *VSC_New(void); /* - * Iterate over all statistics counters, calling "func" for - * each counter not suppressed by any "-f" arguments. + * Create a new VSC instance + */ + +void VSC_Destroy(struct vsc **); + /* + * Destroy a VSC instance * - * fantom points to a struct vsm_fantom. If non-NULL, it can be - * used with VSM_StillValid to check the validity of the points - * returned. + * If a destroy function was installed with VSC_State() + * it will be called for all remaining points + */ + +int VSC_Arg(struct vsc *, char arg, const char *opt); + /* + * Handle standard stat-presenter arguments + * 'f' - filter * - * The returned points are valid for at most 60 seconds after - * VSM_StillValid(,fantom) starts returning anything but - * VSM_valid, or until the next call to VSC_Iter. Using the point - * values after any of these events gives undefined behavior. + * Return: + * -1 error, VSM_Error() returns diagnostic string + * 0 not handled + * 1 Handled. + */ + +void VSC_State(struct vsc *, VSC_new_f *, VSC_destroy_f *, void *); + /* + * Install function pointers for create/destroy and their + * priv pointer. All arguments can be NULL. + */ + +int VSC_Iter(struct vsc *, struct vsm *, VSC_iter_f *, void *priv); + /* + * Iterate over all statistics counters, calling a function for + * each counter not suppressed by any "-f" arguments. * - * Func is called with pt == NULL, whenever VSM allocations - * change (child restart, allocations/deallocations) + * To discover new/deleted points, call VSM_Status() first. + * + * The returned points are valid until the next call to VSC_Iter() * * Arguments: * vd: The vsm context - * fantom: Pointer to a fantom. Can be NULL. * func: The callback function * priv: Passed as argument to func * * Returns: * !=0: func returned non-zero - * -1: No VSC's available * 0: Done */ const struct VSC_level_desc *VSC_ChangeLevel(const struct VSC_level_desc*, int); + /* + * Change a level up or down. + */ #endif /* VAPI_VSC_H_INCLUDED */ diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index b89c90c..aee341b 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -195,5 +195,5 @@ LIBVARNISHAPI_1.7 { VSM_Dup; VSC_New; VSC_Destroy; - VSC_Iter2; + VSC_State; } LIBVARNISHAPI_1.0; diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 6ccbc9d..417c834 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -69,7 +69,7 @@ struct vsc_seg { #define VSC_SEG_MAGIC 0x801177d4 VTAILQ_ENTRY(vsc_seg) list; struct vsm_fantom fantom[1]; - struct vjsn *vj; + struct vjsn *vj; unsigned npoints; struct vsc_pt *points; }; @@ -81,6 +81,10 @@ struct vsc { struct vsc_sf_head sf_list_include; struct vsc_sf_head sf_list_exclude; VTAILQ_HEAD(,vsc_seg) segs; + + VSC_new_f *fnew; + VSC_destroy_f *fdestroy; + void *priv; }; /*-------------------------------------------------------------------- @@ -101,34 +105,6 @@ static const size_t nlevels = sizeof(levels)/sizeof(*levels); /*--------------------------------------------------------------------*/ -struct VSC_point * -VSC_Clone_Point(const struct VSC_point * const vp) -{ - struct VSC_point *pt; - char *p; - - pt = calloc(sizeof *pt, 1); - AN(pt); - *pt = *vp; - p = strdup(pt->name); AN(p); pt->name = p; - p = strdup(pt->sdesc); AN(p); pt->sdesc = p; - p = strdup(pt->ldesc); AN(p); pt->ldesc = p; - return (pt); -} - -void -VSC_Destroy_Point(struct VSC_point **p) -{ - AN(p); - free(TRUST_ME((*p)->ldesc)); - free(TRUST_ME((*p)->sdesc)); - free(TRUST_ME((*p)->name)); - free(*p); - *p = NULL; -} - -/*--------------------------------------------------------------------*/ - struct vsc * VSC_New(void) { @@ -215,6 +191,18 @@ VSC_Arg(struct vsc *vsc, char arg, const char *opt) /*-------------------------------------------------------------------- */ +void +VSC_State(struct vsc *vsc, VSC_new_f *fn, VSC_destroy_f *fd, void *priv) +{ + + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + vsc->fnew = fn; + vsc->fdestroy = fd; + vsc->priv = priv; +} + +/*-------------------------------------------------------------------- + */ static int vsc_filter(const struct vsc *vsc, const char *nm) @@ -329,16 +317,22 @@ vsc_fill_point(const struct vsc *vsc, const struct vsm_fantom *fantom, } static void -vsc_del_seg(struct vsm *vsm, struct vsc_seg *sp) +vsc_del_seg(const struct vsc *vsc, struct vsm *vsm, struct vsc_seg *sp) { unsigned u; + struct vsc_pt *pp; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); AN(vsm); CHECK_OBJ_NOTNULL(sp, VSC_SEG_MAGIC); AZ(VSM_Unmap(vsm, sp->fantom)); vjsn_delete(&sp->vj); - for(u = 0; u < sp->npoints; u++) - vsc_clean_point(&sp->points[u]); + pp = sp->points; + for(u = 0; u < sp->npoints; u++, pp++) { + if (vsc->fdestroy != NULL) + vsc->fdestroy(vsc->priv, &pp->point); + vsc_clean_point(pp); + } free(sp->points); FREE_OBJ(sp); } @@ -348,11 +342,11 @@ vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp) { struct vsc_seg *sp; uint64_t u; - unsigned j; const char *p; const char *e; struct vjsn_val *vv, *vve; struct vsb *vsb; + struct vsc_pt *pp; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); AN(vsm); @@ -380,37 +374,41 @@ vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp) AN(sp->points); vsb = VSB_new_auto(); AN(vsb); - j = 0; vve = vjsn_child(sp->vj->value, "elem"); AN(vve); - VTAILQ_FOREACH(vv, &vve->children, list) - (void)vsc_fill_point(vsc, sp->fantom, vv, vsb, sp->points + j++); + pp = sp->points; + VTAILQ_FOREACH(vv, &vve->children, list) { + if (vsc_fill_point(vsc, sp->fantom, vv, vsb, pp) && + vsc->fnew != NULL) + pp->point.priv = vsc->fnew(vsc->priv, &pp->point); + pp++; + } VSB_destroy(&vsb); AN(sp->vj); return (sp); } static int -vsc_iter_seg(const struct vsc_seg *sp, VSC_iter_f *fiter, void *priv) +vsc_iter_seg(const struct vsc *vsc, const struct vsc_seg *sp, + VSC_iter_f *fiter, void *priv) { unsigned u; int i = 0; + struct vsc_pt *pp; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); CHECK_OBJ_NOTNULL(sp, VSC_SEG_MAGIC); AN(fiter); - for(u = 0; u < sp->npoints; u++) { - if (sp->points[u].name != NULL) { - i = fiter(priv, &sp->points[u].point); - if (i) - break; - } + pp = sp->points; + for(u = 0; u < sp->npoints && i == 0; u++, pp++) { + if (pp->name != NULL) + i = fiter(priv, &pp->point); } return (i); } int -VSC_Iter(struct vsc *vsc, struct vsm *vsm, - VSC_new_f *fnew, VSC_iter_f *fiter, VSC_destroy_f *fdestroy, void *priv) +VSC_Iter(struct vsc *vsc, struct vsm *vsm, VSC_iter_f *fiter, void *priv) { struct vsm_fantom ifantom; struct vsc_seg *sp, *sp2; @@ -418,8 +416,6 @@ VSC_Iter(struct vsc *vsc, struct vsm *vsm, CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); AN(vsm); - (void)fnew; - (void)fdestroy; sp = VTAILQ_FIRST(&vsc->segs); VSM_FOREACH(&ifantom, vsm) { if (strcmp(ifantom.class, VSC_CLASS)) @@ -430,20 +426,28 @@ VSC_Iter(struct vsc *vsc, struct vsm *vsm, sp2 = sp; sp = VTAILQ_NEXT(sp, list); VTAILQ_REMOVE(&vsc->segs, sp2, list); - vsc_del_seg(vsm, sp2); + vsc_del_seg(vsc, vsm, sp2); } if (sp != NULL) { - i = vsc_iter_seg(sp, fiter, priv); + if (fiter != NULL) + i = vsc_iter_seg(vsc, sp, fiter, priv); sp = VTAILQ_NEXT(sp, list); } else { sp = vsc_add_seg(vsc, vsm, &ifantom); VTAILQ_INSERT_TAIL(&vsc->segs, sp, list); - i = vsc_iter_seg(sp, fiter, priv); + if (fiter != NULL) + i = vsc_iter_seg(vsc, sp, fiter, priv); sp = NULL; } if (i) break; } + while (sp != NULL) { + sp2 = sp; + sp = VTAILQ_NEXT(sp, list); + VTAILQ_REMOVE(&vsc->segs, sp2, list); + vsc_del_seg(vsc, vsm, sp2); + } return (i); } diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 96c171b..50e1805 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -353,7 +354,7 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) retval |= VSM_MGT_CHANGED; vs->fd = openat(vs->dfd, "_.index", O_RDONLY); if (vs->fd < 0) - return (retval|VSM_NUKE_ALL); + return (retval|VSM_MGT_RESTARTED); AZ(fstat(vs->fd, &vs->fst)); @@ -376,17 +377,17 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) * XXX: be kill(pid,0)'ed for more rapid abandonment detection. */ i = sscanf(VSB_data(vsb), "# %ju %ju\n%n", &id1, &id2, &ac); - if (i != 2) { - retval |= VSM_MGT_RESTARTED; - return (retval|VSM_NUKE_ALL); + if (i != 2 || kill(id1, 0)) { + retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; + return (retval); } + retval |= VSM_MGT_RUNNING; if (id1 != vs->id1 || id2 != vs->id2) { - retval |= VSM_MGT_RESTARTED; + retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; vs->id1 = id1; vs->id2 = id2; } p = VSB_data(vsb) + ac; - retval |= VSM_MGT_RUNNING; VTAILQ_FOREACH(vg, &vs->segs, list) vg->markscan = 0; From phk at FreeBSD.org Fri Sep 8 10:00:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Sep 2017 10:00:08 +0000 (UTC) Subject: [master] 7f457cf Only react on kill(2) if process doesn't exist. Message-ID: <20170908100008.8A0BA93EB5@lists.varnish-cache.org> commit 7f457cf016b1f44329e6272bded76888ae2a5613 Author: Poul-Henning Kamp Date: Fri Sep 8 09:54:13 2017 +0000 Only react on kill(2) if process doesn't exist. diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 50e1805..ccb0dfb 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -377,7 +377,7 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) * XXX: be kill(pid,0)'ed for more rapid abandonment detection. */ i = sscanf(VSB_data(vsb), "# %ju %ju\n%n", &id1, &id2, &ac); - if (i != 2 || kill(id1, 0)) { + if (i != 2 || (kill(id1, 0) && errno == ESRCH)) { retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; return (retval); } From phk at FreeBSD.org Fri Sep 8 10:00:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Sep 2017 10:00:08 +0000 (UTC) Subject: [master] ede8c3d Change the jail-API so we can get the vsm dir permissions right. Message-ID: <20170908100008.A54F493EB8@lists.varnish-cache.org> commit ede8c3dbe84b131d7e1240f28f2eb16c2818c309 Author: Poul-Henning Kamp Date: Fri Sep 8 09:58:51 2017 +0000 Change the jail-API so we can get the vsm dir permissions right. Fixes #2419 diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index ad6abe7..f5ba1e3 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -99,11 +99,17 @@ enum jail_master_e { JAIL_MASTER_KILL, }; +enum jail_fixfd_e { + JAIL_FIXFD_FILE, + JAIL_FIXFD_VSMMGT, + JAIL_FIXFD_VSMWRK, +}; + typedef int jail_init_f(char **); typedef void jail_master_f(enum jail_master_e); typedef void jail_subproc_f(enum jail_subproc_e); typedef int jail_make_dir_f(const char *dname); -typedef void jail_fixfile_f(int fd); +typedef void jail_fixfd_f(int fd, enum jail_fixfd_e); struct jail_tech { unsigned magic; @@ -114,8 +120,7 @@ struct jail_tech { jail_subproc_f *subproc; jail_make_dir_f *make_workdir; jail_make_dir_f *make_vcldir; - jail_fixfile_f *vsm_file; - jail_fixfile_f *storage_file; + jail_fixfd_f *fixfd; }; void VJ_Init(const char *j_arg); @@ -123,8 +128,7 @@ void VJ_master(enum jail_master_e jme); void VJ_subproc(enum jail_subproc_e jse); int VJ_make_workdir(const char *dname); int VJ_make_vcldir(const char *dname); -void VJ_fix_vsm_dir(int fd); -void VJ_fix_storage_file(int fd); +void VJ_fix_fd(int fd, enum jail_fixfd_e); extern const struct jail_tech jail_tech_unix; extern const struct jail_tech jail_tech_solaris; diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c index ea5fff2..d241cf7 100644 --- a/bin/varnishd/mgt/mgt_jail.c +++ b/bin/varnishd/mgt/mgt_jail.c @@ -181,19 +181,10 @@ VJ_make_vcldir(const char *dname) } void -VJ_fix_storage_file(int fd) +VJ_fix_fd(int fd, enum jail_fixfd_e what) { CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC); - if (vjt->storage_file != NULL) - vjt->storage_file(fd); -} - -void -VJ_fix_vsm_dir(int fd) -{ - - CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC); - if (vjt->vsm_file != NULL) - vjt->vsm_file(fd); + if (vjt->fixfd != NULL) + vjt->fixfd(fd, what); } diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index f4097d0..4d4c56d 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -254,22 +254,27 @@ vju_make_vcldir(const char *dname) } -static void __match_proto__(jail_fixfile_f) -vju_vsm_dir(int fd) +static void __match_proto__(jail_fixfd_f) +vju_fixfd(int fd, enum jail_fixfd_e what) { /* Called under JAIL_MASTER_FILE */ - AZ(fchmod(fd, 0750)); - AZ(fchown(fd, vju_wrkuid, vju_wrkgid)); -} - -static void __match_proto__(jail_fixfile_f) -vju_storage_file(int fd) -{ - /* Called under JAIL_MASTER_STORAGE */ - - AZ(fchmod(fd, 0600)); - AZ(fchown(fd, vju_uid, vju_gid)); + switch (what) { + case JAIL_FIXFD_FILE: + AZ(fchmod(fd, 0750)); + AZ(fchown(fd, vju_wrkuid, vju_wrkgid)); + break; + case JAIL_FIXFD_VSMMGT: + AZ(fchmod(fd, 0750)); + AZ(fchown(fd, vju_uid, vju_gid)); + break; + case JAIL_FIXFD_VSMWRK: + AZ(fchmod(fd, 0750)); + AZ(fchown(fd, vju_wrkuid, vju_wrkgid)); + break; + default: + WRONG("Ain't Fixin'"); + } } const struct jail_tech jail_tech_unix = { @@ -278,7 +283,6 @@ const struct jail_tech jail_tech_unix = { .init = vju_init, .master = vju_master, .make_vcldir = vju_make_vcldir, - .vsm_file = vju_vsm_dir, - .storage_file = vju_storage_file, + .fixfd = vju_fixfd, .subproc = vju_subproc, }; diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index b81c8a5..6853a1f 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -96,7 +96,7 @@ mgt_SHM_Init(void) AZ(system("rm -rf " VSM_MGT_DIRNAME)); AZ(mkdir(VSM_MGT_DIRNAME, 0755)); fd = open(VSM_MGT_DIRNAME, O_RDONLY); - VJ_fix_vsm_dir(fd); + VJ_fix_fd(fd, JAIL_FIXFD_VSMMGT); VJ_master(JAIL_MASTER_LOW); mgt_vsmw = VSMW_New(fd, 0640, "_.index"); AN(mgt_vsmw); @@ -117,7 +117,7 @@ mgt_SHM_ChildNew(void) heritage.vsm_fd = open(VSM_CHILD_DIRNAME, O_RDONLY); assert(heritage.vsm_fd >= 0); - VJ_fix_vsm_dir(heritage.vsm_fd); + VJ_fix_fd(heritage.vsm_fd, JAIL_FIXFD_VSMWRK); VJ_master(JAIL_MASTER_LOW); MCH_Fd_Inherit(heritage.vsm_fd, "VSMW"); diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index 5ee2ada..d620447 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -84,7 +84,7 @@ STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx) VJ_master(JAIL_MASTER_STORAGE); fd = open(fn, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600); if (fd >= 0) { - VJ_fix_storage_file(fd); + VJ_fix_fd(fd, JAIL_FIXFD_FILE); *fdp = fd; *fnp = fn; VJ_master(JAIL_MASTER_LOW); @@ -123,7 +123,7 @@ STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx) ctx, fn); *fdp = fd; - VJ_fix_storage_file(fd); + VJ_fix_fd(fd, JAIL_FIXFD_FILE); VJ_master(JAIL_MASTER_LOW); return (retval); } From phk at FreeBSD.org Fri Sep 8 11:38:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Sep 2017 11:38:04 +0000 (UTC) Subject: [master] 74efa16 Properly implement VSC_Destroy() Message-ID: <20170908113804.0440593141@lists.varnish-cache.org> commit 74efa16887ce5a3e38f991e9e1fec4df9d1f9e05 Author: Poul-Henning Kamp Date: Fri Sep 8 11:36:59 2017 +0000 Properly implement VSC_Destroy() Fixes #2420 diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index dec9c47..fb492f7 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -1041,7 +1041,7 @@ do_curses(struct vsm *vsm, struct vsc *vsc, double delay) break; } } - VSC_Destroy(&vsc); + VSC_Destroy(&vsc, vsm); AN(VTAILQ_EMPTY(&ptlist)); VSM_Destroy(&vsm); AZ(endwin()); diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 965931c..6dfaae7 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -332,6 +332,10 @@ varnish_delete(struct varnish *v) vtc_logclose(v->vl); free(v->name); free(v->workdir); + if (v->vsc != NULL) + VSC_Destroy(&v->vsc, v->vsm_vsc); + if (v->vsm_vsc != NULL) + VSM_Destroy(&v->vsm_vsc); if (v->vsm_vsl != NULL) VSM_Destroy(&v->vsm_vsl); diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 969c243..88ac0b7 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -103,7 +103,7 @@ struct vsc *VSC_New(void); * Create a new VSC instance */ -void VSC_Destroy(struct vsc **); +void VSC_Destroy(struct vsc **, struct vsm *); /* * Destroy a VSC instance * diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 417c834..8ca2572 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -121,33 +121,6 @@ VSC_New(void) /*--------------------------------------------------------------------*/ -static void -vsc_delete_sf_list(struct vsc_sf_head *head) -{ - struct vsc_sf *sf; - - while (!VTAILQ_EMPTY(head)) { - sf = VTAILQ_FIRST(head); - CHECK_OBJ_NOTNULL(sf, VSC_SF_MAGIC); - VTAILQ_REMOVE(head, sf, list); - free(sf->pattern); - FREE_OBJ(sf); - } -} - -void -VSC_Destroy(struct vsc **vscp) -{ - struct vsc *vsc; - - TAKE_OBJ_NOTNULL(vsc, vscp, VSC_MAGIC); - vsc_delete_sf_list(&vsc->sf_list_include); - vsc_delete_sf_list(&vsc->sf_list_exclude); - FREE_OBJ(vsc); -} - -/*--------------------------------------------------------------------*/ - static int vsc_f_arg(struct vsc *vsc, const char *opt) { @@ -475,3 +448,36 @@ VSC_ChangeLevel(const struct VSC_level_desc *old, int chg) i = 0; return (levels[i]); } + +/*--------------------------------------------------------------------*/ + +static void +vsc_delete_sf_list(struct vsc_sf_head *head) +{ + struct vsc_sf *sf; + + while (!VTAILQ_EMPTY(head)) { + sf = VTAILQ_FIRST(head); + CHECK_OBJ_NOTNULL(sf, VSC_SF_MAGIC); + VTAILQ_REMOVE(head, sf, list); + free(sf->pattern); + FREE_OBJ(sf); + } +} + +void +VSC_Destroy(struct vsc **vscp, struct vsm *vsm) +{ + struct vsc *vsc; + struct vsc_seg *sp, *sp2; + + TAKE_OBJ_NOTNULL(vsc, vscp, VSC_MAGIC); + vsc_delete_sf_list(&vsc->sf_list_include); + vsc_delete_sf_list(&vsc->sf_list_exclude); + VTAILQ_FOREACH_SAFE(sp, &vsc->segs, list, sp2) { + VTAILQ_REMOVE(&vsc->segs, sp, list); + vsc_del_seg(vsc, vsm, sp); + } + FREE_OBJ(vsc); +} + From phk at FreeBSD.org Fri Sep 8 12:19:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Sep 2017 12:19:04 +0000 (UTC) Subject: [master] 6a1d6d2 Only use the kill(pid, 0) test to detect dead process if it has indicated the process was present at one point. Message-ID: <20170908121904.B321093FD2@lists.varnish-cache.org> commit 6a1d6d2b3739719848cfd18f768649c069254cec Author: Poul-Henning Kamp Date: Fri Sep 8 12:17:15 2017 +0000 Only use the kill(pid,0) test to detect dead process if it has indicated the process was present at one point. diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index ccb0dfb..e7cc519 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -120,6 +120,8 @@ struct vsm { int attached; double patience; + + int couldkill; }; /*--------------------------------------------------------------------*/ @@ -347,9 +349,11 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) closefd(&vs->fd); } - - if (vs->fd >= 0) - return (retval|VSM_MGT_RUNNING); + if (vs->fd >= 0) { + if (!vd->couldkill || !kill(vs->id1, 0)) + retval |= VSM_MGT_RUNNING; + return (retval); + } retval |= VSM_MGT_CHANGED; vs->fd = openat(vs->dfd, "_.index", O_RDONLY); @@ -377,7 +381,13 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) * XXX: be kill(pid,0)'ed for more rapid abandonment detection. */ i = sscanf(VSB_data(vsb), "# %ju %ju\n%n", &id1, &id2, &ac); - if (i != 2 || (kill(id1, 0) && errno == ESRCH)) { + if (i != 2) { + retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; + return (retval); + } + if (!kill(id1, 0)) { + vd->couldkill = 1; + } else if (vd->couldkill && errno == ESRCH) { retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; return (retval); } From phk at FreeBSD.org Fri Sep 8 13:21:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Sep 2017 13:21:05 +0000 (UTC) Subject: [master] 1e696ea Make vxp_test at least compile, while pondering if it should be removed. Message-ID: <20170908132105.70C51934E6@lists.varnish-cache.org> commit 1e696ea10dc96e1f0976e746f04503fac15734bc Author: Poul-Henning Kamp Date: Fri Sep 8 13:20:38 2017 +0000 Make vxp_test at least compile, while pondering if it should be removed. diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c index 0848ee3..527bbb7 100644 --- a/lib/libvarnishapi/vxp_lexer.c +++ b/lib/libvarnishapi/vxp_lexer.c @@ -173,6 +173,7 @@ vxp_Lexer(struct vxp *vxp) } #ifdef VXP_DEBUG +#include void vxp_PrintTokens(const struct vxp *vxp) { diff --git a/lib/libvarnishapi/vxp_test.c b/lib/libvarnishapi/vxp_test.c index bcca61b..4cc0f8d 100644 --- a/lib/libvarnishapi/vxp_test.c +++ b/lib/libvarnishapi/vxp_test.c @@ -34,6 +34,9 @@ #include #include "miniobj.h" +#include "vdef.h" +#include "vqueue.h" +#include "vre.h" #include "vas.h" #include "vsb.h" @@ -69,7 +72,7 @@ main(int argc, char * const *argv) vsb = VSB_new_auto(); AN(vsb); - vex = vex_New(q_arg, vsb); + vex = vex_New(q_arg, vsb, 0); if (vex == NULL) { VSB_finish(vsb); From nils.goroll at uplex.de Fri Sep 8 16:57:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 8 Sep 2017 16:57:06 +0000 (UTC) Subject: [master] 23c08c1 Add VSM_NOPID environment variable to disable pid-based tests Message-ID: <20170908165706.0908A933F0@lists.varnish-cache.org> commit 23c08c16be38108b57bc42f3e8c8947f01bedef0 Author: Nils Goroll Date: Fri Sep 8 17:09:48 2017 +0200 Add VSM_NOPID environment variable to disable pid-based tests varnishd writes its pids to vsm segments for vsm clients to determine if varnishd processes are alive. When running varnishd and vsm clients in different containers, the pid information has no relevance and may even be ambiguous across name spaces. Setting the environment variable VSM_NOPID for vsm clients disables use of pid information. Patch by phk diff --git a/doc/sphinx/reference/vsm.rst b/doc/sphinx/reference/vsm.rst index fbea284..a6a0713 100644 --- a/doc/sphinx/reference/vsm.rst +++ b/doc/sphinx/reference/vsm.rst @@ -102,3 +102,22 @@ a chance to discover the deallocation. The include file provides the supported API for accessing VSM files. + +VSM and Containers +------------------ + +The varnish way works great with single purpose containers. By sharing +the varnish working directory read-only, vsm clients can be run in +containers separate from those running varnishd instances on the same +host. + +When running varnishd and vsm clients in the same process namespace, +pid information can be used by vsm clients to determine if varnishd +processes are alive. + +But, when running varnishd and vsm clients in different containers, +the pid information has no relevance and may even be ambiguous across +name spaces. + +Thus, with such setups, the environment variable VSM_NOPID needs to be +set for vsm clients to disable use of pid information. diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index e7cc519..9d3ed85 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -191,6 +191,8 @@ VSM_New(void) vd->child = vsm_newset(VSM_CHILD_DIRNAME); vd->dfd = -1; vd->patience = 5; + if (getenv("VSM_NOPID") != NULL) + vd->couldkill = -1; return (vd); } @@ -350,7 +352,7 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) } if (vs->fd >= 0) { - if (!vd->couldkill || !kill(vs->id1, 0)) + if (vd->couldkill < 1 || !kill(vs->id1, 0)) retval |= VSM_MGT_RUNNING; return (retval); } @@ -385,9 +387,9 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; return (retval); } - if (!kill(id1, 0)) { + if (vd->couldkill >= 0 && !kill(id1, 0)) { vd->couldkill = 1; - } else if (vd->couldkill && errno == ESRCH) { + } else if (vd->couldkill > 0 && errno == ESRCH) { retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; return (retval); } From nils.goroll at uplex.de Fri Sep 8 17:39:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 8 Sep 2017 17:39:05 +0000 (UTC) Subject: [master] 8e0db2c bring back mlock() of vsm mappings Message-ID: <20170908173905.14237932F7@lists.varnish-cache.org> commit 8e0db2caaee32d87c098c345132832c71d018317 Author: Nils Goroll Date: Fri Sep 8 19:22:13 2017 +0200 bring back mlock() of vsm mappings It got lost during the new world order megacommit 74328de8eeb2703591fe59190f73fcabf057adbe diff --git a/lib/libvarnish/vsmw.c b/lib/libvarnish/vsmw.c index a5c7e3f..ee2a443 100644 --- a/lib/libvarnish/vsmw.c +++ b/lib/libvarnish/vsmw.c @@ -181,6 +181,7 @@ VSMW_Allocv(struct vsmw *vsmw, const char *class, size_t len, AZ(close(fd)); assert(seg->ptr != MAP_FAILED); + (void)mlock(seg->ptr, len); VTAILQ_INSERT_TAIL(&vsmw->segs, seg, list); fd = openat(vsmw->vdirfd, vsmw->idx, O_APPEND | O_WRONLY); From nils.goroll at uplex.de Fri Sep 8 17:39:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 8 Sep 2017 17:39:05 +0000 (UTC) Subject: [master] 1d5de12 Some progress with the vsm docs for new world order Message-ID: <20170908173905.2F4BC932FA@lists.varnish-cache.org> commit 1d5de1227165a3e7a03eab2b84408d156ef25eaf Author: Nils Goroll Date: Fri Sep 8 19:35:53 2017 +0200 Some progress with the vsm docs for new world order This still needs more TLC! Please feel free to continue... diff --git a/doc/sphinx/reference/vsm.rst b/doc/sphinx/reference/vsm.rst index a6a0713..7771b01 100644 --- a/doc/sphinx/reference/vsm.rst +++ b/doc/sphinx/reference/vsm.rst @@ -6,26 +6,20 @@ Varnish uses shared memory to export parameters, logging and statistics, because it is faster and much more efficient than regular files. -"Varnish Shared Memory" or VSM, is the overall mechanism, which -manages a number of allocated "chunks" inside the same shared -memory file. - -Each Chunk is just a slap of memory, which has -a three-part name (class, type, ident) and a length. +"Varnish Shared Memory" or VSM, is the overall mechanism maintaining +sets of shared memory files, each consisting a chunk of memory +identified by a two-part name (class, ident). The Class indicates what type of data is stored in the chunk, for instance "Arg" for command line arguments useful for establishing an CLI connection to the varnishd, "Stat" for statistics counters (VSC) and "Log" for log records (VSL). -The type and ident name parts are mostly used with stats -counters, where they identify dynamic counters, such as: +The ident name part is mostly used with stats counters, where they +identify dynamic counters, such as: SMA.Transient.c_bytes -The size of the VSM is a parameter, but changes only take -effect when the child process is restarted. - Shared memory trickery ---------------------- @@ -67,13 +61,14 @@ off" period. The Varnish way: ---------------- -If varnishd starts, and finds a locked shared memory file, it will -exit with a message about using different -n arguments if you want -multiple instances of varnishd. +.. XXX: not yet up to date with VSM new world order + +When varnishd starts, it opens locked shared memory files, advising to +use different -n arguments if an attempt is made to run multiple +varnishd instances with the same name. -Otherwise, it will create a new shared memory file each time it -starts a child process, since that marks a clean break in operation -anyway. +Child processes each use their own shared memory files, since a worker +process restart marks a clean break in operation anyway. To the extent possible, old shared memory files are marked as abandoned by setting the alloc_seq field to zero, which should be @@ -107,17 +102,17 @@ VSM and Containers ------------------ The varnish way works great with single purpose containers. By sharing -the varnish working directory read-only, vsm clients can be run in +the varnish working directory read-only, vsm readers can be run in containers separate from those running varnishd instances on the same host. -When running varnishd and vsm clients in the same process namespace, -pid information can be used by vsm clients to determine if varnishd +When running varnishd and vsm readers in the same process namespace, +pid information can be used by vsm readers to determine if varnishd processes are alive. -But, when running varnishd and vsm clients in different containers, +But, when running varnishd and vsm readers in different containers, the pid information has no relevance and may even be ambiguous across name spaces. Thus, with such setups, the environment variable VSM_NOPID needs to be -set for vsm clients to disable use of pid information. +set for vsm readers to disable use of pid information. From fgsch at lodoss.net Sun Sep 10 20:48:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 10 Sep 2017 20:48:06 +0000 (UTC) Subject: [master] ddf99e4 Remove blob operations from vmod-debug Message-ID: <20170910204806.6669B934C7@lists.varnish-cache.org> commit ddf99e4e8202c7b4831048ed0bfbed1844d46806 Author: Federico G. Schwindt Date: Sun Sep 10 19:02:24 2017 +0200 Remove blob operations from vmod-debug Missed in 32877991. diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 5a3ce7e..324d389 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -64,14 +64,6 @@ $Function STRING test_priv_top(PRIV_TOP, STRING) Test function for TOP private pointers -$Function BLOB str2blob(STRING src="foo") - -Turn a string into a blob - -$Function STRING blob2hex(BLOB src) - -Hexdump a blob - $Function BACKEND no_backend() Fails at backend selection diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index f4fac46..09312cf 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -151,42 +151,6 @@ vmod_test_priv_vcl(VRT_CTX, struct vmod_priv *priv) assert(!strcmp(priv_vcl->foo, "FOO")); } -VCL_BLOB -vmod_str2blob(VRT_CTX, VCL_STRING s) -{ - struct vmod_priv *p; - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - WARN_RETIRED(); - p = (void*)WS_Alloc(ctx->ws, sizeof *p); - AN(p); - memset(p, 0, sizeof *p); - p->len = strlen(s); - p->priv = WS_Copy(ctx->ws, s, -1); - return (p); -} - -VCL_STRING -vmod_blob2hex(VRT_CTX, VCL_BLOB b) -{ - char *s, *p; - uint8_t *q; - int i; - - WARN_RETIRED(); - s = WS_Alloc(ctx->ws, b->len * 2 + 2); - AN(s); - p = s; - q = b->priv; - for (i = 0; i < b->len; i++) { - assert(snprintf(p, 3, "%02x", *q) == 2); - p += 2; - q += 1; - } - VRT_priv_fini(b); - return (s); -} - VCL_BACKEND vmod_no_backend(VRT_CTX) { From fgsch at lodoss.net Sun Sep 10 20:48:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 10 Sep 2017 20:48:06 +0000 (UTC) Subject: [master] 4003d52 Update the travis-ci build Message-ID: <20170910204806.8C753934CA@lists.varnish-cache.org> commit 4003d522bbf5c65b8a6372ad60a42849fa63a950 Author: Federico G. Schwindt Date: Sun Sep 10 22:40:52 2017 +0200 Update the travis-ci build - Revert to previous trusty image (ref. google/sanitizers/issues/837) - Switch to xcode9 on osx - Scaffolding to get the sanitizer job using clang 5.0 - ASAN: Disable stack protector - ASAN: Ignore sigsegv and sigbus diff --git a/.travis.yml b/.travis.yml index 98239ec..a3b1cb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ --- sudo: required language: c +group: deprecated-2017Q3 matrix: include: - os: linux @@ -14,7 +15,7 @@ matrix: compiler: clang env: CLANG=4.0 - os: osx - osx_image: xcode8.3 + osx_image: xcode9 compiler: clang allow_failures: - os: osx @@ -28,16 +29,19 @@ before_install: brew update; brew install docutils nghttp2; fi - - if [[ "$CLANG" == "4.0" ]]; then + - if [[ -n "$CLANG" ]]; then wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -; sudo apt-add-repository -y - 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main'; + "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-$CLANG main"; + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA9EF27F; + sudo apt-add-repository -y + "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main"; sudo apt-get update; - sudo apt-get install -y clang-4.0 llvm-4.0; - export CC=clang-4.0; - export CONFIGURE_ARGS="--enable-developer-warnings --enable-debugging-symbols --enable-asan --enable-ubsan"; - export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1; + sudo apt-get install -y clang-$CLANG llvm-$CLANG; + export CC=clang-$CLANG; + export CONFIGURE_ARGS="--enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --enable-asan --enable-ubsan"; + export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0; export LSAN_OPTIONS=suppressions=$(pwd)/tools/lsan.suppr; export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,suppressions=$(pwd)/tools/ubsan.suppr; fi From dridi at varnish-software.com Sun Sep 10 21:05:20 2017 From: dridi at varnish-software.com (Dridi Boukelmoune) Date: Sun, 10 Sep 2017 23:05:20 +0200 Subject: [master] ddf99e4 Remove blob operations from vmod-debug In-Reply-To: <20170910204806.6669B934C7@lists.varnish-cache.org> References: <20170910204806.6669B934C7@lists.varnish-cache.org> Message-ID: That was left on purpose, we can discuss that tomorrow. There's a pull request to remove things that overlap with vmod vtc after the 5.2 release, phk wanted to keep them in despite vmod debug not being installed. Dridi On Sep 10, 2017 22:48, "Federico G. Schwindt" wrote: > > commit ddf99e4e8202c7b4831048ed0bfbed1844d46806 > Author: Federico G. Schwindt > Date: Sun Sep 10 19:02:24 2017 +0200 > > Remove blob operations from vmod-debug > > Missed in 32877991. > > diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc > index 5a3ce7e..324d389 100644 > --- a/lib/libvmod_debug/vmod.vcc > +++ b/lib/libvmod_debug/vmod.vcc > @@ -64,14 +64,6 @@ $Function STRING test_priv_top(PRIV_TOP, STRING) > > Test function for TOP private pointers > > -$Function BLOB str2blob(STRING src="foo") > - > -Turn a string into a blob > - > -$Function STRING blob2hex(BLOB src) > - > -Hexdump a blob > - > $Function BACKEND no_backend() > > Fails at backend selection > diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_ > debug.c > index f4fac46..09312cf 100644 > --- a/lib/libvmod_debug/vmod_debug.c > +++ b/lib/libvmod_debug/vmod_debug.c > @@ -151,42 +151,6 @@ vmod_test_priv_vcl(VRT_CTX, struct vmod_priv *priv) > assert(!strcmp(priv_vcl->foo, "FOO")); > } > > -VCL_BLOB > -vmod_str2blob(VRT_CTX, VCL_STRING s) > -{ > - struct vmod_priv *p; > - > - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); > - WARN_RETIRED(); > - p = (void*)WS_Alloc(ctx->ws, sizeof *p); > - AN(p); > - memset(p, 0, sizeof *p); > - p->len = strlen(s); > - p->priv = WS_Copy(ctx->ws, s, -1); > - return (p); > -} > - > -VCL_STRING > -vmod_blob2hex(VRT_CTX, VCL_BLOB b) > -{ > - char *s, *p; > - uint8_t *q; > - int i; > - > - WARN_RETIRED(); > - s = WS_Alloc(ctx->ws, b->len * 2 + 2); > - AN(s); > - p = s; > - q = b->priv; > - for (i = 0; i < b->len; i++) { > - assert(snprintf(p, 3, "%02x", *q) == 2); > - p += 2; > - q += 1; > - } > - VRT_priv_fini(b); > - return (s); > -} > - > VCL_BACKEND > vmod_no_backend(VRT_CTX) > { > _______________________________________________ > varnish-commit mailing list > varnish-commit at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit > -------------- next part -------------- An HTML attachment was scrubbed... URL: From phk at FreeBSD.org Sun Sep 10 21:38:03 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 10 Sep 2017 21:38:03 +0000 (UTC) Subject: [master] 07d4e75 Rewrite the .map file and only expose LIBVARNISHAPI_2.0 Message-ID: <20170910213803.AEC7593B08@lists.varnish-cache.org> commit 07d4e752952eee1151257a71a7ad310bc3b1a3e0 Author: Poul-Henning Kamp Date: Sun Sep 10 21:37:20 2017 +0000 Rewrite the .map file and only expose LIBVARNISHAPI_2.0 diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index aee341b..37d8e72 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -26,174 +26,115 @@ * SUCH DAMAGE. */ -LIBVARNISHAPI_1.0 { - global: - # Functions - VSM_New; - VSM_Diag; - VSM_n_Arg; - VSM_Name; - VSM_Delete; - VSM_Open; - VSM_ReOpen; - VSM_Seq; - VSM_Head; - VSM_Find_Chunk; - VSM_Close; - VSM__iter0; - VSM__itern; - - VSC_Setup; - VSC_Arg; - VSC_Open; - VSC_Main; - VSC_Iter; - - VSL_Setup; - VSL_Open; - VSL_Arg; - VSL_H_Print; - VSL_Select; - VSL_NonBlocking; - VSL_Dispatch; - VSL_NextLog; - VSL_Matched; - - VCLI_WriteResult; - VCLI_ReadResult; - VCLI_AuthResponse; - - # Variables - VSL_tags; - local: +LIBVARNISHAPI_2.0 { + global: + # vas.c + VAS_Fail; + + # vcli.c + VCLI_AuthResponse; + VCLI_ReadResult; + VCLI_WriteResult; + + # vcs.c + VCS_Message; + + # vsb.c + VSB_bcat; + VSB_cat; + VSB_clear; + VSB_data; + VSB_delete; + VSB_destroy; + VSB_error; + VSB_finish; + VSB_indent; + VSB_len; + VSB_new; + VSB_printf; + VSB_putc; + VSB_quote; + VSB_quote_pfx; + VSB_vprintf; + + # vsc.c + VSC_Arg; + VSC_ChangeLevel; + VSC_Destroy; + VSC_Iter; + VSC_New; + VSC_State; + + # vsl*.c + VSLQ_Delete; + VSLQ_Dispatch; + VSLQ_Flush; + VSLQ_Name2Grouping; + VSLQ_New; + VSLQ_SetCursor; + VSLQ_grouping; + VSL_Arg; + VSL_Check; + VSL_CursorFile; + VSL_CursorVSM; + VSL_Delete; + VSL_DeleteCursor; + VSL_Error; + VSL_Glob2Tags; + VSL_List2Tags; + VSL_Match; + VSL_Name2Tag; + VSL_New; + VSL_Next; + VSL_Print; + VSL_PrintAll; + VSL_PrintTerse; + VSL_PrintTransactions; + VSL_ResetCursor; + VSL_ResetError; + VSL_Write; + VSL_WriteAll; + VSL_WriteOpen; + VSL_WriteTransactions; + VSL_tagflags; + VSL_tags; + + # vsm.c + VSM_Arg; + VSM_Attach; + VSM_Destroy; + VSM_Dup; + VSM_Error; + VSM_Get; + VSM_Map; + VSM_New; + VSM_ResetError; + VSM_Status; + VSM_StillValid; + VSM_Unmap; + VSM__iter0; + VSM__itern; + VSM_invalid; + VSM_valid; + # vtim.c + VTIM_format; + VTIM_mono; + VTIM_parse; + VTIM_real; + VTIM_sleep; + VTIM_timespec; + VTIM_timeval; + + # vut.c + VUT; + VUT_Arg; + VUT_Error; + VUT_Fini; + VUT_Init; + VUT_Main; + VUT_Setup; + VUT_g_Arg; + + local: *; }; - -LIBVARNISHAPI_1.1 { - global: - # Functions: - VSL_Name2Tag; - # Variables: -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.2 { - global: - # Functions: - VSL_NextSLT; - VSM_Error; - VSM_Get; - # Variables: -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.3 { - global: - # Functions: - VSM_Abandoned; - VSM_ResetError; - VSM_StillValid; - VSC_Mgt; - VSC_LevelDesc; - VSL_New; - VSL_Delete; - VSL_Error; - VSL_ResetError; - VSL_CursorVSM; - VSL_CursorFile; - VSL_DeleteCursor; - VSL_Next; - VSL_Match; - VSL_Print; - VSL_PrintTerse; - VSL_PrintAll; - VSL_PrintTransactions; - VSL_WriteOpen; - VSL_Write; - VSL_WriteAll; - VSL_WriteTransactions; - VSLQ_New; - VSLQ_Delete; - VSLQ_Dispatch; - VSLQ_Flush; - VSLQ_Name2Grouping; - VSL_Glob2Tags; - VSL_List2Tags; - VSM_N_Arg; - VSL_Check; - VSL_ResetCursor; - # Variables: - VSLQ_grouping; - VSL_tagflags; -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.4 { - global: - VNUM; - VSLQ_SetCursor; - VSM_IsOpen; -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.5 { - global: - VUT_Error; - VUT_g_Arg; - VUT_Arg; - VUT_Setup; - VUT_Init; - VUT_Fini; - VUT_Main; - VUT; - - VTIM_mono; - VTIM_real; - VTIM_sleep; - - VSB_new; - VSB_destroy; - VSB_error; - VSB_cat; - VSB_putc; - VSB_printf; - VSB_clear; - VSB_finish; - VSB_len; - VSB_data; - - VAS_Fail; - - VCS_Message; -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.6 { - global: - VTIM_format; - VSB_bcat; - VSB_quote; - VSB_vprintf; - VSB_delete; - VSB_indent; - VTIM_parse; - VTIM_timespec; - VTIM_timeval; -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.7 { - global: - VSC_ChangeLevel; - VSM_invalid; - VSM_valid; - VSM_similar; - VSM_Start; - VSM_Destroy; - VSM_Map; - VSM_Unmap; - VSC_Destroy_Point; - VSC_Clone_Point; - VSM_Refresh; - VSM_Attach; - VSM_Status; - VSM_Arg; - VSM_Dup; - VSC_New; - VSC_Destroy; - VSC_State; -} LIBVARNISHAPI_1.0; From fgsch at lodoss.net Sun Sep 10 23:56:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 10 Sep 2017 23:56:04 +0000 (UTC) Subject: [master] f5ffd65 Fail the test if we panic when stopping the child Message-ID: <20170910235604.6441493DCA@lists.varnish-cache.org> commit f5ffd65d7250fc9457bf2c82371d3034e9498469 Author: Federico G. Schwindt Date: Mon Sep 11 01:53:10 2017 +0200 Fail the test if we panic when stopping the child diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index c7ee3c6..5853b70 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -38,4 +38,4 @@ client c1 { expect_close } -run -varnish v1 -cliok "panic.show" +varnish v1 -cliok "panic.clear" diff --git a/bin/varnishtest/tests/p00007.vtc b/bin/varnishtest/tests/p00007.vtc index 7cb0743..559f170 100644 --- a/bin/varnishtest/tests/p00007.vtc +++ b/bin/varnishtest/tests/p00007.vtc @@ -56,6 +56,8 @@ varnish v1 -cliok "debug.persistent s0 dump" # Panic worker so second segment does not get closed varnish v1 -clierr 400 "debug.panic.worker" +varnish v1 -cliok "panic.clear" + delay 0.5 # start again diff --git a/bin/varnishtest/tests/t02004.vtc b/bin/varnishtest/tests/t02004.vtc index 58e8743..24610d1 100644 --- a/bin/varnishtest/tests/t02004.vtc +++ b/bin/varnishtest/tests/t02004.vtc @@ -24,4 +24,4 @@ client c1 { expect_close } -run -varnish v1 -wait-stopped +varnish v1 -cliok "panic.clear" diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 6dfaae7..33cfcb9 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -137,8 +137,8 @@ wait_stopped(const struct varnish *v) char *r = NULL; enum VCLI_status_e st; + vtc_log(v->vl, 3, "wait-stopped"); while (1) { - vtc_log(v->vl, 3, "wait-stopped"); st = varnish_ask_cli(v, "status", &r); if (st != CLIS_OK) vtc_fatal(v->vl, @@ -600,26 +600,13 @@ varnish_start(struct varnish *v) static void varnish_stop(struct varnish *v) { - char *r = NULL; - if (v->cli_fd < 0) varnish_launch(v); if (vtc_error) return; vtc_log(v->vl, 2, "Stop"); (void)varnish_ask_cli(v, "stop", NULL); - while (1) { - (void)varnish_ask_cli(v, "status", &r); - AN(r); - if (!strcmp(r, "Child in state stopped")) { - free(r); - break; - } - free(r); - r = NULL; - (void)sleep (1); - /* XXX: should fail eventually */ - } + wait_stopped(v); } /********************************************************************** @@ -685,6 +672,9 @@ varnish_wait(struct varnish *v) /* Then stop it */ varnish_stop(v); + if (varnish_ask_cli(v, "panic.clear", NULL) != CLIS_CANT) + vtc_fatal(v->vl, "Unexpected panic"); + varnish_cleanup(v); } From phk at FreeBSD.org Mon Sep 11 07:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Sep 2017 07:46:05 +0000 (UTC) Subject: [master] 90757fc Clean up and systematize our blessed vmod's Makefile.am Message-ID: <20170911074605.DC4B993FD7@lists.varnish-cache.org> commit 90757fc3aef6a08b2211804284f62f389c1bb862 Author: Poul-Henning Kamp Date: Mon Sep 11 07:39:39 2017 +0000 Clean up and systematize our blessed vmod's Makefile.am diff --git a/lib/libvmod_blob/Makefile.am b/lib/libvmod_blob/Makefile.am index b0de15f..bb7b363 100644 --- a/lib/libvmod_blob/Makefile.am +++ b/lib/libvmod_blob/Makefile.am @@ -1,4 +1,23 @@ # + +libvmod_blob_la_SOURCES = \ + vmod_blob.c \ + vmod_blob.h \ + id.c \ + base64.h \ + base64.c \ + hex.h \ + hex.c \ + url.c \ + wb.h \ + wb.c \ + parse_encoding.h \ + parse_encoding.c + +base64.o: base64.c base64.h + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -10,42 +29,34 @@ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_blob vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs = --strict + vmod_LTLIBRARIES = libvmod_blob.la libvmod_blob_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_blob_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ +libvmod_blob_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_blob_la_SOURCES = \ - vmod_blob.c \ - vmod_blob.h \ - id.c \ - base64.h \ - base64.c \ - hex.h \ - hex.c \ - url.c \ - wb.h \ - wb.c \ - parse_encoding.h \ - parse_encoding.c - nodist_libvmod_blob_la_SOURCES = \ vcc_if.c \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_blob_la_OBJECTS):vcc_if.h +$(libvmod_blob_la_OBJECTS): vcc_if.h vcc_if.h vmod_blob.rst vmod_blob.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc -base64.o: base64.c base64.h - EXTRA_DIST = vmod.vcc CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index 4376ef5..58bd825 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -1,4 +1,12 @@ # + +libvmod_debug_la_SOURCES = \ + vmod_debug.c \ + vmod_debug_obj.c \ + vmod_debug_dyn.c + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -9,27 +17,30 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_debug vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = +vmodtoolargs = --strict + noinst_LTLIBRARIES = libvmod_debug.la libvmod_debug_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_debug_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared -rpath /nowhere \ +libvmod_debug_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_debug_la_SOURCES = \ - vmod_debug.c \ - vmod_debug_obj.c \ - vmod_debug_dyn.c - nodist_libvmod_debug_la_SOURCES = \ vcc_if.c \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_debug_la_OBJECTS):vcc_if.h +$(libvmod_debug_la_OBJECTS): vcc_if.h vcc_if.h vmod_debug.rst vmod_debug.man.rst: vcc_if.c diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 324d389..2ed8a9e 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -37,8 +37,6 @@ of VMOD handling in Varnish. $Event event_function -You are not supposed to be able to see this text in the .RST - $Function VOID panic(STRING_LIST) Don't. diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index dfcbbee..23bcf94 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -1,22 +1,4 @@ # -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_directors -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict -vmod_LTLIBRARIES = libvmod_directors.la - -libvmod_directors_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_directors_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ - @SAN_LDFLAGS@ libvmod_directors_la_SOURCES = \ vdir.c \ @@ -35,19 +17,47 @@ libvmod_directors_la_SOURCES = \ shard_parse_vcc_enums.h \ shard_parse_vcc_enums.c +# Boilerplate, do not change + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmod_srcdir = $(top_srcdir)/lib/libvmod_directors +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict + +vmod_LTLIBRARIES = libvmod_directors.la + +libvmod_directors_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_directors_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ + @SAN_LDFLAGS@ + nodist_libvmod_directors_la_SOURCES = \ vcc_if.c \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_directors_la_OBJECTS):vcc_if.h +$(libvmod_directors_la_OBJECTS): vcc_if.h vcc_if.h vmod_directors.rst vmod_directors.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - EXTRA_DIST = vmod.vcc CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ diff --git a/lib/libvmod_purge/Makefile.am b/lib/libvmod_purge/Makefile.am index 4a1098b..44a69cb 100644 --- a/lib/libvmod_purge/Makefile.am +++ b/lib/libvmod_purge/Makefile.am @@ -1,5 +1,10 @@ # +libvmod_purge_la_SOURCES = \ + vmod_purge.c + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -11,16 +16,22 @@ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_purge vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs = --strict + vmod_LTLIBRARIES = libvmod_purge.la libvmod_purge_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_purge_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ +libvmod_purge_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_purge_la_SOURCES = vmod_purge.c - nodist_libvmod_purge_la_SOURCES = \ vcc_if.c \ vcc_if.h diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index ec9580c..2ddf28b 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -1,5 +1,13 @@ # +libvmod_std_la_SOURCES = \ + vmod_std.c \ + vmod_std_conversions.c \ + vmod_std_fileread.c \ + vmod_std_querysort.c + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -11,20 +19,22 @@ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_std vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs = --strict + vmod_LTLIBRARIES = libvmod_std.la libvmod_std_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_std_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ +libvmod_std_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_std_la_SOURCES = \ - vmod_std.c \ - vmod_std_conversions.c \ - vmod_std_fileread.c \ - vmod_std_querysort.c - nodist_libvmod_std_la_SOURCES = \ vcc_if.c \ vcc_if.h diff --git a/lib/libvmod_vtc/Makefile.am b/lib/libvmod_vtc/Makefile.am index 98baa91..fbf1d0d 100644 --- a/lib/libvmod_vtc/Makefile.am +++ b/lib/libvmod_vtc/Makefile.am @@ -1,4 +1,10 @@ # + +libvmod_vtc_la_SOURCES = \ + vmod_vtc.c + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -9,25 +15,29 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_vtc vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = +vmodtoolargs = --strict vmod_LTLIBRARIES = libvmod_vtc.la libvmod_vtc_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_vtc_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared -rpath /nowhere \ +libvmod_vtc_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_vtc_la_SOURCES = \ - vmod_vtc.c - nodist_libvmod_vtc_la_SOURCES = \ vcc_if.c \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_vtc_la_OBJECTS):vcc_if.h +$(libvmod_vtc_la_OBJECTS): vcc_if.h vcc_if.h vmod_vtc.rst vmod_vtc.man.rst: vcc_if.c From phk at FreeBSD.org Mon Sep 11 08:30:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Sep 2017 08:30:07 +0000 (UTC) Subject: [master] df662d1 Dont filter VMOD symbols just yet. Message-ID: <20170911083007.BA6D99306B@lists.varnish-cache.org> commit df662d17b69781b99861a47825c36e0232d38d23 Author: Poul-Henning Kamp Date: Mon Sep 11 08:29:31 2017 +0000 Dont filter VMOD symbols just yet. diff --git a/lib/libvmod_blob/Makefile.am b/lib/libvmod_blob/Makefile.am index bb7b363..15522e1 100644 --- a/lib/libvmod_blob/Makefile.am +++ b/lib/libvmod_blob/Makefile.am @@ -41,7 +41,6 @@ libvmod_blob_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index 58bd825..d328960 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -31,7 +31,6 @@ libvmod_debug_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index 23bcf94..5910add 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -42,7 +42,6 @@ libvmod_directors_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_purge/Makefile.am b/lib/libvmod_purge/Makefile.am index 44a69cb..aa88be7 100644 --- a/lib/libvmod_purge/Makefile.am +++ b/lib/libvmod_purge/Makefile.am @@ -28,7 +28,6 @@ libvmod_purge_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index 2ddf28b..ba57322 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -31,7 +31,6 @@ libvmod_std_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_vtc/Makefile.am b/lib/libvmod_vtc/Makefile.am index fbf1d0d..45c141f 100644 --- a/lib/libvmod_vtc/Makefile.am +++ b/lib/libvmod_vtc/Makefile.am @@ -28,7 +28,6 @@ libvmod_vtc_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ From dridi.boukelmoune at gmail.com Mon Sep 11 09:41:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 09:41:06 +0000 (UTC) Subject: [master] 53ad9f1 Update stale comment Message-ID: <20170911094106.0CD1D93105@lists.varnish-cache.org> commit 53ad9f1f9b4c129fc559d420a99855a9340703aa Author: Dridi Boukelmoune Date: Fri Sep 8 15:24:48 2017 +0200 Update stale comment diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 2a2435c..55fa342 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -259,7 +259,7 @@ hsh_testmagic(void *result) /*--------------------------------------------------------------------- * Insert an object which magically appears out of nowhere or, more likely, * comes off some persistent storage device. - * Return it with a reference held. + * Insert it with a reference held. */ void From dridi.boukelmoune at gmail.com Mon Sep 11 09:41:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 09:41:06 +0000 (UTC) Subject: [master] c4d1309 Pack prototypes in the order they are used Message-ID: <20170911094106.2A7A993108@lists.varnish-cache.org> commit c4d1309a80ba89b77de9d030d9c209ada0052f91 Author: Dridi Boukelmoune Date: Tue Apr 18 09:16:16 2017 +0200 Pack prototypes in the order they are used diff --git a/include/vut.h b/include/vut.h index 346d7bd..e47ff79 100644 --- a/include/vut.h +++ b/include/vut.h @@ -73,11 +73,9 @@ int VUT_g_Arg(const char *arg); int VUT_Arg(int opt, const char *arg); -void VUT_Setup(void); - void VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *); +void VUT_Setup(void); +int VUT_Main(void); void VUT_Fini(void); - -int VUT_Main(void); From dridi.boukelmoune at gmail.com Mon Sep 11 09:41:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 09:41:06 +0000 (UTC) Subject: [master] 12814ef Whitespace OCD Message-ID: <20170911094106.4E8E49310C@lists.varnish-cache.org> commit 12814efb6d7c7d55e6bb44e260a264d74a032a0a Author: Dridi Boukelmoune Date: Tue Apr 18 09:17:28 2017 +0200 Whitespace OCD diff --git a/include/vut_options.h b/include/vut_options.h index 5e6d094..9f0ad78 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -29,7 +29,7 @@ /* VUT options */ -#define VUT_OPT_d \ +#define VUT_OPT_d \ VOPT("d", "[-d]", "Process old log entries and exit", \ "Process log records at the head of the log and exit." \ ) From dridi.boukelmoune at gmail.com Mon Sep 11 09:41:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 09:41:06 +0000 (UTC) Subject: [master] aa35082 Simplify VUT options initialization Message-ID: <20170911094106.7B44493111@lists.varnish-cache.org> commit aa35082583106c65d6c3166d169a9f11ee37d572 Author: Dridi Boukelmoune Date: Tue Apr 18 09:27:48 2017 +0200 Simplify VUT options initialization We don't need an indirection in a separate C file per VUT. diff --git a/bin/varnishhist/Makefile.am b/bin/varnishhist/Makefile.am index 281c05a..9c58a86 100644 --- a/bin/varnishhist/Makefile.am +++ b/bin/varnishhist/Makefile.am @@ -6,10 +6,10 @@ AM_CPPFLAGS = \ bin_PROGRAMS = varnishhist -varnishhist_SOURCES = varnishhist.c \ +varnishhist_SOURCES = \ + varnishhist.c \ varnishhist_options.h \ - varnishhist_profiles.h \ - varnishhist_options.c + varnishhist_profiles.h varnishhist_CFLAGS = \ @SAN_CFLAGS@ diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 27afddc..6dc3aa9 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -42,6 +42,9 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishhist_options.h" + #include "vdef.h" #include "vcurses.h" #include "vapi/vsl.h" diff --git a/bin/varnishhist/varnishhist_options.c b/bin/varnishhist/varnishhist_options.c deleted file mode 100644 index c4f5d27..0000000 --- a/bin/varnishhist/varnishhist_options.c +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2014 Varnish Software AS - * All rights reserved. - * - * Author: Martin Blix Grydeland - * - * 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. - * - * Option definitions for varnishhist - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishhist_options.h" -#include "vapi/voptget.h" diff --git a/bin/varnishlog/Makefile.am b/bin/varnishlog/Makefile.am index 28d5e67..9fccdc5 100644 --- a/bin/varnishlog/Makefile.am +++ b/bin/varnishlog/Makefile.am @@ -8,8 +8,7 @@ bin_PROGRAMS = varnishlog varnishlog_SOURCES = \ varnishlog.c \ - varnishlog_options.h \ - varnishlog_options.c + varnishlog_options.h varnishlog_CFLAGS = \ @SAN_CFLAGS@ diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 87f98a3..8018f7b 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -39,6 +39,10 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishlog_options.h" + +#include "vapi/vsm.h" #include "vapi/vsl.h" #include "vapi/voptget.h" #include "vas.h" diff --git a/bin/varnishlog/varnishlog_options.c b/bin/varnishlog/varnishlog_options.c deleted file mode 100644 index b12d3e4..0000000 --- a/bin/varnishlog/varnishlog_options.c +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS - * All rights reserved. - * - * Author: Martin Blix Grydeland - * - * 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. - * - * Option definitions for varnishlog - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishlog_options.h" -#include "vapi/voptget.h" diff --git a/bin/varnishncsa/Makefile.am b/bin/varnishncsa/Makefile.am index b970910..cbed83b 100644 --- a/bin/varnishncsa/Makefile.am +++ b/bin/varnishncsa/Makefile.am @@ -9,7 +9,6 @@ bin_PROGRAMS = varnishncsa varnishncsa_SOURCES = \ varnishncsa.c \ varnishncsa_options.h \ - varnishncsa_options.c \ base64.h \ base64.c diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 99413a1..0fa722f 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -53,6 +53,9 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishncsa_options.h" + #include "base64.h" #include "vapi/vsl.h" #include "vapi/voptget.h" diff --git a/bin/varnishncsa/varnishncsa_options.c b/bin/varnishncsa/varnishncsa_options.c deleted file mode 100644 index 44e3dfe..0000000 --- a/bin/varnishncsa/varnishncsa_options.c +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2013-2015 Varnish Software AS - * All rights reserved. - * - * Author: Martin Blix Grydeland - * - * 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. - * - * Option definitions for varnishlog - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishncsa_options.h" -#include "vapi/voptget.h" diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index 9e404bb..c13bcd3 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -10,8 +10,7 @@ varnishstat_SOURCES = \ varnishstat.h \ varnishstat.c \ varnishstat_curses.c \ - varnishstat_options.h \ - varnishstat_options.c + varnishstat_options.h varnishstat_CFLAGS = \ @SAN_CFLAGS@ diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index d114281..aa268c9 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -39,6 +39,9 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishstat_options.h" + #include "vapi/voptget.h" #include "vapi/vsl.h" #include "vdef.h" diff --git a/bin/varnishstat/varnishstat_options.c b/bin/varnishstat/varnishstat_options.c deleted file mode 100644 index 60b8d28..0000000 --- a/bin/varnishstat/varnishstat_options.c +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2016 Varnish Software AS - * All rights reserved. - * - * Author: Federico G. Schwindt - * - * 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. - * - * Option definitions for varnishstat - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishstat_options.h" -#include "vapi/voptget.h" diff --git a/bin/varnishtop/Makefile.am b/bin/varnishtop/Makefile.am index 68adae8..d6923c1 100644 --- a/bin/varnishtop/Makefile.am +++ b/bin/varnishtop/Makefile.am @@ -6,9 +6,9 @@ AM_CPPFLAGS = \ bin_PROGRAMS = varnishtop -varnishtop_SOURCES = varnishtop.c \ - varnishtop_options.h \ - varnishtop_options.c +varnishtop_SOURCES = \ + varnishtop.c \ + varnishtop_options.h varnishtop_CFLAGS = \ diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 1d7ebe0..07386ed 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -42,6 +42,9 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishtop_options.h" + #include "vcurses.h" #include "vapi/vsl.h" #include "vapi/vsm.h" diff --git a/bin/varnishtop/varnishtop_options.c b/bin/varnishtop/varnishtop_options.c deleted file mode 100644 index 58d132e..0000000 --- a/bin/varnishtop/varnishtop_options.c +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2014 Varnish Software AS - * All rights reserved. - * - * Author: Martin Blix Grydeland - * - * 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. - * - * Option definitions for varnishtop - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishtop_options.h" -#include "vapi/voptget.h" From dridi.boukelmoune at gmail.com Mon Sep 11 09:41:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 09:41:06 +0000 (UTC) Subject: [master] ab14ed4 Help flexelint find the path of this VUT_Arg call Message-ID: <20170911094106.9462B93114@lists.varnish-cache.org> commit ab14ed43af718a0e2fcdd61be40abe1f3fb17c44 Author: Dridi Boukelmoune Date: Tue Apr 25 09:40:48 2017 +0200 Help flexelint find the path of this VUT_Arg call diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 6dc3aa9..1a51afe 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -586,6 +586,8 @@ main(int argc, char **argv) if (!active_profile->name) VUT_Error(1, "-P: No such profile '%s'", profile); + assert(active_profile->VSL_arg == 'b' || + active_profile->VSL_arg == 'c'); assert(VUT_Arg(active_profile->VSL_arg, NULL)); match_tag = active_profile->tag; fnum = active_profile->field; From dridi.boukelmoune at gmail.com Mon Sep 11 09:41:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 09:41:06 +0000 (UTC) Subject: [master] 063be1b Assert when an optarg is expected Message-ID: <20170911094106.B07AB9312B@lists.varnish-cache.org> commit 063be1b636088c32b87e53d7ea43a92b544c7a29 Author: Dridi Boukelmoune Date: Tue Apr 25 09:41:59 2017 +0200 Assert when an optarg is expected diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 355299e..26f5673 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -153,6 +153,7 @@ VUT_Arg(int opt, const char *arg) return (1); case 'g': /* Grouping */ + AN(arg); return (VUT_g_Arg(arg)); case 'k': /* Log transaction limit */ @@ -163,18 +164,22 @@ VUT_Arg(int opt, const char *arg) return (1); case 'n': /* Varnish instance name */ + AN(arg); REPLACE(VUT.n_arg, arg); return (1); case 'P': /* PID file */ + AN(arg); REPLACE(VUT.P_arg, arg); return (1); case 'q': /* Query to use */ + AN(arg); REPLACE(VUT.q_arg, arg); return (1); case 'r': /* Binary file input */ + AN(arg); REPLACE(VUT.r_arg, arg); return (1); case 't': From dridi.boukelmoune at gmail.com Mon Sep 11 09:41:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 09:41:06 +0000 (UTC) Subject: [master] ae6d8f5 Remove the VUT_g_Arg special case Message-ID: <20170911094106.CD59193145@lists.varnish-cache.org> commit ae6d8f57693576f8e9463170297734ca1f1648eb Author: Dridi Boukelmoune Date: Tue Sep 5 10:08:40 2017 +0200 Remove the VUT_g_Arg special case It's no longer used anyway, and was already called via the generic VUT_Arg function. diff --git a/include/vut.h b/include/vut.h index e47ff79..aab3608 100644 --- a/include/vut.h +++ b/include/vut.h @@ -69,8 +69,6 @@ extern struct VUT VUT; void VUT_Error(int status, const char *fmt, ...) __v_printflike(2, 3) __attribute__((__noreturn__)); -int VUT_g_Arg(const char *arg); - int VUT_Arg(int opt, const char *arg); void VUT_Init(const char *progname, int argc, char * const *argv, diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 37d8e72..e3e343d 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -133,7 +133,6 @@ LIBVARNISHAPI_2.0 { VUT_Init; VUT_Main; VUT_Setup; - VUT_g_Arg; local: *; diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 26f5673..9ce1af5 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -125,18 +125,6 @@ VUT_Error(int status, const char *fmt, ...) } int -VUT_g_Arg(const char *arg) -{ - - VUT.g_arg = VSLQ_Name2Grouping(arg, -1); - if (VUT.g_arg == -2) - VUT_Error(1, "Ambiguous grouping type: %s", arg); - else if (VUT.g_arg < 0) - VUT_Error(1, "Unknown grouping type: %s", arg); - return (1); -} - -int VUT_Arg(int opt, const char *arg) { int i; @@ -154,7 +142,12 @@ VUT_Arg(int opt, const char *arg) case 'g': /* Grouping */ AN(arg); - return (VUT_g_Arg(arg)); + VUT.g_arg = VSLQ_Name2Grouping(arg, -1); + if (VUT.g_arg == -2) + VUT_Error(1, "Ambiguous grouping type: %s", arg); + else if (VUT.g_arg < 0) + VUT_Error(1, "Unknown grouping type: %s", arg); + return (1); case 'k': /* Log transaction limit */ AN(arg); From dridi.boukelmoune at gmail.com Mon Sep 11 09:41:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 09:41:06 +0000 (UTC) Subject: [master] 35ffe6a Merge VUT signal handlers together Message-ID: <20170911094106.EA49D93155@lists.varnish-cache.org> commit 35ffe6a6f226e5c14783ac86340579bb12eac297 Author: Dridi Boukelmoune Date: Fri Sep 8 15:29:57 2017 +0200 Merge VUT signal handlers together diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 9ce1af5..4057c3f 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -71,24 +71,12 @@ vut_vpf_remove(void) } static void -vut_sighup(int sig) +vut_signal(int sig) { - (void)sig; - VUT.sighup = 1; -} -static void -vut_sigint(int sig) -{ - (void)sig; - VUT.sigint = 1; -} - -static void -vut_sigusr1(int sig) -{ - (void)sig; - VUT.sigusr1 = 1; + VUT.sighup |= (sig == SIGHUP); + VUT.sigint |= (sig == SIGINT || sig == SIGTERM); + VUT.sigusr1 |= (sig == SIGUSR1); } static int __match_proto__(VSLQ_dispatch_f) @@ -255,10 +243,10 @@ VUT_Setup(void) } /* Signal handlers */ - (void)signal(SIGHUP, vut_sighup); - (void)signal(SIGINT, vut_sigint); - (void)signal(SIGTERM, vut_sigint); - (void)signal(SIGUSR1, vut_sigusr1); + (void)signal(SIGHUP, vut_signal); + (void)signal(SIGINT, vut_signal); + (void)signal(SIGTERM, vut_signal); + (void)signal(SIGUSR1, vut_signal); /* Open PID file */ if (VUT.P_arg) { From nils.goroll at uplex.de Mon Sep 11 10:36:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Sep 2017 10:36:06 +0000 (UTC) Subject: [master] 421ebab Move the sigaltstack init to a generic THR_Init() and use it for all threads Message-ID: <20170911103607.0549594AEE@lists.varnish-cache.org> commit 421ebab3589fde462f551b1ff0103a646afbc25a Author: Nils Goroll Date: Mon Sep 11 12:34:32 2017 +0200 Move the sigaltstack init to a generic THR_Init() and use it for all threads diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 91f5c08..8da85ae 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -524,6 +524,7 @@ vca_acct(void *arg) double t0, now; THR_SetName("cache-acceptor"); + THR_Init(); (void)arg; (void)vca_tcp_opt_init(); diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 8602fcf..684d456 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -113,6 +113,22 @@ THR_GetName(void) } /*-------------------------------------------------------------------- + * Generic setup all our threads should call + */ +#ifdef HAVE_SIGALTSTACK +#include +extern stack_t altstack; +#endif + +void +THR_Init(void) +{ +#ifdef HAVE_SIGALTSTACK + AZ(sigaltstack(&altstack, NULL)); +#endif +} + +/*-------------------------------------------------------------------- * VXID's are unique transaction numbers allocated with a minimum of * locking overhead via pools in the worker threads. * diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 98c22f0..0e05bcc 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -104,6 +104,7 @@ mpl_guard(void *priv) CAST_OBJ_NOTNULL(mpl, priv, MEMPOOL_MAGIC); THR_SetName(mpl->name); + THR_Init(); mpl_slp = 0.15; // random while (1) { VTIM_sleep(mpl_slp); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 0bf34f2..595e836 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -187,6 +187,7 @@ pool_poolherder(void *priv) void *rvp; THR_SetName("pool_poolherder"); + THR_Init(); (void)priv; nwq = 0; diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index 941d567..18bb141 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -88,6 +88,7 @@ void THR_SetBusyobj(const struct busyobj *); struct busyobj * THR_GetBusyobj(void); void THR_SetRequest(const struct req *); struct req * THR_GetRequest(void); +void THR_Init(void); /* cache_lck.c */ void LCK_Init(void); diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index cf2948b..8735929 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -41,11 +41,6 @@ #include "hash/hash_slinger.h" -#ifdef HAVE_SIGALTSTACK -#include -extern stack_t altstack; -#endif - static void Pool_Work_Thread(struct pool *pp, struct worker *wrk); /*-------------------------------------------------------------------- @@ -70,6 +65,7 @@ wrk_bgthread(void *arg) CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC); THR_SetName(bt->name); + THR_Init(); INIT_OBJ(&wrk, WORKER_MAGIC); memset(&ds, 0, sizeof ds); wrk.stats = &ds; @@ -406,9 +402,7 @@ pool_thread(void *priv) struct pool_info *pi; CAST_OBJ_NOTNULL(pi, priv, POOL_INFO_MAGIC); -#ifdef HAVE_SIGALTSTACK - AZ(sigaltstack(&altstack, NULL)); -#endif + THR_Init(); WRK_Thread(pi->qp, pi->stacksize, cache_param->workspace_thread); FREE_OBJ(pi); return (NULL); @@ -483,6 +477,7 @@ pool_herder(void *priv) CAST_OBJ_NOTNULL(pp, priv, POOL_MAGIC); THR_SetName("pool_herder"); + THR_Init(); while (!pp->die || pp->nthr > 0) { wthread_min = cache_param->wthread_min; diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 5c40597..358d2be 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -80,6 +80,7 @@ vwe_thread(void *priv) w = vwe->waiter; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-epoll"); + THR_Init(); now = VTIM_real(); while (1) { diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 5d06b2d..ff870e7 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -75,6 +75,7 @@ vwk_thread(void *priv) w = vwk->waiter; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-kqueue"); + THR_Init(); now = VTIM_real(); while (1) { diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index ee70140..52e4de3 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -161,6 +161,7 @@ vwp_main(void *priv) int i; THR_SetName("cache-poll"); + THR_Init(); CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC); w = vwp->waiter; diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index b7259bf..3a1dc49 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -152,6 +152,7 @@ vws_thread(void *priv) w = vws->waiter; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-ports"); + THR_Init(); now = VTIM_real(); From nils.goroll at uplex.de Mon Sep 11 10:36:07 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Sep 2017 10:36:07 +0000 (UTC) Subject: [master] 7f7be28 try to stabilize this test Message-ID: <20170911103607.227AB94AF1@lists.varnish-cache.org> commit 7f7be284ceabaeef765bf705386e0586e22f8984 Author: Nils Goroll Date: Mon Sep 11 12:35:35 2017 +0200 try to stabilize this test diff --git a/bin/varnishtest/tests/p00007.vtc b/bin/varnishtest/tests/p00007.vtc index 559f170..6b9e1be 100644 --- a/bin/varnishtest/tests/p00007.vtc +++ b/bin/varnishtest/tests/p00007.vtc @@ -56,6 +56,8 @@ varnish v1 -cliok "debug.persistent s0 dump" # Panic worker so second segment does not get closed varnish v1 -clierr 400 "debug.panic.worker" +delay 0.5 + varnish v1 -cliok "panic.clear" delay 0.5 From phk at FreeBSD.org Mon Sep 11 10:45:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Sep 2017 10:45:07 +0000 (UTC) Subject: [master] 6bf7a9e De-boilerplate the "normal" vmods in the tree. Message-ID: <20170911104507.8C13594008@lists.varnish-cache.org> commit 6bf7a9ed9b14ce1958213023a4458dee067226e4 Author: Poul-Henning Kamp Date: Mon Sep 11 10:36:51 2017 +0000 De-boilerplate the "normal" vmods in the tree. There are undoubtedly better ways, but I couldn't find them... diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index ab78cff..b7f58e5 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -46,6 +46,49 @@ import random rstfmt = False strict_abi = True +AMBOILERPLATE=''' +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \\ + -I$(top_srcdir)/include \\ + -I$(top_srcdir)/bin/varnishd \\ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_XXX.la + +libvmod_XXX_la_CFLAGS = \\ + @SAN_CFLAGS@ + +libvmod_XXX_la_LDFLAGS = \\ + $(AM_LDFLAGS) \\ + $(VMOD_LDFLAGS) \\ + @SAN_LDFLAGS@ + +nodist_libvmod_XXX_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_XXX_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_XXX.rst vmod_XXX.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \\ + $(builddir)/vmod_XXX.rst \\ + $(builddir)/vmod_XXX.man.rst + +''' + ctypes = { 'ACL': "VCL_ACL", 'BACKEND': "VCL_BACKEND", @@ -701,6 +744,13 @@ class vcc(object): fo.close() + def amboilerplate(self): + fn = "automake_boilerplate.am" + self.commit_files.append(fn) + fo = open(fn + ".tmp", "w") + fo.write(AMBOILERPLATE.replace("XXX", self.modname)) + fo.close() + def hfile(self): fn = self.pfx + ".h" self.commit_files.append(fn) @@ -831,6 +881,8 @@ def runmain(inputvcc, rstdir, outputprefix): v.rstfile(man=True) v.hfile() v.cfile() + if opts.boilerplate: + v.amboilerplate() v.commit() @@ -838,6 +890,9 @@ if __name__ == "__main__": usagetext = "Usage: %prog [options] " oparser = optparse.OptionParser(usage=usagetext) + oparser.add_option('-b', '--boilerplate', action='store_true', + default=False, + help="Be strict when parsing the input file") oparser.add_option('-N', '--strict', action='store_true', default=False, help="Be strict when parsing the input file") oparser.add_option('-o', '--output', metavar="prefix", default='vcc_if', diff --git a/lib/libvmod_blob/Makefile.am b/lib/libvmod_blob/Makefile.am index 15522e1..7b5ce59 100644 --- a/lib/libvmod_blob/Makefile.am +++ b/lib/libvmod_blob/Makefile.am @@ -16,48 +16,5 @@ libvmod_blob_la_SOURCES = \ base64.o: base64.c base64.h -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_blob -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_blob.la - -libvmod_blob_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_blob_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_blob_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_blob_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_blob.rst vmod_blob.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_blob.rst \ - $(builddir)/vmod_blob.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am new file mode 100644 index 0000000..3b4ed7a --- /dev/null +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_blob.la + +libvmod_blob_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_blob_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_blob_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_blob_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_blob.rst vmod_blob.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_blob.rst \ + $(builddir)/vmod_blob.man.rst + diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index 5910add..ff0c244 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -17,48 +17,5 @@ libvmod_directors_la_SOURCES = \ shard_parse_vcc_enums.h \ shard_parse_vcc_enums.c -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_directors -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_directors.la - -libvmod_directors_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_directors_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_directors_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_directors_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_directors.rst vmod_directors.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_directors.rst \ - $(builddir)/vmod_directors.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am new file mode 100644 index 0000000..19e10a3 --- /dev/null +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_directors.la + +libvmod_directors_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_directors_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_directors_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_directors_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_directors.rst vmod_directors.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_directors.rst \ + $(builddir)/vmod_directors.man.rst + diff --git a/lib/libvmod_purge/Makefile.am b/lib/libvmod_purge/Makefile.am index aa88be7..38e1e58 100644 --- a/lib/libvmod_purge/Makefile.am +++ b/lib/libvmod_purge/Makefile.am @@ -3,48 +3,5 @@ libvmod_purge_la_SOURCES = \ vmod_purge.c -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_purge -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_purge.la - -libvmod_purge_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_purge_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_purge_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_purge_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_purge.rst vmod_purge.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_purge.rst \ - $(builddir)/vmod_purge.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am new file mode 100644 index 0000000..3a5b4a5 --- /dev/null +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_purge.la + +libvmod_purge_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_purge_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_purge_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_purge_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_purge.rst vmod_purge.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_purge.rst \ + $(builddir)/vmod_purge.man.rst + diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index ba57322..8bde752 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -6,48 +6,5 @@ libvmod_std_la_SOURCES = \ vmod_std_fileread.c \ vmod_std_querysort.c -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_std -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_std.la - -libvmod_std_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_std_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_std_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_std_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_std.rst vmod_std.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_std.rst \ - $(builddir)/vmod_std.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am new file mode 100644 index 0000000..66410b0 --- /dev/null +++ b/lib/libvmod_std/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_std.la + +libvmod_std_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_std_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_std_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_std_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_std.rst vmod_std.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_std.rst \ + $(builddir)/vmod_std.man.rst + diff --git a/lib/libvmod_vtc/Makefile.am b/lib/libvmod_vtc/Makefile.am index 45c141f..3575d7e 100644 --- a/lib/libvmod_vtc/Makefile.am +++ b/lib/libvmod_vtc/Makefile.am @@ -3,48 +3,5 @@ libvmod_vtc_la_SOURCES = \ vmod_vtc.c -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_vtc -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_vtc.la - -libvmod_vtc_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_vtc_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_vtc_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_vtc_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_vtc.rst vmod_vtc.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_vtc.rst \ - $(builddir)/vmod_vtc.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am new file mode 100644 index 0000000..1eb8f6f --- /dev/null +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_vtc.la + +libvmod_vtc_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_vtc_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_vtc_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_vtc_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_vtc.rst vmod_vtc.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_vtc.rst \ + $(builddir)/vmod_vtc.man.rst + From phk at FreeBSD.org Mon Sep 11 11:20:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Sep 2017 11:20:07 +0000 (UTC) Subject: [master] 3656e3b Now filter the vmods symbols, and make libvmod_debug exercise the $Event RST test again. Message-ID: <20170911112007.24EA894C5F@lists.varnish-cache.org> commit 3656e3b660618b35e63eed0e5b012fac40fa1762 Author: Poul-Henning Kamp Date: Mon Sep 11 11:18:47 2017 +0000 Now filter the vmods symbols, and make libvmod_debug exercise the $Event RST test again. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index b7f58e5..2325c50 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -68,6 +68,7 @@ libvmod_XXX_la_CFLAGS = \\ libvmod_XXX_la_LDFLAGS = \\ $(AM_LDFLAGS) \\ $(VMOD_LDFLAGS) \\ + -export-symbols-regex '^Vmod_XXX_Data' \\ @SAN_LDFLAGS@ nodist_libvmod_XXX_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 3b4ed7a..2971a68 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_blob_la_CFLAGS = \ libvmod_blob_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_blob_Data' \ @SAN_LDFLAGS@ nodist_libvmod_blob_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index d328960..a15b241 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -17,7 +17,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_debug vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict +vmodtoolargs = noinst_LTLIBRARIES = libvmod_debug.la @@ -27,10 +27,7 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ + $(VMOD_LDFLAGS) \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 2ed8a9e..324d389 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -37,6 +37,8 @@ of VMOD handling in Varnish. $Event event_function +You are not supposed to be able to see this text in the .RST + $Function VOID panic(STRING_LIST) Don't. diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index 19e10a3..b949004 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_directors_la_CFLAGS = \ libvmod_directors_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_directors_Data' \ @SAN_LDFLAGS@ nodist_libvmod_directors_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index 3a5b4a5..ef9f8a3 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_purge_la_CFLAGS = \ libvmod_purge_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_purge_Data' \ @SAN_LDFLAGS@ nodist_libvmod_purge_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 66410b0..8ad8dae 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_std_la_CFLAGS = \ libvmod_std_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_std_Data' \ @SAN_LDFLAGS@ nodist_libvmod_std_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 1eb8f6f..20e0848 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_vtc_la_CFLAGS = \ libvmod_vtc_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_vtc_Data' \ @SAN_LDFLAGS@ nodist_libvmod_vtc_la_SOURCES = vcc_if.c vcc_if.h From dridi.boukelmoune at gmail.com Mon Sep 11 12:35:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 12:35:05 +0000 (UTC) Subject: [master] aa4298c Ignore req.ttl when keeping track of epired objects Message-ID: <20170911123505.C2BE394F2C@lists.varnish-cache.org> commit aa4298c951461a3baaafd9d23666c09d3e217fc3 Author: Dridi Boukelmoune Date: Mon Sep 11 13:03:52 2017 +0200 Ignore req.ttl when keeping track of epired objects The goal of `req.ttl` is to allow lower requirements for known transactions (since this has to be done in VCL) but objects with an age higher than `req.ttl` would always be considered expired during lookup even if their actual TTL (obj.ttl) is still positive. Ignoring `req.ttl` gives a better control over explicit refreshes made to optimize latency and greatly reduces the risk of running into #1799 (for a subset of use cases). Closes #2422 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 55fa342..2e9baf9 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -461,7 +461,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, *ocp = oc; return (HSH_HIT); } - if (oc->t_origin > exp_t_origin) { + if (EXP_Ttl(NULL, oc) < req->t_req && /* ignore req.ttl */ + oc->t_origin > exp_t_origin) { /* record the newest object */ exp_oc = oc; exp_t_origin = oc->t_origin; From nils.goroll at uplex.de Mon Sep 11 12:54:04 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Sep 2017 12:54:04 +0000 (UTC) Subject: [master] 9b5e553 Build generated sources before anything else Message-ID: <20170911125404.4FFEF94711@lists.varnish-cache.org> commit 9b5e55326121216a6a5e334ef984f17348bb1252 Author: Nils Goroll Date: Mon Sep 11 14:52:07 2017 +0200 Build generated sources before anything else Works for all, check, install targets but not for individual targets, see ref: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html Fixes #2423 diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index c6228b8..55409d7 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -224,6 +224,7 @@ $(varnishd_OBJECTS): VSC_main.h EXTRA_DIST += main.vsc DISTCLEANFILES += VSC_main.c VSC_main.h +BUILT_SOURCES += VSC_main.c VSC_main.h nodist_varnishd_SOURCES += VSC_main.c ####################################################################### @@ -235,6 +236,7 @@ $(varnishd_OBJECTS): VSC_lck.h EXTRA_DIST += lck.vsc DISTCLEANFILES += VSC_lck.c VSC_lck.h +BUILT_SOURCES += VSC_lck.c VSC_lck.h nodist_varnishd_SOURCES += VSC_lck.c ####################################################################### @@ -246,6 +248,7 @@ $(varnishd_OBJECTS): VSC_vbe.h EXTRA_DIST += vbe.vsc DISTCLEANFILES += VSC_vbe.c VSC_vbe.h +BUILT_SOURCES += VSC_vbe.c VSC_vbe.h nodist_varnishd_SOURCES += VSC_vbe.c ####################################################################### @@ -257,6 +260,7 @@ $(varnishd_OBJECTS): VSC_sma.h EXTRA_DIST += sma.vsc DISTCLEANFILES += VSC_sma.c VSC_sma.h +BUILT_SOURCES += VSC_sma.c VSC_sma.h nodist_varnishd_SOURCES += VSC_sma.c ####################################################################### @@ -268,6 +272,7 @@ $(varnishd_OBJECTS): VSC_smf.h EXTRA_DIST += smf.vsc DISTCLEANFILES += VSC_smf.c VSC_smf.h +BUILT_SOURCES += VSC_smf.c VSC_smf.h nodist_varnishd_SOURCES += VSC_smf.c ####################################################################### @@ -279,6 +284,7 @@ $(varnishd_OBJECTS): VSC_mempool.h EXTRA_DIST += mempool.vsc DISTCLEANFILES += VSC_mempool.c VSC_mempool.h +BUILT_SOURCES += VSC_mempool.c VSC_mempool.h nodist_varnishd_SOURCES += VSC_mempool.c ####################################################################### @@ -290,5 +296,5 @@ $(varnishd_OBJECTS): VSC_mgt.h EXTRA_DIST += mgt.vsc DISTCLEANFILES += VSC_mgt.c VSC_mgt.h +BUILT_SOURCES += VSC_mgt.c VSC_mgt.h nodist_varnishd_SOURCES += VSC_mgt.c - From dridi.boukelmoune at gmail.com Mon Sep 11 13:00:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 13:00:07 +0000 (UTC) Subject: [4.1] ad92c56 Ignore req.ttl when keeping track of epired objects Message-ID: <20170911130007.6895494A13@lists.varnish-cache.org> commit ad92c565109e4850c5ee375160b231a40c6272a4 Author: Dridi Boukelmoune Date: Mon Sep 11 13:03:52 2017 +0200 Ignore req.ttl when keeping track of epired objects The goal of `req.ttl` is to allow lower requirements for known transactions (since this has to be done in VCL) but objects with an age higher than `req.ttl` would always be considered expired during lookup even if their actual TTL (obj.ttl) is still positive. Ignoring `req.ttl` gives a better control over explicit refreshes made to optimize latency and greatly reduces the risk of running into #1799 (for a subset of use cases). Refs #2422 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index c9573de..42f2db6 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -441,7 +441,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, *ocp = oc; return (HSH_HIT); } - if (oc->exp.t_origin > exp_t_origin) { + if (EXP_Ttl(NULL, &oc->exp) < req->t_req && /* ignore req.ttl */ + oc->exp.t_origin > exp_t_origin) { /* record the newest object */ exp_oc = oc; exp_t_origin = oc->exp.t_origin; From geoff at uplex.de Mon Sep 11 13:24:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Sep 2017 13:24:05 +0000 (UTC) Subject: [master] da790a8 VMOD blob tests: add vcl.discard to test freeing cached encodings of blob objects. Message-ID: <20170911132405.90348942D3@lists.varnish-cache.org> commit da790a8a537fc2f4aef4aa0630f1a2400a17ee72 Author: Geoff Simmons Date: Mon Sep 11 15:22:06 2017 +0200 VMOD blob tests: add vcl.discard to test freeing cached encodings of blob objects. Revealed by GCOV. diff --git a/bin/varnishtest/tests/m00043.vtc b/bin/varnishtest/tests/m00043.vtc index 74763b5..7c3408a 100644 --- a/bin/varnishtest/tests/m00043.vtc +++ b/bin/varnishtest/tests/m00043.vtc @@ -269,6 +269,10 @@ client c3 { # run twice client c3 -run +# Discard to test object finalization +varnish v1 -cliok "vcl.discard vcl1" +varnish v1 -cliok "vcl.discard vcl2" + varnish v1 -errvcl {vmod blob error: cannot create blob err, illegal encoding beginning with "g"} { import blob; backend b { .host="${bad_ip}"; } diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index e936944..20e44b7 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -307,7 +307,7 @@ vmod_blob__fini(struct vmod_blob_blob **blobp) } for (int i = 0; i < __MAX_ENCODING; i++) if (b->encoding[i] != NULL && b->encoding[i][0] != '\0') { - free((void *) b->encoding[i]); + free(b->encoding[i]); b->encoding[i] = NULL; } AZ(pthread_mutex_destroy(&b->lock)); From geoff at uplex.de Mon Sep 11 13:31:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Sep 2017 13:31:04 +0000 (UTC) Subject: [master] 2700c19 VMOD blob: correct a special case in object finalization. Message-ID: <20170911133104.F3BE294677@lists.varnish-cache.org> commit 2700c1979a513be7a49314aad2b023a67b68ef75 Author: Geoff Simmons Date: Mon Sep 11 15:28:18 2017 +0200 VMOD blob: correct a special case in object finalization. Don't attempt to free the static empty string that the VMOD assigns for empty encodings. diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 20e44b7..6bb37ed 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -306,7 +306,7 @@ vmod_blob__fini(struct vmod_blob_blob **blobp) b->blob.priv = NULL; } for (int i = 0; i < __MAX_ENCODING; i++) - if (b->encoding[i] != NULL && b->encoding[i][0] != '\0') { + if (b->encoding[i] != NULL && b->encoding[i] != empty) { free(b->encoding[i]); b->encoding[i] = NULL; } From hermunn at varnish-software.com Mon Sep 11 14:25:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Mon, 11 Sep 2017 14:25:06 +0000 (UTC) Subject: [master] 3f5bc7f Move the cli buffer to VSB (from stack) Message-ID: <20170911142506.133CD94976@lists.varnish-cache.org> commit 3f5bc7f3480b043a8480b7cd31c735f8fc843d16 Author: P?l Hermunn Johansen Date: Mon Sep 11 16:21:19 2017 +0200 Move the cli buffer to VSB (from stack) If the cli buffer is allocated on the stack, the mgt process will crash hard for big values of this parameter. Instead we allocate on the heap. The new cli buffer an "auto" VSB. This means that the varnish parameter cli_buffer is ignored from now on, and the manual marks it as deprecated. Closes: #2382 diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index d7fa6a6..ff60b2d 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -67,6 +67,8 @@ static int cli_i = -1, cli_o = -1; struct VCLS *mgt_cls; static const char *secret_file; +struct vsb *cli_buf = NULL; + /*--------------------------------------------------------------------*/ static void __match_proto__(cli_func_t) @@ -177,24 +179,30 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) int i, j; va_list ap; unsigned u; - char buf[mgt_param.cli_buffer], *p; + + if (cli_buf == NULL) { + cli_buf = VSB_new_auto(); + AN(cli_buf); + } else { + VSB_clear(cli_buf); + } if (resp != NULL) *resp = NULL; if (status != NULL) *status = 0; - if (cli_i < 0|| cli_o < 0) { + if (cli_i < 0 || cli_o < 0) { if (status != NULL) *status = CLIS_CANT; return (CLIS_CANT); } va_start(ap, fmt); - vbprintf(buf, fmt, ap); + AZ(VSB_vprintf(cli_buf, fmt, ap)); va_end(ap); - p = strchr(buf, '\0'); - assert(p != NULL && p > buf && p[-1] == '\n'); - i = p - buf; - j = write(cli_o, buf, i); + AZ(VSB_finish(cli_buf)); + i = VSB_len(cli_buf); + assert(i > 0 && VSB_data(cli_buf)[i - 1] == '\n'); + j = write(cli_o, VSB_data(cli_buf), i); if (j != i) { if (status != NULL) *status = CLIS_COMMS; diff --git a/bin/varnishtest/tests/r02382.vtc b/bin/varnishtest/tests/r02382.vtc new file mode 100644 index 0000000..7a398b3 --- /dev/null +++ b/bin/varnishtest/tests/r02382.vtc @@ -0,0 +1,21 @@ +varnishtest "Very very big cli_buffer" + +# If the cli_buffer is on the stack, setting it very big can crash varnish + +server s1 { + rxreq + expect req.url == "/1" + txresp +} -start + +varnish v1 -arg "-p cli_buffer=32M" -vcl+backend { +} -start + +varnish v1 -cliok "ping" + +delay .5 + +client c1 { + txreq -url /1 + rxresp +} -run diff --git a/include/tbl/params.h b/include/tbl/params.h index 91cfd66..837c62f 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -294,10 +294,8 @@ PARAM( /* units */ "bytes", /* flags */ 0, /* s-text */ - "Size of buffer for CLI command input.\n" - "You may need to increase this if you have big VCL files and use " - "the vcl.inline CLI command.\n" - "NB: Must be specified with -p to have effect.", + "DEPRECATED: This parameter is ignored.\n" + "Memory for the CLI command buffer is now dynamically allocated.", /* l-text */ "", /* func */ NULL ) From dridi.boukelmoune at gmail.com Mon Sep 11 15:28:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 15:28:04 +0000 (UTC) Subject: [4.1] 970f2a3 Test case for #2422 Message-ID: <20170911152804.8947B94069@lists.varnish-cache.org> commit 970f2a3a7b397599d821843df23e8038452db635 Author: Dridi Boukelmoune Date: Mon Sep 11 17:23:30 2017 +0200 Test case for #2422 diff --git a/bin/varnishtest/tests/r02422.vtc b/bin/varnishtest/tests/r02422.vtc new file mode 100644 index 0000000..9c956f5 --- /dev/null +++ b/bin/varnishtest/tests/r02422.vtc @@ -0,0 +1,125 @@ +varnishtest "long polling and low latency using req.ttl" + +server s1 { + # s1 uses the etag as a version + rxreq + txresp -hdr "Etag: 5" + + rxreq + # wait until the new version is ready + delay 1 + txresp -hdr "Etag: 6" +} -start + +varnish v1 -cliok "param.set default_grace 0" +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.restarts > 0) { + set req.ttl = 1ms; + } + } + + sub vcl_hit { + if (req.http.If-None-Match == obj.http.ETag) { + return (restart); + } + } + + sub vcl_deliver { + set resp.http.Hit = obj.hits > 0; + } +} -start + +# synchronizes the setup of all clients +barrier b1 cond 2 + +# makes c1..cN send their requests simultaneously-ish +barrier b2 cond 7 + +client c0 { + # wait for all clients to be ready + barrier b1 sync + # send a "new client" request (no INM) + txreq + rxresp + expect resp.status == 200 + expect resp.http.ETag == 5 + expect resp.http.Hit == false + # let all other clients send their requests + barrier b2 sync +} -start + +client c1 { + # new client, immediate hit + barrier b2 sync + txreq + rxresp + expect resp.status == 200 + expect resp.http.ETag == 5 + expect resp.http.Hit == true +} -start + +client c2 { + # late client, immediate hit + barrier b2 sync + txreq -hdr "If-None-Match: 2" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 5 + expect resp.http.Hit == true +} -start + +client c3 { + # late client, immediate hit + barrier b2 sync + txreq -hdr "If-None-Match: 4" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 5 + expect resp.http.Hit == true +} -start + +client c4 { + # up-to-date client, long polling + barrier b2 sync + txreq -hdr "If-None-Match: 5" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 6 + expect resp.http.Hit == false +} -start + +client c5 { + # up-to-date client, long polling + barrier b2 sync + # wait to make sure c4 gets the miss + delay 0.2 + txreq -hdr "If-None-Match: 5" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 6 + expect resp.http.Hit == true +} -start + +client c6 { + # up-to-date client, long polling + barrier b2 sync + # wait to make sure c4 gets the miss + delay 0.2 + txreq -hdr "If-None-Match: 5" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 6 + expect resp.http.Hit == true +} -start + +# start c0 +barrier b1 sync + +client c0 -wait +client c1 -wait +client c2 -wait +client c3 -wait +client c4 -wait +client c5 -wait +client c6 -wait From dridi.boukelmoune at gmail.com Mon Sep 11 15:31:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 15:31:04 +0000 (UTC) Subject: [master] 6e14386 Staticize Message-ID: <20170911153104.EE85F94343@lists.varnish-cache.org> commit 6e143868fdbf023f4a8e0c8c33a3da5c475639e4 Author: Dridi Boukelmoune Date: Mon Sep 11 17:30:19 2017 +0200 Staticize diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index ff60b2d..4d23bba 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -67,7 +67,7 @@ static int cli_i = -1, cli_o = -1; struct VCLS *mgt_cls; static const char *secret_file; -struct vsb *cli_buf = NULL; +static struct vsb *cli_buf = NULL; /*--------------------------------------------------------------------*/ From phk at FreeBSD.org Mon Sep 11 20:11:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Sep 2017 20:11:05 +0000 (UTC) Subject: [master] da91fec We don't actually have VMOD_LDFLAGS from varnish.m4 in our build. Message-ID: <20170911201105.5473495836@lists.varnish-cache.org> commit da91fec9533603a35c9495f89cdb263a78c3b3fa Author: Poul-Henning Kamp Date: Mon Sep 11 19:58:26 2017 +0000 We don't actually have VMOD_LDFLAGS from varnish.m4 in our build. Spotted by: fgs diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 2325c50..3a4472c 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -67,7 +67,7 @@ libvmod_XXX_la_CFLAGS = \\ libvmod_XXX_la_LDFLAGS = \\ $(AM_LDFLAGS) \\ - $(VMOD_LDFLAGS) \\ + -module -export-dynamic -avoid-version -shared \\ -export-symbols-regex '^Vmod_XXX_Data' \\ @SAN_LDFLAGS@ diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 2971a68..ae78a9a 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_blob_la_CFLAGS = \ libvmod_blob_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_blob_Data' \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index a15b241..e5f13a2 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -27,8 +27,9 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -rpath /nowhere \ + -export-symbols-regex '^Vmod_debug_Data' \ @SAN_LDFLAGS@ nodist_libvmod_debug_la_SOURCES = \ diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index b949004..21a702d 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_directors_la_CFLAGS = \ libvmod_directors_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_directors_Data' \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index ef9f8a3..d8f3803 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_purge_la_CFLAGS = \ libvmod_purge_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_purge_Data' \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 8ad8dae..cbd9bc9 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_std_la_CFLAGS = \ libvmod_std_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_std_Data' \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 20e0848..7642a2d 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_vtc_la_CFLAGS = \ libvmod_vtc_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_vtc_Data' \ @SAN_LDFLAGS@ From geoff at uplex.de Mon Sep 11 20:16:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Sep 2017 20:16:05 +0000 (UTC) Subject: [master] 01835f4 VMOD blob: remove the *UC and *LC encoding schemes. Message-ID: <20170911201605.B27E195BD4@lists.varnish-cache.org> commit 01835f40442ada1e3747da6a51e8c3ca10e2560f Author: Geoff Simmons Date: Mon Sep 11 22:14:33 2017 +0200 VMOD blob: remove the *UC and *LC encoding schemes. For HEX and URL, there is now an ENUM case in {LOWER, UPPER} to determine the case of hex digits produced for an encoding, default LOWER. diff --git a/bin/varnishtest/tests/b00051.vtc b/bin/varnishtest/tests/b00051.vtc index ffa5bc5..c6a0125 100644 --- a/bin/varnishtest/tests/b00051.vtc +++ b/bin/varnishtest/tests/b00051.vtc @@ -9,10 +9,10 @@ varnish v1 -vcl+backend { import blob; sub vcl_backend_response { - set beresp.http.bereq_hash = blob.encode(HEXLC, bereq.hash); + set beresp.http.bereq_hash = blob.encode(HEX, blob=bereq.hash); } sub vcl_deliver { - set resp.http.req_hash = blob.encode(HEXLC, req.hash); + set resp.http.req_hash = blob.encode(HEX, blob=req.hash); } } -start diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index cb15b5e..2340eda 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -10,29 +10,29 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.id = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, "The quick brown fox jumps over the lazy dog")); set resp.http.hobbes = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "")); set resp.http.empty = - blob.encode(IDENTITY, blob.decode(IDENTITY, "")); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, "")); set resp.http.undef = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, req.http.unset)); set resp.http.emptylist = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, req.http.unset + "" + req.http.unset + "")); set resp.http.param = @@ -43,7 +43,7 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.paramlist = - blob.encode(IDENTITY, blob.decode(encoded= + blob.encode(IDENTITY, blob=blob.decode(encoded= "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + @@ -51,7 +51,13 @@ varnish v1 -vcl { decoding=IDENTITY)); set resp.http.truncated = - blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); + + set resp.http.lc = + blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, "Don't care")); + + set resp.http.uc = + blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, "Don't care")); } } -start @@ -67,4 +73,6 @@ client c1 { expect resp.http.param == "The quick brown fox jumps over the lazy dog" expect resp.http.paramlist == "/The quick brown fox jumps over the lazy dog/" expect resp.http.truncated == "foo" + expect resp.http.lc == "Don't care" + expect resp.http.uc == "Don't care" } -run diff --git a/bin/varnishtest/tests/m00034.vtc b/bin/varnishtest/tests/m00034.vtc index 24da94c..949df45 100644 --- a/bin/varnishtest/tests/m00034.vtc +++ b/bin/varnishtest/tests/m00034.vtc @@ -10,29 +10,29 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.id = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, "The quick brown fox jumps over the lazy dog")); set resp.http.hobbes = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = - blob.encode(IDENTITY, blob.decode_n(6, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(6, IDENTITY, "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "")); set resp.http.empty = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, "")); + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, "")); set resp.http.undef = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, req.http.unset)); set resp.http.emptylist = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, req.http.unset + "" + req.http.unset + "")); set resp.http.param = @@ -43,7 +43,7 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.paramlist = - blob.encode(IDENTITY, blob.decode_n(encoded= + blob.encode(IDENTITY, blob=blob.decode_n(encoded= "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index b26d151..e1aa0ff 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -18,39 +18,51 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set req.http.b64all = {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; + set resp.http.hex = + blob.encode(HEX, blob=blob.decode(IDENTITY, req.http.pangram)); + set resp.http.hexlc = - blob.encode(HEXLC, - blob.decode(IDENTITY, req.http.pangram)); + blob.encode(HEX, LOWER, + blob.decode(IDENTITY, req.http.pangram)); set resp.http.hexuc = - blob.encode(HEXUC, - blob.decode(IDENTITY, req.http.pangram)); + blob.encode(HEX, UPPER, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.hobbes = + blob.encode(HEX, blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbeslc = - blob.encode(HEXLC, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, LOWER, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(HEXUC, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.all = + blob.encode(HEX, blob=blob.decode(BASE64, req.http.b64all)); set resp.http.all-lc = - blob.encode(HEXLC, blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, LOWER, blob.decode(BASE64, req.http.b64all)); set resp.http.all-uc = - blob.encode(HEXUC, blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, UPPER, blob.decode(BASE64, req.http.b64all)); + + set resp.http.empty = + blob.encode(HEX, blob=blob.decode(IDENTITY, "")); set resp.http.empty-lc = - blob.encode(HEXLC, blob.decode(IDENTITY, "")); + blob.encode(HEX, LOWER, blob.decode(IDENTITY, "")); set resp.http.empty-uc = - blob.encode(HEXUC, blob.decode(IDENTITY, "")); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, "")); set resp.http.hexlcparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=HEXLC); + case=LOWER, encoding=HEX); set resp.http.hexucparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=HEXUC); + case=UPPER, encoding=HEX); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); @@ -64,51 +76,51 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob.decode(HEX, req.http.hexucfoobar)); + blob=blob.decode(HEX, req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob.decode(HEX, req.http.hexlcfoobar)); + blob=blob.decode(HEX, req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob.decode(HEX, req.http.hexhobbesuc)); + blob=blob.decode(HEX, req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob.decode(HEX, req.http.hexhobbeslc)); + blob=blob.decode(HEX, req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode(HEX, req.http.hexalluc)); + blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode(HEX, req.http.hexalllc)); + blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob.decode(HEX, - req.http.hexallucodd)); + blob.encode(BASE64, blob=blob.decode(HEX, + req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob.decode(HEX, - req.http.hexalllcodd)); + blob.encode(BASE64, blob=blob.decode(HEX, + req.http.hexalllcodd)); set resp.http.decempty = - blob.encode(IDENTITY, blob.decode(HEX, "")); + blob.encode(IDENTITY, blob=blob.decode(HEX, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob.decode(HEX, "00")); + blob.encode(IDENTITY, blob=blob.decode(HEX, "00")); set resp.http.decemptynibble = - blob.encode(IDENTITY, blob.decode(HEX, "0")); + blob.encode(IDENTITY, blob=blob.decode(HEX, "0")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob.decode(HEX, req.http.unset + "" - + req.http.unset + "")); + blob=blob.decode(HEX, req.http.unset + "" + + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob.decode(HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(HEX, req.http.part1 + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; @@ -119,11 +131,11 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob.decode(HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(HEX, req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode(HEX, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode(HEX, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -134,14 +146,18 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { client c1 { txreq -url "/" rxresp - expect resp.http.hexlc == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" + expect resp.http.hex == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" + expect resp.http.hexlc == resp.http.hex expect resp.http.hexuc == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67" - expect resp.http.hobbeslc == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" + expect resp.http.hobbes == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" + expect resp.http.hobbeslc == resp.http.hobbes expect resp.http.hobbesuc == "4D616E2069732064697374696E677569736865642C206E6F74206F6E6C792062792068697320726561736F6E2C2062757420627920746869732073696E67756C61722070617373696F6E2066726F6D206F7468657220616E696D616C732C2077686963682069732061206C757374206F6620746865206D696E642C20746861742062792061207065727365766572616E6365206F662064656C6967687420696E2074686520636F6E74696E75656420616E6420696E6465666174696761626C652067656E65726174696F6E206F66206B6E6F776C656467652C2065786365656473207468652073686F727420766568656D656E6365206F6620616E79206361726E616C20706C6561737572652E" + expect resp.http.all == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" expect resp.http.all-uc == "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF" - expect resp.http.all-lc == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + expect resp.http.all-lc == resp.http.all + expect resp.http.empty == "" expect resp.http.empty-uc == "" - expect resp.http.empty-lc == "" + expect resp.http.empty-lc == resp.http.empty expect resp.http.hexlcparam == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" expect resp.http.hexucparam == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67" expect resp.http.decuc == "foo bar baz quux" @@ -174,7 +190,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { set req.http.foo = "123"; - set resp.http.badhex = blob.encode(HEXUC, + set resp.http.badhex = blob.encode(HEX, UPPER, blob.decode(HEX, "g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00036.vtc b/bin/varnishtest/tests/m00036.vtc index 21ff627..cf6335b 100644 --- a/bin/varnishtest/tests/m00036.vtc +++ b/bin/varnishtest/tests/m00036.vtc @@ -18,38 +18,41 @@ varnish v1 -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.hexlc = - blob.encode(HEXLC, - blob.decode_n(5, IDENTITY, req.http.pangram)); + blob.encode(HEX, + blob=blob.decode_n(5, IDENTITY, req.http.pangram)); set resp.http.hexuc = - blob.encode(HEXUC, - blob.decode_n(5, IDENTITY, req.http.pangram)); + blob.encode(HEX, UPPER, + blob.decode_n(5, IDENTITY, req.http.pangram)); set resp.http.hobbeslc = - blob.encode(HEXLC, blob.decode_n(5, IDENTITY, req.http.hobbes)); + blob.encode(HEX, + blob=blob.decode_n(5, IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(HEXUC, blob.decode_n(5, IDENTITY, req.http.hobbes)); + blob.encode(HEX, UPPER, + blob.decode_n(5, IDENTITY, req.http.hobbes)); set resp.http.all-lc = - blob.encode(HEXLC, blob.decode_n(8, BASE64, req.http.b64all)); + blob.encode(HEX, blob=blob.decode_n(8, BASE64, req.http.b64all)); set resp.http.all-uc = - blob.encode(HEXUC, blob.decode_n(8, BASE64, req.http.b64all)); + blob.encode(HEX, UPPER, + blob.decode_n(8, BASE64, req.http.b64all)); set resp.http.empty-lc = - blob.encode(HEXLC, blob.decode_n(5, IDENTITY, "")); + blob.encode(HEX, blob=blob.decode_n(5, IDENTITY, "")); set resp.http.empty-uc = - blob.encode(HEXUC, blob.decode_n(5, IDENTITY, "")); + blob.encode(HEX, UPPER, blob.decode_n(5, IDENTITY, "")); set resp.http.hexlcparam = blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), - encoding=HEXLC); + encoding=HEX, case=LOWER); set resp.http.hexucparam = blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), - encoding=HEXUC); + encoding=HEX, case=UPPER); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); @@ -63,51 +66,53 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob.decode_n(10, HEX, req.http.hexucfoobar)); + blob=blob.decode_n(10, HEX, req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob.decode_n(10, HEX, req.http.hexlcfoobar)); + blob=blob.decode_n(10, HEX, req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob.decode_n(12, HEX, req.http.hexhobbesuc)); + blob=blob.decode_n(12, HEX, req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob.decode_n(12, HEX, req.http.hexhobbeslc)); + blob=blob.decode_n(12, HEX, req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalluc)); + blob.encode(BASE64, + blob=blob.decode_n(12, HEX, req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalllc)); + blob.encode(BASE64, + blob=blob.decode_n(12, HEX, req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob.decode_n(11, HEX, - req.http.hexallucodd)); + blob.encode(BASE64, blob=blob.decode_n(11, HEX, + req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob.decode_n(11, HEX, - req.http.hexalllcodd)); + blob.encode(BASE64, blob=blob.decode_n(11, HEX, + req.http.hexalllcodd)); set resp.http.decempty = - blob.encode(IDENTITY, blob.decode_n(5, HEX, "")); + blob.encode(IDENTITY, blob=blob.decode_n(5, HEX, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob.decode_n(1, HEX, "00")); + blob.encode(IDENTITY, blob=blob.decode_n(1, HEX, "00")); set resp.http.decemptynibble = - blob.encode(IDENTITY, blob.decode_n(2, HEX, "0")); + blob.encode(IDENTITY, blob=blob.decode_n(2, HEX, "0")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob.decode_n(5, HEX, req.http.unset + "" - + req.http.unset + "")); + blob=blob.decode_n(5, HEX, req.http.unset + "" + + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob.decode_n(6, HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode_n(6, HEX, req.http.part1 + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; @@ -118,11 +123,12 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob.decode_n(30, HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode_n(30, HEX, req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode_n(20, HEX, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode_n(20, HEX, "" + + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -173,7 +179,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { set req.http.foo = "123"; - set resp.http.badhex = blob.encode(HEXUC, + set resp.http.badhex = blob.encode(HEX, UPPER, blob.decode_n(2, HEX, "g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index 13dc2d5..25a7dee 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -18,69 +18,93 @@ varnish v1 -vcl { {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set resp.http.b64 = - blob.encode(BASE64, blob.decode(IDENTITY, + blob.encode(BASE64, blob=blob.decode(IDENTITY, + req.http.pangram)); + + set resp.http.b64lc = + blob.encode(BASE64, LOWER, blob.decode(IDENTITY, + req.http.pangram)); + + set resp.http.b64uc = + blob.encode(BASE64, UPPER, blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64hobbes = - blob.encode(BASE64, blob.decode(IDENTITY, + blob.encode(BASE64, blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64all = - blob.encode(BASE64, blob.decode(HEX, req.http.hexall)); + blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexall)); set resp.http.b64url = blob.encode(BASE64URL, - blob.decode(IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64urllc = + blob.encode(BASE64URL, LOWER, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64urluc = + blob.encode(BASE64URL, UPPER, + blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64urlhobbes = blob.encode(BASE64URL, - blob.decode(IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64urlall = - blob.encode(BASE64URL, blob.decode(HEX, req.http.hexall)); + blob.encode(BASE64URL, blob=blob.decode(HEX, req.http.hexall)); set resp.http.b64urlnopad = blob.encode(BASE64URLNOPAD, - blob.decode(IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64urlnopadlc = + blob.encode(BASE64URLNOPAD, LOWER, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64urlnopaduc = + blob.encode(BASE64URLNOPAD, UPPER, + blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64nopadhobbes = blob.encode(BASE64URLNOPAD, - blob.decode(IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64nopadall = blob.encode(BASE64URLNOPAD, - blob.decode(HEX, req.http.hexall)); + blob=blob.decode(HEX, req.http.hexall)); set resp.http.b64empty = - blob.encode(BASE64, blob.decode(IDENTITY, "")); + blob.encode(BASE64, blob=blob.decode(IDENTITY, "")); set resp.http.urlempty = - blob.encode(BASE64URL, blob.decode(IDENTITY, "")); + blob.encode(BASE64URL, blob=blob.decode(IDENTITY, "")); set resp.http.nopadempty = - blob.encode(BASE64URLNOPAD, blob.decode(IDENTITY, "")); + blob.encode(BASE64URLNOPAD, blob=blob.decode(IDENTITY, "")); set resp.http.b64param = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=BASE64); + encoding=BASE64, case=LOWER); set resp.http.b64urlparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=BASE64URL); + encoding=BASE64URL, case=UPPER); set resp.http.b64urlnopadparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=BASE64URLNOPAD); + encoding=BASE64URLNOPAD, case=LOWER); set resp.http.b64xcode = - blob.transcode(IDENTITY, BASE64, req.url + "Hello world" + - req.url); + blob.transcode(IDENTITY, BASE64, + encoded=req.url + "Hello world" + req.url); set resp.http.b64urlxcode = - blob.transcode(IDENTITY, BASE64URL, req.url + "Hello world" + - req.url); + blob.transcode(IDENTITY, BASE64URL, + encoded=req.url + "Hello world" + req.url); set resp.http.b64urlnopadxcode = blob.transcode(IDENTITY, BASE64URLNOPAD, - req.url + "Hello world" + req.url); + encoded=req.url + "Hello world" + req.url); } } -start @@ -88,12 +112,18 @@ client c1 { txreq -url "/" rxresp expect resp.http.b64 == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" + expect resp.http.b64lc == resp.http.b64 + expect resp.http.b64uc == resp.http.b64 expect resp.http.b64hobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" expect resp.http.b64all == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" expect resp.http.b64url == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" + expect resp.http.b64urllc == resp.http.b64url + expect resp.http.b64urluc == resp.http.b64url expect resp.http.b64urlhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" expect resp.http.b64urlall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" expect resp.http.b64urlnopad == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + expect resp.http.b64urlnopadlc == resp.http.b64urlnopad + expect resp.http.b64urlnopaduc == resp.http.b64urlnopad expect resp.http.b64nopadhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" expect resp.http.b64nopadall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" expect resp.http.b64empty == "" @@ -126,66 +156,66 @@ varnish v1 -vcl { set req.http.allurl = {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; - set resp.http.dec = blob.encode(IDENTITY, + set resp.http.dec = blob.encode(IDENTITY, blob= blob.decode(BASE64, req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, - blob.decode(BASE64, req.http.pangram)); + blob=blob.decode(BASE64, req.http.pangram)); set resp.http.b64dechobbes = blob.encode(IDENTITY, - blob.decode(BASE64, req.http.hobbes)); + blob=blob.decode(BASE64, req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEXLC, blob.decode(BASE64, req.http.all)); + blob.encode(HEX, blob=blob.decode(BASE64, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob.decode(BASE64URL, + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEXLC, - blob.decode(BASE64URL, req.http.allurl)); + blob.encode(HEX, + blob=blob.decode(BASE64URL, req.http.allurl)); set resp.http.nopaddechobbes = - blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, req.http.hobbesnopad)); set resp.http.nopaddecall = - blob.encode(HEXLC, - blob.decode(BASE64URLNOPAD, req.http.allurl)); + blob.encode(HEX, + blob=blob.decode(BASE64URLNOPAD, req.http.allurl)); set resp.http.b64empty = - blob.encode(IDENTITY, blob.decode(BASE64, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64, "")); set resp.http.urlempty = - blob.encode(IDENTITY, blob.decode(BASE64URL, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, "")); set resp.http.nopadempty = - blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, "")); set resp.http.emptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob= blob.decode(BASE64, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, - blob.decode(BASE64, req.http.foobarbazquux)); + blob=blob.decode(BASE64, req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces - = blob.encode(IDENTITY, blob.decode(BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces - = blob.encode(IDENTITY, blob.decode(BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, resp.http.l + "0hlbGxvIHdvcmxkLw" + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces - = blob.encode(IDENTITY, blob.decode(BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad)); @@ -197,21 +227,21 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, - blob.decode(BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, "L0hlbGxvIHdvcmxkLw")); set resp.http.decnopad2pieces - = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces - = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, - blob.decode(BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); @@ -258,15 +288,15 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/base64") { set resp.http.bad64 = blob.encode(IDENTITY, - blob.decode(BASE64, "-_-_" + req.http.foo)); + blob=blob.decode(BASE64, "-_-_" + req.http.foo)); } elsif (req.url == "/base64url") { set resp.http.badurl = blob.encode(IDENTITY, - blob.decode(BASE64URL, "+/+/" + req.http.foo)); + blob=blob.decode(BASE64URL, "+/+/" + req.http.foo)); } elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, - blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); + blob=blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00038.vtc b/bin/varnishtest/tests/m00038.vtc index 894618d..4e7e334 100644 --- a/bin/varnishtest/tests/m00038.vtc +++ b/bin/varnishtest/tests/m00038.vtc @@ -22,82 +22,80 @@ varnish v1 -vcl { set resp.http.dec = blob.encode(IDENTITY, - blob.decode_n(8, BASE64, + blob=blob.decode_n(8, BASE64, req.http.foobarbazquux)); set resp.http.deceq = blob.encode(IDENTITY, - blob.decode_n(20, BASE64, + blob=blob.decode_n(20, BASE64, req.http.foobarbazquux)); set resp.http.declong = blob.encode(IDENTITY, - blob.decode_n(30, BASE64, + blob=blob.decode_n(30, BASE64, req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, - blob.decode_n(12, BASE64, req.http.pangram)); + blob=blob.decode_n(12, BASE64, req.http.pangram)); set resp.http.b64dechobbes = blob.encode(IDENTITY, - blob.decode_n(24, BASE64, req.http.hobbes)); + blob=blob.decode_n(24, BASE64, req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEXLC, blob.decode_n(128, BASE64, - req.http.all)); + blob.encode(HEX, blob=blob.decode_n(128, BASE64, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob.decode_n(180, BASE64URL, + blob.encode(IDENTITY, blob=blob.decode_n(180, BASE64URL, req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEXLC, - blob.decode_n(256, BASE64URL, + blob.encode(HEX, + blob=blob.decode_n(256, BASE64URL, req.http.allurl)); set resp.http.nopaddechobbes = blob.encode(IDENTITY, - blob.decode_n(500, BASE64URLNOPAD, + blob=blob.decode_n(500, BASE64URLNOPAD, req.http.hobbesnopad)); set resp.http.nopaddecall = - blob.encode(HEXLC, - blob.decode_n(256, BASE64URLNOPAD, - req.http.allurl)); + blob.encode(HEX, blob=blob.decode_n(256, BASE64URLNOPAD, + req.http.allurl)); set resp.http.b64empty = - blob.encode(IDENTITY, blob.decode_n(0, BASE64, "")); + blob.encode(IDENTITY, blob=blob.decode_n(0, BASE64, "")); set resp.http.urlempty = - blob.encode(IDENTITY, blob.decode_n(1, BASE64URL, "")); + blob.encode(IDENTITY, blob=blob.decode_n(1, BASE64URL, "")); set resp.http.nopadempty = blob.encode(IDENTITY, - blob.decode_n(0, BASE64URLNOPAD, "")); + blob=blob.decode_n(0, BASE64URLNOPAD, "")); set resp.http.emptypieces = blob.encode(IDENTITY, - blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset + blob=blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, - blob.decode_n(20, BASE64, + blob=blob.decode_n(20, BASE64, req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces - = blob.encode(IDENTITY, blob.decode_n(8, BASE64, + = blob.encode(IDENTITY, blob=blob.decode_n(8, BASE64, resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces - = blob.encode(IDENTITY, blob.decode_n(12, BASE64, + = blob.encode(IDENTITY, blob=blob.decode_n(12, BASE64, resp.http.l + "0hlbGxvIHdvcmxkLw" + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces - = blob.encode(IDENTITY, blob.decode_n(16, BASE64, + = blob.encode(IDENTITY, blob=blob.decode_n(16, BASE64, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad)); @@ -109,21 +107,21 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, - blob.decode_n(18, BASE64URLNOPAD, - "L0hlbGxvIHdvcmxkLw")); + blob=blob.decode_n(18, BASE64URLNOPAD, + "L0hlbGxvIHdvcmxkLw")); set resp.http.decnopad2pieces - = blob.encode(IDENTITY, blob.decode_n(19, BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode_n(19, BASE64URLNOPAD, resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces - = blob.encode(IDENTITY, blob.decode_n(18, BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode_n(18, BASE64URLNOPAD, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, - blob.decode_n(60, BASE64URLNOPAD, + blob=blob.decode_n(60, BASE64URLNOPAD, "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); @@ -172,16 +170,16 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/base64") { set resp.http.bad64 = blob.encode(IDENTITY, - blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); + blob=blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); } elsif (req.url == "/base64url") { set resp.http.badurl = blob.encode(IDENTITY, - blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); + blob=blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); } elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, - blob.decode_n(8, BASE64URLNOPAD, - "TWFu" + req.http.foo)); + blob=blob.decode_n(8, BASE64URLNOPAD, + "TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index 8048ccf..440c7ed 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -21,62 +21,117 @@ varnish v1 -vcl { set req.http.b64all = {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; + set resp.http.url = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.pangram)); + set resp.http.urllc = - blob.encode(URLLC, - blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.pangram)); set resp.http.urluc = - blob.encode(URLUC, - blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.hobbes = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbeslc = - blob.encode(URLLC, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(URLUC, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.umlauts = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.umlauts)); set resp.http.umlautslc = - blob.encode(URLLC, - blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.umlauts)); set resp.http.umlautsuc = - blob.encode(URLUC, - blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.umlauts)); + + set resp.http.phk = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.phkspeak)); set resp.http.phklc = - blob.encode(URLLC, - blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.phkspeak)); set resp.http.phkuc = - blob.encode(URLUC, - blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.phkspeak)); + + set resp.http.utf8 = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.utf8)); set resp.http.utf8lc = - blob.encode(URLLC, blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.utf8)); set resp.http.utf8uc = - blob.encode(URLUC, blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.utf8)); + + set resp.http.all = + blob.encode(URL, blob=blob.decode(BASE64, req.http.b64all)); set resp.http.all-lc = - blob.encode(URLLC, blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, LOWER, blob.decode(BASE64, req.http.b64all)); set resp.http.all-uc = - blob.encode(URLUC, blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, UPPER, blob.decode(BASE64, req.http.b64all)); + + set resp.http.empty = + blob.encode(URL, blob=blob.decode(IDENTITY, "")); set resp.http.empty-lc = - blob.encode(URLLC, blob.decode(IDENTITY, "")); + blob.encode(URL, LOWER, blob.decode(IDENTITY, "")); set resp.http.empty-uc = - blob.encode(URLUC, blob.decode(IDENTITY, "")); + blob.encode(URL, UPPER, blob.decode(IDENTITY, "")); set resp.http.urllcparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=URLLC); + encoding=URL, case=LOWER); set resp.http.urlucparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=URLUC); + encoding=URL, case=UPPER); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.url == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.urllc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.urluc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.hobbes == "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." + expect resp.http.hobbeslc == "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." + expect resp.http.hobbesuc == "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." + expect resp.http.umlauts == "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger" + expect resp.http.umlautslc == "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger" + expect resp.http.umlautsuc == "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger" + expect resp.http.phk == "sm%c3%a5b%c3%b8rnsp%c3%a6dagog" + expect resp.http.phklc == "sm%c3%a5b%c3%b8rnsp%c3%a6dagog" + expect resp.http.phkuc == "sm%C3%A5b%C3%B8rnsp%C3%A6dagog" + expect resp.http.utf8 == "%e6%97%a5%e6%89%bc%e8%aa%9e" + expect resp.http.utf8lc == "%e6%97%a5%e6%89%bc%e8%aa%9e" + expect resp.http.utf8uc == "%E6%97%A5%E6%89%BC%E8%AA%9E" + expect resp.http.all == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.all-lc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.all-uc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" + expect resp.http.empty == "" + expect resp.http.empty-uc == "" + expect resp.http.empty-lc == "" + expect resp.http.urllcparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.urlucparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" +} -run + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { set req.http.urllcfoobar = "foo%3abar%3abaz%3aquux"; set req.http.urlucfoobar = "foo%3Abar%3Abaz%3Aquux"; set req.http.urlmixedfoobar = "foo%3Abar%3abaz%3Aquux"; @@ -93,68 +148,68 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlucfoobar)); + blob=blob.decode(URL, req.http.urlucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urllcfoobar)); + blob=blob.decode(URL, req.http.urllcfoobar)); set resp.http.decmixed = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlmixedfoobar)); + blob=blob.decode(URL, req.http.urlmixedfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlhobbesuc)); + blob=blob.decode(URL, req.http.urlhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlhobbeslc)); + blob=blob.decode(URL, req.http.urlhobbeslc)); set resp.http.decumlautsuc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlucumlauts)); + blob=blob.decode(URL, req.http.urlucumlauts)); set resp.http.decumlautslc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urllcumlauts)); + blob=blob.decode(URL, req.http.urllcumlauts)); set resp.http.decphkuc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlucphk)); + blob=blob.decode(URL, req.http.urlucphk)); set resp.http.decphklc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urllcphk)); + blob=blob.decode(URL, req.http.urllcphk)); set resp.http.decutf8uc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlucutf8)); + blob=blob.decode(URL, req.http.urlucutf8)); set resp.http.decutf8lc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urllcutf8)); + blob=blob.decode(URL, req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode(URL, req.http.urlalluc)); + blob.encode(BASE64, blob=blob.decode(URL, req.http.urlalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode(URL, req.http.urlalllc)); + blob.encode(BASE64, blob=blob.decode(URL, req.http.urlalllc)); set resp.http.decempty = - blob.encode(IDENTITY, blob.decode(URL, "")); + blob.encode(IDENTITY, blob=blob.decode(URL, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob.decode(URL, "%00")); + blob.encode(IDENTITY, blob=blob.decode(URL, "%00")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob.decode(URL, req.http.unset + "" + blob=blob.decode(URL, req.http.unset + "" + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob.decode(URL, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(URL, req.http.part1 + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; @@ -165,37 +220,21 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob.decode(URL, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(URL, req.http.part1 + "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode(URL, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode(URL, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 + req.http.unset + "" + req.http.unset)); } -} -start +} client c1 { txreq -url "/" rxresp - expect resp.http.urllc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" - expect resp.http.urluc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" - expect resp.http.hobbeslc == "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." - expect resp.http.hobbesuc == "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." - expect resp.http.umlautslc == "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger" - expect resp.http.umlautsuc == "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger" - expect resp.http.phklc == "sm%c3%a5b%c3%b8rnsp%c3%a6dagog" - expect resp.http.phkuc == "sm%C3%A5b%C3%B8rnsp%C3%A6dagog" - expect resp.http.utf8lc == "%e6%97%a5%e6%89%bc%e8%aa%9e" - expect resp.http.utf8uc == "%E6%97%A5%E6%89%BC%E8%AA%9E" - expect resp.http.all-lc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" - expect resp.http.all-uc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" - expect resp.http.empty-uc == "" - expect resp.http.empty-lc == "" - expect resp.http.urllcparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" - expect resp.http.urlucparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" expect resp.http.decuc == "foo:bar:baz:quux" expect resp.http.declc == "foo:bar:baz:quux" expect resp.http.decmixed == "foo:bar:baz:quux" @@ -231,18 +270,18 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { set resp.http.bad - = blob.encode(URLUC, blob.decode(URL, "%")); + = blob.encode(URL, UPPER, blob.decode(URL, "%")); } elsif (req.url == "/percent-two") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode(URL, "%2")); } elsif (req.url == "/percent-q") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode(URL, "%q")); } elsif (req.url == "/percent-two-q") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode(URL, "%2q")); } } diff --git a/bin/varnishtest/tests/m00040.vtc b/bin/varnishtest/tests/m00040.vtc index b3c87b3..2355ca9 100644 --- a/bin/varnishtest/tests/m00040.vtc +++ b/bin/varnishtest/tests/m00040.vtc @@ -25,69 +25,67 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob.decode_n(9, URL, req.http.urlucfoobar)); + blob=blob.decode_n(9, URL, req.http.urlucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob.decode_n(12, URL, req.http.urllcfoobar)); + blob=blob.decode_n(12, URL, req.http.urllcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob.decode_n(27, URL, req.http.urlhobbesuc)); + blob=blob.decode_n(27, URL, req.http.urlhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob.decode_n(27, URL, req.http.urlhobbeslc)); + blob=blob.decode_n(27, URL, req.http.urlhobbeslc)); set resp.http.decumlautsuc = blob.encode(IDENTITY, - blob.decode_n(17, URL, - req.http.urlucumlauts)); + blob=blob.decode_n(17, URL, req.http.urlucumlauts)); set resp.http.decumlautslc = blob.encode(IDENTITY, - blob.decode_n(25, URL, - req.http.urllcumlauts)); + blob=blob.decode_n(25, URL, req.http.urllcumlauts)); set resp.http.decphkuc = blob.encode(IDENTITY, - blob.decode_n(18, URL, req.http.urlucphk)); + blob=blob.decode_n(18, URL, req.http.urlucphk)); set resp.http.decphklc = blob.encode(IDENTITY, - blob.decode_n(30, URL, req.http.urllcphk)); + blob=blob.decode_n(30, URL, req.http.urllcphk)); set resp.http.decutf8uc = blob.encode(IDENTITY, - blob.decode_n(9, URL, req.http.urlucutf8)); + blob=blob.decode_n(9, URL, req.http.urlucutf8)); set resp.http.decutf8lc = blob.encode(IDENTITY, - blob.decode_n(18, URL, req.http.urllcutf8)); + blob=blob.decode_n(18, URL, req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(HEXLC, - blob.decode_n(252, URL, req.http.urlalluc)); + blob.encode(HEX, + blob=blob.decode_n(252, URL, req.http.urlalluc)); set resp.http.decalllc = - blob.encode(HEXUC, - blob.decode_n(252, URL, req.http.urlalllc)); + blob.encode(HEX, UPPER, + blob.decode_n(252, URL, req.http.urlalllc)); set resp.http.decempty = - blob.encode(IDENTITY, blob.decode_n(10, URL, "")); + blob.encode(IDENTITY, blob=blob.decode_n(10, URL, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob.decode_n(3, URL, "%00")); + blob.encode(IDENTITY, blob=blob.decode_n(3, URL, "%00")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob.decode_n(1, URL, req.http.unset + "" + blob=blob.decode_n(1, URL, req.http.unset + "" + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = blob.encode(IDENTITY, - blob.decode_n(6, URL, req.http.part1 + + blob=blob.decode_n(6, URL, req.http.part1 + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; @@ -99,13 +97,13 @@ varnish v1 -vcl { set resp.http.dec3pieces = blob.encode(IDENTITY, - blob.decode_n(18, URL, req.http.part1 + blob=blob.decode_n(18, URL, req.http.part1 + "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, - blob.decode_n(24, URL, "" + req.http.unset + blob=blob.decode_n(24, URL, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -149,20 +147,20 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode_n(1, URL, "%20")); } elsif (req.url == "/percent-two") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode_n(2, URL, "%20")); } elsif (req.url == "/comma") { - set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%2c%q")); + set resp.http.good = blob.encode(IDENTITY, blob= + blob.decode_n(3, URL, "%2c%q")); } elsif (req.url == "/colon") { - set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%3a%2q")); + set resp.http.good = blob.encode(IDENTITY, blob= + blob.decode_n(3, URL, "%3a%2q")); } } } diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index c350ee1..cfed6ae 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -33,97 +33,186 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { = blob.transcode(encoded=req.http.hobbes, encoding=BASE64); set resp.http.id2b64nopad - = blob.transcode(IDENTITY, BASE64URLNOPAD, req.http.hobbes); + = blob.transcode(IDENTITY, BASE64URLNOPAD, encoded=req.http.hobbes); + + set resp.http.id2hex + = blob.transcode(IDENTITY, HEX, encoded=req.http.hobbes); set resp.http.id2hexuc - = blob.transcode(IDENTITY, HEXUC, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, UPPER, req.http.hobbes); set resp.http.id2hexlc - = blob.transcode(IDENTITY, HEXLC, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, LOWER, req.http.hobbes); + + set resp.http.id2url + = blob.transcode(IDENTITY, URL, encoded=req.http.foobar); set resp.http.id2urluc - = blob.transcode(IDENTITY, URLUC, req.http.foobar); + = blob.transcode(IDENTITY, URL, UPPER, req.http.foobar); set resp.http.id2urllc - = blob.transcode(IDENTITY, URLLC, req.http.foobar); + = blob.transcode(IDENTITY, URL, LOWER, req.http.foobar); set resp.http.b642id - = blob.transcode(BASE64, IDENTITY, req.http.hobbesb64); + = blob.transcode(BASE64, IDENTITY, encoded=req.http.hobbesb64); set resp.http.hex2id - = blob.transcode(HEX, IDENTITY, req.http.hexhobbes); + = blob.transcode(HEX, IDENTITY, encoded=req.http.hexhobbes); set resp.http.hexalldown2b64 - = blob.transcode(HEX, BASE64, req.http.hexalldown); + = blob.transcode(HEX, BASE64, encoded=req.http.hexalldown); set resp.http.hexalldown2b64url - = blob.transcode(HEX, BASE64URL, req.http.hexalldown); + = blob.transcode(HEX, BASE64URL, encoded=req.http.hexalldown); set resp.http.hexalldown2b64nopad - = blob.transcode(HEX, BASE64URLNOPAD, req.http.hexalldown); + = blob.transcode(HEX, BASE64URLNOPAD, encoded=req.http.hexalldown); set resp.http.hexallup2b64 - = blob.transcode(HEX, BASE64, req.http.hexallup); + = blob.transcode(HEX, BASE64, encoded=req.http.hexallup); set resp.http.hexallup2b64url - = blob.transcode(HEX, BASE64URL, req.http.hexallup); + = blob.transcode(HEX, BASE64URL, encoded=req.http.hexallup); set resp.http.hexallup2b64nopad - = blob.transcode(HEX, BASE64URLNOPAD, req.http.hexallup); + = blob.transcode(HEX, BASE64URLNOPAD, encoded=req.http.hexallup); + + set resp.http.hexalldown2url + = blob.transcode(HEX, URL, encoded=req.http.hexalldown); set resp.http.hexalldown2urluc - = blob.transcode(HEX, URLUC, req.http.hexalldown); + = blob.transcode(HEX, URL, UPPER, req.http.hexalldown); set resp.http.hexalldown2urllc - = blob.transcode(HEX, URLLC, req.http.hexalldown); + = blob.transcode(HEX, URL, LOWER, req.http.hexalldown); + + set resp.http.hexallup2url + = blob.transcode(HEX, URL, encoded=req.http.hexallup); set resp.http.hexallup2urluc - = blob.transcode(HEX, URLUC, req.http.hexallup); + = blob.transcode(HEX, URL, UPPER, req.http.hexallup); set resp.http.hexallup2urllc - = blob.transcode(HEX, URLLC, req.http.hexallup); + = blob.transcode(HEX, URL, LOWER, req.http.hexallup); + + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.id2id == "Hello world" + expect resp.http.id2b64 == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" + expect resp.http.id2b64nopad == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" + expect resp.http.id2hex == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" + expect resp.http.id2hexuc == "4D616E2069732064697374696E677569736865642C206E6F74206F6E6C792062792068697320726561736F6E2C2062757420627920746869732073696E67756C61722070617373696F6E2066726F6D206F7468657220616E696D616C732C2077686963682069732061206C757374206F6620746865206D696E642C20746861742062792061207065727365766572616E6365206F662064656C6967687420696E2074686520636F6E74696E75656420616E6420696E6465666174696761626C652067656E65726174696F6E206F66206B6E6F776C656467652C2065786365656473207468652073686F727420766568656D656E6365206F6620616E79206361726E616C20706C6561737572652E" + expect resp.http.id2hexlc == resp.http.id2hex + expect resp.http.id2url == "foo%3abar%3abaz%3aquux" + expect resp.http.id2urluc == "foo%3Abar%3Abaz%3Aquux" + expect resp.http.id2urllc == resp.http.id2url + expect resp.http.b642id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.hex2id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.hexalldown2b64 == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.hexalldown2b64url == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.hexalldown2b64nopad == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" + expect resp.http.hexallup2b64 == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.hexallup2b64url == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w==" + expect resp.http.hexallup2b64nopad == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w" + expect resp.http.hexalldown2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" + expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" + expect resp.http.hexalldown2urllc == resp.http.hexalldown2url + expect resp.http.hexallup2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.hexallup2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" + expect resp.http.hexallup2urllc == resp.http.hexallup2url +} -run + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.foobar = "foo:bar:baz:quux"; + set req.http.hobbes = +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; + set req.http.hobbesb64 = +{"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; + set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexalldown = +{"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; + set req.http.hexallup = +{"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"}; + set req.http.b64all = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; + set req.http.b64allurl = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; + + set resp.http.b64all2hex + = blob.transcode(BASE64, HEX, encoded=req.http.b64all); set resp.http.b64all2hexuc - = blob.transcode(BASE64, HEXUC, req.http.b64all); + = blob.transcode(BASE64, HEX, UPPER, req.http.b64all); set resp.http.b64all2hexlc - = blob.transcode(BASE64, HEXLC, req.http.b64all); + = blob.transcode(BASE64, HEX, LOWER, req.http.b64all); + + set resp.http.b64allurl2hex + = blob.transcode(BASE64URL, HEX, encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc - = blob.transcode(BASE64URL, HEXUC, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, UPPER, req.http.b64allurl); set resp.http.b64allurl2hexlc - = blob.transcode(BASE64URL, HEXLC, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, LOWER, req.http.b64allurl); + + set resp.http.b64all2url + = blob.transcode(BASE64, URL, encoded=req.http.b64all); set resp.http.b64all2urluc - = blob.transcode(BASE64, URLUC, req.http.b64all); + = blob.transcode(BASE64, URL, UPPER, req.http.b64all); set resp.http.b64all2urllc - = blob.transcode(BASE64, URLLC, req.http.b64all); + = blob.transcode(BASE64, URL, LOWER, req.http.b64all); + + set resp.http.b64allurl2url + = blob.transcode(BASE64URL, URL, encoded=req.http.b64allurl); set resp.http.b64allurl2urluc - = blob.transcode(BASE64URL, URLUC, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, UPPER, req.http.b64allurl); set resp.http.b64allurl2urllc - = blob.transcode(BASE64URL, URLLC, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, LOWER, req.http.b64allurl); + + set resp.http.hexuc2hex + = blob.transcode(HEX, HEX, encoded="0123456789ABCDEF"); set resp.http.hexuc2hexuc - = blob.transcode(HEX, HEXUC, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, UPPER, "0123456789ABCDEF"); set resp.http.hexlc2hexlc - = blob.transcode(HEX, HEXLC, "0123456789abcdef"); + = blob.transcode(HEX, HEX, LOWER, "0123456789abcdef"); + + set resp.http.hexlc2hex + = blob.transcode(HEX, HEX, encoded="0123456789abcdef"); set resp.http.hexuc2hexlc - = blob.transcode(HEX, HEXLC, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, LOWER, "0123456789ABCDEF"); set resp.http.hexlc2hexuc - = blob.transcode(HEX, HEXUC, "0123456789abcdef"); + = blob.transcode(HEX, HEX, UPPER, "0123456789abcdef"); + + set resp.http.hexmix2hex + = blob.transcode(HEX, HEX, encoded="0123456789ABCdef"); set resp.http.hexmix2hexuc - = blob.transcode(HEX, HEXUC, "0123456789ABCdef"); + = blob.transcode(HEX, HEX, UPPER, "0123456789ABCdef"); set resp.http.hexmix2hexlc - = blob.transcode(HEX, HEXLC, "0123456789abcDEF"); + = blob.transcode(HEX, HEX, LOWER, "0123456789abcDEF"); set req.http.hexpart1 = "01234567"; set req.http.hexpart2 = "89abcdef"; @@ -132,62 +221,50 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { + req.http.unset + "" + req.http.hexpart1 + "" + req.http.unset + "" + req.http.unset + req.http.hexpart2, decoding=HEX, - encoding=HEXUC); + encoding=HEX, case=UPPER); set resp.http.b642b64 - = blob.transcode(BASE64, BASE64, + = blob.transcode(BASE64, BASE64, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789+/"); set resp.http.b64url2b64url = - blob.transcode(BASE64URL, BASE64URL, + blob.transcode(BASE64URL, BASE64URL, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); set resp.http.b64urlnopad2b64urlnopad = - blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, + blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); } -} -start +} client c1 { txreq rxresp - expect resp.http.id2id == "Hello world" - expect resp.http.id2b64 == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" - expect resp.http.id2b64nopad == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" - expect resp.http.id2hexuc == "4D616E2069732064697374696E677569736865642C206E6F74206F6E6C792062792068697320726561736F6E2C2062757420627920746869732073696E67756C61722070617373696F6E2066726F6D206F7468657220616E696D616C732C2077686963682069732061206C757374206F6620746865206D696E642C20746861742062792061207065727365766572616E6365206F662064656C6967687420696E2074686520636F6E74696E75656420616E6420696E6465666174696761626C652067656E65726174696F6E206F66206B6E6F776C656467652C2065786365656473207468652073686F727420766568656D656E6365206F6620616E79206361726E616C20706C6561737572652E" - expect resp.http.id2hexlc == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" - expect resp.http.id2urluc == "foo%3Abar%3Abaz%3Aquux" - expect resp.http.id2urllc == "foo%3abar%3abaz%3aquux" - expect resp.http.b642id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." - expect resp.http.hex2id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." - expect resp.http.hexalldown2b64 == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" - expect resp.http.hexalldown2b64url == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" - expect resp.http.hexalldown2b64nopad == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" - expect resp.http.hexallup2b64 == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" - expect resp.http.hexallup2b64url == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w==" - expect resp.http.hexallup2b64nopad == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w" - expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" - expect resp.http.hexalldown2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" - expect resp.http.hexallup2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" - expect resp.http.hexallup2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.b64all2hex == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" expect resp.http.b64all2hexuc == "0000000410410820820C30C31041041451451861861C71C720820824924928A28A2CB2CB30C30C34D34D38E38E3CF3CF4104104514514924924D34D35145145555555965965D75D761861865965969A69A6DB6DB71C71C75D75D79E79E7DF7DF8208208618618A28A28E38E39249249659659A69A69E79E7A28A28A69A69AAAAAAAEBAEBB2CB2CB6DB6DBAEBAEBEFBEFC30C30C71C71CB2CB2CF3CF3D34D34D75D75DB6DB6DF7DF7E38E38E79E79EBAEBAEFBEFBF3CF3CF7DF7DFBEFBEFFFFFF" - expect resp.http.b64all2hexlc == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.b64all2hexlc == resp.http.b64all2hex + expect resp.http.b64allurl2hex == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" expect resp.http.b64allurl2hexuc == "0000000410410820820C30C31041041451451861861C71C720820824924928A28A2CB2CB30C30C34D34D38E38E3CF3CF4104104514514924924D34D35145145555555965965D75D761861865965969A69A6DB6DB71C71C75D75D79E79E7DF7DF8208208618618A28A28E38E39249249659659A69A69E79E7A28A28A69A69AAAAAAAEBAEBB2CB2CB6DB6DBAEBAEBEFBEFC30C30C71C71CB2CB2CF3CF3D34D34D75D75DB6DB6DF7DF7E38E38E79E79EBAEBAEFBEFBF3CF3CF7DF7DFBEFBEFFFFFF" - expect resp.http.b64allurl2hexlc == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.b64allurl2hexlc == resp.http.b64allurl2hex + expect resp.http.b64all2url == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" expect resp.http.b64all2urluc == "%00%00%00%04%10A%08%20%82%0C0%C3%10A%04%14QE%18a%86%1Cq%C7%20%82%08%24%92I%28%A2%8A%2C%B2%CB0%C3%0C4%D3M8%E3%8E%3C%F3%CFA%04%10E%14QI%24%92M4%D3QE%14UUUYe%96%5Du%D7a%86%18e%96Yi%A6%9Am%B6%DBq%C7%1Cu%D7%5Dy%E7%9E%7D%F7%DF%82%08%20%86%18a%8A%28%A2%8E8%E3%92I%24%96Ye%9Ai%A6%9Ey%E7%A2%8A%28%A6%9Ai%AA%AA%AA%AE%BA%EB%B2%CB%2C%B6%DBm%BA%EB%AE%BE%FB%EF%C3%0C0%C7%1Cq%CB%2C%B2%CF%3C%F3%D3M4%D7%5Du%DBm%B6%DF%7D%F7%E3%8E8%E7%9Ey%EB%AE%BA%EF%BE%FB%F3%CF%3C%F7%DF%7D%FB%EF%BE%FF%FF%FF" - expect resp.http.b64all2urllc == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" + expect resp.http.b64all2urllc == resp.http.b64all2url + expect resp.http.b64allurl2url == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" expect resp.http.b64allurl2urluc == "%00%00%00%04%10A%08%20%82%0C0%C3%10A%04%14QE%18a%86%1Cq%C7%20%82%08%24%92I%28%A2%8A%2C%B2%CB0%C3%0C4%D3M8%E3%8E%3C%F3%CFA%04%10E%14QI%24%92M4%D3QE%14UUUYe%96%5Du%D7a%86%18e%96Yi%A6%9Am%B6%DBq%C7%1Cu%D7%5Dy%E7%9E%7D%F7%DF%82%08%20%86%18a%8A%28%A2%8E8%E3%92I%24%96Ye%9Ai%A6%9Ey%E7%A2%8A%28%A6%9Ai%AA%AA%AA%AE%BA%EB%B2%CB%2C%B6%DBm%BA%EB%AE%BE%FB%EF%C3%0C0%C7%1Cq%CB%2C%B2%CF%3C%F3%D3M4%D7%5Du%DBm%B6%DF%7D%F7%E3%8E8%E7%9Ey%EB%AE%BA%EF%BE%FB%F3%CF%3C%F7%DF%7D%FB%EF%BE%FF%FF%FF" - expect resp.http.b64allurl2urllc == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" + expect resp.http.b64allurl2urllc == resp.http.b64all2urllc + expect resp.http.hexlc2hex == "0123456789abcdef" expect resp.http.hexuc2hexuc == "0123456789ABCDEF" - expect resp.http.hexlc2hexlc == "0123456789abcdef" - expect resp.http.hexuc2hexlc == "0123456789abcdef" + expect resp.http.hexlc2hexlc == resp.http.hexlc2hex + expect resp.http.hexuc2hex == "0123456789abcdef" + expect resp.http.hexuc2hexlc == resp.http.hexuc2hex expect resp.http.hexlc2hexuc == "0123456789ABCDEF" + expect resp.http.hexmix2hex == "0123456789abcdef" expect resp.http.hexmix2hexuc == "0123456789ABCDEF" - expect resp.http.hexmix2hexlc == "0123456789abcdef" + expect resp.http.hexmix2hexlc == resp.http.hexmix2hex expect resp.http.hexparam == "0123456789ABCDEF" expect resp.http.b642b64 == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" expect resp.http.b64url2b64url == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" @@ -212,70 +289,84 @@ varnish v1 -vcl { set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id - = blob.transcode(URL, IDENTITY, req.http.urlhobbesuc); + = blob.transcode(URL, IDENTITY, encoded=req.http.urlhobbesuc); set resp.http.urllc2id - = blob.transcode(URL, IDENTITY, req.http.urlhobbeslc); + = blob.transcode(URL, IDENTITY, encoded=req.http.urlhobbeslc); set resp.http.urlalldownuc2b64 - = blob.transcode(URL, BASE64, req.http.urlalldownuc); + = blob.transcode(URL, BASE64, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64url - = blob.transcode(URL, BASE64URL, req.http.urlalldownuc); + = blob.transcode(URL, BASE64URL, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64nopad - = blob.transcode(URL, BASE64URLNOPAD, req.http.urlalldownuc); + = blob.transcode(URL, BASE64URLNOPAD, + encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2b64 - = blob.transcode(URL, BASE64, req.http.urlalldownlc); + = blob.transcode(URL, BASE64, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64url - = blob.transcode(URL, BASE64URL, req.http.urlalldownlc); + = blob.transcode(URL, BASE64URL, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64nopad - = blob.transcode(URL, BASE64URLNOPAD, req.http.urlalldownlc); + = blob.transcode(URL, BASE64URLNOPAD, + encoded=req.http.urlalldownlc); set resp.http.urlallupuc2b64 - = blob.transcode(URL, BASE64, req.http.urlallupuc); + = blob.transcode(URL, BASE64, encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64url - = blob.transcode(URL, BASE64URL, req.http.urlallupuc); + = blob.transcode(URL, BASE64URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64nopad - = blob.transcode(URL, BASE64URLNOPAD, req.http.urlallupuc); + = blob.transcode(URL, BASE64URLNOPAD, encoded=req.http.urlallupuc); set resp.http.urlalluplc2b64 - = blob.transcode(URL, BASE64, req.http.urlalluplc); + = blob.transcode(URL, BASE64, encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64url - = blob.transcode(URL, BASE64URL, req.http.urlalluplc); + = blob.transcode(URL, BASE64URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64nopad - = blob.transcode(URL, BASE64URLNOPAD, req.http.urlalluplc); + = blob.transcode(URL, BASE64URLNOPAD, encoded=req.http.urlalluplc); - set resp.http.urlalldownuc2urluc - = blob.transcode(URL, URLUC, req.http.urlalldownuc); + set resp.http.urlalldownuc2url + = blob.transcode(URL, URL, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urllc - = blob.transcode(URL, URLLC, req.http.urlalldownuc); + = blob.transcode(URL, URL, LOWER, req.http.urlalldownuc); - set resp.http.urlalldownlc2urluc - = blob.transcode(URL, URLUC, req.http.urlalldownlc); + set resp.http.urlalldownuc2urluc + = blob.transcode(URL, URL, UPPER, req.http.urlalldownuc); + + set resp.http.urlalldownlc2url + = blob.transcode(URL, URL, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urllc - = blob.transcode(URL, URLLC, req.http.urlalldownlc); + = blob.transcode(URL, URL, LOWER, req.http.urlalldownlc); + + set resp.http.urlalldownlc2urluc + = blob.transcode(URL, URL, UPPER, req.http.urlalldownlc); + + set resp.http.urlallupuc2url + = blob.transcode(URL, URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urluc - = blob.transcode(URL, URLUC, req.http.urlallupuc); + = blob.transcode(URL, URL, UPPER, req.http.urlallupuc); set resp.http.urlallupuc2urllc - = blob.transcode(URL, URLLC, req.http.urlallupuc); + = blob.transcode(URL, URL, LOWER, req.http.urlallupuc); + + set resp.http.urlalluplc2url + = blob.transcode(URL, URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urluc - = blob.transcode(URL, URLUC, req.http.urlalluplc); + = blob.transcode(URL, URL, UPPER, req.http.urlalluplc); set resp.http.urlalluplc2urllc - = blob.transcode(URL, URLLC, req.http.urlalluplc); + = blob.transcode(URL, URL, LOWER, req.http.urlalluplc); } } @@ -297,14 +388,18 @@ client c1 { expect resp.http.urlalluplc2b64 == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" expect resp.http.urlalluplc2b64url == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w==" expect resp.http.urlalluplc2b64nopad == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w" + expect resp.http.urlalldownuc2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" expect resp.http.urlalldownuc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" - expect resp.http.urlalldownuc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" + expect resp.http.urlalldownuc2urllc == resp.http.urlalldownuc2url + expect resp.http.urlalldownlc2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" expect resp.http.urlalldownlc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" - expect resp.http.urlalldownlc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" + expect resp.http.urlalldownlc2urllc == resp.http.urlalldownlc2url expect resp.http.urlallupuc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" expect resp.http.urlalluplc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" - expect resp.http.urlallupuc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" - expect resp.http.urlalluplc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.urlallupuc2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.urlallupuc2urllc == resp.http.urlallupuc2url + expect resp.http.urlalluplc2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.urlalluplc2urllc == resp.http.urlalluplc2url } -run # Decode failures @@ -321,53 +416,53 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/1") { set resp.http.bad - = blob.transcode(HEX, IDENTITY, "0x123456"); + = blob.transcode(HEX, IDENTITY, encoded="0x123456"); } elsif (req.url == "/2") { set resp.http.bad = blob.transcode(BASE64, IDENTITY, - "-_-_" + req.http.foo); + encoded="-_-_" + req.http.foo); } elsif (req.url == "/3") { set resp.http.bad = blob.transcode(BASE64URL, IDENTITY, - "+/+/" + req.http.foo); + encoded="+/+/" + req.http.foo); } elsif (req.url == "/4") { set resp.http.bad = blob.transcode(BASE64URLNOPAD, IDENTITY, - "TWFu" + req.http.foo); + encoded="TWFu" + req.http.foo); } elsif (req.url == "/5") { set resp.http.bad = blob.transcode(BASE64, BASE64, - "_-_-" + req.http.foo); + encoded="_-_-" + req.http.foo); } elsif (req.url == "/6") { set resp.http.bad = blob.transcode(BASE64URL, BASE64URL, - "/+/+" + req.http.foo); + encoded="/+/+" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad = blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, - "Zm9v" + req.http.foo); + encoded="Zm9v" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad - = blob.transcode(URL, IDENTITY, "%"); + = blob.transcode(URL, IDENTITY, encoded="%"); } elsif (req.url == "/9") { set resp.http.bad - = blob.transcode(URL, IDENTITY, "%2"); + = blob.transcode(URL, IDENTITY, encoded="%2"); } elsif (req.url == "/10") { set resp.http.bad - = blob.transcode(URL, IDENTITY, "%q"); + = blob.transcode(URL, IDENTITY, encoded="%q"); } elsif (req.url == "/11") { set resp.http.bad - = blob.transcode(URL, IDENTITY, "%2q"); + = blob.transcode(URL, IDENTITY, encoded="%2q"); } } } diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index 37ed285..4a96c0f 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -20,109 +20,187 @@ varnish v1 -vcl { {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set req.http.hexallup = {"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"}; - set req.http.b64all = -{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; - set req.http.b64allurl = -{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; set resp.http.id2id - = blob.transcode_n(5, IDENTITY, IDENTITY, "Hello world"); + = blob.transcode_n(5, IDENTITY, IDENTITY, encoded="Hello world"); set resp.http.id2b64 - = blob.transcode_n(5, IDENTITY, BASE64, req.http.hobbes); + = blob.transcode_n(5, IDENTITY, BASE64, encoded=req.http.hobbes); set resp.http.id2b64nopad - = blob.transcode_n(5, IDENTITY, BASE64URLNOPAD, req.http.hobbes); + = blob.transcode_n(5, IDENTITY, BASE64URLNOPAD, + encoded=req.http.hobbes); + + set resp.http.id2hex + = blob.transcode_n(5, IDENTITY, HEX, encoded=req.http.hobbes); set resp.http.id2hexuc - = blob.transcode_n(5, IDENTITY, HEXUC, req.http.hobbes); + = blob.transcode_n(5, IDENTITY, HEX, UPPER, req.http.hobbes); set resp.http.id2hexlc - = blob.transcode_n(5, IDENTITY, HEXLC, req.http.hobbes); + = blob.transcode_n(5, IDENTITY, HEX, LOWER, req.http.hobbes); + + set resp.http.id2url + = blob.transcode_n(5, IDENTITY, URL, encoded=req.http.foobar); set resp.http.id2urluc - = blob.transcode_n(5, IDENTITY, URLUC, req.http.foobar); + = blob.transcode_n(5, IDENTITY, URL, UPPER, req.http.foobar); set resp.http.id2urllc - = blob.transcode_n(5, IDENTITY, URLLC, req.http.foobar); + = blob.transcode_n(5, IDENTITY, URL, LOWER, req.http.foobar); set resp.http.b642id - = blob.transcode_n(8, BASE64, IDENTITY, req.http.hobbesb64); + = blob.transcode_n(8, BASE64, IDENTITY, encoded=req.http.hobbesb64); set resp.http.hex2id - = blob.transcode_n(12, HEX, IDENTITY, req.http.hexhobbes); + = blob.transcode_n(12, HEX, IDENTITY, encoded=req.http.hexhobbes); set resp.http.hexalldown2b64 - = blob.transcode_n(12, HEX, BASE64, req.http.hexalldown); + = blob.transcode_n(12, HEX, BASE64, encoded=req.http.hexalldown); set resp.http.hexalldown2b64url - = blob.transcode_n(12, HEX, BASE64URL, req.http.hexalldown); + = blob.transcode_n(12, HEX, BASE64URL, encoded=req.http.hexalldown); set resp.http.hexalldown2b64nopad - = blob.transcode_n(10, HEX, BASE64URLNOPAD, req.http.hexalldown); + = blob.transcode_n(10, HEX, BASE64URLNOPAD, + encoded=req.http.hexalldown); set resp.http.hexallup2b64 - = blob.transcode_n(12, HEX, BASE64, req.http.hexallup); + = blob.transcode_n(12, HEX, BASE64, encoded=req.http.hexallup); set resp.http.hexallup2b64url - = blob.transcode_n(10, HEX, BASE64URL, req.http.hexallup); + = blob.transcode_n(10, HEX, BASE64URL, encoded=req.http.hexallup); set resp.http.hexallup2b64nopad - = blob.transcode_n(10, HEX, BASE64URLNOPAD, req.http.hexallup); + = blob.transcode_n(10, HEX, BASE64URLNOPAD, + encoded=req.http.hexallup); + + set resp.http.hexalldown2url + = blob.transcode_n(12, HEX, URL, encoded=req.http.hexalldown); set resp.http.hexalldown2urluc - = blob.transcode_n(12, HEX, URLUC, req.http.hexalldown); + = blob.transcode_n(12, HEX, URL, UPPER, req.http.hexalldown); set resp.http.hexalldown2urllc - = blob.transcode_n(12, HEX, URLLC, req.http.hexalldown); + = blob.transcode_n(12, HEX, URL, LOWER, req.http.hexalldown); + + set resp.http.hexallup2url + = blob.transcode_n(12, HEX, URL, encoded=req.http.hexallup); set resp.http.hexallup2urluc - = blob.transcode_n(12, HEX, URLUC, req.http.hexallup); + = blob.transcode_n(12, HEX, URL, UPPER, req.http.hexallup); set resp.http.hexallup2urllc - = blob.transcode_n(12, HEX, URLLC, req.http.hexallup); + = blob.transcode_n(12, HEX, URL, LOWER, req.http.hexallup); + + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.id2id == "Hello" + expect resp.http.id2b64 == "TWFuIGk=" + expect resp.http.id2b64nopad == "TWFuIGk" + expect resp.http.id2hex == "4d616e2069" + expect resp.http.id2hexuc == "4D616E2069" + expect resp.http.id2hexlc == resp.http.id2hex + expect resp.http.id2url == "foo%3ab" + expect resp.http.id2urluc == "foo%3Ab" + expect resp.http.id2urllc == resp.http.id2url + expect resp.http.b642id == "Man is" + expect resp.http.hex2id == "Man is" + expect resp.http.hexalldown2b64 == "//79/Pv6" + expect resp.http.hexalldown2b64url == "__79_Pv6" + expect resp.http.hexalldown2b64nopad == "__79_Ps" + expect resp.http.hexallup2b64 == "AAECAwQF" + expect resp.http.hexallup2b64url == "AAECAwQ=" + expect resp.http.hexallup2b64nopad == "AAECAwQ" + expect resp.http.hexalldown2url == "%ff%fe%fd%fc%fb%fa" + expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA" + expect resp.http.hexalldown2urllc == resp.http.hexalldown2url + expect resp.http.hexallup2url == "%00%01%02%03%04%05" + expect resp.http.hexallup2urllc == resp.http.hexallup2url + expect resp.http.hexallup2urllc == resp.http.hexallup2url +} -run + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.b64all = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; + set req.http.b64allurl = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; + + set resp.http.b64all2hex + = blob.transcode_n(8, BASE64, HEX, encoded=req.http.b64all); set resp.http.b64all2hexuc - = blob.transcode_n(8, BASE64, HEXUC, req.http.b64all); + = blob.transcode_n(8, BASE64, HEX, UPPER, req.http.b64all); set resp.http.b64all2hexlc - = blob.transcode_n(8, BASE64, HEXLC, req.http.b64all); + = blob.transcode_n(8, BASE64, HEX, LOWER, req.http.b64all); + + set resp.http.b64allurl2hex + = blob.transcode_n(8, BASE64URL, HEX, encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc - = blob.transcode_n(8, BASE64URL, HEXUC, req.http.b64allurl); + = blob.transcode_n(8, BASE64URL, HEX, UPPER, req.http.b64allurl); set resp.http.b64allurl2hexlc - = blob.transcode_n(8, BASE64URL, HEXLC, req.http.b64allurl); + = blob.transcode_n(8, BASE64URL, HEX, LOWER, req.http.b64allurl); + + set resp.http.b64all2url + = blob.transcode_n(8, BASE64, URL, encoded=req.http.b64all); set resp.http.b64all2urluc - = blob.transcode_n(8, BASE64, URLUC, req.http.b64all); + = blob.transcode_n(8, BASE64, URL, UPPER, req.http.b64all); set resp.http.b64all2urllc - = blob.transcode_n(8, BASE64, URLLC, req.http.b64all); + = blob.transcode_n(8, BASE64, URL, LOWER, req.http.b64all); + + set resp.http.b64allurl2url + = blob.transcode_n(8, BASE64URL, URL, encoded=req.http.b64allurl); set resp.http.b64allurl2urluc - = blob.transcode_n(8, BASE64URL, URLUC, req.http.b64allurl); + = blob.transcode_n(8, BASE64URL, URL, UPPER, req.http.b64allurl); set resp.http.b64allurl2urllc - = blob.transcode_n(8, BASE64URL, URLLC, req.http.b64allurl); + = blob.transcode_n(8, BASE64URL, URL, LOWER, req.http.b64allurl); + + set resp.http.hexuc2hex + = blob.transcode_n(10, HEX, HEX, encoded="0123456789ABCDEF"); set resp.http.hexuc2hexuc - = blob.transcode_n(10, HEX, HEXUC, "0123456789ABCDEF"); + = blob.transcode_n(10, HEX, HEX, UPPER, "0123456789ABCDEF"); + + set resp.http.hexlc2hex + = blob.transcode_n(10, HEX, HEX, encoded="0123456789abcdef"); set resp.http.hexlc2hexlc - = blob.transcode_n(10, HEX, HEXLC, "0123456789abcdef"); + = blob.transcode_n(10, HEX, HEX, LOWER, "0123456789abcdef"); set resp.http.hexuc2hexlc - = blob.transcode_n(9, HEX, HEXLC, "0123456789ABCDEF"); + = blob.transcode_n(9, HEX, HEX, LOWER, "0123456789ABCDEF"); set resp.http.hexlc2hexuc - = blob.transcode_n(9, HEX, HEXUC, "0123456789abcdef"); + = blob.transcode_n(9, HEX, HEX, UPPER, "0123456789abcdef"); + + set resp.http.hexmix2hex + = blob.transcode_n(13, HEX, HEX, encoded="0123456789abcDEF"); set resp.http.hexmix2hexuc - = blob.transcode_n(15, HEX, HEXUC, "0123456789ABCdef"); + = blob.transcode_n(15, HEX, HEX, UPPER, "0123456789ABCdef"); set resp.http.hexmix2hexlc - = blob.transcode_n(13, HEX, HEXLC, "0123456789abcDEF"); + = blob.transcode_n(13, HEX, HEX, LOWER, "0123456789abcDEF"); set req.http.hexpart1 = "01234567"; set req.http.hexpart2 = "89abcdef"; @@ -131,62 +209,49 @@ varnish v1 -vcl { + req.http.unset + "" + req.http.hexpart1 + "" + req.http.unset + "" + req.http.unset + req.http.hexpart2, decoding=HEX, - encoding=HEXUC, n=10); + encoding=HEX, n=10, case=UPPER); set resp.http.b642b64 - = blob.transcode_n(36, BASE64, BASE64, + = blob.transcode_n(36, BASE64, BASE64, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789+/"); set resp.http.b64url2b64url = - blob.transcode_n(34, BASE64URL, BASE64URL, + blob.transcode_n(34, BASE64URL, BASE64URL, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); set resp.http.b64urlnopad2b64urlnopad = - blob.transcode_n(34, BASE64URLNOPAD, BASE64URLNOPAD, + blob.transcode_n(34, BASE64URLNOPAD, BASE64URLNOPAD, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); } -} -start +} client c1 { txreq rxresp - expect resp.http.id2id == "Hello" - expect resp.http.id2b64 == "TWFuIGk=" - expect resp.http.id2b64nopad == "TWFuIGk" - expect resp.http.id2hexuc == "4D616E2069" - expect resp.http.id2hexlc == "4d616e2069" - expect resp.http.id2urluc == "foo%3Ab" - expect resp.http.id2urllc == "foo%3ab" - expect resp.http.b642id == "Man is" - expect resp.http.hex2id == "Man is" - expect resp.http.hexalldown2b64 == "//79/Pv6" - expect resp.http.hexalldown2b64url == "__79_Pv6" - expect resp.http.hexalldown2b64nopad == "__79_Ps" - expect resp.http.hexallup2b64 == "AAECAwQF" - expect resp.http.hexallup2b64url == "AAECAwQ=" - expect resp.http.hexallup2b64nopad == "AAECAwQ" - expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA" - expect resp.http.hexalldown2urllc == "%ff%fe%fd%fc%fb%fa" - expect resp.http.hexallup2urluc == "%00%01%02%03%04%05" - expect resp.http.hexallup2urllc == "%00%01%02%03%04%05" - expect resp.http.b64all2hexuc == "000000041041" - expect resp.http.b64all2hexlc == "000000041041" - expect resp.http.b64allurl2hexuc == "000000041041" - expect resp.http.b64allurl2hexlc == "000000041041" - expect resp.http.b64all2urluc == "%00%00%00%04%10A" - expect resp.http.b64all2urllc == "%00%00%00%04%10A" - expect resp.http.b64allurl2urluc == "%00%00%00%04%10A" - expect resp.http.b64allurl2urllc == "%00%00%00%04%10A" - expect resp.http.hexuc2hexuc == "0123456789" - expect resp.http.hexlc2hexlc == "0123456789" + expect resp.http.b64all2hex == "000000041041" + expect resp.http.b64all2hexuc == resp.http.b64all2hex + expect resp.http.b64all2hexlc == resp.http.b64all2hex + expect resp.http.b64allurl2hex == "000000041041" + expect resp.http.b64allurl2hexuc == resp.http.b64allurl2hex + expect resp.http.b64allurl2hexlc == resp.http.b64allurl2hex + expect resp.http.b64all2url == "%00%00%00%04%10A" + expect resp.http.b64all2urluc == resp.http.b64all2url + expect resp.http.b64all2urllc == resp.http.b64all2url + expect resp.http.b64allurl2url == "%00%00%00%04%10A" + expect resp.http.b64allurl2urluc == resp.http.b64allurl2url + expect resp.http.b64allurl2urllc == resp.http.b64allurl2url + expect resp.http.hexuc2hex == "0123456789" + expect resp.http.hexlc2hex == resp.http.hexuc2hex + expect resp.http.hexlc2hexlc == resp.http.hexuc2hex expect resp.http.hexuc2hexlc == "0012345678" - expect resp.http.hexlc2hexuc == "0012345678" + expect resp.http.hexlc2hexuc == resp.http.hexuc2hexlc + expect resp.http.hexmix2hex == "00123456789abc" expect resp.http.hexmix2hexuc == "00123456789ABCDE" - expect resp.http.hexmix2hexlc == "00123456789abc" + expect resp.http.hexmix2hexlc == resp.http.hexmix2hex expect resp.http.hexparam == "0123456789" expect resp.http.b642b64 == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij" expect resp.http.b64url2b64url == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefeQ==" @@ -211,74 +276,88 @@ varnish v1 -vcl { set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id - = blob.transcode_n(27, URL, IDENTITY, req.http.urlhobbesuc); + = blob.transcode_n(27, URL, IDENTITY, encoded=req.http.urlhobbesuc); set resp.http.urllc2id - = blob.transcode_n(63, URL, IDENTITY, req.http.urlhobbeslc); + = blob.transcode_n(63, URL, IDENTITY, encoded=req.http.urlhobbeslc); set resp.http.urlalldownuc2b64 - = blob.transcode_n(18, URL, BASE64, req.http.urlalldownuc); + = blob.transcode_n(18, URL, BASE64, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64url - = blob.transcode_n(15, URL, BASE64URL, req.http.urlalldownuc); + = blob.transcode_n(15, URL, BASE64URL, + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64nopad = blob.transcode_n(15, URL, BASE64URLNOPAD, - req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2b64 - = blob.transcode_n(18, URL, BASE64, req.http.urlalldownlc); + = blob.transcode_n(18, URL, BASE64, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64url - = blob.transcode_n(15, URL, BASE64URL, req.http.urlalldownlc); + = blob.transcode_n(15, URL, BASE64URL, + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64nopad = blob.transcode_n(15, URL, BASE64URLNOPAD, - req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlallupuc2b64 - = blob.transcode_n(36, URL, BASE64, req.http.urlallupuc); + = blob.transcode_n(36, URL, BASE64, encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64url - = blob.transcode_n(33, URL, BASE64URL, req.http.urlallupuc); + = blob.transcode_n(33, URL, BASE64URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64nopad = blob.transcode_n(33, URL, BASE64URLNOPAD, - req.http.urlallupuc); + encoded=req.http.urlallupuc); set resp.http.urlalluplc2b64 - = blob.transcode_n(36, URL, BASE64, req.http.urlalluplc); + = blob.transcode_n(36, URL, BASE64, encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64url - = blob.transcode_n(33, URL, BASE64URL, req.http.urlalluplc); + = blob.transcode_n(33, URL, BASE64URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64nopad = blob.transcode_n(33, URL, BASE64URLNOPAD, - req.http.urlalluplc); + encoded=req.http.urlalluplc); + + set resp.http.urlalldownuc2url + = blob.transcode_n(423, URL, URL, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urluc - = blob.transcode_n(423, URL, URLUC, req.http.urlalldownuc); + = blob.transcode_n(423, URL, URL, UPPER, req.http.urlalldownuc); set resp.http.urlalldownuc2urllc - = blob.transcode_n(423, URL, URLLC, req.http.urlalldownuc); + = blob.transcode_n(423, URL, URL, LOWER, req.http.urlalldownuc); + + set resp.http.urlalldownlc2url + = blob.transcode_n(423, URL, URL, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urluc - = blob.transcode_n(423, URL, URLUC, req.http.urlalldownlc); + = blob.transcode_n(423, URL, URL, UPPER, req.http.urlalldownlc); set resp.http.urlalldownlc2urllc - = blob.transcode_n(423, URL, URLLC, req.http.urlalldownlc); + = blob.transcode_n(423, URL, URL, LOWER, req.http.urlalldownlc); + + set resp.http.urlallupuc2url + = blob.transcode_n(197, URL, URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urluc - = blob.transcode_n(197, URL, URLUC, req.http.urlallupuc); + = blob.transcode_n(197, URL, URL, UPPER, req.http.urlallupuc); set resp.http.urlallupuc2urllc - = blob.transcode_n(197, URL, URLLC, req.http.urlallupuc); + = blob.transcode_n(197, URL, URL, LOWER, req.http.urlallupuc); + + set resp.http.urlalluplc2url + = blob.transcode_n(197, URL, URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urluc - = blob.transcode_n(197, URL, URLUC, req.http.urlalluplc); + = blob.transcode_n(197, URL, URL, UPPER, req.http.urlalluplc); set resp.http.urlalluplc2urllc - = blob.transcode_n(197, URL, URLLC, req.http.urlalluplc); + = blob.transcode_n(197, URL, URL, LOWER, req.http.urlalluplc); } } @@ -300,14 +379,18 @@ client c1 { expect resp.http.urlalluplc2b64 == "AAECAwQFBgcICQoL" expect resp.http.urlalluplc2b64url == "AAECAwQFBgcICQo=" expect resp.http.urlalluplc2b64nopad == "AAECAwQFBgcICQo" + expect resp.http.urlalldownuc2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" expect resp.http.urlalldownuc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba" - expect resp.http.urlalldownuc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" + expect resp.http.urlalldownuc2urllc == resp.http.urlalldownuc2url + expect resp.http.urlalldownlc2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" expect resp.http.urlalldownlc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba" - expect resp.http.urlalldownlc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" + expect resp.http.urlalldownlc2urllc == resp.http.urlalldownlc2url + expect resp.http.urlallupuc2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" + expect resp.http.urlalluplc2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" expect resp.http.urlallupuc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" expect resp.http.urlalluplc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" - expect resp.http.urlallupuc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" - expect resp.http.urlalluplc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" + expect resp.http.urlallupuc2urllc == resp.http.urlallupuc2url + expect resp.http.urlalluplc2urllc == resp.http.urlalluplc2url } -run # Decode failures @@ -324,55 +407,57 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/1") { set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, "%2c%q"); + = blob.transcode_n(3, URL, IDENTITY, + encoded="%2c%q"); } elsif (req.url == "/2") { set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, "%3a%2q"); + = blob.transcode_n(3, URL, IDENTITY, + encoded="%3a%2q"); } elsif (req.url == "/3") { set resp.http.bad = blob.transcode_n(8, HEX, IDENTITY, - "0x123456"); + encoded="0x123456"); } elsif (req.url == "/4") { set resp.http.bad = blob.transcode_n(4, BASE64, IDENTITY, - "-_-_" + req.http.foo); + encoded="-_-_" + req.http.foo); } elsif (req.url == "/5") { set resp.http.bad = blob.transcode_n(4, BASE64URL, IDENTITY, - "+/+/" + req.http.foo); + encoded="+/+/" + req.http.foo); } elsif (req.url == "/6") { set resp.http.bad = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, - "TWFu" + req.http.foo); + encoded="TWFu" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad = blob.transcode_n(4, BASE64, BASE64, - "_-_-" + req.http.foo); + encoded="_-_-" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad = blob.transcode_n(4, BASE64URL, BASE64URL, - "/+/+" + req.http.foo); + encoded="/+/+" + req.http.foo); } elsif (req.url == "/9") { set resp.http.bad = blob.transcode_n(8, BASE64URLNOPAD, - BASE64URLNOPAD, - "Zm9v" + req.http.foo); + BASE64URLNOPAD, + encoded="Zm9v" + req.http.foo); } elsif (req.url == "/10") { set resp.http.bad - = blob.transcode_n(1, URL, IDENTITY, "%20"); + = blob.transcode_n(1, URL, IDENTITY, encoded="%20"); } elsif (req.url == "/11") { set resp.http.bad - = blob.transcode_n(2, URL, IDENTITY, "%20"); + = blob.transcode_n(2, URL, IDENTITY, encoded="%20"); } } } diff --git a/bin/varnishtest/tests/m00043.vtc b/bin/varnishtest/tests/m00043.vtc index 7c3408a..7521255 100644 --- a/bin/varnishtest/tests/m00043.vtc +++ b/bin/varnishtest/tests/m00043.vtc @@ -33,50 +33,32 @@ varnish v1 -arg "-i serverid" -vcl+backend { } sub vcl_synth { - set resp.http.id = blob.encode(IDENTITY, id.get()); - set resp.http.idpieces = blob.encode(IDENTITY, idpieces.get()); - set resp.http.idparam = blob.encode(IDENTITY, idparam.get()); - set resp.http.idempty = blob.encode(IDENTITY, idempty.get()); - set resp.http.hexuc = blob.encode(IDENTITY, hexuc.get()); - set resp.http.hexlc = blob.encode(IDENTITY, hexlc.get()); - set resp.http.hexmix = blob.encode(IDENTITY, hexmix.get()); - set resp.http.b64 = blob.encode(IDENTITY, b64.get()); - set resp.http.b64nopad = blob.encode(IDENTITY, b64nopad.get()); + set resp.http.id = blob.encode(IDENTITY, blob=id.get()); + set resp.http.idpieces = blob.encode(IDENTITY, blob=idpieces.get()); + set resp.http.idparam = blob.encode(IDENTITY, blob=idparam.get()); + set resp.http.idempty = blob.encode(IDENTITY, blob=idempty.get()); + set resp.http.hexuc = blob.encode(IDENTITY, blob=hexuc.get()); + set resp.http.hexlc = blob.encode(IDENTITY, blob=hexlc.get()); + set resp.http.hexmix = blob.encode(IDENTITY, blob=hexmix.get()); + set resp.http.b64 = blob.encode(IDENTITY, blob=b64.get()); + set resp.http.b64nopad = blob.encode(IDENTITY, blob=b64nopad.get()); set resp.http.allhex2b64func = blob.encode(BASE64, - hexall.get()); - set resp.http.allb642hexlcfunc = blob.encode(HEXLC, - b64all.get()); + blob=hexall.get()); + set resp.http.allb642hexlcfunc = blob.encode(HEX, + blob=b64all.get()); set resp.http.allhex2b64meth = hexall.encode(BASE64); - set resp.http.allb642hexlcmeth = b64all.encode(HEXLC); + set resp.http.allb642hexmeth = b64all.encode(HEX); + set resp.http.allb642hexlcmeth = b64all.encode(HEX, LOWER); set resp.http.id2id = id.encode(IDENTITY); set resp.http.id2b64 = id.encode(BASE64); set resp.http.id2b64url = id.encode(BASE64URL); set resp.http.id2b64urlnopad = id.encode(BASE64URLNOPAD); - set resp.http.id2hexuc = id.encode(HEXUC); - set resp.http.id2hexlc = id.encode(HEXLC); + set resp.http.id2hex = id.encode(HEX); + set resp.http.id2hexuc = id.encode(HEX, UPPER); + set resp.http.id2hexlc = id.encode(HEX, LOWER); - set resp.http.emptyid = idempty.encode(IDENTITY); - set resp.http.emptyb64 = idempty.encode(BASE64); - set resp.http.emptyb64url = idempty.encode(BASE64URL); - set resp.http.emptyb64urlnopad = idempty.encode(BASE64URLNOPAD); - set resp.http.emptyhexuc = idempty.encode(HEXUC); - set resp.http.emptyhexlc = idempty.encode(HEXLC); - - set resp.http.hexuc2id = hexuc.encode(IDENTITY); - set resp.http.hexuc2b64 = hexuc.encode(BASE64); - set resp.http.hexuc2b64url = hexuc.encode(BASE64URL); - set resp.http.hexuc2b64nopad = hexuc.encode(BASE64URLNOPAD); - set resp.http.hexuc2hexuc = hexuc.encode(HEXUC); - set resp.http.hexuc2hexlc = hexuc.encode(HEXLC); - - set resp.http.hexlc2id = hexlc.encode(IDENTITY); - set resp.http.hexlc2b64 = hexlc.encode(BASE64); - set resp.http.hexlc2b64url = hexlc.encode(BASE64URL); - set resp.http.hexlc2b64nopad = hexlc.encode(BASE64URLNOPAD); - set resp.http.hexlc2hexuc = hexlc.encode(HEXUC); - set resp.http.hexlc2hexlc = hexlc.encode(HEXLC); } } -start @@ -96,35 +78,88 @@ client c1 { expect resp.http.allhex2b64func == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" expect resp.http.allb642hexlcfunc == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" expect resp.http.allhex2b64meth == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" - expect resp.http.allb642hexlcmeth == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + expect resp.http.allb642hexmeth == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + expect resp.http.allb642hexlcmeth == resp.http.allb642hexmeth expect resp.http.id2id == "The quick brown fox jumps over the lazy dog" expect resp.http.id2b64 == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" expect resp.http.id2b64url == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" expect resp.http.id2b64urlnopad == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + expect resp.http.id2hex == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" expect resp.http.id2hexuc == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67" - expect resp.http.id2hexlc == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" + expect resp.http.id2hexlc == resp.http.id2hex +} -run + +# run twice to test retrieving cached encodings +client c1 -run + +varnish v1 -vcl+backend { + import blob; + sub vcl_init { + new idempty = blob.blob(IDENTITY, ""); + + new hexuc = blob.blob(HEX, "666F6F206261722062617A2071757578"); + new hexlc = blob.blob(HEX, "666f6f206261722062617a2071757578"); + } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.emptyid = idempty.encode(IDENTITY); + set resp.http.emptyb64 = idempty.encode(BASE64); + set resp.http.emptyb64url = idempty.encode(BASE64URL); + set resp.http.emptyb64urlnopad = idempty.encode(BASE64URLNOPAD); + set resp.http.emptyhex = idempty.encode(HEX); + set resp.http.emptyhexuc = idempty.encode(HEX, UPPER); + set resp.http.emptyhexlc = idempty.encode(HEX, LOWER); + + set resp.http.hexuc2id = hexuc.encode(IDENTITY); + set resp.http.hexuc2b64 = hexuc.encode(BASE64); + set resp.http.hexuc2b64url = hexuc.encode(BASE64URL); + set resp.http.hexuc2b64nopad = hexuc.encode(BASE64URLNOPAD); + set resp.http.hexuc2hex = hexuc.encode(HEX); + set resp.http.hexuc2hexuc = hexuc.encode(HEX, UPPER); + set resp.http.hexuc2hexlc = hexuc.encode(HEX, LOWER); + + set resp.http.hexlc2id = hexlc.encode(IDENTITY); + set resp.http.hexlc2b64 = hexlc.encode(BASE64); + set resp.http.hexlc2b64url = hexlc.encode(BASE64URL); + set resp.http.hexlc2b64nopad = hexlc.encode(BASE64URLNOPAD); + set resp.http.hexlc2hex = hexlc.encode(HEX); + set resp.http.hexlc2hexuc = hexlc.encode(HEX, UPPER); + set resp.http.hexlc2hexlc = hexlc.encode(HEX, LOWER); + } +} + +client c1 { + txreq + rxresp expect resp.http.emptyid == "" expect resp.http.emptyb64 == "" expect resp.http.emptyb64url == "" expect resp.http.emptyb64urlnopad == "" + expect resp.http.emptyhex == "" expect resp.http.emptyhexuc == "" - expect resp.http.emptyhexlc == "" + expect resp.http.emptyhexlc == resp.http.emptyhex expect resp.http.hexuc2id == "foo bar baz quux" expect resp.http.hexuc2b64 == "Zm9vIGJhciBiYXogcXV1eA==" expect resp.http.hexuc2b64url == "Zm9vIGJhciBiYXogcXV1eA==" expect resp.http.hexuc2b64nopad == "Zm9vIGJhciBiYXogcXV1eA" + expect resp.http.hexuc2hex == "666f6f206261722062617a2071757578" expect resp.http.hexuc2hexuc == "666F6F206261722062617A2071757578" - expect resp.http.hexuc2hexlc == "666f6f206261722062617a2071757578" + expect resp.http.hexuc2hexlc == resp.http.hexuc2hex expect resp.http.hexlc2id == "foo bar baz quux" expect resp.http.hexlc2b64 == "Zm9vIGJhciBiYXogcXV1eA==" expect resp.http.hexlc2b64url == "Zm9vIGJhciBiYXogcXV1eA==" expect resp.http.hexlc2b64nopad == "Zm9vIGJhciBiYXogcXV1eA" + expect resp.http.hexlc2hex == "666f6f206261722062617a2071757578" expect resp.http.hexlc2hexuc == "666F6F206261722062617A2071757578" - expect resp.http.hexlc2hexlc == "666f6f206261722062617a2071757578" + expect resp.http.hexlc2hexlc == resp.http.hexlc2hex } -run # run twice to test retrieving cached encodings @@ -148,28 +183,34 @@ varnish v1 -vcl+backend { set resp.http.b642b64 = b64.encode(BASE64); set resp.http.b642b64url = b64.encode(BASE64URL); set resp.http.b642b64nopad = b64.encode(BASE64URLNOPAD); - set resp.http.b642hexuc = b64.encode(HEXUC); - set resp.http.b642hexlc = b64.encode(HEXLC); - set resp.http.b642urluc = b64.encode(URLUC); - set resp.http.b642urllc = b64.encode(URLLC); + set resp.http.b642hex = b64.encode(HEX); + set resp.http.b642hexuc = b64.encode(HEX, UPPER); + set resp.http.b642hexlc = b64.encode(HEX, LOWER); + set resp.http.b642url = b64.encode(URL); + set resp.http.b642urluc = b64.encode(URL, UPPER); + set resp.http.b642urllc = b64.encode(URL, LOWER); set resp.http.b64url2id = b64url.encode(IDENTITY); set resp.http.b64url2b64 = b64url.encode(BASE64); set resp.http.b64url2b64url = b64url.encode(BASE64URL); set resp.http.b64url2b64nopad = b64url.encode(BASE64URLNOPAD); - set resp.http.b64url2hexuc = b64url.encode(HEXUC); - set resp.http.b64url2hexlc = b64url.encode(HEXLC); - set resp.http.b64url2urluc = b64url.encode(URLUC); - set resp.http.b64url2urllc = b64url.encode(URLLC); + set resp.http.b64url2hex = b64url.encode(HEX); + set resp.http.b64url2hexuc = b64url.encode(HEX, UPPER); + set resp.http.b64url2hexlc = b64url.encode(HEX, LOWER); + set resp.http.b64url2url = b64url.encode(URL); + set resp.http.b64url2urluc = b64url.encode(URL, UPPER); + set resp.http.b64url2urllc = b64url.encode(URL, LOWER); set resp.http.b64nopad2id = b64nopad.encode(IDENTITY); set resp.http.b64nopad2b64 = b64nopad.encode(BASE64); set resp.http.b64nopad2b64url = b64nopad.encode(BASE64URL); set resp.http.b64nopad2b64nopad = b64nopad.encode(BASE64URLNOPAD); - set resp.http.b64nopad2hexuc = b64nopad.encode(HEXUC); - set resp.http.b64nopad2hexlc = b64nopad.encode(HEXLC); - set resp.http.b64nopad2urluc = b64nopad.encode(URLUC); - set resp.http.b64nopad2urllc = b64nopad.encode(URLLC); + set resp.http.b64nopad2hex = b64nopad.encode(HEX); + set resp.http.b64nopad2hexuc = b64nopad.encode(HEX, UPPER); + set resp.http.b64nopad2hexlc = b64nopad.encode(HEX, LOWER); + set resp.http.b64nopad2url = b64nopad.encode(URL); + set resp.http.b64nopad2urluc = b64nopad.encode(URL, UPPER); + set resp.http.b64nopad2urllc = b64nopad.encode(URL, LOWER); } } @@ -180,28 +221,34 @@ client c2 { expect resp.http.b642b64 == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b642b64url == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b642b64nopad == "L0hlbGxvIHdvcmxkLw" + expect resp.http.b642hex == "2f48656c6c6f20776f726c642f" expect resp.http.b642hexuc == "2F48656C6C6F20776F726C642F" - expect resp.http.b642hexlc == "2f48656c6c6f20776f726c642f" + expect resp.http.b642hexlc == resp.http.b642hex + expect resp.http.b642url == "%2fHello%20world%2f" expect resp.http.b642urluc == "%2FHello%20world%2F" - expect resp.http.b642urllc == "%2fHello%20world%2f" + expect resp.http.b642urllc == resp.http.b642url expect resp.http.b64url2id == "/Hello world/" expect resp.http.b64url2b64 == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b64url2b64url == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b64url2b64nopad == "L0hlbGxvIHdvcmxkLw" + expect resp.http.b64url2hex == "2f48656c6c6f20776f726c642f" expect resp.http.b64url2hexuc == "2F48656C6C6F20776F726C642F" - expect resp.http.b64url2hexlc == "2f48656c6c6f20776f726c642f" + expect resp.http.b64url2hexlc == resp.http.b64url2hex + expect resp.http.b64url2url == "%2fHello%20world%2f" expect resp.http.b64url2urluc == "%2FHello%20world%2F" - expect resp.http.b64url2urllc == "%2fHello%20world%2f" + expect resp.http.b64url2urllc == resp.http.b64url2url expect resp.http.b64nopad2id == "/Hello world/" expect resp.http.b64nopad2b64 == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b64nopad2b64url == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b64nopad2b64nopad == "L0hlbGxvIHdvcmxkLw" + expect resp.http.b64nopad2hex == "2f48656c6c6f20776f726c642f" expect resp.http.b64nopad2hexuc == "2F48656C6C6F20776F726C642F" - expect resp.http.b64nopad2hexlc == "2f48656c6c6f20776f726c642f" + expect resp.http.b64nopad2hexlc == resp.http.b64nopad2hex + expect resp.http.b64nopad2url == "%2fHello%20world%2f" expect resp.http.b64nopad2urluc == "%2FHello%20world%2F" - expect resp.http.b64nopad2urllc == "%2fHello%20world%2f" + expect resp.http.b64nopad2urllc == resp.http.b64nopad2url } -run # run twice @@ -224,46 +271,58 @@ varnish v1 -vcl+backend { } sub vcl_synth { - set resp.http.id2urluc = id.encode(URLUC); - set resp.http.id2urllc = id.encode(URLLC); - set resp.http.emptyurluc = idempty.encode(URLUC); - set resp.http.emptyurllc = idempty.encode(URLLC); - set resp.http.url = blob.encode(IDENTITY, url.get()); - set resp.http.hexuc2urluc = hexuc.encode(URLUC); - set resp.http.hexuc2urllc = hexuc.encode(URLLC); - set resp.http.hexlc2urluc = hexlc.encode(URLUC); - set resp.http.hexlc2urllc = hexlc.encode(URLLC); + set resp.http.id2url = id.encode(URL); + set resp.http.id2urluc = id.encode(URL, UPPER); + set resp.http.id2urllc = id.encode(URL, LOWER); + set resp.http.emptyurl = idempty.encode(URL); + set resp.http.emptyurluc = idempty.encode(URL, UPPER); + set resp.http.emptyurllc = idempty.encode(URL, LOWER); + set resp.http.url = blob.encode(IDENTITY, blob=url.get()); + set resp.http.hexuc2url = hexuc.encode(URL); + set resp.http.hexuc2urluc = hexuc.encode(URL, UPPER); + set resp.http.hexuc2urllc = hexuc.encode(URL, LOWER); + set resp.http.hexlc2url = hexlc.encode(URL); + set resp.http.hexlc2urluc = hexlc.encode(URL, UPPER); + set resp.http.hexlc2urllc = hexlc.encode(URL, LOWER); set resp.http.url2id = url.encode(IDENTITY); set resp.http.url2b64 = url.encode(BASE64); set resp.http.url2b64url = url.encode(BASE64URL); set resp.http.url2b64nopad = url.encode(BASE64URLNOPAD); - set resp.http.url2hexuc = url.encode(HEXUC); - set resp.http.url2hexlc = url.encode(HEXLC); - set resp.http.url2urluc = url.encode(URLUC); - set resp.http.url2urllc = url.encode(URLLC); + set resp.http.url2hex = url.encode(HEX); + set resp.http.url2hexuc = url.encode(HEX, UPPER); + set resp.http.url2hexlc = url.encode(HEX, LOWER); + set resp.http.url2url = url.encode(URL); + set resp.http.url2urluc = url.encode(URL, UPPER); + set resp.http.url2urllc = url.encode(URL, LOWER); } } client c3 { txreq rxresp + expect resp.http.id2url == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" expect resp.http.id2urluc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" - expect resp.http.id2urllc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.id2urllc == resp.http.id2url + expect resp.http.emptyurl == "" expect resp.http.emptyurluc == "" - expect resp.http.emptyurllc == "" + expect resp.http.emptyurllc == resp.http.emptyurl + expect resp.http.hexuc2url == "foo%20bar%20baz%20quux" expect resp.http.hexuc2urluc == "foo%20bar%20baz%20quux" - expect resp.http.hexuc2urllc == "foo%20bar%20baz%20quux" + expect resp.http.hexuc2urllc == resp.http.hexuc2url + expect resp.http.hexlc2url == "foo%20bar%20baz%20quux" expect resp.http.hexlc2urluc == "foo%20bar%20baz%20quux" - expect resp.http.hexlc2urllc == "foo%20bar%20baz%20quux" + expect resp.http.hexlc2urllc == resp.http.hexlc2url expect resp.http.url == "foo:bar:baz:quux" expect resp.http.url2id == "foo:bar:baz:quux" expect resp.http.url2b64 == "Zm9vOmJhcjpiYXo6cXV1eA==" expect resp.http.url2b64url == "Zm9vOmJhcjpiYXo6cXV1eA==" expect resp.http.url2b64nopad == "Zm9vOmJhcjpiYXo6cXV1eA" + expect resp.http.url2hex == "666f6f3a6261723a62617a3a71757578" expect resp.http.url2hexuc == "666F6F3A6261723A62617A3A71757578" - expect resp.http.url2hexlc == "666f6f3a6261723a62617a3a71757578" + expect resp.http.url2hexlc == resp.http.url2hexlc + expect resp.http.url2url == "foo%3abar%3abaz%3aquux" expect resp.http.url2urluc == "foo%3Abar%3Abaz%3Aquux" - expect resp.http.url2urllc == "foo%3abar%3abaz%3aquux" + expect resp.http.url2urllc == resp.http.url2url } -run # run twice diff --git a/bin/varnishtest/tests/m00044.vtc b/bin/varnishtest/tests/m00044.vtc index 20b6b51..ba4b757 100644 --- a/bin/varnishtest/tests/m00044.vtc +++ b/bin/varnishtest/tests/m00044.vtc @@ -20,7 +20,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { sub vcl_deliver { # The .get() method retrieves the BLOB from an object. set resp.http.MyBlob-As-Hex - = blob.encode(blob=myblob.get(), encoding=HEXLC); + = blob.encode(blob=myblob.get(), encoding=HEX); # The .encode() method efficiently retrieves an encoding. set resp.http.YourBlob-As-Base64 = yourblob.encode(BASE64); @@ -29,19 +29,20 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # vice versa at runtime. set resp.http.Base64-Encoded = blob.encode(BASE64, - blob.decode(HEX, req.http.Hex-Encoded)); + blob=blob.decode(HEX, req.http.Hex-Encoded)); } sub vcl_recv { # transcode() converts from one encoding to another. set req.http.Hex-Encoded - = blob.transcode(decoding=BASE64, encoding=HEXUC, encoded="YmF6"); + = blob.transcode(decoding=BASE64, encoding=HEX, case=UPPER, + encoded="YmF6"); # transcode() can replace other specific encoding/deconding # vmods - e.g. vmod_urlcode set req.url = blob.transcode(encoded=req.url, decoding=URL); set req.http.url_urlcoded - = blob.transcode(encoded=req.url, encoding=URLLC); + = blob.transcode(encoded=req.url, encoding=URL); } # get output from recv sub vcl_deliver { @@ -52,7 +53,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # IDENTITY sub vcl_deliver { set resp.http.Trunced-Foo1 - = blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + = blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); set resp.http.Trunced-Foo2 = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); } @@ -63,21 +64,21 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { set resp.http.First = "abc"; set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode( - HEXLC, - blob.decode(HEX, resp.http.First + resp.http.Second)); + HEX, + blob=blob.decode(HEX, resp.http.First + resp.http.Second)); } ############################################################ # encode - also contains decode examples sub vcl_deliver { set resp.http.encode1 - = blob.encode(HEXLC, blob.decode(BASE64, "Zm9vYmFyYmF6")); + = blob.encode(HEX, blob=blob.decode(BASE64, "Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 = blob.encode(blob=blob.decode(encoded="Zm9vYmFyYmF6", decoding=BASE64), - encoding=HEXLC); + encoding=HEX); # convert blob to string set resp.http.encode3 @@ -87,7 +88,8 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { ############################################################ # transcode sub vcl_deliver { - set resp.http.Hex2Base64-1 = blob.transcode(HEX, BASE64, "666f6f"); + set resp.http.Hex2Base64-1 + = blob.transcode(HEX, BASE64, encoded="666f6f"); # same with named parameters set resp.http.Hex2Base64-2 @@ -100,7 +102,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # replacement for urlcode.encode("foo bar") set resp.http.urlencoded - = blob.transcode(encoded="foo bar", encoding=URLLC); + = blob.transcode(encoded="foo bar", encoding=URL); } ############################################################ diff --git a/bin/varnishtest/tests/m00045.vtc b/bin/varnishtest/tests/m00045.vtc index 654b16a..83697a7 100644 --- a/bin/varnishtest/tests/m00045.vtc +++ b/bin/varnishtest/tests/m00045.vtc @@ -183,19 +183,21 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.up03 - = blob.encode(BASE64, blob.subblob(up07.get(), 4B)); + = blob.encode(BASE64, blob=blob.subblob(up07.get(), 4B)); set resp.http.down07060504 - = blob.encode(BASE64, blob.subblob(down07.get(), 4B)); + = blob.encode(BASE64, blob=blob.subblob(down07.get(), 4B)); set resp.http.up04050607 - = blob.encode(BASE64, blob.subblob(up07.get(), 4B, 4B)); + = blob.encode(BASE64, + blob=blob.subblob(up07.get(), 4B, 4B)); set resp.http.down03 - = blob.encode(BASE64, blob.subblob(down07.get(), 4B, 4B)); + = blob.encode(BASE64, + blob=blob.subblob(down07.get(), 4B, 4B)); set resp.http.up07 - = blob.encode(BASE64, blob.subblob(up07.get(), 8B)); + = blob.encode(BASE64, blob=blob.subblob(up07.get(), 8B)); set resp.http.down07 - = blob.encode(BASE64, blob.subblob(down07.get(), 8B)); + = blob.encode(BASE64, blob=blob.subblob(down07.get(), 8B)); set resp.http.zerobytes - = blob.encode(BASE64, blob.subblob(down07.get(), 0B)); + = blob.encode(BASE64, blob=blob.subblob(down07.get(), 0B)); set resp.http.zerolen = blob.length(blob.subblob(down07.get(), 0B)); } @@ -231,16 +233,17 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/empty") { - set resp.http.empty = blob.encode(BASE64, + set resp.http.empty = blob.encode(BASE64, blob= blob.subblob(empty.get(), 1B)); } elsif (req.url == "/toolong") { set resp.http.toolong - = blob.encode(BASE64, blob.subblob(up07.get(), 9B)); + = blob.encode(BASE64, + blob=blob.subblob(up07.get(), 9B)); } elsif (req.url == "/badoffset") { set resp.http.badoffset = blob.encode(BASE64, - blob.subblob(up07.get(), 4B, 5B)); + blob=blob.subblob(up07.get(), 4B, 5B)); } } } diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index ba2dd54..6c8ea69 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -222,7 +222,7 @@ varnish v1 -errvcl {'req.hash': Not available in method 'vcl_recv'.} { import blob; backend b { .host = "127.0.0.1"; } sub vcl_recv { - blob.encode(HEXLC, req.hash); + blob.encode(HEX, LOWER, req.hash); } } @@ -230,7 +230,7 @@ varnish v1 -errvcl {'req.hash': Not available in method 'vcl_hash'.} { import blob; backend b { .host = "127.0.0.1"; } sub vcl_hash { - blob.encode(HEXLC, req.hash); + blob.encode(HEX, LOWER, req.hash); } } diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c index d06e323..a46d88c 100644 --- a/lib/libvmod_blob/base64.c +++ b/lib/libvmod_blob/base64.c @@ -80,15 +80,16 @@ decode(char *restrict *restrict dest, char *restrict const buf, } ssize_t -base64_encode(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const inbuf, - const size_t inlength) +base64_encode(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const inbuf, const size_t inlength) { const struct b64_alphabet *alpha = &b64_alphabet[enc]; char *p = buf; const uint8_t *in = (const uint8_t *)inbuf; const uint8_t * const end = in + inlength; + (void) kase; AN(buf); AN(alpha); if (in == NULL || inlength == 0) diff --git a/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c index 0195123..b65b07e 100644 --- a/lib/libvmod_blob/hex.c +++ b/lib/libvmod_blob/hex.c @@ -75,21 +75,21 @@ hex2byte(const unsigned char hi, const unsigned char lo) } ssize_t -hex_encode(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const in, - const size_t inlen) +hex_encode(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen) { char *p = buf; const char *alphabet = hex_alphabet[0]; AN(buf); - assert(enc == HEXUC || enc == HEXLC); + assert(enc == HEX); if (in == NULL || inlen == 0) return 0; if (buflen < hex_encode_l(inlen)) return -1; - if (enc != HEXLC) + if (kase == UPPER) alphabet = hex_alphabet[1]; for (int i = 0; i < inlen; i++) { diff --git a/lib/libvmod_blob/id.c b/lib/libvmod_blob/id.c index 3a32061..34bb34b 100644 --- a/lib/libvmod_blob/id.c +++ b/lib/libvmod_blob/id.c @@ -50,11 +50,12 @@ id_decode_l(size_t l) } ssize_t -id_encode(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const in, - const size_t inlen) +id_encode(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen) { (void) enc; + (void) kase; AN(buf); if (buflen < inlen + 1) diff --git a/lib/libvmod_blob/parse_encoding.c b/lib/libvmod_blob/parse_encoding.c index b18185f..2f7a538 100644 --- a/lib/libvmod_blob/parse_encoding.c +++ b/lib/libvmod_blob/parse_encoding.c @@ -17,9 +17,9 @@ parse_encoding (const char *m) { switch (m[0]) { case 'B': goto _0B; // BASE64, BASE64URL, BASE64URLNOPAD - case 'H': goto _0H; // HEX, HEXLC, HEXUC + case 'H': goto _0H; // HEX case 'I': goto _0I; // IDENTITY - case 'U': goto _0U; // URL, URLLC, URLUC + case 'U': goto _0U; // URL default: goto invalid; } _0B: @@ -85,39 +85,11 @@ parse_encoding (const char *m) { } goto invalid; _0H: - switch (m[1]) { - case 'E': goto _1HE; // HEX, HEXLC, HEXUC - default: goto invalid; - } - _1HE: - switch (m[2]) { - case 'X': goto _2HEX; // HEX, HEXLC, HEXUC - default: goto invalid; - } - _2HEX: //HEX - if (term(m[3])) { + if ((m[1] == 'E') && (m[2] == 'X') && (term(m[3]))) { r = HEX; goto ok; } - switch (m[3]) { - case 'L': goto _3HEXL; // HEXLC - case 'U': goto _3HEXU; // HEXUC - default: goto invalid; - } - _3HEXL: - //HEXLC - if ((m[4] == 'C') && (term(m[5]))) { - r = HEXLC; - goto ok; - } - goto invalid; - _3HEXU: - //HEXUC - if ((m[4] == 'C') && (term(m[5]))) { - r = HEXUC; - goto ok; - } goto invalid; _0I: //IDENTITY @@ -127,39 +99,11 @@ parse_encoding (const char *m) { } goto invalid; _0U: - switch (m[1]) { - case 'R': goto _1UR; // URL, URLLC, URLUC - default: goto invalid; - } - _1UR: - switch (m[2]) { - case 'L': goto _2URL; // URL, URLLC, URLUC - default: goto invalid; - } - _2URL: //URL - if (term(m[3])) { + if ((m[1] == 'R') && (m[2] == 'L') && (term(m[3]))) { r = URL; goto ok; } - switch (m[3]) { - case 'L': goto _3URLL; // URLLC - case 'U': goto _3URLU; // URLUC - default: goto invalid; - } - _3URLL: - //URLLC - if ((m[4] == 'C') && (term(m[5]))) { - r = URLLC; - goto ok; - } - goto invalid; - _3URLU: - //URLUC - if ((m[4] == 'C') && (term(m[5]))) { - r = URLUC; - goto ok; - } goto invalid; ok: return r; diff --git a/lib/libvmod_blob/parse_encoding.h b/lib/libvmod_blob/parse_encoding.h index 6d6068b..472ebf8 100644 --- a/lib/libvmod_blob/parse_encoding.h +++ b/lib/libvmod_blob/parse_encoding.h @@ -14,11 +14,7 @@ enum encoding { BASE64URL, BASE64URLNOPAD, HEX, - HEXUC, - HEXLC, URL, - URLLC, - URLUC, __MAX_ENCODING }; diff --git a/lib/libvmod_blob/url.c b/lib/libvmod_blob/url.c index 7368030..deb7355 100644 --- a/lib/libvmod_blob/url.c +++ b/lib/libvmod_blob/url.c @@ -79,20 +79,20 @@ isoutofrange(const uint8_t c) } ssize_t -url_encode(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const in, - const size_t inlen) +url_encode(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen) { char *p = buf; const char * const end = buf + buflen; const char *alphabet = hex_alphabet[0]; AN(buf); - assert(enc == URLUC || enc == URLLC); + assert(enc == URL); if (in == NULL || inlen == 0) return 0; - if (enc != URLLC) + if (kase == UPPER) alphabet = hex_alphabet[1]; for (int i = 0; i < inlen; i++) { diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index aa88db4..a5553c6 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -11,13 +11,13 @@ $Module blob 3 utilities for the VCL blob type :: # binary-to-text encodings - STRING blob.encode(ENUM encoding, BLOB blob) - BLOB blob.decode(ENUM decoding, STRING_LIST encoded) - BLOB blob.decode_n(INT n, ENUM decoding, STRING_LIST encoded) - STRING blob.transcode(ENUM decoding, ENUM encoding, + STRING blob.encode([ENUM encoding,] [ENUM case,] BLOB blob) + BLOB blob.decode([ENUM decoding,] STRING_LIST encoded) + BLOB blob.decode_n(INT n, [ENUM decoding,] STRING_LIST encoded) + STRING blob.transcode([ENUM decoding,] [ENUM encoding,] [ENUM case,] STRING_LIST encoded) - STRING blob.transcode_n(INT n, ENUM decoding, ENUM encoding, - STRING_LIST encoded) + STRING blob.transcode_n(INT n, [ENUM decoding,] [ENUM encoding,] + [ENUM case,] STRING_LIST encoded) # other utilities BOOL blob.same(BLOB, BLOB) @@ -26,9 +26,9 @@ $Module blob 3 utilities for the VCL blob type BLOB blob.subblob(BLOB, BYTES length [, BYTES offset]) # blob object - new OBJ = blob.blob(ENUM decoding, STRING_LIST encoded) + new OBJ = blob.blob([ENUM decoding,] STRING_LIST encoded) BLOB .get() - STRING .encode(ENUM encoding) + STRING .encode([ENUM encoding,] [ENUM case]) DESCRIPTION =========== @@ -47,7 +47,7 @@ Examples:: sub vcl_deliver { # The .get() method retrieves the BLOB from an object. set resp.http.MyBlob-As-Hex - = blob.encode(blob=myblob.get(), encoding=HEXLC); + = blob.encode(blob=myblob.get(), encoding=HEX); # The .encode() method efficiently retrieves an encoding. set resp.http.YourBlob-As-Base64 = yourblob.encode(BASE64); @@ -56,21 +56,22 @@ Examples:: # vice versa at runtime. set resp.http.Base64-Encoded = blob.encode(BASE64, - blob.decode(HEX, req.http.Hex-Encoded)); + blob=blob.decode(HEX, req.http.Hex-Encoded)); } sub vcl_recv { # transcode() converts from one encoding to another. + # case=UPPER specifies upper-case hex digits A-F. set req.http.Hex-Encoded - = blob.transcode(decoding=BASE64, encoding=HEXUC, - encoded="YmF6"); + = blob.transcode(decoding=BASE64, encoding=HEX, + case=UPPER, encoded="YmF6"); # transcode() from URL to IDENTITY effects a URL decode. set req.url = blob.transcode(encoded=req.url, decoding=URL); # transcode() from IDENTITY to URL effects a URL encode. set req.http.url_urlcoded - = blob.transcode(encoded=req.url, encoding=URLLC); + = blob.transcode(encoded=req.url, encoding=URL); } ENCODING SCHEMES @@ -81,7 +82,7 @@ constructor, methods and functions. Decodings convert a (possibly concatenated) string into a blob, while encodings convert a blob into a string. -ENUM values for a decoding can be one of: +ENUM values for an encoding scheme can be one of: * ``IDENTITY`` * ``BASE64`` @@ -90,20 +91,22 @@ ENUM values for a decoding can be one of: * ``HEX`` * ``URL`` -An encoding can be one of: - -* ``IDENTITY`` -* ``BASE64`` -* ``BASE64URL`` -* ``BASE64URLNOPAD`` -* ``HEXUC`` -* ``HEXLC`` -* ``URLUC`` -* ``URLLC`` - Empty strings are decoded into a "null blob" (of length 0), and conversely a null blob is encoded as the empty string. +For encodings with ``HEX`` or ``URL``, you may also specify a ``case`` +ENUM with one of the values ``LOWER`` or ``UPPER`` to produce a string +with lower- or uppercase hex digits (in ``[a-f]`` or ``[A-F]``), +respectively. The default value for ``case`` is ``LOWER``. + +The ``case`` ENUM is not relevant for decodings; ``HEX`` or ``URL`` +strings to be decoded as BLOBs may have hex digits in either case, or +in mixed case. The ``case`` ENUM is also ignored for all other +encodings. You cannot, for example, produce an uppercase string by +using the IDENTITY scheme with ``case=UPPER``. To change the case of a +string, use the ``toupper`` or ``tolower`` functions from +:ref:`vmod_std(3)`. + IDENTITY -------- @@ -120,7 +123,7 @@ blob. For example:: # Decode from the hex encoding for "foo\0bar". # The header will be seen as "foo". set resp.http.Trunced-Foo1 - = blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + = blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); IDENTITY is the default encoding and decoding. So the above can also be written as:: @@ -130,6 +133,8 @@ be written as:: set resp.http.Trunced-Foo2 = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); +The ``case`` ENUM is ignored for ``IDENTITY`` encodings. + BASE64* ------- @@ -150,14 +155,16 @@ The ``BASE64URLNOPAD`` encoding uses the same alphabet as ``BASE6URL``, but leaves out the padding. Thus the length of an encoding with this scheme is not necessarily a mutltiple of four. -HEX* ----- +The ``case`` ENUM is ignored for for all of the ``BASE64*`` encodings. + +HEX +--- -The ``HEX`` decoding converts a hex string, which may contain upper- -or lowercase characters for hex digits ``A`` through ``f``, into a -blob. The ``HEXUC`` or ``HEXLC`` encodings convert a blob into a hex -string with upper- and lowercase digits, respectively. A prefix such -as ``0x`` is not used for any of these schemes. +The ``HEX`` encoding scheme converts hex strings into blobs and vice +versa. For encodings, you may use the ``case`` ENUM to specify upper- +or lowercase hex digits ``A`` through ``f`` (default ``LOWER``). A +prefix such as ``0x`` is not used for an encoding and is illegal for a +decoding. If a hex string to be decoded has an odd number of digits, it is decoded as if a ``0`` is prepended to it; that is, the first digit is @@ -168,18 +175,18 @@ byte. For example:: set resp.http.First = "abc"; set resp.http.Second = "def0"; set resp.http.Hex-Decoded - = blob.encode(HEXLC, blob.decode(HEX, - resp.http.First + resp.http.Second)); + = blob.encode(HEX, blob=blob.decode(HEX, + resp.http.First + resp.http.Second)); -URL* ----- +URL +--- The ``URL`` decoding replaces any ``%<2-hex-digits>`` substrings with the binary value of the hexadecimal number after the % sign. -The ``URLLC`` and ``URLUC`` encodings implement "percent encoding" as per -RFC3986, the hexadecimal characters A-F being output in lower- and -uppercase, respectively. +The ``URL`` encoding implements "percent encoding" as per RFC3986. The +``case`` ENUM determines the case of the hex digits, but does not +affect alphabetic characters that are not percent-encoded. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", STRING_LIST encoded) @@ -187,7 +194,7 @@ $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, Returns the BLOB derived from the string ``encoded`` according to the scheme specified by ``decoding``. -``decoding`` defaults to IDENTITY +``decoding`` defaults to IDENTITY. Example:: @@ -209,24 +216,25 @@ the encoded string. If ``n`` is greater than the length of the string, then return the same result as ``decode()``. $Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", - BLOB blob) + HEX, URL} encoding="IDENTITY", + ENUM {LOWER, UPPER} case="LOWER", BLOB blob) Returns a string representation of the BLOB ``blob`` as specifed by -``encoding``. +``encoding``. ``case`` determines the case of hex digits for the +``HEX`` and ``URL`` encodings, and is ignored for the other encodings. -``encoding`` defaults to IDENTITY +``encoding`` defaults to IDENTITY, and ``case`` defaults to LOWER. Example:: set resp.http.encode1 - = blob.encode(HEXLC, blob.decode(BASE64, "Zm9vYmFyYmF6")); + = blob.encode(HEX, blob=blob.decode(BASE64, "Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 = blob.encode(blob=blob.decode(encoded="Zm9vYmFyYmF6", decoding=BASE64), - encoding=HEXLC); + encoding=HEX); # convert blob to string set resp.http.encode3 @@ -235,28 +243,32 @@ Example:: $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + HEX, URL} encoding="IDENTITY", + ENUM {LOWER, UPPER} case="LOWER", STRING_LIST encoded) Translates from one encoding to another, by first decoding the string ``encoded`` according to the scheme ``decoding``, and then returning the encoding of the resulting blob according to the scheme -``encoding``. +``encoding``. ``case`` determines the case of hex digits for the +``HEX`` and ``URL`` encodings, and is ignored for other encodings. -``decoding`` and ``encoding`` default to IDENTITY +``decoding`` and ``encoding`` default to IDENTITY, and ``case`` +defaults to LOWER. Example:: - set resp.http.Hex2Base64-1 = blob.transcode(HEX, BASE64, "666f6f"); + set resp.http.Hex2Base64-1 + = blob.transcode(HEX, BASE64, encoded="666f6f"); # same with named parameters set resp.http.Hex2Base64-2 - = blob.transcode(encoded="666f6f", + = blob.transcode(encoded="666f6f", encoding=BASE64, decoding=HEX); # URL decode -- recall that IDENTITY is the default encoding. set resp.http.urldecoded - = blob.transcode(encoded="foo%20bar", decoding=URLLC); + = blob.transcode(encoded="foo%20bar", decoding=URL); # URL encode set resp.http.urlencoded @@ -266,7 +278,8 @@ $Function STRING transcode_n(INT n, ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + HEX, URL} encoding="IDENTITY", + ENUM {LOWER, UPPER} case="LOWER", STRING_LIST encoded) Same as ``transcode()``, but only from the first ``n`` characters of @@ -336,11 +349,14 @@ Example:: set resp.http.The-Stringblob = blob.encode(blob=stringblob.get()); -$Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXUC, - HEXLC, URLUC, URLLC} encoding="IDENTITY") +$Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, + URL} encoding="IDENTITY", + ENUM {LOWER, UPPER} case="LOWER") Returns an encoding of BLOB created by the constructor, according to -the scheme ``encoding``. +the scheme ``encoding``. ``case`` determines the case of hex digits +for the ``HEX`` and ``URL`` encodings, and is ignored for other +encodings. Example:: @@ -350,11 +366,11 @@ Example:: # blob as base64 set resp.http.The-Blob-b64 = theblob1.encode(BASE64); -For any ``blob`` object and encoding ``ENC``, encodings via the ``.encode()`` -method and the ``encode()`` function are equal:: +For any ``blob`` object, encoding ``ENC`` and case ``CASE``, encodings +via the ``.encode()`` method and the ``encode()`` function are equal:: # Always true: - blob.encode(ENC, blob.get()) == blob.encode(ENC) + blob.encode(ENC, CASE, blob.get()) == blob.encode(ENC, CASE) But the object method is more efficient -- the encoding is computed once and cached (with allocation in heap memory), and the cached @@ -416,3 +432,4 @@ SEE ALSO * :ref:`varnishd(1)` * :ref:`vcl(7)` +* :ref:`vmod_std(3)` diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 6bb37ed..850f975 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -42,7 +42,7 @@ struct vmod_blob_blob { unsigned magic; #define VMOD_BLOB_MAGIC 0xfade4fa9 struct vmod_priv blob; - char *encoding[__MAX_ENCODING]; + char *encoding[__MAX_ENCODING][2]; pthread_mutex_t lock; }; @@ -51,18 +51,6 @@ struct vmod_blob_blob { .decode = base64_decode, \ .encode = base64_encode -#define HEX_FUNCS \ - .decode_l = hex_decode_l, \ - .decode = hex_decode, \ - .encode_l = hex_encode_l, \ - .encode = hex_encode - -#define URL_FUNCS \ - .decode_l = url_decode_l, \ - .decode = url_decode, \ - .encode_l = url_encode_l, \ - .encode = url_encode - static const struct vmod_blob_fptr { len_f *const decode_l; decode_f *const decode; @@ -95,28 +83,20 @@ static const struct vmod_blob_fptr { .encode_l = base64nopad_encode_l }, [HEX] = { - HEX_FUNCS - }, - [HEXUC] = { - HEX_FUNCS - }, - [HEXLC] = { - HEX_FUNCS + .decode_l = hex_decode_l, + .decode = hex_decode, + .encode_l = hex_encode_l, + .encode = hex_encode }, [URL] = { - URL_FUNCS - }, - [URLUC] = { - URL_FUNCS + .decode_l = url_decode_l, + .decode = url_decode, + .encode_l = url_encode_l, + .encode = url_encode }, - [URLLC] = { - URL_FUNCS - } }; #undef B64_FUNCS -#undef HEX_FUNCS -#undef URL_FUNCS #define ERR(ctx, msg) \ VRT_fail((ctx), "vmod blob error: " msg) @@ -175,6 +155,21 @@ err_decode(VRT_CTX, const char *enc) } } +static inline enum case_e +parse_case(VCL_ENUM case_s) +{ + switch(*case_s) { + case 'L': + AZ(strcmp(case_s + 1, "OWER")); + return LOWER; + case 'U': + AZ(strcmp(case_s + 1, "PPER")); + return UPPER; + default: + WRONG("illegal case enum"); + } +} + /* Objects */ VCL_VOID __match_proto__(td_blob_blob__init) @@ -245,10 +240,12 @@ vmod_blob_get(VRT_CTX, struct vmod_blob_blob *b) } VCL_STRING __match_proto__(td_blob_blob_encode) -vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs) +vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs, + VCL_ENUM case_s) { enum encoding enc = parse_encoding(encs); AENC(enc); + enum case_e kase = parse_case(case_s); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(b, VMOD_BLOB_MAGIC); @@ -256,29 +253,29 @@ vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs) if (b->blob.len == 0) return ""; - if (b->encoding[enc] == NULL) { + if (b->encoding[enc][kase] == NULL) { AZ(pthread_mutex_lock(&b->lock)); - if (b->encoding[enc] == NULL) { + if (b->encoding[enc][kase] == NULL) { ssize_t len = func[enc].encode_l(b->blob.len); assert(len >= 0); if (len == 0) - b->encoding[enc] = empty; + b->encoding[enc][kase] = empty; else { - b->encoding[enc] = malloc(len); - if (b->encoding[enc] == NULL) + b->encoding[enc][kase] = malloc(len); + if (b->encoding[enc][kase] == NULL) ERRNOMEM(ctx, "cannot encode"); else { - char *s = b->encoding[enc]; + char *s = b->encoding[enc][kase]; len = func[enc].encode( - enc, s, len, + enc, kase, s, len, b->blob.priv, b->blob.len); assert(len >= 0); if (len == 0) { free(s); - b->encoding[enc] = empty; + b->encoding[enc][kase] = empty; } else s[len] = '\0'; @@ -287,7 +284,7 @@ vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs) } AZ(pthread_mutex_unlock(&b->lock)); } - return b->encoding[enc]; + return b->encoding[enc][kase]; } VCL_VOID __match_proto__(td_blob_blob__fini) @@ -306,9 +303,12 @@ vmod_blob__fini(struct vmod_blob_blob **blobp) b->blob.priv = NULL; } for (int i = 0; i < __MAX_ENCODING; i++) - if (b->encoding[i] != NULL && b->encoding[i] != empty) { - free(b->encoding[i]); - b->encoding[i] = NULL; + for (int j = 0; j < 2; j++) { + char *s = b->encoding[i][j]; + if (s != NULL && s != empty) { + free(s); + b->encoding[i][j] = NULL; + } } AZ(pthread_mutex_destroy(&b->lock)); FREE_OBJ(b); @@ -413,7 +413,7 @@ vmod_decode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *p, ...) } static VCL_STRING -encode(VRT_CTX, enum encoding enc, VCL_BLOB b) +encode(VRT_CTX, enum encoding enc, enum case_e kase, VCL_BLOB b) { struct wb_s wb; ssize_t len; @@ -430,7 +430,7 @@ encode(VRT_CTX, enum encoding enc, VCL_BLOB b) return NULL; } - len = func[enc].encode(enc, + len = func[enc].encode(enc, kase, wb_buf(&wb), wb_space(&wb), b->priv, b->len); if (len == -1) { @@ -447,18 +447,26 @@ encode(VRT_CTX, enum encoding enc, VCL_BLOB b) } VCL_STRING __match_proto__(td_blob_encode) -vmod_encode(VRT_CTX, VCL_ENUM encs, VCL_BLOB b) +vmod_encode(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, VCL_BLOB b) { enum encoding enc = parse_encoding(encs); - return encode(ctx, enc, b); + enum case_e kase = parse_case(case_s); + return encode(ctx, enc, kase, b); +} + +static inline int +encodes_hex(enum encoding enc) +{ + return (enc == HEX || enc == URL); } static VCL_STRING -transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, +transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, const char *restrict const p, va_list ap) { enum encoding dec = parse_encoding(decs); enum encoding enc = parse_encoding(encs); + enum case_e kase = parse_case(case_s); va_list aq; struct vmod_priv b; VCL_STRING r; @@ -497,8 +505,11 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, * If the encoding and decoding are the same, and the decoding was * legal, just return the string, if there was only one in the * STRING_LIST, or else the concatenated string. + * For encodings with hex digits, we cannot assume the same result. + * since the call may specify upper- or lower-case that differs + * from the encoded string. */ - if (n == -1 && enc == dec) { + if (n == -1 && enc == dec && !encodes_hex(enc)) { const char *q, *pp = p; va_copy(aq, ap); q = find_nonempty_va(&pp, ap); @@ -514,19 +525,19 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, return r; } - r = encode(ctx, enc, &b); + r = encode(ctx, enc, kase, &b); return (r); } VCL_STRING __match_proto__(td_blob_transcode) -vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, +vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, const char *p, ...) { va_list ap; VCL_STRING r; va_start(ap, p); - r = transcode(ctx, -1, decs, encs, p, ap); + r = transcode(ctx, -1, decs, encs, case_s, p, ap); va_end(ap); return (r); @@ -534,13 +545,13 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_STRING __match_proto__(td_blob_transcode_n) vmod_transcode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, - const char *p, ...) + VCL_ENUM case_s, const char *p, ...) { va_list ap; VCL_STRING r; va_start(ap, p); - r = transcode(ctx, n, decs, encs, p, ap); + r = transcode(ctx, n, decs, encs, case_s, p, ap); va_end(ap); return (r); diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h index 3953035..9cc1d45 100644 --- a/lib/libvmod_blob/vmod_blob.h +++ b/lib/libvmod_blob/vmod_blob.h @@ -34,6 +34,11 @@ #define AENC(enc) assert((enc) > _INVALID && (enc) < __MAX_ENCODING) +enum case_e { + LOWER, + UPPER, +}; + /* * Length estimate interface */ @@ -46,6 +51,7 @@ size_t len_f(size_t); * encoding. * * enc: encoding enum (from parse_encoding.h) + * kase: case enum (for encodings with hex digits) * buf: destination of the encoded string * buflen: maximum length available at buf * in: source of data to be encoded @@ -65,9 +71,9 @@ size_t len_f(size_t); * include any terminating null byte) */ typedef -ssize_t encode_f(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const in, - const size_t inlen); +ssize_t encode_f(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen); /* * General interface for a decoder: decode the concatenation of strings From phk at FreeBSD.org Mon Sep 11 21:00:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Sep 2017 21:00:07 +0000 (UTC) Subject: [master] 6d7d399 The -C mode failed to clean up its random workdirectory because of _.pid Message-ID: <20170911210007.4724B94D13@lists.varnish-cache.org> commit 6d7d3992cbb3a7daed0e0766785a8e7095b3b3ad Author: Poul-Henning Kamp Date: Mon Sep 11 20:58:27 2017 +0000 The -C mode failed to clean up its random workdirectory because of _.pid diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 67492d6..8a5f918 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -243,6 +243,7 @@ mgt_Cflag_atexit(void) if (getpid() != mgt_pid) return; (void)rmdir("vmod_cache"); + (void)unlink("_.pid"); (void)rmdir(Cn_arg); } From phk at FreeBSD.org Mon Sep 11 21:53:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Sep 2017 21:53:04 +0000 (UTC) Subject: [master] 5939523 Give up filtering VMOD exported symbols, it breaks at least arm64/FreeBSD Message-ID: <20170911215304.CC81C951A1@lists.varnish-cache.org> commit 5939523bed1655c336be1fbc3f9c49d3a0379ab7 Author: Poul-Henning Kamp Date: Mon Sep 11 21:52:30 2017 +0000 Give up filtering VMOD exported symbols, it breaks at least arm64/FreeBSD diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 3a4472c..30a5928 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -68,7 +68,6 @@ libvmod_XXX_la_CFLAGS = \\ libvmod_XXX_la_LDFLAGS = \\ $(AM_LDFLAGS) \\ -module -export-dynamic -avoid-version -shared \\ - -export-symbols-regex '^Vmod_XXX_Data' \\ @SAN_LDFLAGS@ nodist_libvmod_XXX_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index ae78a9a..9871b3f 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_blob_la_CFLAGS = \ libvmod_blob_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_blob_Data' \ @SAN_LDFLAGS@ nodist_libvmod_blob_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index e5f13a2..5b0195a 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -28,8 +28,6 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -rpath /nowhere \ - -export-symbols-regex '^Vmod_debug_Data' \ @SAN_LDFLAGS@ nodist_libvmod_debug_la_SOURCES = \ diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index 21a702d..f30062d 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_directors_la_CFLAGS = \ libvmod_directors_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_directors_Data' \ @SAN_LDFLAGS@ nodist_libvmod_directors_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index d8f3803..9671d53 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_purge_la_CFLAGS = \ libvmod_purge_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_purge_Data' \ @SAN_LDFLAGS@ nodist_libvmod_purge_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index cbd9bc9..259476e 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_std_la_CFLAGS = \ libvmod_std_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_std_Data' \ @SAN_LDFLAGS@ nodist_libvmod_std_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 7642a2d..545bb56 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_vtc_la_CFLAGS = \ libvmod_vtc_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_vtc_Data' \ @SAN_LDFLAGS@ nodist_libvmod_vtc_la_SOURCES = vcc_if.c vcc_if.h From phk at FreeBSD.org Mon Sep 11 22:26:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Sep 2017 22:26:05 +0000 (UTC) Subject: [master] 4b9f4ce Arg... Deleted one line too much here... Message-ID: <20170911222605.8662D95C9D@lists.varnish-cache.org> commit 4b9f4ce4457b1ad8833d9a1a862ddb3c0d95983b Author: Poul-Henning Kamp Date: Mon Sep 11 22:25:00 2017 +0000 Arg... Deleted one line too much here... diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index 5b0195a..3fb7d98 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -28,6 +28,7 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ + -rpath /nowhere @SAN_LDFLAGS@ nodist_libvmod_debug_la_SOURCES = \ From dridi.boukelmoune at gmail.com Mon Sep 11 22:34:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 22:34:04 +0000 (UTC) Subject: [master] 6f0d0e3 Put the calloc(3) arguments in the right order Message-ID: <20170911223404.DE52C9505F@lists.varnish-cache.org> commit 6f0d0e3582dbd49635609357e548cc78ef6e498c Author: Dridi Boukelmoune Date: Tue Sep 12 00:21:03 2017 +0200 Put the calloc(3) arguments in the right order This is mostly a mechanical patch. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 8da85ae..79d5e41 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -150,7 +150,7 @@ vca_tcp_opt_init(void) for (n = 0; n < n_tcp_opts; n++) { to = &tcp_opts[n]; if (to->ptr == NULL) - to->ptr = calloc(to->sz, 1); + to->ptr = calloc(1, to->sz); AN(to->ptr); if (!strcmp(to->strname, "SO_LINGER")) { assert(to->sz == sizeof linger); @@ -212,7 +212,7 @@ vca_tcp_opt_test(int sock) for (n = 0; n < n_tcp_opts; n++) { to = &tcp_opts[n]; to->need = 1; - ptr = calloc(to->sz, 1); + ptr = calloc(1, to->sz); AN(ptr); l = to->sz; i = getsockopt(sock, to->level, to->optname, ptr, &l); diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 0e05bcc..160d1da 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -78,7 +78,7 @@ mpl_alloc(const struct mempool *mpl) CHECK_OBJ_NOTNULL(mpl, MEMPOOL_MAGIC); tsz = *mpl->cur_size; - mi = calloc(tsz, 1); + mi = calloc(1, tsz); AN(mi); mi->magic = MEMITEM_MAGIC; mi->size = tsz; diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index e89e411..87db657 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -93,7 +93,7 @@ hcl_start(void) unsigned u; lck_hcl = Lck_CreateClass("hcl"); - hcl_head = calloc(sizeof *hcl_head, hcl_nhash); + hcl_head = calloc(hcl_nhash, sizeof *hcl_head); XXXAN(hcl_head); for (u = 0; u < hcl_nhash; u++) { diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 1a51afe..417c97e 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -596,8 +596,8 @@ main(int argc, char **argv) hist_range = hist_high - hist_low; hist_buckets = hist_range * HIST_RES; - bucket_hit = calloc(sizeof *bucket_hit, hist_buckets); - bucket_miss = calloc(sizeof *bucket_miss, hist_buckets); + bucket_hit = calloc(hist_buckets, sizeof *bucket_hit); + bucket_miss = calloc(hist_buckets, sizeof *bucket_miss); if (timebend > 0) t0 = VTIM_mono(); diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 7645faa..c65139b 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -745,7 +745,7 @@ cmd_http_gunzip(CMD_ARGS) vz.avail_in = hp->bodyl; l = hp->bodyl * 10; - p = calloc(l, 1); + p = calloc(1, l); AN(p); vz.next_out = TRUST_ME(p); @@ -790,7 +790,7 @@ gzip_body(const struct http *hp, const char *txt, char **body, int *bodylen) memset(&vz, 0, sizeof vz); l = strlen(txt); - *body = calloc(l + OVERHEAD, 1); + *body = calloc(1, l + OVERHEAD); AN(*body); vz.next_in = TRUST_ME(txt); diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 07386ed..39600ce 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -158,7 +158,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], VRB_INSERT(t_order, &h_order, tp); } else { ntop++; - tp = calloc(sizeof *tp, 1); + tp = calloc(1, sizeof *tp); assert(tp != NULL); tp->hash = u; tp->count = 1.0; diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 910d613..3b63f56 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -386,7 +386,7 @@ In the common case where a private data structure is allocated with malloc would look like this:: if (priv->priv == NULL) { - priv->priv = calloc(sizeof(struct myfoo), 1); + priv->priv = calloc(1, sizeof(struct myfoo)); AN(priv->priv); priv->free = free; /* free(3) */ mystate = priv->priv; diff --git a/include/miniobj.h b/include/miniobj.h index 13aa3a6..b714c70 100644 --- a/include/miniobj.h +++ b/include/miniobj.h @@ -19,7 +19,7 @@ #define ALLOC_OBJ(to, type_magic) \ do { \ - (to) = calloc(sizeof *(to), 1); \ + (to) = calloc(1, sizeof *(to)); \ if ((to) != NULL) \ (to)->magic = (type_magic); \ } while (0) diff --git a/include/vbm.h b/include/vbm.h index f56447d..9dcc3d0 100644 --- a/include/vbm.h +++ b/include/vbm.h @@ -121,7 +121,7 @@ vbit_new(unsigned initial) { struct vbitmap *vb; - vb = calloc(sizeof *vb, 1); + vb = calloc(1, sizeof *vb); assert(vb != NULL); vb->flags |= VBITMAP_FL_MALLOC; if (initial == 0) diff --git a/lib/libvarnish/binary_heap.c b/lib/libvarnish/binary_heap.c index e3bd2eb..9799276 100644 --- a/lib/libvarnish/binary_heap.c +++ b/lib/libvarnish/binary_heap.c @@ -207,7 +207,7 @@ binheap_new(void *priv, binheap_cmp_t *cmp_f, binheap_update_t *update_f) struct binheap *bh; unsigned u; - bh = calloc(sizeof *bh, 1); + bh = calloc(1, sizeof *bh); if (bh == NULL) return (bh); bh->priv = priv; @@ -224,7 +224,7 @@ binheap_new(void *priv, binheap_cmp_t *cmp_f, binheap_update_t *update_f) bh->update = update_f; bh->next = ROOT_IDX; bh->rows = 16; /* A tiny-ish number */ - bh->array = calloc(sizeof *bh->array, bh->rows); + bh->array = calloc(bh->rows, sizeof *bh->array); assert(bh->array != NULL); binheap_addrow(bh); A(bh, ROOT_IDX) = NULL; diff --git a/lib/libvarnish/vav.c b/lib/libvarnish/vav.c index 51a7ef6..4c4a779 100644 --- a/lib/libvarnish/vav.c +++ b/lib/libvarnish/vav.c @@ -112,7 +112,7 @@ VAV_BackSlashDecode(const char *s, const char *e) if (e == NULL) e = strchr(s, '\0'); assert(e != NULL); - p = calloc((e - s) + 1L, 1); + p = calloc(1, (e - s) + 1L); if (p == NULL) return (p); for (r = p, q = s; q < e; ) { @@ -142,7 +142,7 @@ VAV_Parse(const char *s, int *argc, int flag) assert(s != NULL); nargv = 1; largv = 16; - argv = calloc(sizeof *argv, largv); + argv = calloc(largv, sizeof *argv); if (argv == NULL) return (NULL); diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c index 7c8011f..88f7057 100644 --- a/lib/libvarnish/vev.c +++ b/lib/libvarnish/vev.c @@ -156,7 +156,7 @@ vev_get_sig(int sig) if (sig < vev_nsig) return (0); - os = calloc(sizeof *os, (sig + 1L)); + os = calloc((sig + 1L), sizeof *os); if (os == NULL) return (ENOMEM); @@ -192,7 +192,7 @@ vev_new_base(void) { struct vev_base *evb; - evb = calloc(sizeof *evb, 1); + evb = calloc(1, sizeof *evb); if (evb == NULL) return (evb); evb->lpfd = BINHEAP_NOIDX + 1; @@ -230,7 +230,7 @@ vev_new(void) { struct vev *e; - e = calloc(sizeof *e, 1); + e = calloc(1, sizeof *e); if (e != NULL) { e->fd = -1; } diff --git a/lib/libvarnish/vfil.c b/lib/libvarnish/vfil.c index 6df5af6..64f3c56 100644 --- a/lib/libvarnish/vfil.c +++ b/lib/libvarnish/vfil.c @@ -275,7 +275,7 @@ VFIL_allocate(int fd, off_t size, int insist) bufsiz = 64 * 1024; else bufsiz = size; - buf = calloc(bufsiz, 1); + buf = calloc(1, bufsiz); AN(buf); assert(lseek(fd, 0, SEEK_SET) == 0); for (l = 0; l < size; l += l2) { diff --git a/lib/libvarnishapi/vxp.c b/lib/libvarnishapi/vxp.c index ae86282..039fafe 100644 --- a/lib/libvarnishapi/vxp.c +++ b/lib/libvarnishapi/vxp.c @@ -143,7 +143,7 @@ vxp_DoFree(struct vxp *vxp, void *p) { struct membit *mb; - mb = calloc(sizeof *mb, 1); + mb = calloc(1, sizeof *mb); AN(mb); mb->ptr = p; VTAILQ_INSERT_TAIL(&vxp->membits, mb, list); @@ -154,7 +154,7 @@ vxp_Alloc(struct vxp *vxp, unsigned len) { void *p; - p = calloc(len, 1); + p = calloc(1, len); AN(p); vxp_DoFree(vxp, p); return (p); diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index a8d0352..468a4c5 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -77,7 +77,7 @@ TlAlloc(struct vcc *tl, unsigned len) void *p; (void)tl; - p = calloc(len, 1); + p = calloc(1, len); assert(p != NULL); return (p); } @@ -418,7 +418,7 @@ vcc_new_source(const char *b, const char *e, const char *name) if (e == NULL) e = strchr(b, '\0'); - sp = calloc(sizeof *sp, 1); + sp = calloc(1, sizeof *sp); assert(sp != NULL); sp->name = strdup(name); AN(sp->name); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 5aa28a7..52159cb 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -608,7 +608,7 @@ vcc_func(struct vcc *tl, struct expr **e, const char *spec, AN(rfmt); VTAILQ_INIT(&head); while (*p != '\0') { - fa = calloc(sizeof *fa, 1); + fa = calloc(1, sizeof *fa); AN(fa); VTAILQ_INSERT_TAIL(&head, fa, list); if (!memcmp(p, "PRIV_", 5)) { From geoff at uplex.de Mon Sep 11 22:42:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Sep 2017 22:42:04 +0000 (UTC) Subject: [master] e2e12a1 VMOD blob: remove the decode_n() and transcode_n() functions. Message-ID: <20170911224204.5CE289545E@lists.varnish-cache.org> commit e2e12a11d7e67cd179a50bd45c1a9a1c2e68d984 Author: Geoff Simmons Date: Tue Sep 12 00:40:15 2017 +0200 VMOD blob: remove the decode_n() and transcode_n() functions. decode() and transcode() now have an optional parameter length; if length > 0, decode that many characters from the encoded string. References #2421 diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index 2340eda..81b654d 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -11,29 +11,29 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.id = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, - "The quick brown fox jumps over the lazy dog")); + encoded="The quick brown fox jumps over the lazy dog")); set resp.http.hobbes = - blob.encode(IDENTITY, blob=blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, encoded= {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = - blob.encode(IDENTITY, blob=blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, encoded= "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "")); set resp.http.empty = - blob.encode(IDENTITY, blob=blob.decode(IDENTITY, "")); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, encoded="")); set resp.http.undef = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, - req.http.unset)); + encoded=req.http.unset)); set resp.http.emptylist = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, - req.http.unset + "" + req.http.unset + "")); + encoded=req.http.unset + "" + req.http.unset + "")); set resp.http.param = blob.encode(blob= @@ -51,13 +51,16 @@ varnish v1 -vcl { decoding=IDENTITY)); set resp.http.truncated = - blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); + blob.encode(IDENTITY, + blob=blob.decode(HEX, encoded="666f6f00626172")); set resp.http.lc = - blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, "Don't care")); + blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, + encoded="Don't care")); set resp.http.uc = - blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, "Don't care")); + blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, + encoded="Don't care")); } } -start diff --git a/bin/varnishtest/tests/m00034.vtc b/bin/varnishtest/tests/m00034.vtc index 949df45..95ea934 100644 --- a/bin/varnishtest/tests/m00034.vtc +++ b/bin/varnishtest/tests/m00034.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob IDENTITY decode_n()" +varnishtest "VMOD blob IDENTITY decode() n chars" varnish v1 -vcl { import blob; @@ -10,45 +10,47 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.id = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, - "The quick brown fox jumps over the lazy dog")); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, + encoded="The quick brown fox jumps over the lazy dog")); set resp.http.hobbes = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, + encoded= {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = - blob.encode(IDENTITY, blob=blob.decode_n(6, IDENTITY, - "" + req.http.unset + req.url + + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=6, + encoded="" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "")); set resp.http.empty = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, "")); + blob.encode(IDENTITY, + blob=blob.decode(IDENTITY, length=5, encoded="")); set resp.http.undef = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, - req.http.unset)); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, + encoded=req.http.unset)); set resp.http.emptylist = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, - req.http.unset + "" + req.http.unset + "")); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, + encoded=req.http.unset + "" + req.http.unset + "")); set resp.http.param = blob.encode(blob= - blob.decode_n(encoded= + blob.decode(encoded= "The quick brown fox jumps over the lazy dog", - n=7, decoding=IDENTITY), + length=7, decoding=IDENTITY), encoding=IDENTITY); set resp.http.paramlist = - blob.encode(IDENTITY, blob=blob.decode_n(encoded= + blob.encode(IDENTITY, blob=blob.decode(encoded= "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "", - decoding=IDENTITY, n=37)); + decoding=IDENTITY, length=37)); } } -start diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index e1aa0ff..6190914 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -19,49 +19,56 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.hex = - blob.encode(HEX, blob=blob.decode(IDENTITY, req.http.pangram)); + blob.encode(HEX, blob=blob.decode(IDENTITY, + encoded=req.http.pangram)); set resp.http.hexlc = blob.encode(HEX, LOWER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.hexuc = blob.encode(HEX, UPPER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.hobbes = - blob.encode(HEX, blob=blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, blob=blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.hobbeslc = - blob.encode(HEX, LOWER, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, LOWER, blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(HEX, UPPER, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.all = - blob.encode(HEX, blob=blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, blob=blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.all-lc = - blob.encode(HEX, LOWER, blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, LOWER, blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.all-uc = - blob.encode(HEX, UPPER, blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, UPPER, blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.empty = - blob.encode(HEX, blob=blob.decode(IDENTITY, "")); + blob.encode(HEX, blob=blob.decode(IDENTITY, encoded="")); set resp.http.empty-lc = - blob.encode(HEX, LOWER, blob.decode(IDENTITY, "")); + blob.encode(HEX, LOWER, blob.decode(IDENTITY, encoded="")); set resp.http.empty-uc = - blob.encode(HEX, UPPER, blob.decode(IDENTITY, "")); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, encoded="")); set resp.http.hexlcparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), case=LOWER, encoding=HEX); set resp.http.hexucparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), case=UPPER, encoding=HEX); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; @@ -76,52 +83,55 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.hexucfoobar)); + blob=blob.decode(HEX, encoded=req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.hexlcfoobar)); + blob=blob.decode(HEX, encoded=req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.hexhobbesuc)); + blob=blob.decode(HEX, encoded=req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.hexhobbeslc)); + blob=blob.decode(HEX, encoded=req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexalluc)); + blob.encode(BASE64, blob=blob.decode(HEX, + encoded=req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexalllc)); + blob.encode(BASE64, blob=blob.decode(HEX, + encoded=req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob=blob.decode(HEX, - req.http.hexallucodd)); + blob.encode(BASE64, + blob=blob.decode(HEX, encoded=req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob=blob.decode(HEX, - req.http.hexalllcodd)); + blob.encode(BASE64, + blob=blob.decode(HEX, encoded=req.http.hexalllcodd)); set resp.http.decempty = - blob.encode(IDENTITY, blob=blob.decode(HEX, "")); + blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob=blob.decode(HEX, "00")); + blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="00")); set resp.http.decemptynibble = - blob.encode(IDENTITY, blob=blob.decode(HEX, "0")); + blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="0")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.unset + "" - + req.http.unset + "")); + blob=blob.decode(HEX, encoded=req.http.unset + "" + + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob=blob.decode(HEX, req.http.part1 + - "F6F206261722062617A2071757578")); + blob.encode(IDENTITY, blob=blob.decode(HEX, + encoded=req.http.part1 + + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; set resp.http.dec3param = @@ -131,11 +141,13 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob=blob.decode(HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(HEX, + encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob=blob.decode(HEX, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode(HEX, encoded= + "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -191,7 +203,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { set req.http.foo = "123"; set resp.http.badhex = blob.encode(HEX, UPPER, - blob.decode(HEX, "g" + req.http.foo)); + blob.decode(HEX, encoded="g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00036.vtc b/bin/varnishtest/tests/m00036.vtc index cf6335b..635d726 100644 --- a/bin/varnishtest/tests/m00036.vtc +++ b/bin/varnishtest/tests/m00036.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob hex decode_n()" +varnishtest "VMOD blob hex decode() n chars" varnish v1 -vcl { import blob; @@ -19,40 +19,45 @@ varnish v1 -vcl { set resp.http.hexlc = blob.encode(HEX, - blob=blob.decode_n(5, IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, 5, + encoded=req.http.pangram)); set resp.http.hexuc = blob.encode(HEX, UPPER, - blob.decode_n(5, IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, 5, encoded=req.http.pangram)); set resp.http.hobbeslc = blob.encode(HEX, - blob=blob.decode_n(5, IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, 5, + encoded=req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEX, UPPER, - blob.decode_n(5, IDENTITY, req.http.hobbes)); + blob.decode(IDENTITY, 5, encoded=req.http.hobbes)); set resp.http.all-lc = - blob.encode(HEX, blob=blob.decode_n(8, BASE64, req.http.b64all)); + blob.encode(HEX, blob=blob.decode(BASE64, 8, + encoded=req.http.b64all)); set resp.http.all-uc = blob.encode(HEX, UPPER, - blob.decode_n(8, BASE64, req.http.b64all)); + blob.decode(BASE64, 8, encoded=req.http.b64all)); set resp.http.empty-lc = - blob.encode(HEX, blob=blob.decode_n(5, IDENTITY, "")); + blob.encode(HEX, blob=blob.decode(IDENTITY, 5, encoded="")); set resp.http.empty-uc = - blob.encode(HEX, UPPER, blob.decode_n(5, IDENTITY, "")); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, 5, encoded="")); set resp.http.hexlcparam = - blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), - encoding=HEX, case=LOWER); + blob.encode(blob=blob.decode(IDENTITY, 5, + encoded=req.http.pangram), + encoding=HEX, case=LOWER); set resp.http.hexucparam = - blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), - encoding=HEX, case=UPPER); + blob.encode(blob=blob.decode(IDENTITY, 5, + encoded=req.http.pangram), + encoding=HEX, case=UPPER); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); @@ -66,68 +71,74 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob=blob.decode_n(10, HEX, req.http.hexucfoobar)); + blob=blob.decode(HEX, 10, + encoded=req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob=blob.decode_n(10, HEX, req.http.hexlcfoobar)); + blob=blob.decode(HEX, 10, + encoded=req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob=blob.decode_n(12, HEX, req.http.hexhobbesuc)); + blob=blob.decode(HEX, 12, + encoded=req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob=blob.decode_n(12, HEX, req.http.hexhobbeslc)); + blob=blob.decode(HEX, 12, + encoded=req.http.hexhobbeslc)); set resp.http.decalluc = blob.encode(BASE64, - blob=blob.decode_n(12, HEX, req.http.hexalluc)); + blob=blob.decode(HEX, 12, encoded=req.http.hexalluc)); set resp.http.decalllc = blob.encode(BASE64, - blob=blob.decode_n(12, HEX, req.http.hexalllc)); + blob=blob.decode(HEX, 12, encoded=req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob=blob.decode_n(11, HEX, - req.http.hexallucodd)); + blob.encode(BASE64, blob=blob.decode(HEX, 11, + encoded=req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob=blob.decode_n(11, HEX, - req.http.hexalllcodd)); + blob.encode(BASE64, blob=blob.decode(HEX, 11, + encoded=req.http.hexalllcodd)); set resp.http.decempty = - blob.encode(IDENTITY, blob=blob.decode_n(5, HEX, "")); + blob.encode(IDENTITY, blob=blob.decode(HEX, 5, encoded="")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob=blob.decode_n(1, HEX, "00")); + blob.encode(IDENTITY, blob=blob.decode(HEX, 1, encoded="00")); set resp.http.decemptynibble = - blob.encode(IDENTITY, blob=blob.decode_n(2, HEX, "0")); + blob.encode(IDENTITY, blob=blob.decode(HEX, 2, encoded="0")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob=blob.decode_n(5, HEX, req.http.unset + "" + blob=blob.decode(HEX, 5, encoded=req.http.unset + "" + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob=blob.decode_n(6, HEX, req.http.part1 + - "F6F206261722062617A2071757578")); + blob.encode(IDENTITY, blob=blob.decode(HEX, 6, + encoded=req.http.part1 + + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; set resp.http.dec3param = - blob.encode(blob=blob.decode_n(encoded=req.http.part1 + + blob.encode(blob=blob.decode(encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2, - decoding=HEX,n=8), + decoding=HEX, length=8), encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob=blob.decode_n(30, HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(HEX, 30, + encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob=blob.decode_n(20, HEX, "" + blob.encode(IDENTITY, blob=blob.decode(HEX, 20, encoded="" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" @@ -180,7 +191,8 @@ varnish v1 -vcl+backend { sub vcl_deliver { set req.http.foo = "123"; set resp.http.badhex = blob.encode(HEX, UPPER, - blob.decode_n(2, HEX, "g" + req.http.foo)); + blob.decode(HEX, 2, + encoded="g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index 25a7dee..e8ee70a 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -18,80 +18,83 @@ varnish v1 -vcl { {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set resp.http.b64 = - blob.encode(BASE64, blob=blob.decode(IDENTITY, + blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded= req.http.pangram)); set resp.http.b64lc = - blob.encode(BASE64, LOWER, blob.decode(IDENTITY, + blob.encode(BASE64, LOWER, blob.decode(IDENTITY, encoded= req.http.pangram)); set resp.http.b64uc = - blob.encode(BASE64, UPPER, blob.decode(IDENTITY, + blob.encode(BASE64, UPPER, blob.decode(IDENTITY, encoded= req.http.pangram)); set resp.http.b64hobbes = - blob.encode(BASE64, blob=blob.decode(IDENTITY, + blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded= req.http.hobbes)); set resp.http.b64all = - blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexall)); + blob.encode(BASE64, blob=blob.decode(HEX, + encoded=req.http.hexall)); set resp.http.b64url = blob.encode(BASE64URL, - blob=blob.decode(IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urllc = blob.encode(BASE64URL, LOWER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urluc = blob.encode(BASE64URL, UPPER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urlhobbes = blob.encode(BASE64URL, - blob=blob.decode(IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, encoded=req.http.hobbes)); set resp.http.b64urlall = - blob.encode(BASE64URL, blob=blob.decode(HEX, req.http.hexall)); + blob.encode(BASE64URL, blob=blob.decode(HEX, + encoded=req.http.hexall)); set resp.http.b64urlnopad = blob.encode(BASE64URLNOPAD, - blob=blob.decode(IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urlnopadlc = blob.encode(BASE64URLNOPAD, LOWER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urlnopaduc = blob.encode(BASE64URLNOPAD, UPPER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64nopadhobbes = blob.encode(BASE64URLNOPAD, - blob=blob.decode(IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, encoded=req.http.hobbes)); set resp.http.b64nopadall = blob.encode(BASE64URLNOPAD, - blob=blob.decode(HEX, req.http.hexall)); + blob=blob.decode(HEX, encoded=req.http.hexall)); set resp.http.b64empty = - blob.encode(BASE64, blob=blob.decode(IDENTITY, "")); + blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded="")); set resp.http.urlempty = - blob.encode(BASE64URL, blob=blob.decode(IDENTITY, "")); + blob.encode(BASE64URL, blob=blob.decode(IDENTITY, encoded="")); set resp.http.nopadempty = - blob.encode(BASE64URLNOPAD, blob=blob.decode(IDENTITY, "")); + blob.encode(BASE64URLNOPAD, + blob=blob.decode(IDENTITY, encoded="")); set resp.http.b64param = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=BASE64, case=LOWER); set resp.http.b64urlparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=BASE64URL, case=UPPER); set resp.http.b64urlnopadparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=BASE64URLNOPAD, case=LOWER); set resp.http.b64xcode = @@ -157,66 +160,71 @@ varnish v1 -vcl { {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; set resp.http.dec = blob.encode(IDENTITY, blob= - blob.decode(BASE64, req.http.foobarbazquux)); + blob.decode(BASE64, + encoded=req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, - blob=blob.decode(BASE64, req.http.pangram)); + blob=blob.decode(BASE64, encoded=req.http.pangram)); set resp.http.b64dechobbes = blob.encode(IDENTITY, - blob=blob.decode(BASE64, req.http.hobbes)); + blob=blob.decode(BASE64, encoded=req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEX, blob=blob.decode(BASE64, req.http.all)); + blob.encode(HEX, blob=blob.decode(BASE64, encoded=req.http.all)); set resp.http.urldechobbes = blob.encode(IDENTITY, blob=blob.decode(BASE64URL, - req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.urldecall = blob.encode(HEX, - blob=blob.decode(BASE64URL, req.http.allurl)); + blob=blob.decode(BASE64URL, encoded=req.http.allurl)); set resp.http.nopaddechobbes = - blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, - req.http.hobbesnopad)); + blob.encode(IDENTITY, + blob=blob.decode(BASE64URLNOPAD, + encoded=req.http.hobbesnopad)); set resp.http.nopaddecall = blob.encode(HEX, - blob=blob.decode(BASE64URLNOPAD, req.http.allurl)); + blob=blob.decode(BASE64URLNOPAD, + encoded=req.http.allurl)); set resp.http.b64empty = - blob.encode(IDENTITY, blob=blob.decode(BASE64, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64, encoded="")); set resp.http.urlempty = - blob.encode(IDENTITY, blob=blob.decode(BASE64URL, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, encoded="")); set resp.http.nopadempty = - blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, "")); + blob.encode(IDENTITY, + blob=blob.decode(BASE64URLNOPAD, encoded="")); set resp.http.emptypieces = blob.encode(IDENTITY, blob= - blob.decode(BASE64, req.http.unset + "" + req.http.unset + blob.decode(BASE64, encoded=req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, - blob=blob.decode(BASE64, req.http.foobarbazquux)); + blob=blob.decode(BASE64, + encoded=req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw==")); + encoded=resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw" + encoded=resp.http.l + "0hlbGxvIHdvcmxkLw" + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64, - resp.http.l + "0hlb" + resp.http.mid1 + encoded=resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad)); @@ -226,22 +234,22 @@ varnish v1 -vcl { + resp.http.pad, decoding=BASE64), encoding=IDENTITY); - set resp.http.decnopad = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, - "L0hlbGxvIHdvcmxkLw")); + set resp.http.decnopad + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, + encoded="L0hlbGxvIHdvcmxkLw")); set resp.http.decnopad2pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, - resp.http.l + "0hlbGxvIHdvcmxkLw")); + encoded=resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw")); + encoded=resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, encoded= "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); @@ -288,15 +296,16 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/base64") { set resp.http.bad64 = blob.encode(IDENTITY, - blob=blob.decode(BASE64, "-_-_" + req.http.foo)); + blob=blob.decode(BASE64, encoded="-_-_" + req.http.foo)); } elsif (req.url == "/base64url") { set resp.http.badurl = blob.encode(IDENTITY, - blob=blob.decode(BASE64URL, "+/+/" + req.http.foo)); + blob=blob.decode(BASE64URL, encoded="+/+/" + req.http.foo)); } elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); + blob=blob.decode(BASE64URLNOPAD, + encoded="TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00038.vtc b/bin/varnishtest/tests/m00038.vtc index 4e7e334..a585981 100644 --- a/bin/varnishtest/tests/m00038.vtc +++ b/bin/varnishtest/tests/m00038.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob base64 decode_n()" +varnishtest "VMOD blob base64 decode() n chars" varnish v1 -vcl { import blob; @@ -22,106 +22,105 @@ varnish v1 -vcl { set resp.http.dec = blob.encode(IDENTITY, - blob=blob.decode_n(8, BASE64, - req.http.foobarbazquux)); + blob=blob.decode(BASE64, 8, + req.http.foobarbazquux)); set resp.http.deceq = blob.encode(IDENTITY, - blob=blob.decode_n(20, BASE64, - req.http.foobarbazquux)); + blob=blob.decode(BASE64, 20, + req.http.foobarbazquux)); set resp.http.declong = blob.encode(IDENTITY, - blob=blob.decode_n(30, BASE64, - req.http.foobarbazquux)); + blob=blob.decode(BASE64, 30, + req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, - blob=blob.decode_n(12, BASE64, req.http.pangram)); + blob=blob.decode(BASE64, 12, req.http.pangram)); set resp.http.b64dechobbes = blob.encode(IDENTITY, - blob=blob.decode_n(24, BASE64, req.http.hobbes)); + blob=blob.decode(BASE64, 24, req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEX, blob=blob.decode_n(128, BASE64, req.http.all)); + blob.encode(HEX, blob=blob.decode(BASE64, 128, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob=blob.decode_n(180, BASE64URL, - req.http.hobbes)); + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, 180, + req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEX, - blob=blob.decode_n(256, BASE64URL, + blob.encode(HEX, blob=blob.decode(BASE64URL, 256, req.http.allurl)); set resp.http.nopaddechobbes = blob.encode(IDENTITY, - blob=blob.decode_n(500, BASE64URLNOPAD, - req.http.hobbesnopad)); + blob=blob.decode(BASE64URLNOPAD, 500, + req.http.hobbesnopad)); set resp.http.nopaddecall = - blob.encode(HEX, blob=blob.decode_n(256, BASE64URLNOPAD, + blob.encode(HEX, blob=blob.decode(BASE64URLNOPAD, 256, req.http.allurl)); set resp.http.b64empty = - blob.encode(IDENTITY, blob=blob.decode_n(0, BASE64, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64, 0, "")); set resp.http.urlempty = - blob.encode(IDENTITY, blob=blob.decode_n(1, BASE64URL, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, 1, "")); set resp.http.nopadempty = blob.encode(IDENTITY, - blob=blob.decode_n(0, BASE64URLNOPAD, "")); + blob=blob.decode(BASE64URLNOPAD, 0, "")); set resp.http.emptypieces = blob.encode(IDENTITY, - blob=blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset + blob=blob.decode(BASE64, 0, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, - blob=blob.decode_n(20, BASE64, - req.http.foobarbazquux)); + blob=blob.decode(BASE64, 20, + req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces - = blob.encode(IDENTITY, blob=blob.decode_n(8, BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, 8, resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces - = blob.encode(IDENTITY, blob=blob.decode_n(12, BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, 12, resp.http.l + "0hlbGxvIHdvcmxkLw" + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces - = blob.encode(IDENTITY, blob=blob.decode_n(16, BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, 16, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad)); set resp.http.dec7param - = blob.encode(blob=blob.decode_n(encoded=resp.http.l + = blob.encode(blob=blob.decode(encoded=resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 - + "kLw" + resp.http.pad, decoding=BASE64, n=20), - encoding=IDENTITY); + + "kLw" + resp.http.pad, decoding=BASE64, + length=20), encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, - blob=blob.decode_n(18, BASE64URLNOPAD, - "L0hlbGxvIHdvcmxkLw")); + blob=blob.decode(BASE64URLNOPAD, 18, + "L0hlbGxvIHdvcmxkLw")); set resp.http.decnopad2pieces - = blob.encode(IDENTITY, blob=blob.decode_n(19, BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, 19, resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces - = blob.encode(IDENTITY, blob=blob.decode_n(18, BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, 18, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, - blob=blob.decode_n(60, BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, 60, "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); @@ -170,16 +169,16 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/base64") { set resp.http.bad64 = blob.encode(IDENTITY, - blob=blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); + blob=blob.decode(BASE64, 8, "-_-_" + req.http.foo)); } elsif (req.url == "/base64url") { set resp.http.badurl = blob.encode(IDENTITY, - blob=blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); + blob=blob.decode(BASE64URL, 8, "+/+/" + req.http.foo)); } elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, - blob=blob.decode_n(8, BASE64URLNOPAD, - "TWFu" + req.http.foo)); + blob=blob.decode(BASE64URLNOPAD, 8, + "TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index 440c7ed..2149585 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -22,74 +22,92 @@ varnish v1 -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.url = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.pangram)); set resp.http.urllc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.pangram)); set resp.http.urluc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.pangram)); set resp.http.hobbes = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.hobbeslc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.umlauts = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.umlauts)); set resp.http.umlautslc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.umlauts)); set resp.http.umlautsuc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.umlauts)); set resp.http.phk = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.phkspeak)); set resp.http.phklc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.phkspeak)); set resp.http.phkuc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.phkspeak)); set resp.http.utf8 = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.utf8)); set resp.http.utf8lc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.utf8)); set resp.http.utf8uc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.utf8)); set resp.http.all = - blob.encode(URL, blob=blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, blob=blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.all-lc = - blob.encode(URL, LOWER, blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, LOWER, blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.all-uc = - blob.encode(URL, UPPER, blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, UPPER, blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.empty = - blob.encode(URL, blob=blob.decode(IDENTITY, "")); + blob.encode(URL, blob=blob.decode(IDENTITY, encoded="")); set resp.http.empty-lc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, "")); + blob.encode(URL, LOWER, blob.decode(IDENTITY, encoded="")); set resp.http.empty-uc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, "")); + blob.encode(URL, UPPER, blob.decode(IDENTITY, encoded="")); set resp.http.urllcparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=URL, case=LOWER); set resp.http.urlucparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=URL, case=UPPER); } } -start @@ -148,69 +166,73 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlucfoobar)); + blob=blob.decode(URL, encoded=req.http.urlucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urllcfoobar)); + blob=blob.decode(URL, encoded=req.http.urllcfoobar)); set resp.http.decmixed = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlmixedfoobar)); + blob=blob.decode(URL, + encoded=req.http.urlmixedfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlhobbesuc)); + blob=blob.decode(URL, encoded=req.http.urlhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlhobbeslc)); + blob=blob.decode(URL, encoded=req.http.urlhobbeslc)); set resp.http.decumlautsuc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlucumlauts)); + blob=blob.decode(URL, encoded=req.http.urlucumlauts)); set resp.http.decumlautslc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urllcumlauts)); + blob=blob.decode(URL, encoded=req.http.urllcumlauts)); set resp.http.decphkuc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlucphk)); + blob=blob.decode(URL, encoded=req.http.urlucphk)); set resp.http.decphklc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urllcphk)); + blob=blob.decode(URL, encoded=req.http.urllcphk)); set resp.http.decutf8uc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlucutf8)); + blob=blob.decode(URL, encoded=req.http.urlucutf8)); set resp.http.decutf8lc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urllcutf8)); + blob=blob.decode(URL, encoded=req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(BASE64, blob=blob.decode(URL, req.http.urlalluc)); + blob.encode(BASE64, blob=blob.decode(URL, + encoded=req.http.urlalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob=blob.decode(URL, req.http.urlalllc)); + blob.encode(BASE64, blob=blob.decode(URL, + encoded=req.http.urlalllc)); set resp.http.decempty = - blob.encode(IDENTITY, blob=blob.decode(URL, "")); + blob.encode(IDENTITY, blob=blob.decode(URL, encoded="")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob=blob.decode(URL, "%00")); + blob.encode(IDENTITY, blob=blob.decode(URL, encoded="%00")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.unset + "" + blob=blob.decode(URL, encoded=req.http.unset + "" + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob=blob.decode(URL, req.http.part1 + - "20bar%20baz%20quux")); + blob.encode(IDENTITY, blob=blob.decode(URL, + encoded=req.http.part1 + + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = @@ -220,11 +242,12 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob=blob.decode(URL, req.http.part1 + - "20bar%20baz%2" + req.http.part2)); + blob.encode(IDENTITY, blob=blob.decode(URL, encoded= + req.http.part1 + "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob=blob.decode(URL, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode(URL, encoded= + "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -270,19 +293,20 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { set resp.http.bad - = blob.encode(URL, UPPER, blob.decode(URL, "%")); + = blob.encode(URL, UPPER, blob.decode(URL, + encoded="%")); } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode(URL, "%2")); + blob.decode(URL, encoded="%2")); } elsif (req.url == "/percent-q") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode(URL, "%q")); + blob.decode(URL, encoded="%q")); } elsif (req.url == "/percent-two-q") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode(URL, "%2q")); + blob.decode(URL, encoded="%2q")); } } } diff --git a/bin/varnishtest/tests/m00040.vtc b/bin/varnishtest/tests/m00040.vtc index 2355ca9..2177f8a 100644 --- a/bin/varnishtest/tests/m00040.vtc +++ b/bin/varnishtest/tests/m00040.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob decode_n() with URL" +varnishtest "VMOD blob decode() n chars with URL" varnish v1 -vcl { import blob; @@ -25,85 +25,85 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob=blob.decode_n(9, URL, req.http.urlucfoobar)); + blob=blob.decode(URL, 9, req.http.urlucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob=blob.decode_n(12, URL, req.http.urllcfoobar)); + blob=blob.decode(URL, 12, req.http.urllcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob=blob.decode_n(27, URL, req.http.urlhobbesuc)); + blob=blob.decode(URL, 27, req.http.urlhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob=blob.decode_n(27, URL, req.http.urlhobbeslc)); + blob=blob.decode(URL, 27, req.http.urlhobbeslc)); set resp.http.decumlautsuc = blob.encode(IDENTITY, - blob=blob.decode_n(17, URL, req.http.urlucumlauts)); + blob=blob.decode(URL, 17, req.http.urlucumlauts)); set resp.http.decumlautslc = blob.encode(IDENTITY, - blob=blob.decode_n(25, URL, req.http.urllcumlauts)); + blob=blob.decode(URL, 25, req.http.urllcumlauts)); set resp.http.decphkuc = blob.encode(IDENTITY, - blob=blob.decode_n(18, URL, req.http.urlucphk)); + blob=blob.decode(URL, 18, req.http.urlucphk)); set resp.http.decphklc = blob.encode(IDENTITY, - blob=blob.decode_n(30, URL, req.http.urllcphk)); + blob=blob.decode(URL, 30, req.http.urllcphk)); set resp.http.decutf8uc = blob.encode(IDENTITY, - blob=blob.decode_n(9, URL, req.http.urlucutf8)); + blob=blob.decode(URL, 9, req.http.urlucutf8)); set resp.http.decutf8lc = blob.encode(IDENTITY, - blob=blob.decode_n(18, URL, req.http.urllcutf8)); + blob=blob.decode(URL, 18, req.http.urllcutf8)); set resp.http.decalluc = blob.encode(HEX, - blob=blob.decode_n(252, URL, req.http.urlalluc)); + blob=blob.decode(URL, 252, req.http.urlalluc)); set resp.http.decalllc = blob.encode(HEX, UPPER, - blob.decode_n(252, URL, req.http.urlalllc)); + blob.decode(URL, 252, req.http.urlalllc)); set resp.http.decempty = - blob.encode(IDENTITY, blob=blob.decode_n(10, URL, "")); + blob.encode(IDENTITY, blob=blob.decode(URL, 10, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob=blob.decode_n(3, URL, "%00")); + blob.encode(IDENTITY, blob=blob.decode(URL, 3, "%00")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob=blob.decode_n(1, URL, req.http.unset + "" - + req.http.unset + "")); + blob=blob.decode(URL, 1, req.http.unset + "" + + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = blob.encode(IDENTITY, - blob=blob.decode_n(6, URL, req.http.part1 + - "20bar%20baz%20quux")); + blob=blob.decode(URL, 6, req.http.part1 + + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = - blob.encode(blob=blob.decode_n(encoded=req.http.part1 + + blob.encode(blob=blob.decode(encoded=req.http.part1 + "20bar%20baz%2" + req.http.part2, - decoding=URL, n=12), + decoding=URL, length=12), encoding=IDENTITY); set resp.http.dec3pieces = blob.encode(IDENTITY, - blob=blob.decode_n(18, URL, req.http.part1 - + "20bar%20baz%2" - + req.http.part2)); + blob=blob.decode(URL, 18, req.http.part1 + + "20bar%20baz%2" + + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, - blob=blob.decode_n(24, URL, "" + req.http.unset + blob=blob.decode(URL, 24, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -148,19 +148,19 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode_n(1, URL, "%20")); + blob.decode(URL, 1, "%20")); } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode_n(2, URL, "%20")); + blob.decode(URL, 2, "%20")); } elsif (req.url == "/comma") { set resp.http.good = blob.encode(IDENTITY, blob= - blob.decode_n(3, URL, "%2c%q")); + blob.decode(URL, 3, "%2c%q")); } elsif (req.url == "/colon") { set resp.http.good = blob.encode(IDENTITY, blob= - blob.decode_n(3, URL, "%3a%2q")); + blob.decode(URL, 3, "%3a%2q")); } } } diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index cfed6ae..4056d9c 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -39,19 +39,19 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { = blob.transcode(IDENTITY, HEX, encoded=req.http.hobbes); set resp.http.id2hexuc - = blob.transcode(IDENTITY, HEX, UPPER, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, UPPER, encoded=req.http.hobbes); set resp.http.id2hexlc - = blob.transcode(IDENTITY, HEX, LOWER, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, LOWER, encoded=req.http.hobbes); set resp.http.id2url = blob.transcode(IDENTITY, URL, encoded=req.http.foobar); set resp.http.id2urluc - = blob.transcode(IDENTITY, URL, UPPER, req.http.foobar); + = blob.transcode(IDENTITY, URL, UPPER, encoded=req.http.foobar); set resp.http.id2urllc - = blob.transcode(IDENTITY, URL, LOWER, req.http.foobar); + = blob.transcode(IDENTITY, URL, LOWER, encoded=req.http.foobar); set resp.http.b642id = blob.transcode(BASE64, IDENTITY, encoded=req.http.hobbesb64); @@ -81,19 +81,19 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { = blob.transcode(HEX, URL, encoded=req.http.hexalldown); set resp.http.hexalldown2urluc - = blob.transcode(HEX, URL, UPPER, req.http.hexalldown); + = blob.transcode(HEX, URL, UPPER, encoded=req.http.hexalldown); set resp.http.hexalldown2urllc - = blob.transcode(HEX, URL, LOWER, req.http.hexalldown); + = blob.transcode(HEX, URL, LOWER, encoded=req.http.hexalldown); set resp.http.hexallup2url = blob.transcode(HEX, URL, encoded=req.http.hexallup); set resp.http.hexallup2urluc - = blob.transcode(HEX, URL, UPPER, req.http.hexallup); + = blob.transcode(HEX, URL, UPPER, encoded=req.http.hexallup); set resp.http.hexallup2urllc - = blob.transcode(HEX, URL, LOWER, req.http.hexallup); + = blob.transcode(HEX, URL, LOWER, encoded=req.http.hexallup); } } -start @@ -155,64 +155,64 @@ varnish v1 -vcl { = blob.transcode(BASE64, HEX, encoded=req.http.b64all); set resp.http.b64all2hexuc - = blob.transcode(BASE64, HEX, UPPER, req.http.b64all); + = blob.transcode(BASE64, HEX, UPPER, encoded=req.http.b64all); set resp.http.b64all2hexlc - = blob.transcode(BASE64, HEX, LOWER, req.http.b64all); + = blob.transcode(BASE64, HEX, LOWER, encoded=req.http.b64all); set resp.http.b64allurl2hex = blob.transcode(BASE64URL, HEX, encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc - = blob.transcode(BASE64URL, HEX, UPPER, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, UPPER, encoded=req.http.b64allurl); set resp.http.b64allurl2hexlc - = blob.transcode(BASE64URL, HEX, LOWER, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, LOWER, encoded=req.http.b64allurl); set resp.http.b64all2url = blob.transcode(BASE64, URL, encoded=req.http.b64all); set resp.http.b64all2urluc - = blob.transcode(BASE64, URL, UPPER, req.http.b64all); + = blob.transcode(BASE64, URL, UPPER, encoded=req.http.b64all); set resp.http.b64all2urllc - = blob.transcode(BASE64, URL, LOWER, req.http.b64all); + = blob.transcode(BASE64, URL, LOWER, encoded=req.http.b64all); set resp.http.b64allurl2url = blob.transcode(BASE64URL, URL, encoded=req.http.b64allurl); set resp.http.b64allurl2urluc - = blob.transcode(BASE64URL, URL, UPPER, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, UPPER, encoded=req.http.b64allurl); set resp.http.b64allurl2urllc - = blob.transcode(BASE64URL, URL, LOWER, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, LOWER, encoded=req.http.b64allurl); set resp.http.hexuc2hex = blob.transcode(HEX, HEX, encoded="0123456789ABCDEF"); set resp.http.hexuc2hexuc - = blob.transcode(HEX, HEX, UPPER, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, UPPER, encoded="0123456789ABCDEF"); set resp.http.hexlc2hexlc - = blob.transcode(HEX, HEX, LOWER, "0123456789abcdef"); + = blob.transcode(HEX, HEX, LOWER, encoded="0123456789abcdef"); set resp.http.hexlc2hex = blob.transcode(HEX, HEX, encoded="0123456789abcdef"); set resp.http.hexuc2hexlc - = blob.transcode(HEX, HEX, LOWER, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, LOWER, encoded="0123456789ABCDEF"); set resp.http.hexlc2hexuc - = blob.transcode(HEX, HEX, UPPER, "0123456789abcdef"); + = blob.transcode(HEX, HEX, UPPER, encoded="0123456789abcdef"); set resp.http.hexmix2hex = blob.transcode(HEX, HEX, encoded="0123456789ABCdef"); set resp.http.hexmix2hexuc - = blob.transcode(HEX, HEX, UPPER, "0123456789ABCdef"); + = blob.transcode(HEX, HEX, UPPER, encoded="0123456789ABCdef"); set resp.http.hexmix2hexlc - = blob.transcode(HEX, HEX, LOWER, "0123456789abcDEF"); + = blob.transcode(HEX, HEX, LOWER, encoded="0123456789abcDEF"); set req.http.hexpart1 = "01234567"; set req.http.hexpart2 = "89abcdef"; @@ -336,37 +336,37 @@ varnish v1 -vcl { = blob.transcode(URL, URL, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urllc - = blob.transcode(URL, URL, LOWER, req.http.urlalldownuc); + = blob.transcode(URL, URL, LOWER, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urluc - = blob.transcode(URL, URL, UPPER, req.http.urlalldownuc); + = blob.transcode(URL, URL, UPPER, encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2url = blob.transcode(URL, URL, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urllc - = blob.transcode(URL, URL, LOWER, req.http.urlalldownlc); + = blob.transcode(URL, URL, LOWER, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urluc - = blob.transcode(URL, URL, UPPER, req.http.urlalldownlc); + = blob.transcode(URL, URL, UPPER, encoded=req.http.urlalldownlc); set resp.http.urlallupuc2url = blob.transcode(URL, URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urluc - = blob.transcode(URL, URL, UPPER, req.http.urlallupuc); + = blob.transcode(URL, URL, UPPER, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urllc - = blob.transcode(URL, URL, LOWER, req.http.urlallupuc); + = blob.transcode(URL, URL, LOWER, encoded=req.http.urlallupuc); set resp.http.urlalluplc2url = blob.transcode(URL, URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urluc - = blob.transcode(URL, URL, UPPER, req.http.urlalluplc); + = blob.transcode(URL, URL, UPPER, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urllc - = blob.transcode(URL, URL, LOWER, req.http.urlalluplc); + = blob.transcode(URL, URL, LOWER, encoded=req.http.urlalluplc); } } diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index 4a96c0f..ecd8b44 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob test transcode_n()" +varnishtest "VMOD blob test transcode() n chars" varnish v1 -vcl { import blob; @@ -22,76 +22,83 @@ varnish v1 -vcl { {"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"}; set resp.http.id2id - = blob.transcode_n(5, IDENTITY, IDENTITY, encoded="Hello world"); + = blob.transcode(IDENTITY, IDENTITY, length=5, + encoded="Hello world"); set resp.http.id2b64 - = blob.transcode_n(5, IDENTITY, BASE64, encoded=req.http.hobbes); + = blob.transcode(IDENTITY, BASE64, length=5, + encoded=req.http.hobbes); set resp.http.id2b64nopad - = blob.transcode_n(5, IDENTITY, BASE64URLNOPAD, - encoded=req.http.hobbes); + = blob.transcode(IDENTITY, BASE64URLNOPAD, length=5, + encoded=req.http.hobbes); set resp.http.id2hex - = blob.transcode_n(5, IDENTITY, HEX, encoded=req.http.hobbes); + = blob.transcode(IDENTITY, HEX, length=5, encoded=req.http.hobbes); set resp.http.id2hexuc - = blob.transcode_n(5, IDENTITY, HEX, UPPER, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, UPPER, 5, req.http.hobbes); set resp.http.id2hexlc - = blob.transcode_n(5, IDENTITY, HEX, LOWER, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, LOWER, 5, req.http.hobbes); set resp.http.id2url - = blob.transcode_n(5, IDENTITY, URL, encoded=req.http.foobar); + = blob.transcode(IDENTITY, URL, length=5, encoded=req.http.foobar); set resp.http.id2urluc - = blob.transcode_n(5, IDENTITY, URL, UPPER, req.http.foobar); + = blob.transcode(IDENTITY, URL, UPPER, 5, req.http.foobar); set resp.http.id2urllc - = blob.transcode_n(5, IDENTITY, URL, LOWER, req.http.foobar); + = blob.transcode(IDENTITY, URL, LOWER, 5, req.http.foobar); set resp.http.b642id - = blob.transcode_n(8, BASE64, IDENTITY, encoded=req.http.hobbesb64); + = blob.transcode(BASE64, IDENTITY, length=8, + encoded=req.http.hobbesb64); set resp.http.hex2id - = blob.transcode_n(12, HEX, IDENTITY, encoded=req.http.hexhobbes); + = blob.transcode(HEX, IDENTITY, length=12, + encoded=req.http.hexhobbes); set resp.http.hexalldown2b64 - = blob.transcode_n(12, HEX, BASE64, encoded=req.http.hexalldown); + = blob.transcode(HEX, BASE64, length=12, + encoded=req.http.hexalldown); set resp.http.hexalldown2b64url - = blob.transcode_n(12, HEX, BASE64URL, encoded=req.http.hexalldown); + = blob.transcode(HEX, BASE64URL, length=12, + encoded=req.http.hexalldown); set resp.http.hexalldown2b64nopad - = blob.transcode_n(10, HEX, BASE64URLNOPAD, - encoded=req.http.hexalldown); + = blob.transcode(HEX, BASE64URLNOPAD, length=10, + encoded=req.http.hexalldown); set resp.http.hexallup2b64 - = blob.transcode_n(12, HEX, BASE64, encoded=req.http.hexallup); + = blob.transcode(HEX, BASE64, length=12, encoded=req.http.hexallup); set resp.http.hexallup2b64url - = blob.transcode_n(10, HEX, BASE64URL, encoded=req.http.hexallup); + = blob.transcode(HEX, BASE64URL, length=10, + encoded=req.http.hexallup); set resp.http.hexallup2b64nopad - = blob.transcode_n(10, HEX, BASE64URLNOPAD, - encoded=req.http.hexallup); + = blob.transcode(HEX, BASE64URLNOPAD, length=10, + encoded=req.http.hexallup); set resp.http.hexalldown2url - = blob.transcode_n(12, HEX, URL, encoded=req.http.hexalldown); + = blob.transcode(HEX, URL, length=12, encoded=req.http.hexalldown); set resp.http.hexalldown2urluc - = blob.transcode_n(12, HEX, URL, UPPER, req.http.hexalldown); + = blob.transcode(HEX, URL, UPPER, 12, req.http.hexalldown); set resp.http.hexalldown2urllc - = blob.transcode_n(12, HEX, URL, LOWER, req.http.hexalldown); + = blob.transcode(HEX, URL, LOWER, 12, req.http.hexalldown); set resp.http.hexallup2url - = blob.transcode_n(12, HEX, URL, encoded=req.http.hexallup); + = blob.transcode(HEX, URL, length=12, encoded=req.http.hexallup); set resp.http.hexallup2urluc - = blob.transcode_n(12, HEX, URL, UPPER, req.http.hexallup); + = blob.transcode(HEX, URL, UPPER, 12, req.http.hexallup); set resp.http.hexallup2urllc - = blob.transcode_n(12, HEX, URL, LOWER, req.http.hexallup); + = blob.transcode(HEX, URL, LOWER, 12, req.http.hexallup); } } -start @@ -140,89 +147,91 @@ varnish v1 -vcl { {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; set resp.http.b64all2hex - = blob.transcode_n(8, BASE64, HEX, encoded=req.http.b64all); + = blob.transcode(BASE64, HEX, length=8, encoded=req.http.b64all); set resp.http.b64all2hexuc - = blob.transcode_n(8, BASE64, HEX, UPPER, req.http.b64all); + = blob.transcode(BASE64, HEX, UPPER, 8, req.http.b64all); set resp.http.b64all2hexlc - = blob.transcode_n(8, BASE64, HEX, LOWER, req.http.b64all); + = blob.transcode(BASE64, HEX, LOWER, 8, req.http.b64all); set resp.http.b64allurl2hex - = blob.transcode_n(8, BASE64URL, HEX, encoded=req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, length=8, + encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc - = blob.transcode_n(8, BASE64URL, HEX, UPPER, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, UPPER, 8, req.http.b64allurl); set resp.http.b64allurl2hexlc - = blob.transcode_n(8, BASE64URL, HEX, LOWER, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, LOWER, 8, req.http.b64allurl); set resp.http.b64all2url - = blob.transcode_n(8, BASE64, URL, encoded=req.http.b64all); + = blob.transcode(BASE64, URL, length=8, encoded=req.http.b64all); set resp.http.b64all2urluc - = blob.transcode_n(8, BASE64, URL, UPPER, req.http.b64all); + = blob.transcode(BASE64, URL, UPPER, 8, req.http.b64all); set resp.http.b64all2urllc - = blob.transcode_n(8, BASE64, URL, LOWER, req.http.b64all); + = blob.transcode(BASE64, URL, LOWER, 8, req.http.b64all); set resp.http.b64allurl2url - = blob.transcode_n(8, BASE64URL, URL, encoded=req.http.b64allurl); + = blob.transcode(BASE64URL, URL, length=8, + encoded=req.http.b64allurl); set resp.http.b64allurl2urluc - = blob.transcode_n(8, BASE64URL, URL, UPPER, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, UPPER, 8, req.http.b64allurl); set resp.http.b64allurl2urllc - = blob.transcode_n(8, BASE64URL, URL, LOWER, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, LOWER, 8, req.http.b64allurl); set resp.http.hexuc2hex - = blob.transcode_n(10, HEX, HEX, encoded="0123456789ABCDEF"); + = blob.transcode(HEX, HEX, length=10, encoded="0123456789ABCDEF"); set resp.http.hexuc2hexuc - = blob.transcode_n(10, HEX, HEX, UPPER, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, UPPER, 10, "0123456789ABCDEF"); set resp.http.hexlc2hex - = blob.transcode_n(10, HEX, HEX, encoded="0123456789abcdef"); + = blob.transcode(HEX, HEX, length=10, encoded="0123456789abcdef"); set resp.http.hexlc2hexlc - = blob.transcode_n(10, HEX, HEX, LOWER, "0123456789abcdef"); + = blob.transcode(HEX, HEX, LOWER, 10, "0123456789abcdef"); set resp.http.hexuc2hexlc - = blob.transcode_n(9, HEX, HEX, LOWER, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, LOWER, 9, "0123456789ABCDEF"); set resp.http.hexlc2hexuc - = blob.transcode_n(9, HEX, HEX, UPPER, "0123456789abcdef"); + = blob.transcode(HEX, HEX, UPPER, 9, "0123456789abcdef"); set resp.http.hexmix2hex - = blob.transcode_n(13, HEX, HEX, encoded="0123456789abcDEF"); + = blob.transcode(HEX, HEX, length=13, encoded="0123456789abcDEF"); set resp.http.hexmix2hexuc - = blob.transcode_n(15, HEX, HEX, UPPER, "0123456789ABCdef"); + = blob.transcode(HEX, HEX, UPPER, 15, "0123456789ABCdef"); set resp.http.hexmix2hexlc - = blob.transcode_n(13, HEX, HEX, LOWER, "0123456789abcDEF"); + = blob.transcode(HEX, HEX, LOWER, 13, "0123456789abcDEF"); set req.http.hexpart1 = "01234567"; set req.http.hexpart2 = "89abcdef"; set resp.http.hexparam - = blob.transcode_n(encoded="" + req.http.unset + "" + = blob.transcode(encoded="" + req.http.unset + "" + req.http.unset + "" + req.http.hexpart1 + "" + req.http.unset + "" + req.http.unset + req.http.hexpart2, decoding=HEX, - encoding=HEX, n=10, case=UPPER); + encoding=HEX, length=10, case=UPPER); set resp.http.b642b64 - = blob.transcode_n(36, BASE64, BASE64, encoded= + = blob.transcode(BASE64, BASE64, length=36, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789+/"); set resp.http.b64url2b64url = - blob.transcode_n(34, BASE64URL, BASE64URL, encoded= + blob.transcode(BASE64URL, BASE64URL, length=34, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); set resp.http.b64urlnopad2b64urlnopad = - blob.transcode_n(34, BASE64URLNOPAD, BASE64URLNOPAD, encoded= + blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, length=34, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); @@ -276,88 +285,98 @@ varnish v1 -vcl { set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id - = blob.transcode_n(27, URL, IDENTITY, encoded=req.http.urlhobbesuc); + = blob.transcode(URL, IDENTITY, length=27, + encoded=req.http.urlhobbesuc); set resp.http.urllc2id - = blob.transcode_n(63, URL, IDENTITY, encoded=req.http.urlhobbeslc); + = blob.transcode(URL, IDENTITY, length=63, + encoded=req.http.urlhobbeslc); set resp.http.urlalldownuc2b64 - = blob.transcode_n(18, URL, BASE64, encoded=req.http.urlalldownuc); + = blob.transcode(URL, BASE64, length=18, + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64url - = blob.transcode_n(15, URL, BASE64URL, - encoded=req.http.urlalldownuc); + = blob.transcode(URL, BASE64URL, length=15, + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64nopad - = blob.transcode_n(15, URL, BASE64URLNOPAD, - encoded=req.http.urlalldownuc); + = blob.transcode(URL, BASE64URLNOPAD, length=15, + encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2b64 - = blob.transcode_n(18, URL, BASE64, encoded=req.http.urlalldownlc); + = blob.transcode(URL, BASE64, length=18, + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64url - = blob.transcode_n(15, URL, BASE64URL, - encoded=req.http.urlalldownlc); + = blob.transcode(URL, BASE64URL, length=15, + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64nopad - = blob.transcode_n(15, URL, BASE64URLNOPAD, - encoded=req.http.urlalldownlc); + = blob.transcode(URL, BASE64URLNOPAD, length=15, + encoded=req.http.urlalldownlc); set resp.http.urlallupuc2b64 - = blob.transcode_n(36, URL, BASE64, encoded=req.http.urlallupuc); + = blob.transcode(URL, BASE64, length=36, + encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64url - = blob.transcode_n(33, URL, BASE64URL, encoded=req.http.urlallupuc); + = blob.transcode(URL, BASE64URL, length=33, + encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64nopad - = blob.transcode_n(33, URL, BASE64URLNOPAD, - encoded=req.http.urlallupuc); + = blob.transcode(URL, BASE64URLNOPAD, length=33, + encoded=req.http.urlallupuc); set resp.http.urlalluplc2b64 - = blob.transcode_n(36, URL, BASE64, encoded=req.http.urlalluplc); + = blob.transcode(URL, BASE64, length=36, + encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64url - = blob.transcode_n(33, URL, BASE64URL, encoded=req.http.urlalluplc); + = blob.transcode(URL, BASE64URL, length=33, + encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64nopad - = blob.transcode_n(33, URL, BASE64URLNOPAD, - encoded=req.http.urlalluplc); + = blob.transcode(URL, BASE64URLNOPAD, length=33, + encoded=req.http.urlalluplc); set resp.http.urlalldownuc2url - = blob.transcode_n(423, URL, URL, encoded=req.http.urlalldownuc); + = blob.transcode(URL, URL, length=423, + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urluc - = blob.transcode_n(423, URL, URL, UPPER, req.http.urlalldownuc); + = blob.transcode(URL, URL, UPPER, 423, req.http.urlalldownuc); set resp.http.urlalldownuc2urllc - = blob.transcode_n(423, URL, URL, LOWER, req.http.urlalldownuc); + = blob.transcode(URL, URL, LOWER, 423, req.http.urlalldownuc); set resp.http.urlalldownlc2url - = blob.transcode_n(423, URL, URL, encoded=req.http.urlalldownlc); + = blob.transcode(URL, URL, length=423, + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urluc - = blob.transcode_n(423, URL, URL, UPPER, req.http.urlalldownlc); + = blob.transcode(URL, URL, UPPER, 423, req.http.urlalldownlc); set resp.http.urlalldownlc2urllc - = blob.transcode_n(423, URL, URL, LOWER, req.http.urlalldownlc); + = blob.transcode(URL, URL, LOWER, 423, req.http.urlalldownlc); set resp.http.urlallupuc2url - = blob.transcode_n(197, URL, URL, encoded=req.http.urlallupuc); + = blob.transcode(URL, URL, length=197, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urluc - = blob.transcode_n(197, URL, URL, UPPER, req.http.urlallupuc); + = blob.transcode(URL, URL, UPPER, 197, req.http.urlallupuc); set resp.http.urlallupuc2urllc - = blob.transcode_n(197, URL, URL, LOWER, req.http.urlallupuc); + = blob.transcode(URL, URL, LOWER, 197, req.http.urlallupuc); set resp.http.urlalluplc2url - = blob.transcode_n(197, URL, URL, encoded=req.http.urlalluplc); + = blob.transcode(URL, URL, length=197, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urluc - = blob.transcode_n(197, URL, URL, UPPER, req.http.urlalluplc); + = blob.transcode(URL, URL, UPPER, 197, req.http.urlalluplc); set resp.http.urlalluplc2urllc - = blob.transcode_n(197, URL, URL, LOWER, req.http.urlalluplc); + = blob.transcode(URL, URL, LOWER, 197, req.http.urlalluplc); } } @@ -407,57 +426,59 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/1") { set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, - encoded="%2c%q"); + = blob.transcode(URL, IDENTITY, length=3, + encoded="%2c%q"); } elsif (req.url == "/2") { set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, - encoded="%3a%2q"); + = blob.transcode(URL, IDENTITY, length=3, + encoded="%3a%2q"); } elsif (req.url == "/3") { set resp.http.bad - = blob.transcode_n(8, HEX, IDENTITY, - encoded="0x123456"); + = blob.transcode(HEX, IDENTITY, length=8, + encoded="0x123456"); } elsif (req.url == "/4") { set resp.http.bad - = blob.transcode_n(4, BASE64, IDENTITY, - encoded="-_-_" + req.http.foo); + = blob.transcode(BASE64, IDENTITY, length=4, + encoded="-_-_" + req.http.foo); } elsif (req.url == "/5") { set resp.http.bad - = blob.transcode_n(4, BASE64URL, IDENTITY, - encoded="+/+/" + req.http.foo); + = blob.transcode(BASE64URL, IDENTITY, length=4, + encoded="+/+/" + req.http.foo); } elsif (req.url == "/6") { set resp.http.bad - = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, - encoded="TWFu" + req.http.foo); + = blob.transcode(BASE64URLNOPAD, IDENTITY, length=8, + encoded="TWFu" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad - = blob.transcode_n(4, BASE64, BASE64, - encoded="_-_-" + req.http.foo); + = blob.transcode(BASE64, BASE64, length=4, + encoded="_-_-" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad - = blob.transcode_n(4, BASE64URL, BASE64URL, - encoded="/+/+" + req.http.foo); + = blob.transcode(BASE64URL, BASE64URL, length=4, + encoded="/+/+" + req.http.foo); } elsif (req.url == "/9") { set resp.http.bad - = blob.transcode_n(8, BASE64URLNOPAD, - BASE64URLNOPAD, - encoded="Zm9v" + req.http.foo); + = blob.transcode(BASE64URLNOPAD, + BASE64URLNOPAD, length=8, + encoded="Zm9v" + req.http.foo); } elsif (req.url == "/10") { set resp.http.bad - = blob.transcode_n(1, URL, IDENTITY, encoded="%20"); + = blob.transcode(URL, IDENTITY, length=1, + encoded="%20"); } elsif (req.url == "/11") { set resp.http.bad - = blob.transcode_n(2, URL, IDENTITY, encoded="%20"); + = blob.transcode(URL, IDENTITY, length=2, + encoded="%20"); } } } diff --git a/bin/varnishtest/tests/m00044.vtc b/bin/varnishtest/tests/m00044.vtc index ba4b757..e68374a 100644 --- a/bin/varnishtest/tests/m00044.vtc +++ b/bin/varnishtest/tests/m00044.vtc @@ -29,7 +29,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # vice versa at runtime. set resp.http.Base64-Encoded = blob.encode(BASE64, - blob=blob.decode(HEX, req.http.Hex-Encoded)); + blob=blob.decode(HEX, encoded=req.http.Hex-Encoded)); } sub vcl_recv { @@ -53,9 +53,10 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # IDENTITY sub vcl_deliver { set resp.http.Trunced-Foo1 - = blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); + = blob.encode(IDENTITY, blob=blob.decode(HEX, + encoded="666f6f00626172")); set resp.http.Trunced-Foo2 - = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); + = blob.encode(blob=blob.decode(HEX, encoded="666f6f00626172")); } ############################################################ @@ -65,14 +66,15 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode( HEX, - blob=blob.decode(HEX, resp.http.First + resp.http.Second)); + blob=blob.decode(HEX, encoded=resp.http.First + resp.http.Second)); } ############################################################ # encode - also contains decode examples sub vcl_deliver { set resp.http.encode1 - = blob.encode(HEX, blob=blob.decode(BASE64, "Zm9vYmFyYmF6")); + = blob.encode(HEX, blob=blob.decode(BASE64, + encoded="Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 @@ -108,7 +110,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { ############################################################ # blob init + .get + .encode sub vcl_init { - new theblob1 = blob.blob(BASE64, "YmxvYg=="); + new theblob1 = blob.blob(BASE64, encoded="YmxvYg=="); # same with named arguments new theblob2 = blob.blob(encoded="YmxvYg==", decoding=BASE64); diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 6c8ea69..3688987 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -257,7 +257,7 @@ varnish v1 -errvcl {Expected 'from path ...'} { varnish v1 -errvcl {INT * BLOB not possible.} { import blob; sub vcl_deliver { - set resp.status = 100 * blob.decode(HEX, "a"); + set resp.status = 100 * blob.decode(HEX, encoded="a"); } } diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index a5553c6..290e716 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -12,12 +12,9 @@ $Module blob 3 utilities for the VCL blob type # binary-to-text encodings STRING blob.encode([ENUM encoding,] [ENUM case,] BLOB blob) - BLOB blob.decode([ENUM decoding,] STRING_LIST encoded) - BLOB blob.decode_n(INT n, [ENUM decoding,] STRING_LIST encoded) + BLOB blob.decode([ENUM decoding,] [INT length,] STRING_LIST encoded) STRING blob.transcode([ENUM decoding,] [ENUM encoding,] [ENUM case,] - STRING_LIST encoded) - STRING blob.transcode_n(INT n, [ENUM decoding,] [ENUM encoding,] - [ENUM case,] STRING_LIST encoded) + [INT length,] STRING_LIST encoded) # other utilities BOOL blob.same(BLOB, BLOB) @@ -55,8 +52,9 @@ Examples:: # decode() and encode() functions convert blobs to text and # vice versa at runtime. set resp.http.Base64-Encoded - = blob.encode(BASE64, - blob=blob.decode(HEX, req.http.Hex-Encoded)); + = blob.encode(BASE64, + blob=blob.decode(HEX, + encoded=req.http.Hex-Encoded)); } sub vcl_recv { @@ -123,7 +121,8 @@ blob. For example:: # Decode from the hex encoding for "foo\0bar". # The header will be seen as "foo". set resp.http.Trunced-Foo1 - = blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); + = blob.encode(IDENTITY, blob=blob.decode(HEX, + encoded="666f6f00626172")); IDENTITY is the default encoding and decoding. So the above can also be written as:: @@ -131,7 +130,7 @@ be written as:: # Decode from the hex encoding for "foo\0bar". # The header will be seen as "foo". set resp.http.Trunced-Foo2 - = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); + = blob.encode(blob=blob.decode(HEX, encoded="666f6f00626172")); The ``case`` ENUM is ignored for ``IDENTITY`` encodings. @@ -176,7 +175,7 @@ byte. For example:: set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode(HEX, blob=blob.decode(HEX, - resp.http.First + resp.http.Second)); + encoded=resp.http.First + resp.http.Second)); URL --- @@ -189,16 +188,22 @@ The ``URL`` encoding implements "percent encoding" as per RFC3986. The affect alphabetic characters that are not percent-encoded. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", INT length=0, + STRING_LIST encoded) Returns the BLOB derived from the string ``encoded`` according to the scheme specified by ``decoding``. +If ``length`` > 0, only decode the first ``length`` characters of the +encoded string. If ``length`` <= 0 or greater than the length of the +string, then decode the entire string. The default value of ``length`` +is 0. + ``decoding`` defaults to IDENTITY. Example:: - blob.decode(BASE64, "Zm9vYmFyYmF6"); + blob.decode(BASE64, encoded="Zm9vYmFyYmF6"); # same with named parameters blob.decode(encoded="Zm9vYmFyYmF6", decoding=BASE64); @@ -206,15 +211,6 @@ Example:: # convert string to blob blob.decode(encoded="foo"); -$Function BLOB decode_n(INT n, - ENUM {IDENTITY, BASE64, BASE64URL, - BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", - STRING_LIST encoded) - -Same as ``decode()``, but only decode the first ``n`` characters of -the encoded string. If ``n`` is greater than the length of the string, -then return the same result as ``decode()``. - $Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", ENUM {LOWER, UPPER} case="LOWER", BLOB blob) @@ -228,7 +224,8 @@ Returns a string representation of the BLOB ``blob`` as specifed by Example:: set resp.http.encode1 - = blob.encode(HEX, blob=blob.decode(BASE64, "Zm9vYmFyYmF6")); + = blob.encode(HEX, + blob=blob.decode(BASE64, encoded="Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 @@ -244,7 +241,7 @@ $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER", + ENUM {LOWER, UPPER} case="LOWER", INT length=0, STRING_LIST encoded) Translates from one encoding to another, by first decoding the string @@ -253,6 +250,10 @@ the encoding of the resulting blob according to the scheme ``encoding``. ``case`` determines the case of hex digits for the ``HEX`` and ``URL`` encodings, and is ignored for other encodings. +As with ``decode()``: If ``length`` > 0, only decode the first +``length`` characters of the encoded string, otherwise decode the +entire string. The default value of ``length`` is 0. + ``decoding`` and ``encoding`` default to IDENTITY, and ``case`` defaults to LOWER. @@ -274,17 +275,6 @@ Example:: set resp.http.urlencoded = blob.transcode(encoded="foo bar", encoding=URL); -$Function STRING transcode_n(INT n, - ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", - ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER", - STRING_LIST encoded) - -Same as ``transcode()``, but only from the first ``n`` characters of -the encoded string. - $Function BOOL same(BLOB, BLOB) Returns true if and only if the two BLOB arguments are the same @@ -326,7 +316,7 @@ Creates an object that contains the BLOB derived from the string Example:: - new theblob1 = blob.blob(BASE64, "YmxvYg=="); + new theblob1 = blob.blob(BASE64, encoded="YmxvYg=="); # same with named arguments new theblob2 = blob.blob(encoded="YmxvYg==", decoding=BASE64); diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 850f975..2da7781 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -336,11 +336,11 @@ find_nonempty_va(const char *restrict *p, va_list ap) return (q); } -static VCL_BLOB -decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *restrict const p, - va_list ap) +VCL_BLOB __match_proto__(td_blob_decode) +vmod_decode(VRT_CTX, VCL_ENUM decs, VCL_INT length, const char *p, ...) { enum encoding dec = parse_encoding(decs); + va_list ap; struct wb_s wb; struct vmod_priv *b; char *buf; @@ -364,8 +364,12 @@ decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *restrict const p, } buf = wb_buf(&wb); + if (length <= 0) + length = -1; + va_start(ap, p); errno = 0; - len = func[dec].decode(dec, buf, wb_space(&wb), n, p, ap); + len = func[dec].decode(dec, buf, wb_space(&wb), length, p, ap); + va_end(ap); if (len == -1) { err_decode(ctx, p); @@ -383,33 +387,7 @@ decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *restrict const p, b->priv = buf; b->len = len; b->free = NULL; - return b; -} - -VCL_BLOB __match_proto__(td_blob_decode) -vmod_decode(VRT_CTX, VCL_ENUM decs, const char *p, ...) -{ - va_list ap; - VCL_BLOB r; - - va_start(ap, p); - r = decode(ctx, -1, decs, p, ap); - va_end(ap); - - return (r); -} - -VCL_BLOB __match_proto__(td_blob_decode_n) -vmod_decode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *p, ...) -{ - va_list ap; - VCL_BLOB r; - - va_start(ap, p); - r = decode(ctx, n, decs, p, ap); - va_end(ap); - - return (r); + return (b); } static VCL_STRING @@ -460,14 +438,14 @@ encodes_hex(enum encoding enc) return (enc == HEX || enc == URL); } -static VCL_STRING -transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, - const char *restrict const p, va_list ap) +VCL_STRING __match_proto__(td_blob_transcode) +vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, + VCL_INT length, const char *p, ...) { enum encoding dec = parse_encoding(decs); enum encoding enc = parse_encoding(encs); enum case_e kase = parse_case(case_s); - va_list aq; + va_list ap; struct vmod_priv b; VCL_STRING r; @@ -481,9 +459,9 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, * Allocate space for the decoded blob on the stack * ignoring the limitation imposed by n */ - va_copy(aq, ap); - size_t l = decode_l_va(dec, p, aq); - va_end(aq); + va_start(ap, p); + size_t l = decode_l_va(dec, p, ap); + va_end(ap); if (l == 0) return ""; /* XXX: handle stack overflow? */ @@ -491,10 +469,12 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, b.free = NULL; b.priv = buf; + if (length <= 0) + length = -1; + va_start(ap, p); errno = 0; - va_copy(aq, ap); - b.len = func[dec].decode(dec, buf, l, n, p, aq); - va_end(aq); + b.len = func[dec].decode(dec, buf, l, length, p, ap); + va_end(ap); if (b.len == -1) { err_decode(ctx, p); @@ -509,11 +489,11 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, * since the call may specify upper- or lower-case that differs * from the encoded string. */ - if (n == -1 && enc == dec && !encodes_hex(enc)) { + if (length == -1 && enc == dec && !encodes_hex(enc)) { const char *q, *pp = p; - va_copy(aq, ap); + va_start(ap, p); q = find_nonempty_va(&pp, ap); - va_end(aq); + va_end(ap); if (pp == vrt_magic_string_end) return ""; @@ -529,34 +509,6 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, return (r); } -VCL_STRING __match_proto__(td_blob_transcode) -vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, - const char *p, ...) -{ - va_list ap; - VCL_STRING r; - - va_start(ap, p); - r = transcode(ctx, -1, decs, encs, case_s, p, ap); - va_end(ap); - - return (r); -} - -VCL_STRING __match_proto__(td_blob_transcode_n) -vmod_transcode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, - VCL_ENUM case_s, const char *p, ...) -{ - va_list ap; - VCL_STRING r; - - va_start(ap, p); - r = transcode(ctx, n, decs, encs, case_s, p, ap); - va_end(ap); - - return (r); -} - VCL_BOOL __match_proto__(td_blob_same) vmod_same(VRT_CTX, VCL_BLOB b1, VCL_BLOB b2) { From dridi.boukelmoune at gmail.com Mon Sep 11 22:45:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Sep 2017 22:45:05 +0000 (UTC) Subject: [master] e982595 Make $(VMOD_LDFLAGS) available in our build too Message-ID: <20170911224506.0B32C956F7@lists.varnish-cache.org> commit e982595c2d2fe9ace715f74decdc6c361ffa3c8b Author: Dridi Boukelmoune Date: Tue Sep 12 00:39:05 2017 +0200 Make $(VMOD_LDFLAGS) available in our build too Refs da91fec diff --git a/configure.ac b/configure.ac index c3a0984..fa43c1e 100644 --- a/configure.ac +++ b/configure.ac @@ -67,6 +67,9 @@ AC_ARG_WITH([dot], fi]) AM_CONDITIONAL(HAVE_DOT,[test "x$DOT" != "xno"]) +# Define VMOD flags +_VARNISH_VMOD_LDFLAGS + # Check for python. _VARNISH_CHECK_PYTHON diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 30a5928..b7f58e5 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -67,7 +67,7 @@ libvmod_XXX_la_CFLAGS = \\ libvmod_XXX_la_LDFLAGS = \\ $(AM_LDFLAGS) \\ - -module -export-dynamic -avoid-version -shared \\ + $(VMOD_LDFLAGS) \\ @SAN_LDFLAGS@ nodist_libvmod_XXX_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 9871b3f..3b4ed7a 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_blob_la_CFLAGS = \ libvmod_blob_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_blob_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index 3fb7d98..dddd350 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -27,7 +27,7 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ -rpath /nowhere @SAN_LDFLAGS@ diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index f30062d..19e10a3 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_directors_la_CFLAGS = \ libvmod_directors_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_directors_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index 9671d53..3a5b4a5 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_purge_la_CFLAGS = \ libvmod_purge_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_purge_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 259476e..66410b0 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_std_la_CFLAGS = \ libvmod_std_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_std_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 545bb56..1eb8f6f 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_vtc_la_CFLAGS = \ libvmod_vtc_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_vtc_la_SOURCES = vcc_if.c vcc_if.h diff --git a/varnish.m4 b/varnish.m4 index 82514ea..9a7f868 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -135,12 +135,22 @@ AC_DEFUN([_VARNISH_CHECK_PYTHON], [ ]) +# _VARNISH_VMOD_LDFLAGS +# --------------------- +AC_DEFUN([_VARNISH_VMOD_LDFLAGS], [ + + AC_SUBST([VMOD_LDFLAGS], + "-module -export-dynamic -avoid-version -shared") + +]) + # _VARNISH_VMOD_CONFIG # -------------------- AC_DEFUN([_VARNISH_VMOD_CONFIG], [ AC_REQUIRE([_VARNISH_PKG_CONFIG]) AC_REQUIRE([_VARNISH_CHECK_DEVEL]) + AC_REQUIRE([_VARNISH_VMOD_LDFLAGS]) dnl Check the VMOD toolchain AC_REQUIRE([AC_LANG_C]) @@ -175,10 +185,6 @@ AC_DEFUN([_VARNISH_VMOD_CONFIG], [ AC_SUBST([am__v_VMODTOOL_]) AC_SUBST([AM_V_VMODTOOL]) - dnl Define VMODs LDFLAGS - AC_SUBST([VMOD_LDFLAGS], - "-module -export-dynamic -avoid-version -shared") - dnl Substitute an alias for compatibility reasons AC_SUBST([VMOD_TEST_PATH], [$VARNISH_TEST_PATH]) ]) From geoff at uplex.de Mon Sep 11 22:47:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Sep 2017 22:47:04 +0000 (UTC) Subject: [master] 8bfa766 VMOD blob: clarify the docs for same() concerning empty BLOBs. Message-ID: <20170911224704.AC2C095914@lists.varnish-cache.org> commit 8bfa76628dfff0d0bc1ca52d16e05760082333bd Author: Geoff Simmons Date: Tue Sep 12 00:46:02 2017 +0200 VMOD blob: clarify the docs for same() concerning empty BLOBs. References #2421 diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 290e716..0f3dbb4 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -278,7 +278,8 @@ Example:: $Function BOOL same(BLOB, BLOB) Returns true if and only if the two BLOB arguments are the same -object, i.e. they specify exactly the same region of memory. +object, i.e. they specify exactly the same region of memory, or both +are empty. If the BLOBs are both empty (length is 0 and/or the internal pointer is NULL), then ``same()`` returns ``true``. If any non-empty BLOB From fgsch at lodoss.net Mon Sep 11 22:57:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 11 Sep 2017 22:57:04 +0000 (UTC) Subject: [master] 33523f0 Free decode object on failure Message-ID: <20170911225704.541FB95D86@lists.varnish-cache.org> commit 33523f058765d566c92f2df4949624940eee44b9 Author: Federico G. Schwindt Date: Mon Sep 11 23:25:18 2017 +0100 Free decode object on failure To be revisited post release. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index c5d9530..4dc75f1 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -209,8 +209,10 @@ h2_kill_req(struct worker *wrk, const struct h2_sess *h2, AZ(pthread_cond_signal(r2->cond)); r2 = NULL; } else { - if (r2->state == H2_S_OPEN) + if (r2->state == H2_S_OPEN) { (void)h2h_decode_fini(h2, r2->decode); + FREE_OBJ(r2->decode); + } } Lck_Unlock(&h2->sess->mtx); if (r2 != NULL) @@ -596,6 +598,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) VSLb(h2->vsl, SLT_Debug, "HPACK(hdr) %s", h2e->name); Lck_Unlock(&h2->sess->mtx); (void)h2h_decode_fini(h2, r2->decode); + FREE_OBJ(r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); return (h2e); @@ -630,6 +633,7 @@ h2_rx_continuation(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) VSLb(h2->vsl, SLT_Debug, "HPACK(cont) %s", h2e->name); Lck_Unlock(&h2->sess->mtx); (void)h2h_decode_fini(h2, r2->decode); + FREE_OBJ(r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); return (h2e); From geoff at uplex.de Mon Sep 11 23:02:03 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Sep 2017 23:02:03 +0000 (UTC) Subject: [master] 30e9021 VMOD blob: rename subblob() as sub(). Message-ID: <20170911230203.862CD95FE6@lists.varnish-cache.org> commit 30e90214e162a7749c1b7a43dea2468ee8082e98 Author: Geoff Simmons Date: Tue Sep 12 00:59:28 2017 +0200 VMOD blob: rename subblob() as sub(). Closes #2421 diff --git a/bin/varnishtest/tests/m00045.vtc b/bin/varnishtest/tests/m00045.vtc index 83697a7..d82e7f5 100644 --- a/bin/varnishtest/tests/m00045.vtc +++ b/bin/varnishtest/tests/m00045.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob same(), equal(), length() and subblob()" +varnishtest "VMOD blob same(), equal(), length() and sub()" varnish v1 -vcl { import blob; @@ -165,7 +165,7 @@ client c1 { expect resp.http.empty2len == "0" } -run -# subblob() +# sub() varnish v1 -vcl { import blob; backend b { .host = "${bad_ip}"; } @@ -183,23 +183,23 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.up03 - = blob.encode(BASE64, blob=blob.subblob(up07.get(), 4B)); + = blob.encode(BASE64, blob=blob.sub(up07.get(), 4B)); set resp.http.down07060504 - = blob.encode(BASE64, blob=blob.subblob(down07.get(), 4B)); + = blob.encode(BASE64, blob=blob.sub(down07.get(), 4B)); set resp.http.up04050607 = blob.encode(BASE64, - blob=blob.subblob(up07.get(), 4B, 4B)); + blob=blob.sub(up07.get(), 4B, 4B)); set resp.http.down03 = blob.encode(BASE64, - blob=blob.subblob(down07.get(), 4B, 4B)); + blob=blob.sub(down07.get(), 4B, 4B)); set resp.http.up07 - = blob.encode(BASE64, blob=blob.subblob(up07.get(), 8B)); + = blob.encode(BASE64, blob=blob.sub(up07.get(), 8B)); set resp.http.down07 - = blob.encode(BASE64, blob=blob.subblob(down07.get(), 8B)); + = blob.encode(BASE64, blob=blob.sub(down07.get(), 8B)); set resp.http.zerobytes - = blob.encode(BASE64, blob=blob.subblob(down07.get(), 0B)); + = blob.encode(BASE64, blob=blob.sub(down07.get(), 0B)); set resp.http.zerolen - = blob.length(blob.subblob(down07.get(), 0B)); + = blob.length(blob.sub(down07.get(), 0B)); } } @@ -217,7 +217,7 @@ client c1 { expect resp.http.zerolen == "0" } -run -# subblob() failures +# sub() failures server s1 -repeat 3 { rxreq txresp @@ -234,23 +234,23 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/empty") { set resp.http.empty = blob.encode(BASE64, blob= - blob.subblob(empty.get(), 1B)); + blob.sub(empty.get(), 1B)); } elsif (req.url == "/toolong") { set resp.http.toolong = blob.encode(BASE64, - blob=blob.subblob(up07.get(), 9B)); + blob=blob.sub(up07.get(), 9B)); } elsif (req.url == "/badoffset") { set resp.http.badoffset = blob.encode(BASE64, - blob=blob.subblob(up07.get(), 4B, 5B)); + blob=blob.sub(up07.get(), 4B, 5B)); } } } logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" { expect 0 * Begin req - expect * = VCL_Error "^vmod blob error: blob is empty in blob.subblob..$" + expect * = VCL_Error "^vmod blob error: blob is empty in blob.sub..$" expect * = End } -start @@ -273,7 +273,7 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error "^vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.subblob..$" + expect * * VCL_Error "^vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.sub..$" } -run client c1 { @@ -285,41 +285,41 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error "^vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.subblob..$" + expect * * VCL_Error "^vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.sub..$" } -run -# VCL load failures from subblob() -varnish v1 -errvcl {vmod blob error: blob is empty in blob.subblob()} { +# VCL load failures from sub() +varnish v1 -errvcl {vmod blob error: blob is empty in blob.sub()} { import blob; backend b { .host = "${bad_ip}"; } sub vcl_init { new empty = blob.blob(IDENTITY, ""); - if (blob.same(empty.get(), blob.subblob(empty.get(), 0B))) { + if (blob.same(empty.get(), blob.sub(empty.get(), 0B))) { new B = blob.blob(IDENTITY, "b"); } } } -varnish v1 -errvcl {vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.subblob()} { +varnish v1 -errvcl {vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.sub()} { import blob; backend b { .host = "${bad_ip}"; } sub vcl_init { new up07 = blob.blob(BASE64, "AAECAwQFBgc="); - if (blob.same(up07.get(), blob.subblob(up07.get(), 9B))) { + if (blob.same(up07.get(), blob.sub(up07.get(), 9B))) { new B = blob.blob(IDENTITY, "b"); } } } -varnish v1 -errvcl {vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.subblob()} { +varnish v1 -errvcl {vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.sub()} { import blob; backend b { .host = "${bad_ip}"; } sub vcl_init { new up07 = blob.blob(BASE64, "AAECAwQFBgc="); - if (blob.same(up07.get(), blob.subblob(up07.get(), 4B, 5B))) { + if (blob.same(up07.get(), blob.sub(up07.get(), 4B, 5B))) { new B = blob.blob(IDENTITY, "b"); } } diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 0f3dbb4..2c4df6d 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -20,7 +20,7 @@ $Module blob 3 utilities for the VCL blob type BOOL blob.same(BLOB, BLOB) BOOL blob.equal(BLOB, BLOB) INT blob.length(BLOB) - BLOB blob.subblob(BLOB, BYTES length [, BYTES offset]) + BLOB blob.sub(BLOB, BYTES length [, BYTES offset]) # blob object new OBJ = blob.blob([ENUM decoding,] STRING_LIST encoded) @@ -298,14 +298,14 @@ $Function INT length(BLOB) Returns the length of the BLOB. -$Function BLOB subblob(BLOB, BYTES length, BYTES offset = 0) +$Function BLOB sub(BLOB, BYTES length, BYTES offset = 0) Returns a new BLOB formed from ``length`` bytes of the BLOB argument starting at ``offset`` bytes from the start of its memory region. The default value of ``offset`` is 0B. -``subblob()`` fails and returns NULL if the BLOB argument is empty, or -if ``offset + length`` requires more bytes than are available in the +``sub()`` fails and returns NULL if the BLOB argument is empty, or if +``offset + length`` requires more bytes than are available in the BLOB. $Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, @@ -377,7 +377,7 @@ not known until runtime. ERRORS ====== -The encoders, decoders and ``subblob()`` may fail if there is +The encoders, decoders and ``sub()`` may fail if there is insufficient space to create the new blob or string. Decoders may also fail if the encoded string is an illegal format for the decoding scheme. @@ -408,11 +408,11 @@ strings. The ``blob`` object and its methods allocate memory from the heap, and hence they are only limited by available virtual memory. The ``encode()``, ``decode()`` and ``transcode()`` functions allocate -Varnish workspace, as does ``subblob()`` for the newly created BLOB. -If these functions are failing, as indicated by "out of space" -messages in the Varnish log (with the ``VCL_Error`` tag), then you -will need to increase the varnishd parameters ``workspace_client`` -and/or ``workspace_backend``. +Varnish workspace, as does ``sub()`` for the newly created BLOB. If +these functions are failing, as indicated by "out of space" messages +in the Varnish log (with the ``VCL_Error`` tag), then you will need to +increase the varnishd parameters ``workspace_client`` and/or +``workspace_backend``. The ``transcode()`` function also allocates space on the stack for a temporary BLOB. If this function causes stack overflow, you may need diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 2da7781..7ded3a8 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -549,8 +549,8 @@ vmod_length(VRT_CTX, VCL_BLOB b) return b->len; } -VCL_BLOB __match_proto__(td_blob_subblob) -vmod_subblob(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) +VCL_BLOB __match_proto__(td_blob_sub) +vmod_sub(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) { uintptr_t snap; struct vmod_priv *sub; @@ -560,13 +560,13 @@ vmod_subblob(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) assert(off >= 0); if (b == NULL || b->len == 0 || b->priv == NULL) { - ERR(ctx, "blob is empty in blob.subblob()"); + ERR(ctx, "blob is empty in blob.sub()"); return NULL; } assert(b->len >= 0); if (off + n > b->len) { VERR(ctx, "size %lld from offset %lld requires more bytes than " - "blob length %d in blob.subblob()", n, off, b->len); + "blob length %d in blob.sub()", n, off, b->len); return NULL; } @@ -575,11 +575,11 @@ vmod_subblob(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) snap = WS_Snapshot(ctx->ws); if ((sub = WS_Alloc(ctx->ws, sizeof(*sub))) == NULL) { - ERRNOMEM(ctx, "Allocating BLOB result in blob.subblob()"); + ERRNOMEM(ctx, "Allocating BLOB result in blob.sub()"); return NULL; } if ((sub->priv = WS_Alloc(ctx->ws, n)) == NULL) { - VERRNOMEM(ctx, "Allocating %lld bytes in blob.subblob()", n); + VERRNOMEM(ctx, "Allocating %lld bytes in blob.sub()", n); WS_Reset(ctx->ws, snap); return NULL; } From phk at FreeBSD.org Tue Sep 12 04:16:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Sep 2017 04:16:05 +0000 (UTC) Subject: [master] fcbfce5 Also flexelint new vmods Message-ID: <20170912041605.E263E956FE@lists.varnish-cache.org> commit fcbfce539b6713defcecf3d741690af6263d1b1c Author: Poul-Henning Kamp Date: Tue Sep 12 04:15:26 2017 +0000 Also flexelint new vmods diff --git a/lib/libvmod_blob/flint.lnt b/lib/libvmod_blob/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvmod_blob/flint.sh b/lib/libvmod_blob/flint.sh new file mode 100755 index 0000000..522e30d --- /dev/null +++ b/lib/libvmod_blob/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + -I../../bin/varnishd + *.c +' + +. ../../tools/flint_skel.sh diff --git a/lib/libvmod_vtc/flint.lnt b/lib/libvmod_vtc/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvmod_vtc/flint.sh b/lib/libvmod_vtc/flint.sh new file mode 100755 index 0000000..522e30d --- /dev/null +++ b/lib/libvmod_vtc/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + -I../../bin/varnishd + *.c +' + +. ../../tools/flint_skel.sh From phk at FreeBSD.org Tue Sep 12 04:39:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Sep 2017 04:39:04 +0000 (UTC) Subject: [master] c6999ca Flexelintery Message-ID: <20170912043904.6FD4F950E9@lists.varnish-cache.org> commit c6999ca327d0e5c03c63d24ea3a6217c13a72745 Author: Poul-Henning Kamp Date: Tue Sep 12 04:38:32 2017 +0000 Flexelintery diff --git a/flint.lnt b/flint.lnt index 3fa3bf4..aab7299 100644 --- a/flint.lnt +++ b/flint.lnt @@ -39,6 +39,8 @@ -e785 // Too few initializers for aggregate -e786 // String concatenation within initializer +-e788 // enum constant '___' not used within defaulted switch + -esym(818, argv) // Pointer parameter '...' could be declared as pointing to const /* @@ -75,6 +77,8 @@ -esym(534, sleep) -esym(534, usleep) +-esym(768, vmod_priv) // global struct member '___' (___) not referenced + /////////////////////////////////////////////////////////////////////// // diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c index e1afcf8..9fd3fc4 100644 --- a/lib/libvmod_vtc/vmod_vtc.c +++ b/lib/libvmod_vtc/vmod_vtc.c @@ -187,7 +187,7 @@ vmod_workspace_##name(VRT_CTX, VCL_ENUM which) \ \ op; \ } -VTC_WS_OP(VOID, snapshot, vtc_ws_snapshot = WS_Snapshot(ws)) +VTC_WS_OP(VOID, snapshot, (vtc_ws_snapshot = WS_Snapshot(ws))) VTC_WS_OP(VOID, reset, WS_Reset(ws, vtc_ws_snapshot)) VTC_WS_OP(VOID, overflow, WS_MarkOverflow(ws)) VTC_WS_OP(BOOL, overflowed, return (WS_Overflowed(ws))) @@ -198,7 +198,7 @@ VTC_WS_OP(BOOL, overflowed, return (WS_Overflowed(ws))) VCL_INT __match_proto__(td_vtc_typesize) vmod_typesize(VRT_CTX, VCL_STRING s) { - VCL_INT i = 0; + size_t i = 0; const char *p; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -219,5 +219,5 @@ vmod_typesize(VRT_CTX, VCL_STRING s) default: return (-1); } } - return (i); + return ((VCL_INT)i); } From phk at FreeBSD.org Tue Sep 12 06:35:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Sep 2017 06:35:05 +0000 (UTC) Subject: [master] 0f0c8b8 Umap and free all segments on VSM_Destroy() Message-ID: <20170912063505.ACB36959F0@lists.varnish-cache.org> commit 0f0c8b8722b68dee38d4d2aec51b19c383483eef Author: Poul-Henning Kamp Date: Tue Sep 12 06:34:00 2017 +0000 Umap and free all segments on VSM_Destroy() Fixes #2416 diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 9d3ed85..2b8c7e6 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -147,6 +147,44 @@ vsm_diag(struct vsm *vd, const char *fmt, ...) /*--------------------------------------------------------------------*/ +static void +vsm_unmapseg(struct vsm_seg *vg) +{ + size_t sz, ps, len; + + CHECK_OBJ_NOTNULL(vg, VSM_SEG_MAGIC); + + AN(vg->b); + AN(vg->e); + sz = strtoul(vg->av[2], NULL, 10); + assert(sz > 0); + ps = getpagesize(); + len = RUP2(sz, ps); + AZ(munmap(vg->b, len)); + vg->b = vg->e = NULL; +} + +/*--------------------------------------------------------------------*/ + +static void +vsm_delseg(struct vsm_seg *vg) +{ + + CHECK_OBJ_NOTNULL(vg, VSM_SEG_MAGIC); + + if (vg->b != NULL) + vsm_unmapseg(vg); + + if (vg->stale) + VTAILQ_REMOVE(&vg->set->stale, vg, list); + else + VTAILQ_REMOVE(&vg->set->segs, vg, list); + VAV_Free(vg->av); + FREE_OBJ(vg); +} + +/*--------------------------------------------------------------------*/ + static struct vsm_set * vsm_newset(const char *dirname) { @@ -173,7 +211,10 @@ vsm_delset(struct vsm_set **p) closefd(&vs->fd); if (vs->dfd >= 0) closefd(&vs->dfd); - // XXX: delete segments + while (!VTAILQ_EMPTY(&vs->stale)) + vsm_delseg(VTAILQ_FIRST(&vs->stale)); + while (!VTAILQ_EMPTY(&vs->segs)) + vsm_delseg(VTAILQ_FIRST(&vs->segs)); FREE_OBJ(vs); } @@ -243,11 +284,13 @@ VSM_Destroy(struct vsm **vdp) TAKE_OBJ_NOTNULL(vd, vdp, VSM_MAGIC); VSM_ResetError(vd); - free(vd->dname); - vsm_delset(&vd->mgt); - vsm_delset(&vd->child); + REPLACE(vd->dname, NULL); + if (vd->diag != NULL) + VSB_destroy(&vd->diag); if (vd->dfd >= 0) closefd(&vd->dfd); + vsm_delset(&vd->mgt); + vsm_delset(&vd->child); FREE_OBJ(vd); } @@ -699,7 +742,6 @@ int VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf) { struct vsm_seg *vg; - size_t sz, ps, len; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); AN(vd->attached); @@ -714,19 +756,9 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf) vf->e = NULL; if (vg->refs > 0) return(0); - AN(vg->b); - AN(vg->e); - sz = strtoul(vg->av[2], NULL, 10); - assert(sz > 0); - ps = getpagesize(); - len = RUP2(sz, ps); - AZ(munmap(vg->b, len)); - vg->b = vg->e = NULL; - if (vg->stale) { - VTAILQ_REMOVE(&vg->set->stale, vg, list); - VAV_Free(vg->av); - FREE_OBJ(vg); - } + vsm_unmapseg(vg); + if (vg->stale) + vsm_delseg(vg); return (0); } From geoff at uplex.de Tue Sep 12 08:12:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Tue, 12 Sep 2017 08:12:04 +0000 (UTC) Subject: [master] 242754f Add skeleton What's New and Upgrading docs for 5.2. Message-ID: <20170912081204.EF11394C5A@lists.varnish-cache.org> commit 242754fc81fa2c50aa9b051ec3cb3472c20056de Author: Geoff Simmons Date: Tue Sep 12 10:10:25 2017 +0200 Add skeleton What's New and Upgrading docs for 5.2. At present mostly consisting of XXX's. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst new file mode 100644 index 0000000..e8d46d0 --- /dev/null +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -0,0 +1,51 @@ +.. _whatsnew_changes_5.2: + +Changes in Varnish 5.2 +====================== + +*XXX: preamble* + +Varnish statistics +~~~~~~~~~~~~~~~~~~ + +*XXX: changes and new features of VSC/VSM* + +.. _whatsnew_new_vmods: + +New VMODs in the standard distribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: introductory paragraphs about new VMODs* + +VMOD purge +---------- + +*XXX: about VMOD purge* + +VMOD vtc +-------- + +*XXX: about VMOD vtc* + +VMOD blob +--------- + +*XXX: about VMOD blob* + +XXX: Any other headline changes ... +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: ...* + +News for authors of VMODs and Varnish API client applications +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: such news may include:* + +* *XXX: effects of new VSC/VSM on VMODs* + +* *XXX: effects of new VSC/VSM on API client apps* + +* *XXX: changes in VRT* + +*EOF* diff --git a/doc/sphinx/whats-new/index.rst b/doc/sphinx/whats-new/index.rst index c0b55b3..35d47c3 100644 --- a/doc/sphinx/whats-new/index.rst +++ b/doc/sphinx/whats-new/index.rst @@ -8,6 +8,15 @@ This section describes the changes and improvements between different versions of Varnish, and what upgrading between the different versions entail. +Varnish 5.2 +----------- + +.. toctree:: + :maxdepth: 2 + + changes-5.2 + upgrading-5.2 + Varnish 5.1 ----------- diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst new file mode 100644 index 0000000..8048cb8 --- /dev/null +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -0,0 +1,107 @@ +.. _whatsnew_upgrading_5.2: + +%%%%%%%%%%%%%%%%%%%%%%%% +Upgrading to Varnish 5.2 +%%%%%%%%%%%%%%%%%%%%%%%% + +Varnish statistics and logging +============================== + +*XXX: anything new for users or admins concerning statistics,* +*varnishstat, logging etc* + +varnishd parameters +=================== + +* *XXX: -p params that are new, modified, deprecated or removed* + +* *XXX: use rst refs to keep it short* + +* *XXX: ...* + +Changes to VCL +============== + +*XXX: intro paragraph* + +*XXX: emphasize what most likely needs to be done, if anything,* +*to migrate from 5.1 to 5.2* + +*XXX: ... or reassure that you probably don't have to do anything* +*to migrate from 5.1 to 5.2* + +XXX: headline changes ... +~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: the most important changes or additions first* + +``req.hash`` and ``bereq.hash`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: about {be}req.hash, mention data type BLOB, advise about* +*:ref:`vmod_blob(3)`* + +XXX: vcl_sub_XXX ... +~~~~~~~~~~~~~~~~~~~~ + +*XXX: list changes by VCL sub* + +XXX: more VCL changes ... +~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: any more details and new features that VCL authors have to know* + +vmod_std +~~~~~~~~ + +* *XXX: any changes in VMOD std?* + +New VMODs in the standard distribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +See :ref:`vmod_purge(3)`, :ref:`vmod_vtc(3)`, :ref:`vmod_blob(3)` and +:ref:`whatsnew_new_vmods`. + +Other changes +============= + +* ``varnishstat(1)``: + + * *XXX: changes due to new VSC/VSM* + + * *XXX: ...* + +* ``varnishlog(1)``: + + * *XXX: changes due to new VSC/VSM* + + * *XXX: ...* + +* ``varnishtest(1)`` and ``vtc(7)``: + + * *XXX: changes in test code* + + * *XXX: for example due to VMOD vtc* + + * *XXX: ...* + +* *XXX: any other changes in the standard VUT tools* + + * *XXX: ...* + +* *XXX: changes in VRT that may affect VMOD authors* + + * *XXX: ...* + +* *XXX: changes for developers?* + + * *XXX: such as sanitizer flags?* + + * *XXX: ...* + +* *XXX: other changes in tools and infrastructure in and around + Varnish ...* + + * *XXX: anything new about project tools, VTEST & GCOV, etc?* + + * *XXX: ...* From fgsch at lodoss.net Tue Sep 12 08:21:03 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 12 Sep 2017 08:21:03 +0000 (UTC) Subject: [master] ba5d98f Close the VFPs on error Message-ID: <20170912082103.E732595131@lists.varnish-cache.org> commit ba5d98f4a9335d3aea7a08a475d2b65bd88f5941 Author: Federico G. Schwindt Date: Tue Sep 12 00:12:13 2017 +0100 Close the VFPs on error diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index fe3fdae..20b3596 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -544,6 +544,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) if (vfc->failed) { (void)VFP_Error(vfc, "Fetch pipeline failed to process"); bo->htc->doclose = SC_RX_BODY; + VFP_Close(vfc); VDI_Finish(wrk, bo); if (!bo->do_stream) { assert(bo->fetch_objcore->boc->state < BOS_STREAM); From fgsch at lodoss.net Tue Sep 12 08:35:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 12 Sep 2017 08:35:05 +0000 (UTC) Subject: [master] 629c639 Remove referenses to repo.varnish-cache.org Message-ID: <20170912083505.0BCE5957C3@lists.varnish-cache.org> commit 629c63922ee379a807d4a1eee9205c205f511456 Author: Simon Vikstrom Date: Tue Sep 12 08:05:27 2017 +0200 Remove referenses to repo.varnish-cache.org diff --git a/README.Packaging b/README.Packaging index baccc17..71ac964 100644 --- a/README.Packaging +++ b/README.Packaging @@ -13,7 +13,7 @@ Official packages ----------------- The official Debian and Redhat packages are built by the Varnish Cache team -and made available on https://repo.varnish-cache.org/ . +and made available on https://packagecloud.io/varnishcache/ . Packaging files and scripts for Debian and Redhat: diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index d65588d..fba97e1 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -31,7 +31,7 @@ Red Hat / CentOS ---------------- We try to keep the latest version available as prebuilt RPMs (el5 and el6) -on `repo.varnish-cache.org `_. See the online +on `packagecloud.io/varnishcache `_. See the online `Red Hat installation instructions `_ for more information. @@ -62,7 +62,7 @@ want to compile Varnish from source for other reasons, follow these steps: Download the appropriate release tarball, which you can find on -http://repo.varnish-cache.org/source/ . +https://varnish-cache.org/releases/ . Alternatively, if you want to hack on Varnish, you should clone our git repository by doing. diff --git a/doc/sphinx/whats-new/relnote-5.0.rst b/doc/sphinx/whats-new/relnote-5.0.rst index 71b895e..513f46d 100644 --- a/doc/sphinx/whats-new/relnote-5.0.rst +++ b/doc/sphinx/whats-new/relnote-5.0.rst @@ -25,7 +25,7 @@ stuff in two separate documents: How to get Varnish 5.0 ---------------------- -`Source download `_ +`Source download `_ Packages for mainstream operating systems should appear in as soon as they trickle through the machinery. From phk at FreeBSD.org Tue Sep 12 08:35:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Sep 2017 08:35:05 +0000 (UTC) Subject: [master] 1071160 Add text about VSM/VSC renovation Message-ID: <20170912083505.26D51957C6@lists.varnish-cache.org> commit 1071160c609a7efd2a77ce5dd78e8f5d151bb0a6 Author: Poul-Henning Kamp Date: Tue Sep 12 08:34:44 2017 +0000 Add text about VSM/VSC renovation diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index e8d46d0..0c0140c 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -8,7 +8,14 @@ Changes in Varnish 5.2 Varnish statistics ~~~~~~~~~~~~~~~~~~ -*XXX: changes and new features of VSC/VSM* +The export of statistics counters via shared memory has been +overhauled to get rid of limitations which made sense 11 years +ago but no so much now. + +Statistics counters are now self-describing in shared memory, +paving the way so that VMODs or maybe even VCL can define +counters in the future, and have them show up in varnishstat +and other VSC-API based programs. .. _whatsnew_new_vmods: @@ -42,9 +49,33 @@ News for authors of VMODs and Varnish API client applications *XXX: such news may include:* -* *XXX: effects of new VSC/VSM on VMODs* +VSM/VSC API changes +------------------- + +The rewrite of the VSM/VSC code has similified the API and +made it much more robust, and code calling into these APIs +will have to be updated to match. + +The necessary changes mostly center around detecting if the +varnishd management/worker process has restarted. + +In the new VSM-api once setup is done, VSM_Attach() latches +on to a running varnishd master process and stays there. + +VSM_Status() returns information about the master and worker +process, if they are running, if they have been restarted +(since the previous call to VSM_Status()) and updates the +in-memory list of VSM segments. + +Each VSM segment is now a separate piece of shared memory +and the name of the segment can be much longer now. + +Before the actual shared memory can be accessed, the +applicaiton must call VSM_Map() and when VSM_StillValid() +indicates that the segment is no longer valid, VSM_Unmap() +should be called to release the segment again. -* *XXX: effects of new VSC/VSM on API client apps* +All in all, this should be simpler and more robust now. * *XXX: changes in VRT* From geoff at uplex.de Tue Sep 12 09:01:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Tue, 12 Sep 2017 09:01:04 +0000 (UTC) Subject: [master] c853352 Add a blurb about VMOD blob to What's New in 5.2. Message-ID: <20170912090104.C76229531F@lists.varnish-cache.org> commit c853352627b3d30f8a662c230162d90754c3d957 Author: Geoff Simmons Date: Tue Sep 12 10:59:38 2017 +0200 Add a blurb about VMOD blob to What's New in 5.2. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 0c0140c..a07b1c3 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -37,7 +37,19 @@ VMOD vtc VMOD blob --------- -*XXX: about VMOD blob* +We have added the variables ``req.hash`` and ``bereq.hash`` to VCL, +which contain the hash value computed by Varnish for the current +request, for use in cache lookup. Their data type is BLOB, which +represents arbitrary data of any length -- the new variables contain +the raw binary hashes. + +This is the first time that an element of standard VCL has the BLOB +type (BLOBs have only been used in third-party VMODs until now). So we +have added VMOD blob to facilitate their use. In particular, the VMOD +implements binary-to-text encodings, for example so that you can +assign the hash to a header as a base64 or hex string. It also +provides some other utilities such as getting the length of a BLOB or +testing BLOBs for equality. See :ref:`vmod_blob(3)`. XXX: Any other headline changes ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From geoff at uplex.de Tue Sep 12 09:02:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Tue, 12 Sep 2017 09:02:04 +0000 (UTC) Subject: [master] 2335122 Typo Message-ID: <20170912090204.D56A6954FF@lists.varnish-cache.org> commit 2335122a457c0228d13f0fe4fa5af048288755e6 Author: Geoff Simmons Date: Tue Sep 12 11:01:13 2017 +0200 Typo diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index a07b1c3..0e3a9b6 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -10,7 +10,7 @@ Varnish statistics The export of statistics counters via shared memory has been overhauled to get rid of limitations which made sense 11 years -ago but no so much now. +ago but not so much now. Statistics counters are now self-describing in shared memory, paving the way so that VMODs or maybe even VCL can define From dridi.boukelmoune at gmail.com Tue Sep 12 09:09:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Sep 2017 09:09:04 +0000 (UTC) Subject: [master] 5cb9f07 Update copyright notice Message-ID: <20170912090904.324C79595B@lists.varnish-cache.org> commit 5cb9f07bb841c2a8dc8e5f5263443658560ab310 Author: Dridi Boukelmoune Date: Tue Sep 12 10:16:49 2017 +0200 Update copyright notice diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index e3e343d..0f3fb80 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011-2015 Varnish Software AS + * Copyright (c) 2011-2017 Varnish Software AS * All rights reserved. * * Author: Tollef Fog Heen @@ -116,6 +116,7 @@ LIBVARNISHAPI_2.0 { VSM__itern; VSM_invalid; VSM_valid; + # vtim.c VTIM_format; VTIM_mono; From dridi.boukelmoune at gmail.com Tue Sep 12 09:09:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Sep 2017 09:09:04 +0000 (UTC) Subject: [master] 6bccc48 Sort new VMODs in alphabetic order Message-ID: <20170912090904.5A1229595E@lists.varnish-cache.org> commit 6bccc4892f67f28ae8255dbe5ebbcf60e8c43cff Author: Dridi Boukelmoune Date: Tue Sep 12 11:03:30 2017 +0200 Sort new VMODs in alphabetic order And some whitespace cleanup. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 0e3a9b6..4804a86 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -24,16 +24,6 @@ New VMODs in the standard distribution *XXX: introductory paragraphs about new VMODs* -VMOD purge ----------- - -*XXX: about VMOD purge* - -VMOD vtc --------- - -*XXX: about VMOD vtc* - VMOD blob --------- @@ -51,6 +41,16 @@ assign the hash to a header as a base64 or hex string. It also provides some other utilities such as getting the length of a BLOB or testing BLOBs for equality. See :ref:`vmod_blob(3)`. +VMOD purge +---------- + +*XXX: about VMOD purge* + +VMOD vtc +-------- + +*XXX: about VMOD vtc* + XXX: Any other headline changes ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8048cb8..cc70923 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -16,7 +16,7 @@ varnishd parameters * *XXX: -p params that are new, modified, deprecated or removed* * *XXX: use rst refs to keep it short* - + * *XXX: ...* Changes to VCL @@ -59,9 +59,9 @@ vmod_std New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See :ref:`vmod_purge(3)`, :ref:`vmod_vtc(3)`, :ref:`vmod_blob(3)` and +See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)`, :ref:`vmod_vtc(3)` and :ref:`whatsnew_new_vmods`. - + Other changes ============= From dridi.boukelmoune at gmail.com Tue Sep 12 16:27:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Sep 2017 16:27:07 +0000 (UTC) Subject: [master] 4c4759a Expose vcstool to external projects Message-ID: <20170912162707.2AED396506@lists.varnish-cache.org> commit 4c4759af1489b3b8ce2e524188790b9efd06c7c4 Author: Dridi Boukelmoune Date: Tue Sep 12 18:23:00 2017 +0200 Expose vcstool to external projects diff --git a/varnish.m4 b/varnish.m4 index 9a7f868..8d4a486 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -28,8 +28,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. -# varnish.m4 - Macros to define VMOD builds. -*- Autoconf -*- -# serial 7 (varnish-5.1.2) +# varnish.m4 - Macros to build against Varnish. -*- Autoconf -*- +# serial 8 (varnish-5.2.0) # # This collection of macros helps create VMODs or tools interacting with # Varnish Cache using the GNU build system (autotools). In order to work @@ -85,6 +85,7 @@ AC_DEFUN([_VARNISH_PKG_CONFIG], [ PKG_CHECK_VAR([VARNISHAPI_VMODDIR], [varnishapi], [vmoddir]) PKG_CHECK_VAR([VMODTOOL], [varnishapi], [vmodtool]) + PKG_CHECK_VAR([VCSTOOL], [varnishapi], [vcstool]) AC_SUBST([VARNISH_LIBRARY_PATH], [$VARNISHAPI_LIBDIR:$VARNISHAPI_LIBDIR/varnish]) @@ -384,6 +385,9 @@ AC_DEFUN([VARNISH_VMODS], [ # - vcldir added # - pkgvcldir added # +# Since Varnish 5.2.0: +# - VCSTOOL added +# # Verify that the version of Varnish Cache found by pkg-config is at least # MINIMUM-VERSION. If MAXIMUM-VERSION is specified, verify that the version # is strictly below MAXIMUM-VERSION. @@ -408,6 +412,7 @@ AC_DEFUN([VARNISH_VMODS], [ # - VARNISHAPI_VCLDIR # - VARNISHAPI_VMODDIR # - VMODTOOL +# - VCSTOOL # # In addition, two directories are set up for installation in automake: # diff --git a/varnishapi.pc.in b/varnishapi.pc.in index b452f6b..b9c638b 100644 --- a/varnishapi.pc.in +++ b/varnishapi.pc.in @@ -13,6 +13,7 @@ pkgdatadir=${datadir}/@PACKAGE@ vcldir=${pkgdatadir}/vcl vmoddir=${libdir}/@PACKAGE@/vmods vmodtool=${pkgdatadir}/vmodtool.py +vcstool=${pkgdatadir}/vcstool.py Name: VarnishAPI Description: Varnish API From phk at FreeBSD.org Wed Sep 13 08:48:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Sep 2017 08:48:06 +0000 (UTC) Subject: [master] 716badd Some work on the release docs Message-ID: <20170913084806.5168E96FA6@lists.varnish-cache.org> commit 716baddcf76f3e331c584071c3f871db9b225618 Author: Poul-Henning Kamp Date: Wed Sep 13 08:46:46 2017 +0000 Some work on the release docs diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 4804a86..5688246 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -3,26 +3,15 @@ Changes in Varnish 5.2 ====================== -*XXX: preamble* - -Varnish statistics -~~~~~~~~~~~~~~~~~~ - -The export of statistics counters via shared memory has been -overhauled to get rid of limitations which made sense 11 years -ago but not so much now. - -Statistics counters are now self-describing in shared memory, -paving the way so that VMODs or maybe even VCL can define -counters in the future, and have them show up in varnishstat -and other VSC-API based programs. +Varnish 5.2 is mostly changes under the hood so most varnish +installations will be able to upgrade with no modifications. .. _whatsnew_new_vmods: New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*XXX: introductory paragraphs about new VMODs* +We have added three new VMODs to the varnish project. VMOD blob --------- @@ -30,7 +19,7 @@ VMOD blob We have added the variables ``req.hash`` and ``bereq.hash`` to VCL, which contain the hash value computed by Varnish for the current request, for use in cache lookup. Their data type is BLOB, which -represents arbitrary data of any length -- the new variables contain +represents opaque data of any length -- the new variables contain the raw binary hashes. This is the first time that an element of standard VCL has the BLOB @@ -39,17 +28,34 @@ have added VMOD blob to facilitate their use. In particular, the VMOD implements binary-to-text encodings, for example so that you can assign the hash to a header as a base64 or hex string. It also provides some other utilities such as getting the length of a BLOB or -testing BLOBs for equality. See :ref:`vmod_blob(3)`. +testing BLOBs for equality. + +See :ref:`vmod_blob(3)`. VMOD purge ---------- -*XXX: about VMOD purge* +*XXX: DRIDI ? about VMOD purge* + +See :ref:`vmod_purge(3)`. VMOD vtc -------- -*XXX: about VMOD vtc* +As long as we have had VMODs, we had an internal vmod called ``vmod_debug`` +which were used with ``varnishtest`` to exercise the VMOD related parts of +``varnishd``. Over time this vmod grew other useful functions for writing +test-cases. + +We only distribute ``vmod_debug`` in source releases, because it has some +pretty evil functionality, for instance ``debug.panic()``. + +We have split the non-suicidal test-writing stuff from ``vmod_debug`` +into a new ``vmod_vtc``, which is included in binary releases from +now on, in order to make it easier for people to use ``varnishtest`` +to test local configurations, VMODs etc. + +See :ref:`vmod_vtc(3)`. XXX: Any other headline changes ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -61,11 +67,34 @@ News for authors of VMODs and Varnish API client applications *XXX: such news may include:* + +$ABI [strict|vrt] +----------------- + +*XXX: DRIDI ?* + VSM/VSC API changes ------------------- -The rewrite of the VSM/VSC code has similified the API and -made it much more robust, and code calling into these APIs +The export of statistics counters via shared memory has been +overhauled to get rid of limitations which made sense 11 years +ago but not so much now. + +A set of statistics counters are now fully defined in a ``.vsc`` +file which is processed by the ``vsctool.py`` script into a .c and +.h file, which is compiled into the relevant body of code. + +This means that statistics counters are now self-describing in +shared memory, and ``varnishstat`` or other VSC-API using programs +have no compiled in knowledge about which counters exist or how +to treat them. + +This paves the way for VMODs or maybe even VCL to define +custom counters, and have them show up in varnishstat and +other VSC-API based programs just like the rest of the counters. + +The rewrite of the VSM/VSC code similified both APIs and +made them much more robust but code calling into these APIs will have to be updated to match. The necessary changes mostly center around detecting if the @@ -74,10 +103,10 @@ varnishd management/worker process has restarted. In the new VSM-api once setup is done, VSM_Attach() latches on to a running varnishd master process and stays there. -VSM_Status() returns information about the master and worker -process, if they are running, if they have been restarted -(since the previous call to VSM_Status()) and updates the -in-memory list of VSM segments. +VSM_Status() updates the in-memory list of VSM segments, and +returns information about the master and worker proces: +Are they running? Have they been restarted? Have VSM segments +been added/deleted? Each VSM segment is now a separate piece of shared memory and the name of the segment can be much longer now. @@ -89,6 +118,6 @@ should be called to release the segment again. All in all, this should be simpler and more robust now. -* *XXX: changes in VRT* +*XXX: changes in VRT* *EOF* diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index cc70923..2164e32 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -7,8 +7,8 @@ Upgrading to Varnish 5.2 Varnish statistics and logging ============================== -*XXX: anything new for users or admins concerning statistics,* -*varnishstat, logging etc* +There are extensive changes under the hood with respect to statistics +counters, but these should all be transparent at the user-level. varnishd parameters =================== From phk at FreeBSD.org Wed Sep 13 09:22:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Sep 2017 09:22:04 +0000 (UTC) Subject: [master] 24b8142 Whitespace OCD Message-ID: <20170913092204.7AA55969F1@lists.varnish-cache.org> commit 24b8142136e0b2d3e856171b72d478ae97f2db1e Author: Poul-Henning Kamp Date: Wed Sep 13 09:21:36 2017 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index 81b654d..e4d963c 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -52,15 +52,15 @@ varnish v1 -vcl { set resp.http.truncated = blob.encode(IDENTITY, - blob=blob.decode(HEX, encoded="666f6f00626172")); + blob=blob.decode(HEX, encoded="666f6f00626172")); set resp.http.lc = blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, - encoded="Don't care")); + encoded="Don't care")); set resp.http.uc = blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, - encoded="Don't care")); + encoded="Don't care")); } } -start diff --git a/bin/varnishtest/tests/m00034.vtc b/bin/varnishtest/tests/m00034.vtc index 95ea934..9d7144e 100644 --- a/bin/varnishtest/tests/m00034.vtc +++ b/bin/varnishtest/tests/m00034.vtc @@ -15,7 +15,7 @@ varnish v1 -vcl { set resp.http.hobbes = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, - encoded= + encoded= {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = @@ -27,7 +27,7 @@ varnish v1 -vcl { set resp.http.empty = blob.encode(IDENTITY, - blob=blob.decode(IDENTITY, length=5, encoded="")); + blob=blob.decode(IDENTITY, length=5, encoded="")); set resp.http.undef = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index 6190914..9f7df33 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -20,11 +20,11 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.hex = blob.encode(HEX, blob=blob.decode(IDENTITY, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.hexlc = blob.encode(HEX, LOWER, - blob.decode(IDENTITY, encoded=req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.hexuc = blob.encode(HEX, UPPER, @@ -32,27 +32,27 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.hobbes = blob.encode(HEX, blob=blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.hobbeslc = blob.encode(HEX, LOWER, blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEX, UPPER, blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.all = blob.encode(HEX, blob=blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-lc = blob.encode(HEX, LOWER, blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-uc = blob.encode(HEX, UPPER, blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.empty = blob.encode(HEX, blob=blob.decode(IDENTITY, encoded="")); @@ -99,19 +99,19 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.decalluc = blob.encode(BASE64, blob=blob.decode(HEX, - encoded=req.http.hexalluc)); + encoded=req.http.hexalluc)); set resp.http.decalllc = blob.encode(BASE64, blob=blob.decode(HEX, - encoded=req.http.hexalllc)); + encoded=req.http.hexalllc)); set resp.http.decallucodd = blob.encode(BASE64, - blob=blob.decode(HEX, encoded=req.http.hexallucodd)); + blob=blob.decode(HEX, encoded=req.http.hexallucodd)); set resp.http.decalllcodd = blob.encode(BASE64, - blob=blob.decode(HEX, encoded=req.http.hexalllcodd)); + blob=blob.decode(HEX, encoded=req.http.hexalllcodd)); set resp.http.decempty = blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="")); @@ -125,13 +125,13 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.decemptypieces = blob.encode(IDENTITY, blob=blob.decode(HEX, encoded=req.http.unset + "" - + req.http.unset + "")); + + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob=blob.decode(HEX, - encoded=req.http.part1 + - "F6F206261722062617A2071757578")); + encoded=req.http.part1 + + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; set resp.http.dec3param = @@ -142,12 +142,12 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.dec3pieces = blob.encode(IDENTITY, blob=blob.decode(HEX, - encoded=req.http.part1 + + encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, blob=blob.decode(HEX, encoded= - "" + req.http.unset + "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 diff --git a/bin/varnishtest/tests/m00036.vtc b/bin/varnishtest/tests/m00036.vtc index 635d726..12e1c24 100644 --- a/bin/varnishtest/tests/m00036.vtc +++ b/bin/varnishtest/tests/m00036.vtc @@ -20,7 +20,7 @@ varnish v1 -vcl { set resp.http.hexlc = blob.encode(HEX, blob=blob.decode(IDENTITY, 5, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.hexuc = blob.encode(HEX, UPPER, @@ -28,20 +28,20 @@ varnish v1 -vcl { set resp.http.hobbeslc = blob.encode(HEX, - blob=blob.decode(IDENTITY, 5, - encoded=req.http.hobbes)); + blob=blob.decode(IDENTITY, 5, + encoded=req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEX, UPPER, - blob.decode(IDENTITY, 5, encoded=req.http.hobbes)); + blob.decode(IDENTITY, 5, encoded=req.http.hobbes)); set resp.http.all-lc = blob.encode(HEX, blob=blob.decode(BASE64, 8, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-uc = blob.encode(HEX, UPPER, - blob.decode(BASE64, 8, encoded=req.http.b64all)); + blob.decode(BASE64, 8, encoded=req.http.b64all)); set resp.http.empty-lc = blob.encode(HEX, blob=blob.decode(IDENTITY, 5, encoded="")); @@ -51,13 +51,13 @@ varnish v1 -vcl { set resp.http.hexlcparam = blob.encode(blob=blob.decode(IDENTITY, 5, - encoded=req.http.pangram), - encoding=HEX, case=LOWER); + encoded=req.http.pangram), + encoding=HEX, case=LOWER); set resp.http.hexucparam = blob.encode(blob=blob.decode(IDENTITY, 5, - encoded=req.http.pangram), - encoding=HEX, case=UPPER); + encoded=req.http.pangram), + encoding=HEX, case=UPPER); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); @@ -72,30 +72,30 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, blob=blob.decode(HEX, 10, - encoded=req.http.hexucfoobar)); + encoded=req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, blob=blob.decode(HEX, 10, - encoded=req.http.hexlcfoobar)); + encoded=req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, blob=blob.decode(HEX, 12, - encoded=req.http.hexhobbesuc)); + encoded=req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, blob=blob.decode(HEX, 12, - encoded=req.http.hexhobbeslc)); + encoded=req.http.hexhobbeslc)); set resp.http.decalluc = blob.encode(BASE64, - blob=blob.decode(HEX, 12, encoded=req.http.hexalluc)); + blob=blob.decode(HEX, 12, encoded=req.http.hexalluc)); set resp.http.decalllc = blob.encode(BASE64, - blob=blob.decode(HEX, 12, encoded=req.http.hexalllc)); + blob=blob.decode(HEX, 12, encoded=req.http.hexalllc)); set resp.http.decallucodd = blob.encode(BASE64, blob=blob.decode(HEX, 11, @@ -122,8 +122,8 @@ varnish v1 -vcl { set req.http.part1 = "666"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob=blob.decode(HEX, 6, - encoded=req.http.part1 + - "F6F206261722062617A2071757578")); + encoded=req.http.part1 + + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; set resp.http.dec3param = @@ -134,12 +134,12 @@ varnish v1 -vcl { set resp.http.dec3pieces = blob.encode(IDENTITY, blob=blob.decode(HEX, 30, - encoded=req.http.part1 + + encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, blob=blob.decode(HEX, 20, encoded="" - + req.http.unset + + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -192,7 +192,7 @@ varnish v1 -vcl+backend { set req.http.foo = "123"; set resp.http.badhex = blob.encode(HEX, UPPER, blob.decode(HEX, 2, - encoded="g" + req.http.foo)); + encoded="g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index e8ee70a..3209394 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -35,7 +35,7 @@ varnish v1 -vcl { set resp.http.b64all = blob.encode(BASE64, blob=blob.decode(HEX, - encoded=req.http.hexall)); + encoded=req.http.hexall)); set resp.http.b64url = blob.encode(BASE64URL, @@ -55,7 +55,7 @@ varnish v1 -vcl { set resp.http.b64urlall = blob.encode(BASE64URL, blob=blob.decode(HEX, - encoded=req.http.hexall)); + encoded=req.http.hexall)); set resp.http.b64urlnopad = blob.encode(BASE64URLNOPAD, @@ -83,7 +83,7 @@ varnish v1 -vcl { blob.encode(BASE64URL, blob=blob.decode(IDENTITY, encoded="")); set resp.http.nopadempty = blob.encode(BASE64URLNOPAD, - blob=blob.decode(IDENTITY, encoded="")); + blob=blob.decode(IDENTITY, encoded="")); set resp.http.b64param = blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), @@ -99,11 +99,11 @@ varnish v1 -vcl { set resp.http.b64xcode = blob.transcode(IDENTITY, BASE64, - encoded=req.url + "Hello world" + req.url); + encoded=req.url + "Hello world" + req.url); set resp.http.b64urlxcode = blob.transcode(IDENTITY, BASE64URL, - encoded=req.url + "Hello world" + req.url); + encoded=req.url + "Hello world" + req.url); set resp.http.b64urlnopadxcode = blob.transcode(IDENTITY, BASE64URLNOPAD, @@ -161,7 +161,7 @@ varnish v1 -vcl { set resp.http.dec = blob.encode(IDENTITY, blob= blob.decode(BASE64, - encoded=req.http.foobarbazquux)); + encoded=req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, @@ -184,13 +184,13 @@ varnish v1 -vcl { set resp.http.nopaddechobbes = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, encoded=req.http.hobbesnopad)); set resp.http.nopaddecall = blob.encode(HEX, blob=blob.decode(BASE64URLNOPAD, - encoded=req.http.allurl)); + encoded=req.http.allurl)); set resp.http.b64empty = blob.encode(IDENTITY, blob=blob.decode(BASE64, encoded="")); @@ -198,7 +198,7 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob=blob.decode(BASE64URL, encoded="")); set resp.http.nopadempty = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, encoded="")); + blob=blob.decode(BASE64URLNOPAD, encoded="")); set resp.http.emptypieces = blob.encode(IDENTITY, blob= blob.decode(BASE64, encoded=req.http.unset + "" + req.http.unset @@ -207,7 +207,7 @@ varnish v1 -vcl { set resp.http.decenc = blob.encode(BASE64, blob=blob.decode(BASE64, - encoded=req.http.foobarbazquux)); + encoded=req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces @@ -305,7 +305,7 @@ varnish v1 -vcl+backend { elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, - encoded="TWFu" + req.http.foo)); + encoded="TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index 2149585..bfcd67e 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -23,75 +23,75 @@ varnish v1 -vcl { set resp.http.url = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.urllc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.urluc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.hobbes = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.hobbeslc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.hobbesuc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.umlauts = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.umlauts)); + encoded=req.http.umlauts)); set resp.http.umlautslc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.umlauts)); + encoded=req.http.umlauts)); set resp.http.umlautsuc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.umlauts)); + encoded=req.http.umlauts)); set resp.http.phk = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.phkspeak)); + encoded=req.http.phkspeak)); set resp.http.phklc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.phkspeak)); + encoded=req.http.phkspeak)); set resp.http.phkuc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.phkspeak)); + encoded=req.http.phkspeak)); set resp.http.utf8 = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.utf8)); + encoded=req.http.utf8)); set resp.http.utf8lc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.utf8)); + encoded=req.http.utf8)); set resp.http.utf8uc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.utf8)); + encoded=req.http.utf8)); set resp.http.all = blob.encode(URL, blob=blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-lc = blob.encode(URL, LOWER, blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-uc = blob.encode(URL, UPPER, blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.empty = blob.encode(URL, blob=blob.decode(IDENTITY, encoded="")); @@ -175,7 +175,7 @@ varnish v1 -vcl { set resp.http.decmixed = blob.encode(IDENTITY, blob=blob.decode(URL, - encoded=req.http.urlmixedfoobar)); + encoded=req.http.urlmixedfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, @@ -211,11 +211,11 @@ varnish v1 -vcl { set resp.http.decalluc = blob.encode(BASE64, blob=blob.decode(URL, - encoded=req.http.urlalluc)); + encoded=req.http.urlalluc)); set resp.http.decalllc = blob.encode(BASE64, blob=blob.decode(URL, - encoded=req.http.urlalllc)); + encoded=req.http.urlalllc)); set resp.http.decempty = blob.encode(IDENTITY, blob=blob.decode(URL, encoded="")); @@ -231,8 +231,8 @@ varnish v1 -vcl { set req.http.part1 = "foo%"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob=blob.decode(URL, - encoded=req.http.part1 + - "20bar%20baz%20quux")); + encoded=req.http.part1 + + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = @@ -243,11 +243,11 @@ varnish v1 -vcl { set resp.http.dec3pieces = blob.encode(IDENTITY, blob=blob.decode(URL, encoded= - req.http.part1 + "20bar%20baz%2" + req.http.part2)); + req.http.part1 + "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, blob=blob.decode(URL, encoded= - "" + req.http.unset + "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -294,7 +294,7 @@ varnish v1 -vcl+backend { if (req.url == "/percent") { set resp.http.bad = blob.encode(URL, UPPER, blob.decode(URL, - encoded="%")); + encoded="%")); } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URL, UPPER, diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index 4056d9c..4c543d8 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -302,7 +302,7 @@ varnish v1 -vcl { set resp.http.urlalldownuc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, - encoded=req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2b64 = blob.transcode(URL, BASE64, encoded=req.http.urlalldownlc); @@ -312,7 +312,7 @@ varnish v1 -vcl { set resp.http.urlalldownlc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, - encoded=req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlallupuc2b64 = blob.transcode(URL, BASE64, encoded=req.http.urlallupuc); diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index ecd8b44..aaac4b9 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -23,15 +23,15 @@ varnish v1 -vcl { set resp.http.id2id = blob.transcode(IDENTITY, IDENTITY, length=5, - encoded="Hello world"); + encoded="Hello world"); set resp.http.id2b64 = blob.transcode(IDENTITY, BASE64, length=5, - encoded=req.http.hobbes); + encoded=req.http.hobbes); set resp.http.id2b64nopad = blob.transcode(IDENTITY, BASE64URLNOPAD, length=5, - encoded=req.http.hobbes); + encoded=req.http.hobbes); set resp.http.id2hex = blob.transcode(IDENTITY, HEX, length=5, encoded=req.http.hobbes); @@ -53,34 +53,34 @@ varnish v1 -vcl { set resp.http.b642id = blob.transcode(BASE64, IDENTITY, length=8, - encoded=req.http.hobbesb64); + encoded=req.http.hobbesb64); set resp.http.hex2id = blob.transcode(HEX, IDENTITY, length=12, - encoded=req.http.hexhobbes); + encoded=req.http.hexhobbes); set resp.http.hexalldown2b64 = blob.transcode(HEX, BASE64, length=12, - encoded=req.http.hexalldown); + encoded=req.http.hexalldown); set resp.http.hexalldown2b64url = blob.transcode(HEX, BASE64URL, length=12, - encoded=req.http.hexalldown); + encoded=req.http.hexalldown); set resp.http.hexalldown2b64nopad = blob.transcode(HEX, BASE64URLNOPAD, length=10, - encoded=req.http.hexalldown); + encoded=req.http.hexalldown); set resp.http.hexallup2b64 = blob.transcode(HEX, BASE64, length=12, encoded=req.http.hexallup); set resp.http.hexallup2b64url = blob.transcode(HEX, BASE64URL, length=10, - encoded=req.http.hexallup); + encoded=req.http.hexallup); set resp.http.hexallup2b64nopad = blob.transcode(HEX, BASE64URLNOPAD, length=10, - encoded=req.http.hexallup); + encoded=req.http.hexallup); set resp.http.hexalldown2url = blob.transcode(HEX, URL, length=12, encoded=req.http.hexalldown); @@ -157,7 +157,7 @@ varnish v1 -vcl { set resp.http.b64allurl2hex = blob.transcode(BASE64URL, HEX, length=8, - encoded=req.http.b64allurl); + encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc = blob.transcode(BASE64URL, HEX, UPPER, 8, req.http.b64allurl); @@ -176,7 +176,7 @@ varnish v1 -vcl { set resp.http.b64allurl2url = blob.transcode(BASE64URL, URL, length=8, - encoded=req.http.b64allurl); + encoded=req.http.b64allurl); set resp.http.b64allurl2urluc = blob.transcode(BASE64URL, URL, UPPER, 8, req.http.b64allurl); @@ -286,19 +286,19 @@ varnish v1 -vcl { set resp.http.urluc2id = blob.transcode(URL, IDENTITY, length=27, - encoded=req.http.urlhobbesuc); + encoded=req.http.urlhobbesuc); set resp.http.urllc2id = blob.transcode(URL, IDENTITY, length=63, - encoded=req.http.urlhobbeslc); + encoded=req.http.urlhobbeslc); set resp.http.urlalldownuc2b64 = blob.transcode(URL, BASE64, length=18, - encoded=req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64url = blob.transcode(URL, BASE64URL, length=15, - encoded=req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, length=15, @@ -306,11 +306,11 @@ varnish v1 -vcl { set resp.http.urlalldownlc2b64 = blob.transcode(URL, BASE64, length=18, - encoded=req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64url = blob.transcode(URL, BASE64URL, length=15, - encoded=req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, length=15, @@ -318,11 +318,11 @@ varnish v1 -vcl { set resp.http.urlallupuc2b64 = blob.transcode(URL, BASE64, length=36, - encoded=req.http.urlallupuc); + encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64url = blob.transcode(URL, BASE64URL, length=33, - encoded=req.http.urlallupuc); + encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, length=33, @@ -330,11 +330,11 @@ varnish v1 -vcl { set resp.http.urlalluplc2b64 = blob.transcode(URL, BASE64, length=36, - encoded=req.http.urlalluplc); + encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64url = blob.transcode(URL, BASE64URL, length=33, - encoded=req.http.urlalluplc); + encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, length=33, @@ -342,7 +342,7 @@ varnish v1 -vcl { set resp.http.urlalldownuc2url = blob.transcode(URL, URL, length=423, - encoded=req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urluc = blob.transcode(URL, URL, UPPER, 423, req.http.urlalldownuc); @@ -352,7 +352,7 @@ varnish v1 -vcl { set resp.http.urlalldownlc2url = blob.transcode(URL, URL, length=423, - encoded=req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urluc = blob.transcode(URL, URL, UPPER, 423, req.http.urlalldownlc); @@ -427,12 +427,12 @@ varnish v1 -vcl+backend { if (req.url == "/1") { set resp.http.good = blob.transcode(URL, IDENTITY, length=3, - encoded="%2c%q"); + encoded="%2c%q"); } elsif (req.url == "/2") { set resp.http.good = blob.transcode(URL, IDENTITY, length=3, - encoded="%3a%2q"); + encoded="%3a%2q"); } elsif (req.url == "/3") { set resp.http.bad @@ -473,12 +473,12 @@ varnish v1 -vcl+backend { elsif (req.url == "/10") { set resp.http.bad = blob.transcode(URL, IDENTITY, length=1, - encoded="%20"); + encoded="%20"); } elsif (req.url == "/11") { set resp.http.bad = blob.transcode(URL, IDENTITY, length=2, - encoded="%20"); + encoded="%20"); } } } diff --git a/bin/varnishtest/tests/m00044.vtc b/bin/varnishtest/tests/m00044.vtc index e68374a..edad4d4 100644 --- a/bin/varnishtest/tests/m00044.vtc +++ b/bin/varnishtest/tests/m00044.vtc @@ -36,7 +36,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # transcode() converts from one encoding to another. set req.http.Hex-Encoded = blob.transcode(decoding=BASE64, encoding=HEX, case=UPPER, - encoded="YmF6"); + encoded="YmF6"); # transcode() can replace other specific encoding/deconding # vmods - e.g. vmod_urlcode @@ -54,7 +54,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { sub vcl_deliver { set resp.http.Trunced-Foo1 = blob.encode(IDENTITY, blob=blob.decode(HEX, - encoded="666f6f00626172")); + encoded="666f6f00626172")); set resp.http.Trunced-Foo2 = blob.encode(blob=blob.decode(HEX, encoded="666f6f00626172")); } @@ -74,7 +74,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { sub vcl_deliver { set resp.http.encode1 = blob.encode(HEX, blob=blob.decode(BASE64, - encoded="Zm9vYmFyYmF6")); + encoded="Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 diff --git a/bin/varnishtest/tests/m00045.vtc b/bin/varnishtest/tests/m00045.vtc index d82e7f5..345534c 100644 --- a/bin/varnishtest/tests/m00045.vtc +++ b/bin/varnishtest/tests/m00045.vtc @@ -188,10 +188,10 @@ varnish v1 -vcl { = blob.encode(BASE64, blob=blob.sub(down07.get(), 4B)); set resp.http.up04050607 = blob.encode(BASE64, - blob=blob.sub(up07.get(), 4B, 4B)); + blob=blob.sub(up07.get(), 4B, 4B)); set resp.http.down03 = blob.encode(BASE64, - blob=blob.sub(down07.get(), 4B, 4B)); + blob=blob.sub(down07.get(), 4B, 4B)); set resp.http.up07 = blob.encode(BASE64, blob=blob.sub(up07.get(), 8B)); set resp.http.down07 @@ -239,7 +239,7 @@ varnish v1 -vcl+backend { elsif (req.url == "/toolong") { set resp.http.toolong = blob.encode(BASE64, - blob=blob.sub(up07.get(), 9B)); + blob=blob.sub(up07.get(), 9B)); } elsif (req.url == "/badoffset") { set resp.http.badoffset = blob.encode(BASE64, diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 2c4df6d..48e42c3 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -52,9 +52,9 @@ Examples:: # decode() and encode() functions convert blobs to text and # vice versa at runtime. set resp.http.Base64-Encoded - = blob.encode(BASE64, - blob=blob.decode(HEX, - encoded=req.http.Hex-Encoded)); + = blob.encode(BASE64, + blob=blob.decode(HEX, + encoded=req.http.Hex-Encoded)); } sub vcl_recv { @@ -122,7 +122,7 @@ blob. For example:: # The header will be seen as "foo". set resp.http.Trunced-Foo1 = blob.encode(IDENTITY, blob=blob.decode(HEX, - encoded="666f6f00626172")); + encoded="666f6f00626172")); IDENTITY is the default encoding and decoding. So the above can also be written as:: @@ -175,7 +175,7 @@ byte. For example:: set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode(HEX, blob=blob.decode(HEX, - encoded=resp.http.First + resp.http.Second)); + encoded=resp.http.First + resp.http.Second)); URL --- @@ -188,8 +188,8 @@ The ``URL`` encoding implements "percent encoding" as per RFC3986. The affect alphabetic characters that are not percent-encoded. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", INT length=0, - STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", INT length=0, + STRING_LIST encoded) Returns the BLOB derived from the string ``encoded`` according to the scheme specified by ``decoding``. @@ -225,7 +225,7 @@ Example:: set resp.http.encode1 = blob.encode(HEX, - blob=blob.decode(BASE64, encoded="Zm9vYmFyYmF6")); + blob=blob.decode(BASE64, encoded="Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 @@ -260,7 +260,7 @@ defaults to LOWER. Example:: set resp.http.Hex2Base64-1 - = blob.transcode(HEX, BASE64, encoded="666f6f"); + = blob.transcode(HEX, BASE64, encoded="666f6f"); # same with named parameters set resp.http.Hex2Base64-2 From geoff at uplex.de Wed Sep 13 10:11:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 10:11:05 +0000 (UTC) Subject: [master] cf0b9f5 Document -p param changes in Upgrading to 5.2. Message-ID: <20170913101105.40A5D96A15@lists.varnish-cache.org> commit cf0b9f56e95dc950413d4d0f4b361d3359d50330 Author: Geoff Simmons Date: Wed Sep 13 12:09:35 2017 +0200 Document -p param changes in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 2164e32..bf7da09 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -13,11 +13,13 @@ counters, but these should all be transparent at the user-level. varnishd parameters =================== -* *XXX: -p params that are new, modified, deprecated or removed* +The :ref:`ref_param_cli_buffer` parameter is deprecated and +ignored. Memory for the CLI command buffer is now dynamically +allocated. -* *XXX: use rst refs to keep it short* - -* *XXX: ...* +We have updated the documentation for :ref:`ref_param_send_timeout`, +:ref:`ref_param_idle_send_timeout`, :ref:`ref_param_timeout_idle` and +:ref:`ref_param_ban_cutoff`. Changes to VCL ============== From geoff at uplex.de Wed Sep 13 10:20:06 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 10:20:06 +0000 (UTC) Subject: [master] f5fc202 Grammar/phrasing Message-ID: <20170913102006.491EA96E85@lists.varnish-cache.org> commit f5fc202b3dd6b3fccbaff38a131e6cccfb5bb7a9 Author: Geoff Simmons Date: Wed Sep 13 12:19:10 2017 +0200 Grammar/phrasing diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index bf7da09..0151c33 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -61,8 +61,8 @@ vmod_std New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)`, :ref:`vmod_vtc(3)` and -:ref:`whatsnew_new_vmods`. +See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and +:ref:`vmod_vtc(3)`. See :ref:`whatsnew_new_vmods`. Other changes ============= From dridi.boukelmoune at gmail.com Wed Sep 13 10:21:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 10:21:05 +0000 (UTC) Subject: [master] ecdebdc Documentation Message-ID: <20170913102105.6498F96013@lists.varnish-cache.org> commit ecdebdc792942165ba71b58ff6816decb2d89bef Author: Dridi Boukelmoune Date: Wed Sep 13 12:19:29 2017 +0200 Documentation diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 5688246..de73237 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -35,7 +35,11 @@ See :ref:`vmod_blob(3)`. VMOD purge ---------- -*XXX: DRIDI ? about VMOD purge* +Before the introduction of ``vcl 4.0`` there used to be a ``purge`` function +instead of a ``return(purge)`` transition. This module works like old-style +VCL purges (which should be used from both ``vcl_hit`` and ``vcl_miss``) and +provides more capabilities than regular purges, and lets you know how many +objects were affected. See :ref:`vmod_purge(3)`. @@ -53,7 +57,9 @@ pretty evil functionality, for instance ``debug.panic()``. We have split the non-suicidal test-writing stuff from ``vmod_debug`` into a new ``vmod_vtc``, which is included in binary releases from now on, in order to make it easier for people to use ``varnishtest`` -to test local configurations, VMODs etc. +to test local configurations, VMODs etc. The main highlight is that you +can now synchronize barriers with VCL code thanks to ``vmod_vtc``, other +conveniences were added like workspace manipulations. See :ref:`vmod_vtc(3)`. @@ -71,7 +77,21 @@ News for authors of VMODs and Varnish API client applications $ABI [strict|vrt] ----------------- -*XXX: DRIDI ?* +VMOD authors have the option of only integrating with the blessed +interface provided by ``varnishd`` or go deeper in the stack. As +a general rule of thumb you are considered "on your own" if your +VMOD uses more than the VRT (Varnish RunTime) and it is supposed +to be built for the exact Varnish version. + +Varnish was already capable of checking the major/minor VRT version +a VMOD was built against, or require the exact version, but picking +one or the other depended on how Varnish was built. + +VMOD authors can now specify whether a module complies to the VRT +and only needs to be rebuilt when breaking changes are introduced +by adding ``$ABI vrt`` to their VCC descriptor. The default value +is ``$ABI strict`` when omitted, and all VMODs from the standard +Varnish distribution have a strict requirement. VSM/VSC API changes ------------------- @@ -93,7 +113,7 @@ This paves the way for VMODs or maybe even VCL to define custom counters, and have them show up in varnishstat and other VSC-API based programs just like the rest of the counters. -The rewrite of the VSM/VSC code similified both APIs and +The rewrite of the VSM/VSC code simplified both APIs and made them much more robust but code calling into these APIs will have to be updated to match. @@ -112,12 +132,26 @@ Each VSM segment is now a separate piece of shared memory and the name of the segment can be much longer now. Before the actual shared memory can be accessed, the -applicaiton must call VSM_Map() and when VSM_StillValid() +application must call VSM_Map() and when VSM_StillValid() indicates that the segment is no longer valid, VSM_Unmap() should be called to release the segment again. All in all, this should be simpler and more robust now. -*XXX: changes in VRT* +VRT API changes +--------------- + +``VRT_purge`` now fails a transaction instead of panicking when used +outside of ``vcl_hit`` or ``vcl_miss``. It also returns the number +of purged objects. + +New ``http_CollectHdrSep`` function, ``http_*`` symbols and associated +data structures are part of the curated Varnish RunTime. Using them +does not require strict ABI compliance. + +New VUT API +----------- + +XXX: document once merged *EOF* diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 0151c33..4a7bf2f 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -67,6 +67,19 @@ See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and Other changes ============= +* VSL + +The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an additional +field with the remaining TTL of the object at the time of the lookup. +While this should greatly help troubleshooting, this might break tools +relying on those records to get the VXID of the object hit during lookup. + +Instead of using ``Hit``, such tools should now use ``Hit[1]`` instead, +and the same applies to ``HitMiss`` and ``HitPass``. + +The ``Hit`` record also grew two additional fields for the grace and +keep periods. This should again be useful for troubleshooting. + * ``varnishstat(1)``: * *XXX: changes due to new VSC/VSM* @@ -91,10 +104,6 @@ Other changes * *XXX: ...* -* *XXX: changes in VRT that may affect VMOD authors* - - * *XXX: ...* - * *XXX: changes for developers?* * *XXX: such as sanitizer flags?* diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 48e42c3..96dea4e 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -7,6 +7,7 @@ # $Module blob 3 utilities for the VCL blob type +$ABI strict :: diff --git a/lib/libvmod_vtc/vmod.vcc b/lib/libvmod_vtc/vmod.vcc index b57a794..c521f37 100644 --- a/lib/libvmod_vtc/vmod.vcc +++ b/lib/libvmod_vtc/vmod.vcc @@ -26,6 +26,7 @@ # SUCH DAMAGE. $Module vtc 3 Utility module for varnishtest +$ABI strict DESCRIPTION =========== From geoff at uplex.de Wed Sep 13 10:24:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 10:24:05 +0000 (UTC) Subject: [master] 63467b7 Document addition of std.file_exists() in Upgrading to 5.2. Message-ID: <20170913102405.18D8996216@lists.varnish-cache.org> commit 63467b791537f87cbdcc9a74f52051fdd0a98818 Author: Geoff Simmons Date: Wed Sep 13 12:23:29 2017 +0200 Document addition of std.file_exists() in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 4a7bf2f..b8c3388 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -56,7 +56,7 @@ XXX: more VCL changes ... vmod_std ~~~~~~~~ -* *XXX: any changes in VMOD std?* +Added :ref:`func_file_exists`. New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From dridi.boukelmoune at gmail.com Wed Sep 13 10:49:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 10:49:04 +0000 (UTC) Subject: [master] 950c4d4 Wording Message-ID: <20170913104904.9E79E96AC8@lists.varnish-cache.org> commit 950c4d49498ffb77e0989ca4cba7db9ecc2405a2 Author: Dridi Boukelmoune Date: Wed Sep 13 12:47:12 2017 +0200 Wording diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index b8c3388..31d075b 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -74,11 +74,11 @@ field with the remaining TTL of the object at the time of the lookup. While this should greatly help troubleshooting, this might break tools relying on those records to get the VXID of the object hit during lookup. -Instead of using ``Hit``, such tools should now use ``Hit[1]`` instead, -and the same applies to ``HitMiss`` and ``HitPass``. +Instead of using ``Hit``, such tools should now use ``Hit[1]``, and the +same applies to ``HitMiss`` and ``HitPass``. -The ``Hit`` record also grew two additional fields for the grace and -keep periods. This should again be useful for troubleshooting. +The ``Hit`` record also grew two more fields for the grace and keep periods. +This should again be useful for troubleshooting. * ``varnishstat(1)``: From geoff at uplex.de Wed Sep 13 10:49:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 10:49:04 +0000 (UTC) Subject: [master] 8090cc7 Document addition of {be}req.hash to 5.2. Message-ID: <20170913104904.B39FC96ACB@lists.varnish-cache.org> commit 8090cc73003224c7aaf410088ee9511e3de919f9 Author: Geoff Simmons Date: Wed Sep 13 12:48:16 2017 +0200 Document addition of {be}req.hash to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 31d075b..8a789d1 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -40,8 +40,24 @@ XXX: headline changes ... ``req.hash`` and ``bereq.hash`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*XXX: about {be}req.hash, mention data type BLOB, advise about* -*:ref:`vmod_blob(3)`* +Added ``req.hash`` and ``bereq.hash``, which contain the hash value +computed by Varnish for cache lookup in the current transaction, to +be used in client or backend context, respectively. Their data type +is BLOB, and they contain the raw binary hash. + +You can use :ref:`vmod_blob(3)` to work with the hashes:: + + import blob; + + sub vcl_backend_fetch { + # Send the transaction hash to the backend as a hex string + set bereq.http.Hash = blob.encode(HEX, blob=bereq.hash); + } + + sub vcl_deliver { + # Send the hash in a response header as a base64 string + set resp.http.Hash = blob.encode(BASE64, blob=req.hash); + } XXX: vcl_sub_XXX ... ~~~~~~~~~~~~~~~~~~~~ From geoff at uplex.de Wed Sep 13 11:36:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 11:36:05 +0000 (UTC) Subject: [master] 7e68fee Summarize changes for devs in 5.2. Message-ID: <20170913113605.5075596BCA@lists.varnish-cache.org> commit 7e68fee0ee0c10e9ce3a13627c1c9ea39be98994 Author: Geoff Simmons Date: Wed Sep 13 13:35:11 2017 +0200 Summarize changes for devs in 5.2. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index de73237..7dced4d 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -73,6 +73,7 @@ News for authors of VMODs and Varnish API client applications *XXX: such news may include:* +.. _whatsnew_abi: $ABI [strict|vrt] ----------------- @@ -93,6 +94,8 @@ by adding ``$ABI vrt`` to their VCC descriptor. The default value is ``$ABI strict`` when omitted, and all VMODs from the standard Varnish distribution have a strict requirement. +.. _whatsnew_vsm_vsc_5.2: + VSM/VSC API changes ------------------- @@ -138,6 +141,8 @@ should be called to release the segment again. All in all, this should be simpler and more robust now. +.. _whatsnew_vrt_5.2: + VRT API changes --------------- @@ -149,6 +154,8 @@ New ``http_CollectHdrSep`` function, ``http_*`` symbols and associated data structures are part of the curated Varnish RunTime. Using them does not require strict ABI compliance. +.. _whatsnew_vut_5.2: + New VUT API ----------- diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8a789d1..53291e4 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -120,9 +120,23 @@ This should again be useful for troubleshooting. * *XXX: ...* -* *XXX: changes for developers?* +* Changes for developers: - * *XXX: such as sanitizer flags?* + * The VSM and VSC APIs for shared memory and statistics have + changed, and may necessitate changes in client applications, see + :ref:`whatsnew_vsm_vsc_5.2`. + + * Added the ``$ABI`` directive for VMOD vcc declarations, see + :ref:`whatsnew_abi`. + + * There have been some minor changes in the VRT API, which may be + used for VMODs and client apps, see :ref:`whatsnew_vrt_5.2`. + + * The VUT API (for Varnish UTilities), which facilitates the + development of client apps, is now publicly available, see + :ref:`whatsnew_vut_5.2`. + + * *XXX: anything else, such as sanitizer flags?* * *XXX: ...* From geoff at uplex.de Wed Sep 13 11:47:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 11:47:05 +0000 (UTC) Subject: [master] d1ac4b2 Editorial: move docs about changes in VSL Hit* output to the section about varnishlog(1). Message-ID: <20170913114705.0DEF596085@lists.varnish-cache.org> commit d1ac4b2677044f2c87b41f48938c8de43475600d Author: Geoff Simmons Date: Wed Sep 13 13:44:38 2017 +0200 Editorial: move docs about changes in VSL Hit* output to the section about varnishlog(1). diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 53291e4..3aee8c2 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -83,19 +83,6 @@ See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and Other changes ============= -* VSL - -The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an additional -field with the remaining TTL of the object at the time of the lookup. -While this should greatly help troubleshooting, this might break tools -relying on those records to get the VXID of the object hit during lookup. - -Instead of using ``Hit``, such tools should now use ``Hit[1]``, and the -same applies to ``HitMiss`` and ``HitPass``. - -The ``Hit`` record also grew two more fields for the grace and keep periods. -This should again be useful for troubleshooting. - * ``varnishstat(1)``: * *XXX: changes due to new VSC/VSM* @@ -104,6 +91,20 @@ This should again be useful for troubleshooting. * ``varnishlog(1)``: + * The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an + additional field with the remaining TTL of the object at the time + of the lookup. While this should greatly help troubleshooting, + this might break tools relying on those records to get the VXID of + the object hit during lookup. + + Instead of using ``Hit``, such tools should now use ``Hit[1]``, + and the same applies to ``HitMiss`` and ``HitPass``. + + The ``Hit`` record also grew two more fields for the grace and + keep periods. This should again be useful for troubleshooting. + + See :ref:`vsl(7)`. + * *XXX: changes due to new VSC/VSM* * *XXX: ...* From geoff at uplex.de Wed Sep 13 12:05:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 12:05:05 +0000 (UTC) Subject: [master] db424c0 Document the addition of debug:vmod_so_keep to 5.2. Message-ID: <20170913120506.07CAA966E2@lists.varnish-cache.org> commit db424c0c1f5670ccd1b6a535d6c97585055dd713 Author: Geoff Simmons Date: Wed Sep 13 14:04:26 2017 +0200 Document the addition of debug:vmod_so_keep to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 3aee8c2..6e2a489 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -21,6 +21,9 @@ We have updated the documentation for :ref:`ref_param_send_timeout`, :ref:`ref_param_idle_send_timeout`, :ref:`ref_param_timeout_idle` and :ref:`ref_param_ban_cutoff`. +Added the debug bit ``vmod_so_keep``, see :ref:`ref_param_debug` and +the notes about changes for developers below. + Changes to VCL ============== @@ -137,6 +140,11 @@ Other changes development of client apps, is now publicly available, see :ref:`whatsnew_vut_5.2`. + * The debug bit ``vmod_so_keep`` instructs Varnish not to clean + up its copies of VMOD shared objects when it stops. This makes + it possible for VMOD authors to load their code into a debugger + after a varnishd crash. See :ref:`ref_param_debug`. + * *XXX: anything else, such as sanitizer flags?* * *XXX: ...* From geoff at uplex.de Wed Sep 13 12:18:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 12:18:05 +0000 (UTC) Subject: [master] 615b4d4 Document the "vmod_so_keep" effect of varnishtest -L/-l in 5.2. Message-ID: <20170913121805.61B6996BEF@lists.varnish-cache.org> commit 615b4d4e3b2e4f3542f2ad987df6deaba2aef5d1 Author: Geoff Simmons Date: Wed Sep 13 14:16:48 2017 +0200 Document the "vmod_so_keep" effect of varnishtest -L/-l in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 6e2a489..d9327c5 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -114,9 +114,12 @@ Other changes * ``varnishtest(1)`` and ``vtc(7)``: - * *XXX: changes in test code* + * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* - * *XXX: for example due to VMOD vtc* + * When varnishtest is invoked with ``-L`` or ``-l``, Varnish + instances started by a test do not clean up their copies of VMOD + shared objects when they stop. See the note about ``vmod_so_keep`` + below. * *XXX: ...* From geoff at uplex.de Wed Sep 13 12:36:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 12:36:04 +0000 (UTC) Subject: [master] be7d622 Document the "Not Running" output of varnishstat in 5.2. Message-ID: <20170913123604.659099629F@lists.varnish-cache.org> commit be7d622b5ace8c77c24436c755c204c316dc9a90 Author: Geoff Simmons Date: Wed Sep 13 14:35:06 2017 +0200 Document the "Not Running" output of varnishstat in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index d9327c5..6bb9e9a 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -88,9 +88,11 @@ Other changes * ``varnishstat(1)``: - * *XXX: changes due to new VSC/VSM* + * In curses mode, the top two lines showing uptimes for the + management and child processes show the text ``Not Running`` if + either or both of the processes are down. - * *XXX: ...* + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: @@ -108,10 +110,6 @@ Other changes See :ref:`vsl(7)`. - * *XXX: changes due to new VSC/VSM* - - * *XXX: ...* - * ``varnishtest(1)`` and ``vtc(7)``: * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* From phk at FreeBSD.org Wed Sep 13 12:39:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Sep 2017 12:39:05 +0000 (UTC) Subject: [master] 5c376cb There is a race between the call to VSM_Status() and VSM_Map() where the shared memory segment could have gone away, simply ignore the segment in that case. Message-ID: <20170913123905.0555D96568@lists.varnish-cache.org> commit 5c376cb9aa091c421c4426938ca2d7784be7b98c Author: Poul-Henning Kamp Date: Wed Sep 13 12:36:32 2017 +0000 There is a race between the call to VSM_Status() and VSM_Map() where the shared memory segment could have gone away, simply ignore the segment in that case. Fixes #2411 diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 8ca2572..155c675 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -327,7 +327,15 @@ vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp) ALLOC_OBJ(sp, VSC_SEG_MAGIC); AN(sp); *sp->fantom = *fp; - AZ(VSM_Map(vsm, sp->fantom)); + if (VSM_Map(vsm, sp->fantom)) { + /* + * If the seg was removed between our call to VSM_Status() + * and now, we won't be able to map it. + */ + FREE_OBJ(sp); + return (NULL); + } + // AZ(VSM_Map(vsm, sp->fantom)); u = vbe64dec(sp->fantom->b); if (u == 0) { @@ -407,10 +415,12 @@ VSC_Iter(struct vsc *vsc, struct vsm *vsm, VSC_iter_f *fiter, void *priv) sp = VTAILQ_NEXT(sp, list); } else { sp = vsc_add_seg(vsc, vsm, &ifantom); - VTAILQ_INSERT_TAIL(&vsc->segs, sp, list); - if (fiter != NULL) - i = vsc_iter_seg(vsc, sp, fiter, priv); - sp = NULL; + if (sp != NULL) { + VTAILQ_INSERT_TAIL(&vsc->segs, sp, list); + if (fiter != NULL) + i = vsc_iter_seg(vsc, sp, fiter, priv); + sp = NULL; + } } if (i) break; From geoff at uplex.de Wed Sep 13 12:46:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 12:46:04 +0000 (UTC) Subject: [master] 70349b9 Document the demise of the -N option for the VSL tools in 5.2. Message-ID: <20170913124604.B1E10968D6@lists.varnish-cache.org> commit 70349b9c0221f1c7124372e98313dafdac1fce7b Author: Geoff Simmons Date: Wed Sep 13 14:45:18 2017 +0200 Document the demise of the -N option for the VSL tools in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 6bb9e9a..53573d7 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -121,6 +121,11 @@ Other changes * *XXX: ...* +* The ``-N`` command-line option, which was previously availabe for + ``varnishlog(1)``, ``varnishstat(1)``, ``varnishncsa(1)`` and + ``varnishhist(1)``, is not comaptible with the changed internal + logging API, and has been retired. + * *XXX: any other changes in the standard VUT tools* * *XXX: ...* From geoff at uplex.de Wed Sep 13 12:50:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 12:50:05 +0000 (UTC) Subject: [master] a8be5e9 Mention the changed interpretation of varnishstat -f in 5.2. Message-ID: <20170913125005.B9C6F96BAD@lists.varnish-cache.org> commit a8be5e9a6b17e2a465288b5af740240e9cfa9e4b Author: Geoff Simmons Date: Wed Sep 13 14:49:13 2017 +0200 Mention the changed interpretation of varnishstat -f in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 53573d7..05e6790 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -92,6 +92,9 @@ Other changes management and child processes show the text ``Not Running`` if either or both of the processes are down. + * The interpretation of multiple ``-f`` options in the command line + has changed slightly, see :ref:`varnishstat(1)`. + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: From geoff at uplex.de Wed Sep 13 13:28:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 13:28:04 +0000 (UTC) Subject: [master] 3eca6d2 Document the changed default for server.identity in 5.2. Message-ID: <20170913132804.D7FAC9689F@lists.varnish-cache.org> commit 3eca6d2a8eb5514d86668702dd98212d086ac99b Author: Geoff Simmons Date: Wed Sep 13 15:27:10 2017 +0200 Document the changed default for server.identity in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 05e6790..5e3552a 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -62,6 +62,15 @@ You can use :ref:`vmod_blob(3)` to work with the hashes:: set resp.http.Hash = blob.encode(BASE64, blob=req.hash); } +``server.identity`` +~~~~~~~~~~~~~~~~~~~ + +If the ``-i`` option is not set in the invocation of ``varnishd``, +then ``server.identity`` is set to the host name (as returned by +``gethostname(3)``). Previously, ``server.identity`` was set to the +value of the ``-n`` option (or the default instance name if ``-n`` was +not set). See :ref:`varnishd(1)`. + XXX: vcl_sub_XXX ... ~~~~~~~~~~~~~~~~~~~~ From geoff at uplex.de Wed Sep 13 14:09:03 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 14:09:03 +0000 (UTC) Subject: [master] 4e4424a Document changes around the varnishd -i option in 5.2. Message-ID: <20170913140903.EC0BC96794@lists.varnish-cache.org> commit 4e4424a96e4e68f1f2fa999f4b50bfd7b2fd068a Author: Geoff Simmons Date: Wed Sep 13 16:08:26 2017 +0200 Document changes around the varnishd -i option in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 5e3552a..869906c 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -95,6 +95,22 @@ See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and Other changes ============= +* ``varnishd(1)``: + + * The default value of ``server.identity`` when the ``-i`` option is + not set has been changed as noted above. + + * Also, ``-i`` no longer determines the ``ident`` field used by + ``syslog(3)``; now Varnish is always identified by the string + ``varnishd`` in the syslog. + + * On a system that supports ``setproctitle(3)``, the Varnish + management process will appear in the output of ``ps(1)`` as + ``Varnish-Mgr``, and the child process as ``Varnish-Child``. If + the ``-i`` option has been set, then these strings in the ps + output are followed by ``-i`` and the identity string set by the + option. + * ``varnishstat(1)``: * In curses mode, the top two lines showing uptimes for the From geoff at uplex.de Wed Sep 13 14:28:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 14:28:05 +0000 (UTC) Subject: [master] b896be2 Document use of vcl_path if varnishd -f is relative in Upgrading to 5.2. Message-ID: <20170913142805.404C397DCB@lists.varnish-cache.org> commit b896be2d29796fda4fc76fc1d2b2ff403bbc308f Author: Geoff Simmons Date: Wed Sep 13 16:27:13 2017 +0200 Document use of vcl_path if varnishd -f is relative in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 869906c..6c977bd 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -111,6 +111,10 @@ Other changes output are followed by ``-i`` and the identity string set by the option. + * The ``-f`` option for a VCL source file now honors the + ``vcl_path`` parameter if a relative file name is used, see + :ref:`varnishd(1)` and :ref:`ref_param_vcl_path`. + * ``varnishstat(1)``: * In curses mode, the top two lines showing uptimes for the From geoff at uplex.de Wed Sep 13 14:35:07 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 14:35:07 +0000 (UTC) Subject: [master] ef7e033 Note the clarification of bans with unset fields in Upgrading to 5.2. Message-ID: <20170913143507.547BC96169@lists.varnish-cache.org> commit ef7e03344acceabc986809e124f1cacfc1b9e51d Author: Geoff Simmons Date: Wed Sep 13 16:34:09 2017 +0200 Note the clarification of bans with unset fields in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 6c977bd..3a16ce0 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -92,6 +92,13 @@ New VMODs in the standard distribution See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and :ref:`vmod_vtc(3)`. See :ref:`whatsnew_new_vmods`. +Bans +~~~~ + +We have clarified the interpretation of a ban when a comparison in the +ban expression is attempted against an unset field, see +:ref:`vcl(7)_ban` in :ref:`vcl(7)`. + Other changes ============= From phk at FreeBSD.org Wed Sep 13 14:40:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Sep 2017 14:40:07 +0000 (UTC) Subject: [master] ab512a9 Consistently use "mgt" Message-ID: <20170913144007.7776B96426@lists.varnish-cache.org> commit ab512a907bbe35eea6c73d885f0b752f3d692da9 Author: Poul-Henning Kamp Date: Wed Sep 13 14:39:32 2017 +0000 Consistently use "mgt" Spottes by: dridi diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index ebcaba5..b3b8856 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -308,13 +308,13 @@ mgt_launch_child(struct cli *cli) child_state = CH_STARTING; - /* Open pipe for mgr->child CLI */ + /* Open pipe for mgt->child CLI */ AZ(pipe(cp)); heritage.cli_in = cp[0]; MCH_Fd_Inherit(heritage.cli_in, "cli_in"); child_cli_out = cp[1]; - /* Open pipe for child->mgr CLI */ + /* Open pipe for child->mgt CLI */ AZ(pipe(cp)); heritage.cli_out = cp[1]; MCH_Fd_Inherit(heritage.cli_out, "cli_out"); diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index 4d4c56d..f9c0157 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -46,7 +46,7 @@ #include #endif -static gid_t vju_mgr_gid; +static gid_t vju_mgt_gid; static uid_t vju_uid; static gid_t vju_gid; static const char *vju_user; @@ -166,7 +166,7 @@ vju_init(char **args) AN(vju_user); - vju_mgr_gid = getgid(); + vju_mgt_gid = getgid(); if (vju_wrkuser == NULL && vju_getwrkuid(VCACHE_USER)) { vju_wrkuid = vju_uid; @@ -191,7 +191,7 @@ vju_master(enum jail_master_e jme) AZ(seteuid(vju_uid)); } else { AZ(seteuid(0)); - AZ(setegid(vju_mgr_gid)); + AZ(setegid(vju_mgt_gid)); } } diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 8a5f918..2b341f4 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -758,7 +758,7 @@ main(int argc, char * const *argv) i_arg = mgt_HostName(); heritage.identity = i_arg; - mgt_ProcTitle("Mgr"); + mgt_ProcTitle("Mgt"); openlog("varnishd", LOG_PID, LOG_LOCAL0); From phk at FreeBSD.org Wed Sep 13 14:44:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Sep 2017 14:44:04 +0000 (UTC) Subject: [master] e94b974 s/mgr/mgt/ for consistency Message-ID: <20170913144404.5D899966C3@lists.varnish-cache.org> commit e94b9740c146110cfc4ebbf57a7b81fc0de2a6bc Author: Poul-Henning Kamp Date: Wed Sep 13 14:43:33 2017 +0000 s/mgr/mgt/ for consistency diff --git a/doc/sphinx/phk/barriers.rst b/doc/sphinx/phk/barriers.rst index e85e81a..f9ba31b 100644 --- a/doc/sphinx/phk/barriers.rst +++ b/doc/sphinx/phk/barriers.rst @@ -22,7 +22,7 @@ barriers between the various components:: | | | | |runs | | | | .-<- create -<-. | .->- fork ->-. v | - v |->- check -->-|-- MGR --| |-- VCC <- loads -| + v |->- check -->-|-- MGT --| |-- VCC <- loads -| VSM |-<- write --<-' | '-<- wait -<-' | | TOOLS | | | | ^ | .-------------' | | @@ -48,7 +48,7 @@ barriers between the various components:: The really Important Barrier ============================ -The central actor in Varnish is the Manager process, "MGR", which is the +The central actor in Varnish is the Manager process, "MGT", which is the process the administrator "(ADMIN)" starts to get web-cache service. Having been there myself, I do not subscribe to the "I feel cool and important diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 3a16ce0..8d837f9 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -113,7 +113,7 @@ Other changes * On a system that supports ``setproctitle(3)``, the Varnish management process will appear in the output of ``ps(1)`` as - ``Varnish-Mgr``, and the child process as ``Varnish-Child``. If + ``Varnish-Mgt``, and the child process as ``Varnish-Child``. If the ``-i`` option has been set, then these strings in the ps output are followed by ``-i`` and the identity string set by the option. diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 79f9a02..5a5ffbb 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -184,7 +184,7 @@ struct vcc { int hindent; unsigned cnt; - struct vsb *fi; /* VCC info to MGR */ + struct vsb *fi; /* VCC info to MGT */ struct vsb *fc; /* C-code */ struct vsb *fh; /* H-code (before C-code) */ struct vsb *fb; /* Body of current sub From geoff at uplex.de Wed Sep 13 14:50:09 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 14:50:09 +0000 (UTC) Subject: [master] 1adddf7 Add a section about VCL token parsing in Upgrading to 5.2, currently TBD. Message-ID: <20170913145009.AC23B96A49@lists.varnish-cache.org> commit 1adddf739814f11de49916879e5cde4bd0945e22 Author: Geoff Simmons Date: Wed Sep 13 16:48:32 2017 +0200 Add a section about VCL token parsing in Upgrading to 5.2, currently TBD. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8d837f9..ad0b3d7 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -40,6 +40,11 @@ XXX: headline changes ... *XXX: the most important changes or additions first* +Stricter checking of VCL symbol names +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: TBD by DB* + ``req.hash`` and ``bereq.hash`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From geoff at uplex.de Wed Sep 13 14:57:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 14:57:04 +0000 (UTC) Subject: [master] 408a56b Document addition of vtc feature ignore_unknown_macro to 5.2. Message-ID: <20170913145704.91EF596E2D@lists.varnish-cache.org> commit 408a56bde081c974276acd9af27fc16b36cc45d0 Author: Geoff Simmons Date: Wed Sep 13 16:56:14 2017 +0200 Document addition of vtc feature ignore_unknown_macro to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index ad0b3d7..73d1a3c 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -163,6 +163,9 @@ Other changes shared objects when they stop. See the note about ``vmod_so_keep`` below. + * Added the feature switch ``ignore_unknown_macro`` for test cases, + see :ref:`vtc(7)`. + * *XXX: ...* * The ``-N`` command-line option, which was previously availabe for From geoff at uplex.de Wed Sep 13 15:31:06 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 15:31:06 +0000 (UTC) Subject: [master] b9c3f3d Mention the field specifier limit in varnishncsa in Upgrading to 5.2. Message-ID: <20170913153106.199BC96276@lists.varnish-cache.org> commit b9c3f3d601d376d3b91f4a3e4ae06a1ab88238fe Author: Geoff Simmons Date: Wed Sep 13 17:29:56 2017 +0200 Mention the field specifier limit in varnishncsa in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 73d1a3c..850573c 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -168,6 +168,11 @@ Other changes * *XXX: ...* +* ``varnishncsa(1)`` + + * Field specifiers (such as the 1 in ``Hit[1]``) are now limited to + to 255, see :ref:`varnishncsa(1)`. + * The ``-N`` command-line option, which was previously availabe for ``varnishlog(1)``, ``varnishstat(1)``, ``varnishncsa(1)`` and ``varnishhist(1)``, is not comaptible with the changed internal From geoff at uplex.de Wed Sep 13 15:35:06 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 15:35:06 +0000 (UTC) Subject: [master] f6281c8 Mention removal of type and ident from varnishstat output in Upgrading to 5.2. Message-ID: <20170913153506.35D0496591@lists.varnish-cache.org> commit f6281c87d7ba8af646435cfcc50303391e05304f Author: Geoff Simmons Date: Wed Sep 13 17:33:55 2017 +0200 Mention removal of type and ident from varnishstat output in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 850573c..03f4f2e 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -136,6 +136,9 @@ Other changes * The interpretation of multiple ``-f`` options in the command line has changed slightly, see :ref:`varnishstat(1)`. + * The ``type`` and ``ident`` fields have been removed from the XML + and JSON output formats, see :ref:`varnishstat(1)`. + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: From geoff at uplex.de Wed Sep 13 15:39:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 15:39:04 +0000 (UTC) Subject: [master] 17b36d5 Document removal of the s_req counter in 5.2. Message-ID: <20170913153904.D98F9968A2@lists.varnish-cache.org> commit 17b36d51a609fbe843c7644ec925bf02b6a8dbc4 Author: Geoff Simmons Date: Wed Sep 13 17:37:59 2017 +0200 Document removal of the s_req counter in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 03f4f2e..56c925b 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -139,6 +139,9 @@ Other changes * The ``type`` and ``ident`` fields have been removed from the XML and JSON output formats, see :ref:`varnishstat(1)`. + * The ``MAIN.s_req`` statistic has been removed, as it was identical + to ``MAIN.client_req``. + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: From dridi.boukelmoune at gmail.com Wed Sep 13 15:43:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 15:43:04 +0000 (UTC) Subject: [master] 8204df1 Documentation Message-ID: <20170913154304.AA18B96BF6@lists.varnish-cache.org> commit 8204df120f60b2e9d0309284196f6cfde6c377ce Author: Dridi Boukelmoune Date: Wed Sep 13 17:40:27 2017 +0200 Documentation diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 56c925b..00abba5 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -40,10 +40,37 @@ XXX: headline changes ... *XXX: the most important changes or additions first* -Stricter checking of VCL symbol names -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consistent symbol names +~~~~~~~~~~~~~~~~~~~~~~~ + +VCL symbols originate from various parts of Varnish: there are built-in +variables, subroutines, functions, and the free-form headers. Symbols +may live in a namespace denoted by the ``'.'`` (dot) character as in +``req.http.Cache-Control``. When you create a VCL label, a new symbol +becomes available, named after the label. Storage backends always have +a name, even if you don't specify one, and they can also be accessed in +VCL: for example ``storage.Transient``. + +Because headers and VCL names could contain dashes, while subroutines or +VMOD objects couldn't, this created an inconsistency. All symbols follow +the same rules now and must follow the same (case-insensitive) pattern: +``[a-z][a-z0-9_-]*``. + +You can now write code like:: + + sub my-sub { + new my-obj = my_vmod.my_constuctor(storage.my-store); + } + + sub vcl_init { + call my-sub; + } + +As you may notice in the example above, it is not possible yet to have +dashes in a vmod symbol. -*XXX: TBD by DB* +Long storage backend names used to be truncated due to a limitation in +the VSC subsystem, this is no longer the case. ``req.hash`` and ``bereq.hash`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -127,6 +154,10 @@ Other changes ``vcl_path`` parameter if a relative file name is used, see :ref:`varnishd(1)` and :ref:`ref_param_vcl_path`. + * The ``-a`` option can now take a name, otherwise a default one + is selected to name the listen address. It may become accessible + in VCL in the future. + * ``varnishstat(1)``: * In curses mode, the top two lines showing uptimes for the @@ -160,6 +191,11 @@ Other changes See :ref:`vsl(7)`. + * The ``SessOpen`` log record displays the name of the listen address + instead of the endpoint in its 3rd field. + + See :ref:`vsl(7)`. + * ``varnishtest(1)`` and ``vtc(7)``: * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* From geoff at uplex.de Wed Sep 13 15:51:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 15:51:04 +0000 (UTC) Subject: [master] fc137b0 Mention the addition of bereq.is_bgfetch in Upgrading to 5.2. Message-ID: <20170913155104.9595897030@lists.varnish-cache.org> commit fc137b0cea89d77d3a71c38181e7fdfb57897559 Author: Geoff Simmons Date: Wed Sep 13 17:49:19 2017 +0200 Mention the addition of bereq.is_bgfetch in Upgrading to 5.2. Since we seem to have a number of new VCL variables, there is now a section heading for that in Upgrading. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 00abba5..ee281eb 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -72,8 +72,11 @@ dashes in a vmod symbol. Long storage backend names used to be truncated due to a limitation in the VSC subsystem, this is no longer the case. +New VCL variables +~~~~~~~~~~~~~~~~~ + ``req.hash`` and ``bereq.hash`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------- Added ``req.hash`` and ``bereq.hash``, which contain the hash value computed by Varnish for cache lookup in the current transaction, to @@ -95,7 +98,7 @@ You can use :ref:`vmod_blob(3)` to work with the hashes:: } ``server.identity`` -~~~~~~~~~~~~~~~~~~~ +------------------- If the ``-i`` option is not set in the invocation of ``varnishd``, then ``server.identity`` is set to the host name (as returned by @@ -103,6 +106,16 @@ then ``server.identity`` is set to the host name (as returned by value of the ``-n`` option (or the default instance name if ``-n`` was not set). See :ref:`varnishd(1)`. +``bereq.is_bgfetch`` +-------------------- + +``bereq.is_bgfetch`` is readable in backend contexts, and is true if +the fetch takes place in the background. That is, it is true if +Varnish found a response in the cache whose TTL was expired, but was +still in grace time. Varnish returns the stale cached response to the +client, and initiates the background fetch to refresh the cache +object. + XXX: vcl_sub_XXX ... ~~~~~~~~~~~~~~~~~~~~ From geoff at uplex.de Wed Sep 13 16:02:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 16:02:04 +0000 (UTC) Subject: [master] a1ac5e7 Document the addition of named listen addresses to 5.2. Message-ID: <20170913160204.C22C297469@lists.varnish-cache.org> commit a1ac5e7e4e014b12b11cde584a55abee0d5f8ec1 Author: Geoff Simmons Date: Wed Sep 13 18:01:16 2017 +0200 Document the addition of named listen addresses to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index ee281eb..2166340 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -149,6 +149,14 @@ Other changes * ``varnishd(1)``: + * Listen addresses specified with ``-a`` may now be given a name on + the command line, for example ``-a admin=127.0.0.1:88`` to + identify an address used for administrative requests but not + regular client traffic. If you don't specify a name, then ``a0``, + ``a1`` and so forth are used. The endpoint names are used in the + log output, for example with the ``SessOpen`` tag. See + :ref:`varnishd(1)`. + * The default value of ``server.identity`` when the ``-i`` option is not set has been changed as noted above. From dridi.boukelmoune at gmail.com Wed Sep 13 16:04:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 16:04:05 +0000 (UTC) Subject: [master] 33adc6b s/vcs/vsc/ Message-ID: <20170913160405.5DE8B9764E@lists.varnish-cache.org> commit 33adc6b07f7c78f9465cfd2f5967237684e1c86e Author: Dridi Boukelmoune Date: Wed Sep 13 18:01:58 2017 +0200 s/vcs/vsc/ Too many acronyms... diff --git a/varnish.m4 b/varnish.m4 index 8d4a486..b56d2fc 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -85,7 +85,7 @@ AC_DEFUN([_VARNISH_PKG_CONFIG], [ PKG_CHECK_VAR([VARNISHAPI_VMODDIR], [varnishapi], [vmoddir]) PKG_CHECK_VAR([VMODTOOL], [varnishapi], [vmodtool]) - PKG_CHECK_VAR([VCSTOOL], [varnishapi], [vcstool]) + PKG_CHECK_VAR([VSCTOOL], [varnishapi], [vsctool]) AC_SUBST([VARNISH_LIBRARY_PATH], [$VARNISHAPI_LIBDIR:$VARNISHAPI_LIBDIR/varnish]) @@ -386,7 +386,7 @@ AC_DEFUN([VARNISH_VMODS], [ # - pkgvcldir added # # Since Varnish 5.2.0: -# - VCSTOOL added +# - VSCTOOL added # # Verify that the version of Varnish Cache found by pkg-config is at least # MINIMUM-VERSION. If MAXIMUM-VERSION is specified, verify that the version @@ -412,7 +412,7 @@ AC_DEFUN([VARNISH_VMODS], [ # - VARNISHAPI_VCLDIR # - VARNISHAPI_VMODDIR # - VMODTOOL -# - VCSTOOL +# - VSCTOOL # # In addition, two directories are set up for installation in automake: # diff --git a/varnishapi.pc.in b/varnishapi.pc.in index b9c638b..6441952 100644 --- a/varnishapi.pc.in +++ b/varnishapi.pc.in @@ -13,7 +13,7 @@ pkgdatadir=${datadir}/@PACKAGE@ vcldir=${pkgdatadir}/vcl vmoddir=${libdir}/@PACKAGE@/vmods vmodtool=${pkgdatadir}/vmodtool.py -vcstool=${pkgdatadir}/vcstool.py +vsctool=${pkgdatadir}/vsctool.py Name: VarnishAPI Description: Varnish API From geoff at uplex.de Wed Sep 13 16:12:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 16:12:05 +0000 (UTC) Subject: [master] b352dbd Revert "Document the addition of named listen addresses to 5.2." Message-ID: <20170913161205.7C0CD9797E@lists.varnish-cache.org> commit b352dbd1ba83a92090268e35d0558842668fd328 Author: Geoff Simmons Date: Wed Sep 13 18:06:32 2017 +0200 Revert "Document the addition of named listen addresses to 5.2." This reverts commit a1ac5e7e4e014b12b11cde584a55abee0d5f8ec1. Redundant diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 2166340..ee281eb 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -149,14 +149,6 @@ Other changes * ``varnishd(1)``: - * Listen addresses specified with ``-a`` may now be given a name on - the command line, for example ``-a admin=127.0.0.1:88`` to - identify an address used for administrative requests but not - regular client traffic. If you don't specify a name, then ``a0``, - ``a1`` and so forth are used. The endpoint names are used in the - log output, for example with the ``SessOpen`` tag. See - :ref:`varnishd(1)`. - * The default value of ``server.identity`` when the ``-i`` option is not set has been changed as noted above. From geoff at uplex.de Wed Sep 13 16:12:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Wed, 13 Sep 2017 16:12:05 +0000 (UTC) Subject: [master] e3551ee Elaborate a bit on the addition of named -a addresses in 5.2. Message-ID: <20170913161205.9691597982@lists.varnish-cache.org> commit e3551ee3492f3f90534c28e96ce1982b4fa0728d Author: Geoff Simmons Date: Wed Sep 13 18:11:20 2017 +0200 Elaborate a bit on the addition of named -a addresses in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index ee281eb..c932fca 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -167,9 +167,12 @@ Other changes ``vcl_path`` parameter if a relative file name is used, see :ref:`varnishd(1)` and :ref:`ref_param_vcl_path`. - * The ``-a`` option can now take a name, otherwise a default one - is selected to name the listen address. It may become accessible - in VCL in the future. + * The ``-a`` option can now take a name, for example ``-a + admin=127.0.0.1:88`` to identify an address used for + administrative requests but not regular client traffic. Otherwise, + a default name is selected for the listen address (``a0``, ``a1`` + and so forth). Endpoint names appear in the log output, as noted + below, and may become accessible in VCL in the future. * ``varnishstat(1)``: From dridi.boukelmoune at gmail.com Wed Sep 13 16:26:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 16:26:05 +0000 (UTC) Subject: [master] ffdf340 Use the corect directory Message-ID: <20170913162605.2F41097FA6@lists.varnish-cache.org> commit ffdf3400e8f1668a44ca507df8899ee6c8f19e5f Author: Dridi Boukelmoune Date: Wed Sep 13 18:24:17 2017 +0200 Use the corect directory diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 55409d7..19217df 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -217,7 +217,7 @@ BUILT_SOURCES = vhp_hufdec.h DISTCLEANFILES += vhp_hufdec.h ####################################################################### -VSC_main.c VSC_main.h: $(srcdir)/main.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_main.c VSC_main.h: $(srcdir)/main.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/main.vsc $(varnishd_OBJECTS): VSC_main.h @@ -229,7 +229,7 @@ nodist_varnishd_SOURCES += VSC_main.c ####################################################################### -VSC_lck.c VSC_lck.h: $(srcdir)/lck.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_lck.c VSC_lck.h: $(srcdir)/lck.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/lck.vsc $(varnishd_OBJECTS): VSC_lck.h @@ -241,7 +241,7 @@ nodist_varnishd_SOURCES += VSC_lck.c ####################################################################### -VSC_vbe.c VSC_vbe.h: $(srcdir)/vbe.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_vbe.c VSC_vbe.h: $(srcdir)/vbe.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/vbe.vsc $(varnishd_OBJECTS): VSC_vbe.h @@ -253,7 +253,7 @@ nodist_varnishd_SOURCES += VSC_vbe.c ####################################################################### -VSC_sma.c VSC_sma.h: $(srcdir)/sma.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_sma.c VSC_sma.h: $(srcdir)/sma.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/sma.vsc $(varnishd_OBJECTS): VSC_sma.h @@ -265,7 +265,7 @@ nodist_varnishd_SOURCES += VSC_sma.c ####################################################################### -VSC_smf.c VSC_smf.h: $(srcdir)/smf.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_smf.c VSC_smf.h: $(srcdir)/smf.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/smf.vsc $(varnishd_OBJECTS): VSC_smf.h @@ -277,7 +277,7 @@ nodist_varnishd_SOURCES += VSC_smf.c ####################################################################### -VSC_mempool.c VSC_mempool.h: $(srcdir)/mempool.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_mempool.c VSC_mempool.h: $(srcdir)/mempool.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/mempool.vsc $(varnishd_OBJECTS): VSC_mempool.h @@ -289,7 +289,7 @@ nodist_varnishd_SOURCES += VSC_mempool.c ####################################################################### -VSC_mgt.c VSC_mgt.h: $(srcdir)/mgt.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_mgt.c VSC_mgt.h: $(srcdir)/mgt.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/mgt.vsc $(varnishd_OBJECTS): VSC_mgt.h From dridi.boukelmoune at gmail.com Wed Sep 13 16:43:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 16:43:04 +0000 (UTC) Subject: [master] 20c4b99 Install common/common_vsm.h Message-ID: <20170913164304.928D297559@lists.varnish-cache.org> commit 20c4b99f6c96ae541a9e76d73901f59c1e024c58 Author: Dridi Boukelmoune Date: Wed Sep 13 18:40:36 2017 +0200 Install common/common_vsm.h We need it to build out-of-tree VSCs. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 19217df..0abe151 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -120,7 +120,6 @@ noinst_HEADERS = \ cache/cache_priv.h \ cache/cache_transport.h \ common/heritage.h \ - common/common_vsm.h \ hash/hash_slinger.h \ hpack/vhp.h \ http1/cache_http1.h \ @@ -140,6 +139,7 @@ nobase_pkginclude_HEADERS = \ cache/cache_backend.h \ cache/cache_director.h \ common/common.h \ + common/common_vsm.h \ common/com_params.h \ waiter/waiter.h From phk at FreeBSD.org Wed Sep 13 21:46:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Sep 2017 21:46:07 +0000 (UTC) Subject: [master] 7a85739 Deprecate the second sub-argument to varnishd -l now that VSM autosizes everything. Message-ID: <20170913214607.53C6197E38@lists.varnish-cache.org> commit 7a85739b1bd5f2000f853cb699e15c94d8308f3f Author: Poul-Henning Kamp Date: Wed Sep 13 21:45:21 2017 +0000 Deprecate the second sub-argument to varnishd -l now that VSM autosizes everything. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 2b341f4..6da09e5 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -129,9 +129,8 @@ usage(void) printf(FMT, "", " -s malloc"); printf(FMT, "", " -s file"); - printf(FMT, "-l vsl[,vsm]", "Size of shared memory file"); + printf(FMT, "-l vsl", "Size of shared memory log"); printf(FMT, "", " vsl: space for VSL records [80m]"); - printf(FMT, "", " vsm: space for stats counters [1m]"); printf("\nSecurity options:\n"); @@ -269,7 +268,6 @@ init_params(struct cli *cli) MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G"); - MCF_ParamConf(MCF_MAXIMUM, "vsm_space", "1G"); } #if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux) @@ -661,14 +659,17 @@ main(int argc, char * const *argv) av = VAV_Parse(optarg, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) - ARGV_ERR("\t-l ...: %s\n", av[0]); + ARGV_ERR("-l ...: %s\n", av[0]); + if (av[1] != NULL && av[2] != NULL && av[3] != NULL) + ARGV_ERR("Too many sub arguments to -l\n"); if (av[1] != NULL) { MCF_ParamSet(cli, "vsl_space", av[1]); cli_check(cli); } if (av[1] != NULL && av[2] != NULL) { - MCF_ParamSet(cli, "vsm_space", av[2]); - cli_check(cli); + fprintf(stderr, + "Warning: Ignoring deprecated second" + " subargument to -l\n"); } VAV_Free(av); break; diff --git a/bin/varnishtest/tests/a00016.vtc b/bin/varnishtest/tests/a00016.vtc index 354b01f..4055b7a 100644 --- a/bin/varnishtest/tests/a00016.vtc +++ b/bin/varnishtest/tests/a00016.vtc @@ -1,4 +1,4 @@ -varnishtest "Test -I argument" +varnishtest "Test -I and -l arguments" shell -err -expect {Only one -I allowed} { touch foo bar @@ -9,5 +9,17 @@ shell -err -expect {Error: -I file CLI command failed (104)} { echo "vcl.list" > foo echo "-foobar" >> foo echo "vcl.load" >> foo - varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,1m + varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m +} + +shell -err -expect {Error: -l ...: Missing '"'} { + varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l '2m,"' +} + +shell -err -expect {Error: Too many sub arguments} { + varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m,2m +} + +shell -err -expect {Warning: Ignoring deprecated second subargument} { + varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 33cfcb9..9f97f46 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -422,7 +422,7 @@ varnish_launch(struct varnish *v) VSB_cat(vsb, " -p debug=+vsm_keep"); VSB_cat(vsb, " -p debug=+vmod_so_keep"); } - VSB_printf(vsb, " -l 2m,1m,-"); + VSB_printf(vsb, " -l 2m"); VSB_printf(vsb, " -p auto_restart=off"); VSB_printf(vsb, " -p syslog_cli_traffic=off"); VSB_printf(vsb, " -p sigsegv_handler=on"); diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index b8455c6..195a33b 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -180,12 +180,11 @@ Tuning options files. Name is referenced in logs, VCL, statistics, etc. If name is not specified, "s0", "s1" and so forth is used. --l +-l - Specifies size of shmlog file. vsl is the space for the VSL records - [80M] and vsm is the space for stats counters [1M]. Scaling suffixes - like 'K' and 'M' can be used up to (G)igabytes. - Default is 81 Megabytes. + Specifies size of the space for the VSL records. + Scaling suffixes like 'K' and 'M' can be used up to (G)igabytes. + Default is 80 Megabytes. Security options ---------------- diff --git a/include/tbl/params.h b/include/tbl/params.h index 837c62f..b1c1f33 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1605,11 +1605,10 @@ PARAM( /* max */ "4G", /* default */ "1M", /* units */ "bytes", - /* flags */ MUST_RESTART, + /* flags */ 0, /* s-text */ - "The amount of space to allocate for stats counters in the VSM " - "memory segment. If you make this too small, some counters will " - "be invisible. Making it too large just costs memory resources.", + "DEPRECATED: This parameter is ignored.\n" + "There is no global limit on amount of shared memory now.", /* l-text */ "", /* func */ NULL ) From phk at FreeBSD.org Wed Sep 13 21:54:03 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Sep 2017 21:54:03 +0000 (UTC) Subject: [master] b419d7e Change the max for vsm_space to 1G on all archs, now that we no longer use this parameter any more. Message-ID: <20170913215403.BC754971CD@lists.varnish-cache.org> commit b419d7e63a4ee91a7493eda161deb500c691bf01 Author: Poul-Henning Kamp Date: Wed Sep 13 21:53:03 2017 +0000 Change the max for vsm_space to 1G on all archs, now that we no longer use this parameter any more. diff --git a/include/tbl/params.h b/include/tbl/params.h index b1c1f33..2a2bbf3 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1602,7 +1602,7 @@ PARAM( /* name */ vsm_space, /* typ */ bytes, /* min */ "1M", - /* max */ "4G", + /* max */ "1G", /* default */ "1M", /* units */ "bytes", /* flags */ 0, From dridi.boukelmoune at gmail.com Wed Sep 13 22:04:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:04:04 +0000 (UTC) Subject: [master] f9039e8 Remove stale comments Message-ID: <20170913220404.C3170975FE@lists.varnish-cache.org> commit f9039e84fe1150de6ebe5a28c845b258eed1fd6d Author: Dridi Boukelmoune Date: Thu Sep 14 00:02:36 2017 +0200 Remove stale comments diff --git a/bin/varnishd/lck.vsc b/bin/varnishd/lck.vsc index 99a7824..75b69be 100644 --- a/bin/varnishd/lck.vsc +++ b/bin/varnishd/lck.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: lck :oneliner: Lock Counters :order: 70 diff --git a/bin/varnishd/main.vsc b/bin/varnishd/main.vsc index b513ac4..ca999f7 100644 --- a/bin/varnishd/main.vsc +++ b/bin/varnishd/main.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_f_main.h - .. varnish_vsc_begin:: main :oneliner: Main counters :order: 10 diff --git a/bin/varnishd/mempool.vsc b/bin/varnishd/mempool.vsc index 0f333cc..8c47245 100644 --- a/bin/varnishd/mempool.vsc +++ b/bin/varnishd/mempool.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: mempool :oneliner: Memory Pool Counters :order: 30 diff --git a/bin/varnishd/mgt.vsc b/bin/varnishd/mgt.vsc index d766e99..c3ca867 100644 --- a/bin/varnishd/mgt.vsc +++ b/bin/varnishd/mgt.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: mgt :oneliner: Management Process Counters :order: 20 diff --git a/bin/varnishd/sma.vsc b/bin/varnishd/sma.vsc index 5756bec..d2ecc52 100644 --- a/bin/varnishd/sma.vsc +++ b/bin/varnishd/sma.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: sma :oneliner: Malloc Stevedore Counters :order: 40 diff --git a/bin/varnishd/smf.vsc b/bin/varnishd/smf.vsc index 3ba2f3f..4ec0dcc 100644 --- a/bin/varnishd/smf.vsc +++ b/bin/varnishd/smf.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: smf :oneliner: File Stevedore Counters :order: 50 diff --git a/bin/varnishd/vbe.vsc b/bin/varnishd/vbe.vsc index fee72bf..c5ca37f 100644 --- a/bin/varnishd/vbe.vsc +++ b/bin/varnishd/vbe.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: vbe :oneliner: Backend Counters :order: 60 From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:04 +0000 (UTC) Subject: [master] 4e0c8ae Use argv[0] as the VUT.progname Message-ID: <20170913222104.F3F3D97C15@lists.varnish-cache.org> commit 4e0c8ae1cab06189c8540e877b81950c325f8648 Author: Dridi Boukelmoune Date: Tue Apr 18 09:24:52 2017 +0200 Use argv[0] as the VUT.progname This gives users a consistent usage/help message depending on whether they run VUTs from the PATH or from a specific location. In order to kill some of the redundancy, a VUT_InitProg macro does the $0 magic. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 417c97e..fbf1f39 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -57,8 +57,6 @@ #define HIST_N 2000 /* how far back we remember */ #define HIST_RES 100 /* bucket resolution */ -static const char progname[] = "varnishhist"; - static int hist_low; static int hist_high; static int hist_range; @@ -471,7 +469,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -497,7 +495,7 @@ main(int argc, char **argv) struct profile cli_p = {0}; cli_p.name = 0; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); AZ(pthread_cond_init(&timebend_cv, NULL)); while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 8018f7b..3050a6e 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -50,8 +50,6 @@ #include "vut.h" #include "miniobj.h" -static const char progname[] = "varnishlog"; - static struct log { /* Options */ int a_opt; @@ -66,7 +64,7 @@ static void __attribute__((__noreturn__)) usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -121,7 +119,7 @@ main(int argc, char * const *argv) { int opt; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); memset(&LOG, 0, sizeof LOG); while ((opt = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 0fa722f..58f5234 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -69,8 +69,6 @@ #define TIME_FMT "[%d/%b/%Y:%T %z]" #define FORMAT "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" -static const char progname[] = "varnishncsa"; - struct format; enum e_frag { @@ -165,7 +163,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -1144,7 +1142,7 @@ main(int argc, char * const *argv) signed char opt; char *format = NULL; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); memset(&CTX, 0, sizeof CTX); VTAILQ_INIT(&CTX.format); VTAILQ_INIT(&CTX.watch_vcl_log); diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index aa268c9..af20e65 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -49,8 +49,6 @@ #include "varnishstat.h" -static const char progname[] = "varnishstat"; - /*--------------------------------------------------------------------*/ static int __match_proto__(VSC_iter_f) @@ -243,7 +241,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt +=2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -259,7 +257,7 @@ main(int argc, char * const *argv) int i; struct vsc *vsc; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); vd = VSM_New(); AN(vd); vsc = VSC_New(); diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index e824961..f73530d 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -61,7 +61,7 @@ shell -match {^\d+.\d+.\d+.\d+ - user \[../.../20[1-9][0-9]:..:..:.. (?# shell "grep -q /2 ${tmpdir}/ncsa.log" # command line -shell -expect "Usage: varnishncsa " \ +shell -match "Usage: .*varnishncsa " \ "varnishncsa -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishncsa -V" @@ -107,7 +107,7 @@ shell -err -expect "Invalid grouping mode: session" \ {varnishncsa -g session} shell -err -expect "Can't open output file (No such file or directory)" \ {varnishncsa -w /nonexistent/file} -shell -err -expect "Usage: varnishncsa " \ +shell -err -match "Usage: .*varnishncsa " \ {varnishncsa extra} # -b diff --git a/bin/varnishtest/tests/u00004.vtc b/bin/varnishtest/tests/u00004.vtc index 811b370..4bdc41f 100644 --- a/bin/varnishtest/tests/u00004.vtc +++ b/bin/varnishtest/tests/u00004.vtc @@ -14,9 +14,9 @@ client c1 { shell -expect "fetch" "varnishtop -n ${v1_name} -1 -d" -shell -expect "Usage: varnishtop " \ +shell -match "Usage: .*varnishtop " \ "varnishtop -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishtop -V" -shell -err -expect "Usage: varnishtop " \ +shell -err -match "Usage: .*varnishtop " \ "varnishtop extra" diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc index 52242be..415307c 100644 --- a/bin/varnishtest/tests/u00005.vtc +++ b/bin/varnishtest/tests/u00005.vtc @@ -29,13 +29,13 @@ shell -expect "MGT.uptime" \ shell -match "^MGT" \ "varnishstat -1 -n ${v1_name} -f ^foo" -shell -expect "Usage: varnishstat " \ +shell -match "Usage: .*varnishstat " \ "varnishstat -h" shell -expect "Varnishstat -f option fields:" \ "varnishstat -n ${v1_name} -l" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishstat -V" -shell -err -expect "Usage: varnishstat " \ +shell -err -match "Usage: .*varnishstat " \ "varnishstat extra" shell -err -expect "-t: Invalid argument: -1" \ "varnishstat -t -1" diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index e87e4da..2d16bca 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -15,11 +15,11 @@ shell { -w ${tmpdir}/vlog.bin } -shell -expect "Usage: varnishlog " \ +shell -match "Usage: .*varnishlog " \ "varnishlog -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishlog -V" -shell -err -expect "Usage: varnishlog " \ +shell -err -match "Usage: .*varnishlog " \ "varnishlog extra" shell -err -expect "Missing -w option" \ "varnishlog -D" diff --git a/bin/varnishtest/tests/u00007.vtc b/bin/varnishtest/tests/u00007.vtc index 80d956c..8a095d5 100644 --- a/bin/varnishtest/tests/u00007.vtc +++ b/bin/varnishtest/tests/u00007.vtc @@ -7,11 +7,11 @@ server s1 { varnish v1 -vcl+backend {} -start -shell -expect "Usage: varnishhist " \ +shell -match "Usage: .*varnishhist " \ "varnishhist -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishhist -V" -shell -err -expect "Usage: varnishhist " \ +shell -err -match "Usage: .*varnishhist " \ "varnishhist extra" shell -err -expect "-p: invalid '0'" \ "varnishhist -p 0" diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 39600ce..5639b22 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -71,7 +71,6 @@ struct top { double count; }; -static const char progname[] = "varnishtop"; static float period = 60; /* seconds */ static int end_of_file = 0; static unsigned ntop; @@ -318,7 +317,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt +=2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -331,7 +330,7 @@ main(int argc, char **argv) int o, once = 0; pthread_t thr; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); while ((o = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { switch (o) { diff --git a/include/vut.h b/include/vut.h index aab3608..703faa4 100644 --- a/include/vut.h +++ b/include/vut.h @@ -71,6 +71,8 @@ void VUT_Error(int status, const char *fmt, ...) int VUT_Arg(int opt, const char *arg); +#define VUT_InitProg(argc, argv, spec) VUT_Init(argv[0], argc, argv, spec) + void VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *); From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:05 +0000 (UTC) Subject: [master] 7f9e1e7 Name VUT global options accordingly Message-ID: <20170913222105.1B8E597C18@lists.varnish-cache.org> commit 7f9e1e7627e8abdc8c516db5f0cae368816849d1 Author: Dridi Boukelmoune Date: Tue Sep 5 12:31:51 2017 +0200 Name VUT global options accordingly The API is responsible for checking that global options aren't used more than once, despite it being handled (soon) in individual VUT setups. diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index a4f70cd..7ad374b 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -93,4 +93,4 @@ VUT_OPT_q VUT_OPT_r VUT_OPT_t VSL_OPT_T -VUT_OPT_V +VUT_GLOBAL_OPT_V diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h index 4847268..417b764 100644 --- a/bin/varnishlog/varnishlog_options.h +++ b/bin/varnishlog/varnishlog_options.h @@ -59,7 +59,7 @@ VSL_OPT_b VSL_OPT_c VSL_OPT_C VUT_OPT_d -VUT_OPT_D +VUT_GLOBAL_OPT_D VUT_OPT_g VUT_OPT_h VSL_OPT_i @@ -67,13 +67,13 @@ VSL_OPT_I VUT_OPT_k VSL_OPT_L VUT_OPT_n -VUT_OPT_P +VUT_GLOBAL_OPT_P VUT_OPT_q VUT_OPT_r VUT_OPT_t VSL_OPT_T VSL_OPT_v -VUT_OPT_V +VUT_GLOBAL_OPT_V LOG_OPT_w VSL_OPT_x VSL_OPT_X diff --git a/bin/varnishncsa/varnishncsa_options.h b/bin/varnishncsa/varnishncsa_options.h index 6fe13de..16bcdb1 100644 --- a/bin/varnishncsa/varnishncsa_options.h +++ b/bin/varnishncsa/varnishncsa_options.h @@ -78,16 +78,16 @@ NCSA_OPT_b NCSA_OPT_c VSL_OPT_C VUT_OPT_d -VUT_OPT_D +VUT_GLOBAL_OPT_D NCSA_OPT_F NCSA_OPT_f NCSA_OPT_g VUT_OPT_h VSL_OPT_L VUT_OPT_n -VUT_OPT_P +VUT_GLOBAL_OPT_P VUT_OPT_q VUT_OPT_r VUT_OPT_t -VUT_OPT_V +VUT_GLOBAL_OPT_V NCSA_OPT_w diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index af20e65..a1e70fa 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -274,9 +274,6 @@ main(int argc, char * const *argv) case 'l': f_list = 1; break; - case 'V': - VCS_Message("varnishstat"); - exit(0); case 'x': xml = 1; break; @@ -286,6 +283,9 @@ main(int argc, char * const *argv) case 'f': AN(VSC_Arg(vsc, opt, optarg)); break; + case 'V': + AN(VUT_Arg(opt, optarg)); + break; default: i = VSM_Arg(vd, opt, optarg); if (i < 0) diff --git a/bin/varnishstat/varnishstat_options.h b/bin/varnishstat/varnishstat_options.h index 5307a1d..a1ea33b 100644 --- a/bin/varnishstat/varnishstat_options.h +++ b/bin/varnishstat/varnishstat_options.h @@ -65,5 +65,5 @@ STAT_OPT_j STAT_OPT_l VUT_OPT_n VUT_OPT_t -VUT_OPT_V +VUT_GLOBAL_OPT_V STAT_OPT_x diff --git a/bin/varnishtop/varnishtop_options.h b/bin/varnishtop/varnishtop_options.h index 1cf0e20..dcad737 100644 --- a/bin/varnishtop/varnishtop_options.h +++ b/bin/varnishtop/varnishtop_options.h @@ -72,4 +72,4 @@ VUT_OPT_t VSL_OPT_T VSL_OPT_x VSL_OPT_X -VUT_OPT_V +VUT_GLOBAL_OPT_V diff --git a/include/vut.h b/include/vut.h index 703faa4..b214cdb 100644 --- a/include/vut.h +++ b/include/vut.h @@ -51,7 +51,6 @@ struct VUT { struct VSL_data *vsl; struct vsm *vsm; struct VSLQ *vslq; - struct vpf_fh *pfh; int sighup; int sigint; int sigusr1; diff --git a/include/vut_options.h b/include/vut_options.h index 9f0ad78..d6941e1 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -29,16 +29,26 @@ /* VUT options */ +#define VUT_GLOBAL_OPT_D \ + VOPT("D", "[-D]", "Daemonize", \ + "Daemonize." \ + ) + +#define VUT_GLOBAL_OPT_P \ + VOPT("P:", "[-P ]", "PID file", \ + "Write the process' PID to the specified file." \ + ) + +#define VUT_GLOBAL_OPT_V \ + VOPT("V", "[-V]", "Version", \ + "Print version information and exit." \ + ) + #define VUT_OPT_d \ VOPT("d", "[-d]", "Process old log entries and exit", \ "Process log records at the head of the log and exit." \ ) -#define VUT_OPT_D \ - VOPT("D", "[-D]", "Daemonize", \ - "Daemonize." \ - ) - #define VUT_OPT_g \ VOPT("g:", "[-g ]", "Grouping mode (default: vxid)", \ "The grouping of the log records. The default is to group" \ @@ -63,11 +73,6 @@ " the host name is used." \ ) -#define VUT_OPT_P \ - VOPT("P:", "[-P ]", "PID file", \ - "Write the process' PID to the specified file." \ - ) - #define VUT_OPT_q \ VOPT("q:", "[-q ]", "VSL query", \ "Specifies the VSL query to use." \ @@ -90,8 +95,3 @@ " indefinetely for the Varnish instance to appear. " \ " Defaults to 5 seconds." \ ) - -#define VUT_OPT_V \ - VOPT("V", "[-V]", "Version", \ - "Print version information and exit." \ - ) diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 4057c3f..1797dab 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -61,12 +61,24 @@ struct VUT VUT; static int vut_synopsis(const struct vopt_spec *); static int vut_options(const struct vopt_spec *); +static struct vpf_fh *pfh; +static unsigned daemonized; + +static int +vut_daemon(void) +{ + if (daemonized) + VUT_Error(1, "Already running as a daemon"); + daemonized = 1; + return (varnish_daemon(0, 0)); +} + static void vut_vpf_remove(void) { - if (VUT.pfh) { - AZ(VPF_Remove(VUT.pfh)); - VUT.pfh = NULL; + if (pfh != NULL) { + AZ(VPF_Remove(pfh)); + pfh = NULL; } } @@ -250,19 +262,21 @@ VUT_Setup(void) /* Open PID file */ if (VUT.P_arg) { - AZ(VUT.pfh); - VUT.pfh = VPF_Open(VUT.P_arg, 0644, NULL); - if (VUT.pfh == NULL) + if (pfh != NULL) + VUT_Error(1, "PID file already created"); + pfh = VPF_Open(VUT.P_arg, 0644, NULL); + if (pfh == NULL) VUT_Error(1, "%s: %s", VUT.P_arg, strerror(errno)); } /* Daemon mode */ - if (VUT.D_opt && varnish_daemon(0, 0) == -1) + if (VUT.D_opt && vut_daemon() == -1) VUT_Error(1, "Daemon mode: %s", strerror(errno)); /* Write PID and setup exit handler */ - if (VUT.pfh != NULL) { - AZ(VPF_Write(VUT.pfh)); + if (VUT.P_arg) { + AN(pfh); + AZ(VPF_Write(pfh)); AZ(atexit(vut_vpf_remove)); } } @@ -279,7 +293,7 @@ VUT_Fini(void) free(VUT.t_arg); vut_vpf_remove(); - AZ(VUT.pfh); + AZ(pfh); if (VUT.vslq) VSLQ_Delete(&VUT.vslq); From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:05 +0000 (UTC) Subject: [master] f3e6748 Signals must be forwarded to VUTs by programs Message-ID: <20170913222105.37AFA97C1C@lists.varnish-cache.org> commit f3e674853d3f18f91fc2d40cecaee58ab837e13b Author: Dridi Boukelmoune Date: Tue Sep 5 15:12:14 2017 +0200 Signals must be forwarded to VUTs by programs This is a first step away from the global VUT symbol, handled outside of VUT_Setup in preparation for the "unglobalization". diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index fbf1f39..bb7dc70 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -484,6 +484,12 @@ profile_error(const char *s) exit(1); } +static void +vut_sighandler(int sig) +{ + VUT_Signaled(&VUT, sig); +} + int main(int argc, char **argv) { @@ -608,6 +614,7 @@ main(int argc, char **argv) log_ten = log(10.0); + VUT_Signal(vut_sighandler); VUT_Setup(); ident = VSM_Dup(VUT.vsm, "Arg", "-i"); if (pthread_create(&thr, NULL, do_curses, NULL) != 0) diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 3050a6e..ffd1450 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -114,6 +114,12 @@ sighup(void) return (1); } +static void +vut_sighandler(int sig) +{ + VUT_Signaled(&VUT, sig); +} + int main(int argc, char * const *argv) { @@ -166,6 +172,7 @@ main(int argc, char * const *argv) LOG.fo = stdout; VUT.idle_f = flushout; + VUT_Signal(vut_sighandler); VUT_Setup(); VUT_Main(); VUT_Fini(); diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 58f5234..bd20848 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -1108,6 +1109,12 @@ sighup(void) return (1); } +static void +vut_sighandler(int sig) +{ + VUT_Signaled(&VUT, sig); +} + static char * read_format(const char *formatfile) { @@ -1228,6 +1235,7 @@ main(int argc, char * const *argv) CTX.fo = stdout; VUT.idle_f = flushout; + VUT_Signal(vut_sighandler); VUT_Setup(); VUT_Main(); VUT_Fini(); diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index a1e70fa..a13ce61 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 5639b22..eb0dd6f 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -185,6 +185,12 @@ sighup(void) } static void +vut_sighandler(int sig) +{ + VUT_Signaled(&VUT, sig); +} + +static void update(int p) { struct top *tp, *tp2; @@ -362,6 +368,7 @@ main(int argc, char **argv) if (optind != argc) usage(1); + VUT_Signal(vut_sighandler); VUT_Setup(); ident = VSM_Dup(VUT.vsm, "Arg", "-i"); if (!once) { diff --git a/include/vut.h b/include/vut.h index b214cdb..d084ec3 100644 --- a/include/vut.h +++ b/include/vut.h @@ -31,6 +31,7 @@ struct vopt_spec; +typedef void VUT_sighandler_f(int); typedef int VUT_cb_f(void); struct VUT { @@ -75,6 +76,9 @@ int VUT_Arg(int opt, const char *arg); void VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *); +void VUT_Signal(VUT_sighandler_f); +void VUT_Signaled(struct VUT *, int); + void VUT_Setup(void); int VUT_Main(void); void VUT_Fini(void); diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 0f3fb80..4f23dc5 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -134,6 +134,8 @@ LIBVARNISHAPI_2.0 { VUT_Init; VUT_Main; VUT_Setup; + VUT_Signal; + VUT_Signaled; local: *; diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 1797dab..d6dbbb9 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -82,15 +82,6 @@ vut_vpf_remove(void) } } -static void -vut_signal(int sig) -{ - - VUT.sighup |= (sig == SIGHUP); - VUT.sigint |= (sig == SIGINT || sig == SIGTERM); - VUT.sigusr1 |= (sig == SIGUSR1); -} - static int __match_proto__(VSLQ_dispatch_f) vut_dispatch(struct VSL_data *vsl, struct VSL_transaction * const trans[], void *priv) @@ -216,6 +207,27 @@ VUT_Init(const char *progname, int argc, char * const *argv, } void +VUT_Signal(VUT_sighandler_f sig_cb) +{ + + AN(sig_cb); + (void)signal(SIGHUP, sig_cb); + (void)signal(SIGINT, sig_cb); + (void)signal(SIGTERM, sig_cb); + (void)signal(SIGUSR1, sig_cb); +} + +void +VUT_Signaled(struct VUT *vut, int sig) +{ + + AN(vut); + vut->sighup |= (sig == SIGHUP); + vut->sigint |= (sig == SIGINT || sig == SIGTERM); + vut->sigusr1 |= (sig == SIGUSR1); +} + +void VUT_Setup(void) { struct VSL_cursor *c; @@ -254,12 +266,6 @@ VUT_Setup(void) // Cursor is handled in VUT_Main() } - /* Signal handlers */ - (void)signal(SIGHUP, vut_signal); - (void)signal(SIGINT, vut_signal); - (void)signal(SIGTERM, vut_signal); - (void)signal(SIGUSR1, vut_signal); - /* Open PID file */ if (VUT.P_arg) { if (pfh != NULL) From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:05 +0000 (UTC) Subject: [master] 28b9105 Pass VUTs to callbacks Message-ID: <20170913222105.527F697C21@lists.varnish-cache.org> commit 28b91058d720985606513685d079ab0ecb8cf315 Author: Dridi Boukelmoune Date: Tue Sep 5 15:28:32 2017 +0200 Pass VUTs to callbacks With the exception of dispatch_f that already has a dispatch_priv. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index bb7dc70..fe2df7a 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -366,8 +366,9 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], } static int __match_proto__(VUT_cb_f) -sighup(void) +sighup(struct VUT *v) { + assert(v == &VUT); quit = 1; return (1); } diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index ffd1450..edabf63 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -87,9 +87,10 @@ openout(int append) } static int __match_proto__(VUT_cb_f) -rotateout(void) +rotateout(struct VUT *v) { + assert(v == &VUT); AN(LOG.w_arg); AN(LOG.fo); fclose(LOG.fo); @@ -99,9 +100,11 @@ rotateout(void) } static int __match_proto__(VUT_cb_f) -flushout(void) +flushout(struct VUT *v) { + if (v != NULL) + assert(v == &VUT); AN(LOG.fo); if (fflush(LOG.fo)) return (-5); @@ -109,8 +112,9 @@ flushout(void) } static int __match_proto__(VUT_cb_f) -sighup(void) +sighup(struct VUT *v) { + assert(v == &VUT); return (1); } @@ -177,7 +181,7 @@ main(int argc, char * const *argv) VUT_Main(); VUT_Fini(); - (void)flushout(); + (void)flushout(NULL); exit(0); } diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index bd20848..415691e 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -183,9 +183,10 @@ openout(int append) } static int __match_proto__(VUT_cb_f) -rotateout(void) +rotateout(struct VUT *v) { + assert(v == &VUT); AN(CTX.w_arg); AN(CTX.fo); fclose(CTX.fo); @@ -195,9 +196,10 @@ rotateout(void) } static int __match_proto__(VUT_cb_f) -flushout(void) +flushout(struct VUT *v) { + assert(v == &VUT); AN(CTX.fo); if (fflush(CTX.fo)) return (-5); @@ -1104,8 +1106,9 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], } static int __match_proto__(VUT_cb_f) -sighup(void) +sighup(struct VUT *v) { + assert(v == &VUT); return (1); } diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index eb0dd6f..85d8dab 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -178,8 +178,9 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], } static int __match_proto__(VUT_cb_f) -sighup(void) +sighup(struct VUT *v) { + assert(v == &VUT); quit = 1; return (1); } diff --git a/include/vut.h b/include/vut.h index d084ec3..1fbe755 100644 --- a/include/vut.h +++ b/include/vut.h @@ -29,10 +29,11 @@ * Common functions for the utilities */ +struct VUT; struct vopt_spec; typedef void VUT_sighandler_f(int); -typedef int VUT_cb_f(void); +typedef int VUT_cb_f(struct VUT *); struct VUT { const char *progname; diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index d6dbbb9..5bd24d4 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -324,7 +324,7 @@ VUT_Main(void) if (VUT.sighup && VUT.sighup_f) { /* sighup callback */ VUT.sighup = 0; - i = VUT.sighup_f(); + i = VUT.sighup_f(&VUT); if (i) break; } @@ -370,7 +370,7 @@ VUT_Main(void) else if (i == 0) { /* Nothing to do but wait */ if (VUT.idle_f) { - i = VUT.idle_f(); + i = VUT.idle_f(&VUT); if (i) break; } From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:05 +0000 (UTC) Subject: [master] 36520f2 Remove the global VUT symbol Message-ID: <20170913222105.7139E97C26@lists.varnish-cache.org> commit 36520f2db68123634fb414293d181d2f6721c476 Author: Dridi Boukelmoune Date: Tue Sep 5 11:26:09 2017 +0200 Remove the global VUT symbol diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index fe2df7a..7054b6d 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -57,6 +57,8 @@ #define HIST_N 2000 /* how far back we remember */ #define HIST_RES 100 /* bucket resolution */ +static struct VUT *vut; + static int hist_low; static int hist_high; static int hist_range; @@ -368,7 +370,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], static int __match_proto__(VUT_cb_f) sighup(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); quit = 1; return (1); } @@ -470,7 +472,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -488,7 +490,7 @@ profile_error(const char *s) static void vut_sighandler(int sig) { - VUT_Signaled(&VUT, sig); + VUT_Signaled(vut, sig); } int @@ -502,7 +504,8 @@ main(int argc, char **argv) struct profile cli_p = {0}; cli_p.name = 0; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); AZ(pthread_cond_init(&timebend_cv, NULL)); while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { @@ -565,7 +568,7 @@ main(int argc, char **argv) " (invalid factor '%s')", optarg); break; default: - if (!VUT_Arg(i, optarg)) + if (!VUT_Arg(vut, i, optarg)) usage(1); } } @@ -574,11 +577,11 @@ main(int argc, char **argv) usage(1); /* Check for valid grouping mode */ - assert(VUT.g_arg < VSL_g__MAX); - if (VUT.g_arg != VSL_g_vxid && VUT.g_arg != VSL_g_request) + assert(vut->g_arg < VSL_g__MAX); + if (vut->g_arg != VSL_g_vxid && vut->g_arg != VSL_g_request) VUT_Error(1, "Invalid grouping mode: %s" " (only vxid and request are supported)", - VSLQ_grouping[VUT.g_arg]); + VSLQ_grouping[vut->g_arg]); if (profile) { for (active_profile = profiles; active_profile->name; @@ -593,7 +596,7 @@ main(int argc, char **argv) assert(active_profile->VSL_arg == 'b' || active_profile->VSL_arg == 'c'); - assert(VUT_Arg(active_profile->VSL_arg, NULL)); + assert(VUT_Arg(vut, active_profile->VSL_arg, NULL)); match_tag = active_profile->tag; fnum = active_profile->field; hist_low = active_profile->hist_low; @@ -616,16 +619,16 @@ main(int argc, char **argv) log_ten = log(10.0); VUT_Signal(vut_sighandler); - VUT_Setup(); - ident = VSM_Dup(VUT.vsm, "Arg", "-i"); + VUT_Setup(vut); + ident = VSM_Dup(vut->vsm, "Arg", "-i"); if (pthread_create(&thr, NULL, do_curses, NULL) != 0) VUT_Error(1, "pthread_create(): %s", strerror(errno)); - VUT.dispatch_f = accumulate; - VUT.dispatch_priv = NULL; - VUT.sighup_f = sighup; - VUT_Main(); + vut->dispatch_f = accumulate; + vut->dispatch_priv = NULL; + vut->sighup_f = sighup; + VUT_Main(vut); end_of_file = 1; AZ(pthread_join(thr, NULL)); - VUT_Fini(); + VUT_Fini(&vut); exit(0); } diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index edabf63..6f6772b 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -50,6 +50,8 @@ #include "vut.h" #include "miniobj.h" +static struct VUT *vut; + static struct log { /* Options */ int a_opt; @@ -64,7 +66,7 @@ static void __attribute__((__noreturn__)) usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -79,18 +81,18 @@ openout(int append) if (LOG.A_opt) LOG.fo = fopen(LOG.w_arg, append ? "a" : "w"); else - LOG.fo = VSL_WriteOpen(VUT.vsl, LOG.w_arg, append, 0); + LOG.fo = VSL_WriteOpen(vut->vsl, LOG.w_arg, append, 0); if (LOG.fo == NULL) VUT_Error(2, "Cannot open output file (%s)", - LOG.A_opt ? strerror(errno) : VSL_Error(VUT.vsl)); - VUT.dispatch_priv = LOG.fo; + LOG.A_opt ? strerror(errno) : VSL_Error(vut->vsl)); + vut->dispatch_priv = LOG.fo; } static int __match_proto__(VUT_cb_f) rotateout(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); AN(LOG.w_arg); AN(LOG.fo); fclose(LOG.fo); @@ -103,8 +105,7 @@ static int __match_proto__(VUT_cb_f) flushout(struct VUT *v) { - if (v != NULL) - assert(v == &VUT); + assert(v == vut); AN(LOG.fo); if (fflush(LOG.fo)) return (-5); @@ -114,14 +115,15 @@ flushout(struct VUT *v) static int __match_proto__(VUT_cb_f) sighup(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); return (1); } static void vut_sighandler(int sig) { - VUT_Signaled(&VUT, sig); + AN(vut); + VUT_Signaled(vut, sig); } int @@ -129,7 +131,8 @@ main(int argc, char * const *argv) { int opt; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); memset(&LOG, 0, sizeof LOG); while ((opt = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { @@ -150,7 +153,7 @@ main(int argc, char * const *argv) REPLACE(LOG.w_arg, optarg); break; default: - if (!VUT_Arg(opt, optarg)) + if (!VUT_Arg(vut, opt, optarg)) usage(1); } } @@ -158,28 +161,28 @@ main(int argc, char * const *argv) if (optind != argc) usage(1); - if (VUT.D_opt && !LOG.w_arg) + if (vut->D_opt && !LOG.w_arg) VUT_Error(1, "Missing -w option"); /* Setup output */ if (LOG.A_opt || !LOG.w_arg) - VUT.dispatch_f = VSL_PrintTransactions; + vut->dispatch_f = VSL_PrintTransactions; else - VUT.dispatch_f = VSL_WriteTransactions; - VUT.sighup_f = sighup; + vut->dispatch_f = VSL_WriteTransactions; + vut->sighup_f = sighup; if (LOG.w_arg) { openout(LOG.a_opt); AN(LOG.fo); - if (VUT.D_opt) - VUT.sighup_f = rotateout; + if (vut->D_opt) + vut->sighup_f = rotateout; } else LOG.fo = stdout; - VUT.idle_f = flushout; + vut->idle_f = flushout; VUT_Signal(vut_sighandler); - VUT_Setup(); - VUT_Main(); - VUT_Fini(); + VUT_Setup(vut); + VUT_Main(vut); + VUT_Fini(&vut); (void)flushout(NULL); diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 415691e..22391d1 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -70,6 +70,8 @@ #define TIME_FMT "[%d/%b/%Y:%T %z]" #define FORMAT "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" +static struct VUT *vut; + struct format; enum e_frag { @@ -164,7 +166,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -186,7 +188,7 @@ static int __match_proto__(VUT_cb_f) rotateout(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); AN(CTX.w_arg); AN(CTX.fo); fclose(CTX.fo); @@ -199,7 +201,7 @@ static int __match_proto__(VUT_cb_f) flushout(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); AN(CTX.fo); if (fflush(CTX.fo)) return (-5); @@ -1108,14 +1110,15 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], static int __match_proto__(VUT_cb_f) sighup(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); return (1); } static void vut_sighandler(int sig) { - VUT_Signaled(&VUT, sig); + AN(vut); + VUT_Signaled(vut, sig); } static char * @@ -1152,7 +1155,8 @@ main(int argc, char * const *argv) signed char opt; char *format = NULL; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); memset(&CTX, 0, sizeof CTX); VTAILQ_INIT(&CTX.format); VTAILQ_INIT(&CTX.watch_vcl_log); @@ -1200,7 +1204,7 @@ main(int argc, char * const *argv) REPLACE(CTX.w_arg, optarg); break; default: - if (!VUT_Arg(opt, optarg)) + if (!VUT_Arg(vut, opt, optarg)) usage(1); } } @@ -1211,14 +1215,14 @@ main(int argc, char * const *argv) if (optind != argc) usage(1); - if (VUT.D_opt && !CTX.w_arg) + if (vut->D_opt && !CTX.w_arg) VUT_Error(1, "Missing -w option"); /* Check for valid grouping mode */ - assert(VUT.g_arg < VSL_g__MAX); - if (VUT.g_arg != VSL_g_vxid && VUT.g_arg != VSL_g_request) + assert(vut->g_arg < VSL_g__MAX); + if (vut->g_arg != VSL_g_vxid && vut->g_arg != VSL_g_request) VUT_Error(1, "Invalid grouping mode: %s", - VSLQ_grouping[VUT.g_arg]); + VSLQ_grouping[vut->g_arg]); /* Prepare output format */ parse_format(format); @@ -1226,22 +1230,22 @@ main(int argc, char * const *argv) format = NULL; /* Setup output */ - VUT.dispatch_f = dispatch_f; - VUT.dispatch_priv = NULL; - VUT.sighup_f = sighup; + vut->dispatch_f = dispatch_f; + vut->dispatch_priv = NULL; + vut->sighup_f = sighup; if (CTX.w_arg) { openout(CTX.a_opt); AN(CTX.fo); - if (VUT.D_opt) - VUT.sighup_f = rotateout; + if (vut->D_opt) + vut->sighup_f = rotateout; } else CTX.fo = stdout; - VUT.idle_f = flushout; + vut->idle_f = flushout; VUT_Signal(vut_sighandler); - VUT_Setup(); - VUT_Main(); - VUT_Fini(); + VUT_Setup(vut); + VUT_Main(vut); + VUT_Fini(&vut); exit(0); } diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index a13ce61..7d02906 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -50,6 +50,8 @@ #include "varnishstat.h" +static struct VUT *vut; + /*--------------------------------------------------------------------*/ static int __match_proto__(VSC_iter_f) @@ -242,7 +244,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt +=2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -258,7 +260,8 @@ main(int argc, char * const *argv) int i; struct vsc *vsc; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); vd = VSM_New(); AN(vd); vsc = VSC_New(); @@ -285,7 +288,7 @@ main(int argc, char * const *argv) AN(VSC_Arg(vsc, opt, optarg)); break; case 'V': - AN(VUT_Arg(opt, optarg)); + AN(VUT_Arg(vut, opt, optarg)); break; default: i = VSM_Arg(vd, opt, optarg); diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 85d8dab..09d939f 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -60,6 +60,8 @@ #define AC(x) x #endif +static struct VUT *vut; + struct top { uint8_t tag; const char *rec_data; @@ -180,7 +182,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], static int __match_proto__(VUT_cb_f) sighup(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); quit = 1; return (1); } @@ -188,7 +190,8 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - VUT_Signaled(&VUT, sig); + AN(vut); + VUT_Signaled(vut, sig); } static void @@ -324,7 +327,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt +=2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -337,12 +340,13 @@ main(int argc, char **argv) int o, once = 0; pthread_t thr; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); while ((o = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { switch (o) { case '1': - AN(VUT_Arg('d', NULL)); + AN(VUT_Arg(vut, 'd', NULL)); once = 1; break; case 'f': @@ -361,7 +365,7 @@ main(int argc, char **argv) } break; default: - if (!VUT_Arg(o, optarg)) + if (!VUT_Arg(vut, o, optarg)) usage(1); } } @@ -370,8 +374,8 @@ main(int argc, char **argv) usage(1); VUT_Signal(vut_sighandler); - VUT_Setup(); - ident = VSM_Dup(VUT.vsm, "Arg", "-i"); + VUT_Setup(vut); + ident = VSM_Dup(vut->vsm, "Arg", "-i"); if (!once) { if (pthread_create(&thr, NULL, do_curses, NULL) != 0) { fprintf(stderr, "pthread_create(): %s\n", @@ -379,15 +383,15 @@ main(int argc, char **argv) exit(1); } } - VUT.dispatch_f = accumulate; - VUT.dispatch_priv = NULL; - VUT.sighup_f = sighup; - VUT_Main(); + vut->dispatch_f = accumulate; + vut->dispatch_priv = NULL; + vut->sighup_f = sighup; + VUT_Main(vut); end_of_file = 1; if (once) dump(); else pthread_join(thr, NULL); - VUT_Fini(); + VUT_Fini(&vut); exit(0); } diff --git a/include/vut.h b/include/vut.h index 1fbe755..2e3a3c7 100644 --- a/include/vut.h +++ b/include/vut.h @@ -64,22 +64,20 @@ struct VUT { void *dispatch_priv; }; -extern struct VUT VUT; - //lint -sem(VUT_Error, r_no) void VUT_Error(int status, const char *fmt, ...) __v_printflike(2, 3) __attribute__((__noreturn__)); -int VUT_Arg(int opt, const char *arg); +int VUT_Arg(struct VUT *, int opt, const char *arg); #define VUT_InitProg(argc, argv, spec) VUT_Init(argv[0], argc, argv, spec) -void VUT_Init(const char *progname, int argc, char * const *argv, +struct VUT * VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *); void VUT_Signal(VUT_sighandler_f); void VUT_Signaled(struct VUT *, int); -void VUT_Setup(void); -int VUT_Main(void); -void VUT_Fini(void); +void VUT_Setup(struct VUT *); +int VUT_Main(struct VUT *); +void VUT_Fini(struct VUT **); diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 4f23dc5..7454f4f 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -127,7 +127,6 @@ LIBVARNISHAPI_2.0 { VTIM_timeval; # vut.c - VUT; VUT_Arg; VUT_Error; VUT_Fini; diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 5bd24d4..6103e9c 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -56,8 +56,6 @@ #include "vapi/voptget.h" -struct VUT VUT; - static int vut_synopsis(const struct vopt_spec *); static int vut_options(const struct vopt_spec *); @@ -86,16 +84,18 @@ static int __match_proto__(VSLQ_dispatch_f) vut_dispatch(struct VSL_data *vsl, struct VSL_transaction * const trans[], void *priv) { + struct VUT *vut; int i; - (void)priv; - if (VUT.k_arg == 0) + vut = priv; + AN(vut); + if (vut->k_arg == 0) return (-1); /* End of file */ - AN(VUT.dispatch_f); - i = VUT.dispatch_f(vsl, trans, VUT.dispatch_priv); - if (VUT.k_arg > 0) - VUT.k_arg--; - if (i >= 0 && VUT.k_arg == 0) + AN(vut->dispatch_f); + i = vut->dispatch_f(vsl, trans, vut->dispatch_priv); + if (vut->k_arg > 0) + vut->k_arg--; + if (i >= 0 && vut->k_arg == 0) return (-1); /* End of file */ return (i); } @@ -116,7 +116,7 @@ VUT_Error(int status, const char *fmt, ...) } int -VUT_Arg(int opt, const char *arg) +VUT_Arg(struct VUT *vut, int opt, const char *arg) { int i; char *p; @@ -124,86 +124,90 @@ VUT_Arg(int opt, const char *arg) switch (opt) { case 'd': /* Head */ - VUT.d_opt = 1; + vut->d_opt = 1; return (1); case 'D': /* Daemon mode */ - VUT.D_opt = 1; + vut->D_opt = 1; return (1); case 'g': /* Grouping */ AN(arg); - VUT.g_arg = VSLQ_Name2Grouping(arg, -1); - if (VUT.g_arg == -2) + vut->g_arg = VSLQ_Name2Grouping(arg, -1); + if (vut->g_arg == -2) VUT_Error(1, "Ambiguous grouping type: %s", arg); - else if (VUT.g_arg < 0) + else if (vut->g_arg < 0) VUT_Error(1, "Unknown grouping type: %s", arg); return (1); case 'k': /* Log transaction limit */ AN(arg); - VUT.k_arg = (int)strtol(arg, &p, 10); - if (*p != '\0' || VUT.k_arg <= 0) + vut->k_arg = (int)strtol(arg, &p, 10); + if (*p != '\0' || vut->k_arg <= 0) VUT_Error(1, "-k: Invalid number '%s'", arg); return (1); case 'n': /* Varnish instance name */ AN(arg); - REPLACE(VUT.n_arg, arg); + REPLACE(vut->n_arg, arg); return (1); case 'P': /* PID file */ AN(arg); - REPLACE(VUT.P_arg, arg); + REPLACE(vut->P_arg, arg); return (1); case 'q': /* Query to use */ AN(arg); - REPLACE(VUT.q_arg, arg); + REPLACE(vut->q_arg, arg); return (1); case 'r': /* Binary file input */ AN(arg); - REPLACE(VUT.r_arg, arg); + REPLACE(vut->r_arg, arg); return (1); case 't': /* VSM connect timeout */ - REPLACE(VUT.t_arg, arg); + REPLACE(vut->t_arg, arg); return (1); case 'V': /* Print version number and exit */ - VCS_Message(VUT.progname); + VCS_Message(vut->progname); exit(0); default: - AN(VUT.vsl); - i = VSL_Arg(VUT.vsl, opt, arg); + AN(vut->vsl); + i = VSL_Arg(vut->vsl, opt, arg); if (i < 0) - VUT_Error(1, "%s", VSL_Error(VUT.vsl)); + VUT_Error(1, "%s", VSL_Error(vut->vsl)); return (i); } } -void +struct VUT * VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *voc) { + struct VUT *vut; AN(progname); AN(argv); AN(voc); - AZ(VUT.progname); + + vut = calloc(1, sizeof *vut); + AN(vut); if (argc == 2 && !strcmp(argv[1], "--synopsis")) exit(vut_synopsis(voc)); if (argc == 2 && !strcmp(argv[1], "--options")) exit(vut_options(voc)); - VUT.progname = progname; - VUT.g_arg = VSL_g_vxid; - AZ(VUT.vsl); - VUT.vsl = VSL_New(); - AN(VUT.vsl); - VUT.k_arg = -1; + vut->progname = progname; + vut->g_arg = VSL_g_vxid; + AZ(vut->vsl); + vut->vsl = VSL_New(); + AN(vut->vsl); + vut->k_arg = -1; + return (vut); } void @@ -228,59 +232,60 @@ VUT_Signaled(struct VUT *vut, int sig) } void -VUT_Setup(void) +VUT_Setup(struct VUT *vut) { struct VSL_cursor *c; - AN(VUT.vsl); - AZ(VUT.vsm); - AZ(VUT.vslq); + AN(vut); + AN(vut->vsl); + AZ(vut->vsm); + AZ(vut->vslq); /* Check input arguments (2 used for bug in FlexeLint) */ - if ((VUT.n_arg == NULL ? 0 : 2) + - (VUT.r_arg == NULL ? 0 : 2) > 2) + if ((vut->n_arg == NULL ? 0 : 2) + + (vut->r_arg == NULL ? 0 : 2) > 2) VUT_Error(1, "Only one of -n and -r options may be used"); /* Create and validate the query expression */ - VUT.vslq = VSLQ_New(VUT.vsl, NULL, VUT.g_arg, VUT.q_arg); - if (VUT.vslq == NULL) + vut->vslq = VSLQ_New(vut->vsl, NULL, vut->g_arg, vut->q_arg); + if (vut->vslq == NULL) VUT_Error(1, "Query expression error:\n%s", - VSL_Error(VUT.vsl)); + VSL_Error(vut->vsl)); /* Setup input */ - if (VUT.r_arg) { - c = VSL_CursorFile(VUT.vsl, VUT.r_arg, 0); + if (vut->r_arg) { + c = VSL_CursorFile(vut->vsl, vut->r_arg, 0); if (c == NULL) - VUT_Error(1, "%s", VSL_Error(VUT.vsl)); - VSLQ_SetCursor(VUT.vslq, &c); + VUT_Error(1, "%s", VSL_Error(vut->vsl)); + VSLQ_SetCursor(vut->vslq, &c); AZ(c); } else { - VUT.vsm = VSM_New(); - AN(VUT.vsm); - if (VUT.n_arg && VSM_Arg(VUT.vsm, 'n', VUT.n_arg) <= 0) - VUT_Error(1, "%s", VSM_Error(VUT.vsm)); - if (VUT.t_arg && VSM_Arg(VUT.vsm, 't', VUT.t_arg) <= 0) - VUT_Error(1, "%s", VSM_Error(VUT.vsm)); - if (VSM_Attach(VUT.vsm, STDERR_FILENO)) - VUT_Error(1, "VSM: %s", VSM_Error(VUT.vsm)); + vut->vsm = VSM_New(); + AN(vut->vsm); + if (vut->n_arg && VSM_Arg(vut->vsm, 'n', vut->n_arg) <= 0) + VUT_Error(1, "%s", VSM_Error(vut->vsm)); + if (vut->t_arg && VSM_Arg(vut->vsm, 't', vut->t_arg) <= 0) + VUT_Error(1, "%s", VSM_Error(vut->vsm)); + if (VSM_Attach(vut->vsm, STDERR_FILENO)) + VUT_Error(1, "VSM: %s", VSM_Error(vut->vsm)); // Cursor is handled in VUT_Main() } /* Open PID file */ - if (VUT.P_arg) { + if (vut->P_arg) { if (pfh != NULL) VUT_Error(1, "PID file already created"); - pfh = VPF_Open(VUT.P_arg, 0644, NULL); + pfh = VPF_Open(vut->P_arg, 0644, NULL); if (pfh == NULL) - VUT_Error(1, "%s: %s", VUT.P_arg, strerror(errno)); + VUT_Error(1, "%s: %s", vut->P_arg, strerror(errno)); } /* Daemon mode */ - if (VUT.D_opt && vut_daemon() == -1) + if (vut->D_opt && vut_daemon() == -1) VUT_Error(1, "Daemon mode: %s", strerror(errno)); /* Write PID and setup exit handler */ - if (VUT.P_arg) { + if (vut->P_arg) { AN(pfh); AZ(VPF_Write(pfh)); AZ(atexit(vut_vpf_remove)); @@ -288,89 +293,98 @@ VUT_Setup(void) } void -VUT_Fini(void) +VUT_Fini(struct VUT **vutp) { - AN(VUT.progname); + struct VUT *vut; + + AN(vutp); + vut = *vutp; + *vutp = NULL; - free(VUT.n_arg); - free(VUT.P_arg); - free(VUT.q_arg); - free(VUT.r_arg); - free(VUT.t_arg); + AN(vut); + AN(vut->progname); + + free(vut->n_arg); + free(vut->P_arg); + free(vut->q_arg); + free(vut->r_arg); + free(vut->t_arg); vut_vpf_remove(); AZ(pfh); - if (VUT.vslq) - VSLQ_Delete(&VUT.vslq); - if (VUT.vsl) - VSL_Delete(VUT.vsl); - if (VUT.vsm) - VSM_Destroy(&VUT.vsm); + if (vut->vslq) + VSLQ_Delete(&vut->vslq); + if (vut->vsl) + VSL_Delete(vut->vsl); + if (vut->vsm) + VSM_Destroy(&vut->vsm); - memset(&VUT, 0, sizeof VUT); + memset(vut, 0, sizeof *vut); + free(vut); } int -VUT_Main(void) +VUT_Main(struct VUT *vut) { struct VSL_cursor *c; int i = -1; int hascursor = -1; - AN(VUT.vslq); + AN(vut); + AN(vut->vslq); - while (!VUT.sigint) { - if (VUT.sighup && VUT.sighup_f) { + while (!vut->sigint) { + if (vut->sighup && vut->sighup_f) { /* sighup callback */ - VUT.sighup = 0; - i = VUT.sighup_f(&VUT); + vut->sighup = 0; + i = vut->sighup_f(vut); if (i) break; } - if (VUT.sigusr1) { + if (vut->sigusr1) { /* Flush and report any incomplete records */ - VUT.sigusr1 = 0; - (void)VSLQ_Flush(VUT.vslq, vut_dispatch, NULL); + vut->sigusr1 = 0; + (void)VSLQ_Flush(vut->vslq, vut_dispatch, vut); } // We must repeatedly call VSM_Status() when !hascursor // to make VSM discover our segment. - if (VUT.vsm != NULL && - (VSM_Status(VUT.vsm) & VSM_WRK_RESTARTED)) { + if (vut->vsm != NULL && + (VSM_Status(vut->vsm) & VSM_WRK_RESTARTED)) { if (hascursor < 1) { fprintf(stderr, "Log abandonned\n"); - VSLQ_SetCursor(VUT.vslq, NULL); + VSLQ_SetCursor(vut->vslq, NULL); hascursor = 0; } } - if (VUT.vsm != NULL && hascursor < 1) { + if (vut->vsm != NULL && hascursor < 1) { /* Reconnect VSM */ - AZ(VUT.r_arg); + AZ(vut->r_arg); VTIM_sleep(0.1); - c = VSL_CursorVSM(VUT.vsl, VUT.vsm, - (VUT.d_opt ? VSL_COPT_TAILSTOP : VSL_COPT_TAIL) + c = VSL_CursorVSM(vut->vsl, vut->vsm, + (vut->d_opt ? VSL_COPT_TAILSTOP : VSL_COPT_TAIL) | VSL_COPT_BATCH); if (c == NULL) { - VSL_ResetError(VUT.vsl); + VSL_ResetError(vut->vsl); continue; } if (hascursor >= 0) fprintf(stderr, "Log reacquired\n"); hascursor = 1; - VSLQ_SetCursor(VUT.vslq, &c); + VSLQ_SetCursor(vut->vslq, &c); AZ(c); } - i = VSLQ_Dispatch(VUT.vslq, vut_dispatch, NULL); + i = VSLQ_Dispatch(vut->vslq, vut_dispatch, vut); if (i == 1) /* Call again */ continue; else if (i == 0) { /* Nothing to do but wait */ - if (VUT.idle_f) { - i = VUT.idle_f(&VUT); + if (vut->idle_f) { + i = vut->idle_f(vut); if (i) break; } @@ -381,17 +395,17 @@ VUT_Main(void) break; } - if (VUT.vsm == NULL) + if (vut->vsm == NULL) break; /* XXX: Make continuation optional */ - (void)VSLQ_Flush(VUT.vslq, vut_dispatch, NULL); + (void)VSLQ_Flush(vut->vslq, vut_dispatch, vut); if (i == -2) { /* Abandoned */ fprintf(stderr, "Log abandoned\n"); - VSLQ_SetCursor(VUT.vslq, NULL); + VSLQ_SetCursor(vut->vslq, NULL); hascursor = 0; } else if (i < -2) /* Overrun */ From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:05 +0000 (UTC) Subject: [master] 8e09fd8 Handle VUT errors in a callback Message-ID: <20170913222105.8D07797C2A@lists.varnish-cache.org> commit 8e09fd8ba9c812d35e6d4031ebf3bfc0e11c07b2 Author: Dridi Boukelmoune Date: Tue Sep 5 15:58:16 2017 +0200 Handle VUT errors in a callback When omitted, the callback defaults to printing to stderr and exiting with the provided status. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 7054b6d..b8ebc19 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -516,7 +516,7 @@ main(int argc, char **argv) case 'p': delay = strtod(optarg, NULL); if (delay <= 0) - VUT_Error(1, "-p: invalid '%s'", optarg); + VUT_Error(vut, 1, "-p: invalid '%s'", optarg); break; case 'P': colon = strchr(optarg, ':'); @@ -545,7 +545,7 @@ main(int argc, char **argv) match_tag = VSL_Name2Tag(ptag, colon - ptag); if (match_tag < 0) - VUT_Error(1, + VUT_Error(vut, 1, "-P: '%s' is not a valid tag name", optarg); cli_p.name = "custom"; @@ -557,12 +557,12 @@ main(int argc, char **argv) case 'B': timebend = strtod(optarg, NULL); if (timebend == 0) - VUT_Error(1, + VUT_Error(vut, 1, "-B: being able to bend time does not" " mean we can stop it" " (invalid factor '%s')", optarg); if (timebend < 0) - VUT_Error(1, + VUT_Error(vut, 1, "-B: being able to bend time does not" " mean we can make it go backwards" " (invalid factor '%s')", optarg); @@ -579,7 +579,7 @@ main(int argc, char **argv) /* Check for valid grouping mode */ assert(vut->g_arg < VSL_g__MAX); if (vut->g_arg != VSL_g_vxid && vut->g_arg != VSL_g_request) - VUT_Error(1, "Invalid grouping mode: %s" + VUT_Error(vut, 1, "Invalid grouping mode: %s" " (only vxid and request are supported)", VSLQ_grouping[vut->g_arg]); @@ -592,7 +592,7 @@ main(int argc, char **argv) } AN(active_profile); if (!active_profile->name) - VUT_Error(1, "-P: No such profile '%s'", profile); + VUT_Error(vut, 1, "-P: No such profile '%s'", profile); assert(active_profile->VSL_arg == 'b' || active_profile->VSL_arg == 'c'); @@ -622,7 +622,7 @@ main(int argc, char **argv) VUT_Setup(vut); ident = VSM_Dup(vut->vsm, "Arg", "-i"); if (pthread_create(&thr, NULL, do_curses, NULL) != 0) - VUT_Error(1, "pthread_create(): %s", strerror(errno)); + VUT_Error(vut, 1, "pthread_create(): %s", strerror(errno)); vut->dispatch_f = accumulate; vut->dispatch_priv = NULL; vut->sighup_f = sighup; diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 6f6772b..60f46f9 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -83,7 +83,7 @@ openout(int append) else LOG.fo = VSL_WriteOpen(vut->vsl, LOG.w_arg, append, 0); if (LOG.fo == NULL) - VUT_Error(2, "Cannot open output file (%s)", + VUT_Error(vut, 2, "Cannot open output file (%s)", LOG.A_opt ? strerror(errno) : VSL_Error(vut->vsl)); vut->dispatch_priv = LOG.fo; } @@ -162,7 +162,7 @@ main(int argc, char * const *argv) usage(1); if (vut->D_opt && !LOG.w_arg) - VUT_Error(1, "Missing -w option"); + VUT_Error(vut, 1, "Missing -w option"); /* Setup output */ if (LOG.A_opt || !LOG.w_arg) diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 22391d1..979e598 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -180,7 +180,7 @@ openout(int append) AN(CTX.w_arg); CTX.fo = fopen(CTX.w_arg, append ? "a" : "w"); if (CTX.fo == NULL) - VUT_Error(1, "Can't open output file (%s)", + VUT_Error(vut, 1, "Can't open output file (%s)", strerror(errno)); } @@ -630,19 +630,19 @@ parse_x_format(char *buf) while (*e != '\0') e++; if (e == buf) - VUT_Error(1, "Missing tag in VSL:"); + VUT_Error(vut, 1, "Missing tag in VSL:"); if (e[-1] == ']') { r = e - 1; while (r > buf && *r != '[') r--; if (r == buf || r[1] == ']') - VUT_Error(1, "Syntax error: VSL:%s", buf); + VUT_Error(vut, 1, "Syntax error: VSL:%s", buf); e[-1] = '\0'; lval = strtol(r + 1, &s, 10); if (s != e - 1) - VUT_Error(1, "Syntax error: VSL:%s]", buf); + VUT_Error(vut, 1, "Syntax error: VSL:%s]", buf); if (lval <= 0 || lval > 255) { - VUT_Error(1, + VUT_Error(vut, 1, "Syntax error. Field specifier must be" " between 1 and 255: %s]", buf); @@ -661,15 +661,15 @@ parse_x_format(char *buf) r = NULL; } if (slt == -2) - VUT_Error(1, "Tag not unique: %s", buf); + VUT_Error(vut, 1, "Tag not unique: %s", buf); if (slt == -1) - VUT_Error(1, "Unknown log tag: %s", buf); + VUT_Error(vut, 1, "Unknown log tag: %s", buf); assert(slt >= 0); addf_vsl(slt, lval, r); return; } - VUT_Error(1, "Unknown formatting extension: %s", buf); + VUT_Error(vut, 1, "Unknown formatting extension: %s", buf); } static void @@ -763,7 +763,7 @@ parse_format(const char *format) while (*q && *q != '}') q++; if (!*q) - VUT_Error(1, "Unmatched bracket at: %s", + VUT_Error(vut, 1, "Unmatched bracket at: %s", p - 2); assert(q - p < sizeof buf - 1); strncpy(buf, p, q - p); @@ -783,14 +783,14 @@ parse_format(const char *format) parse_x_format(buf); break; default: - VUT_Error(1, + VUT_Error(vut, 1, "Unknown format specifier at: %s", p - 2); } p = q; break; default: - VUT_Error(1, "Unknown format specifier at: %s", + VUT_Error(vut, 1, "Unknown format specifier at: %s", p - 1); } } @@ -1131,16 +1131,16 @@ read_format(const char *formatfile) fmtfile = fopen(formatfile, "r"); if (fmtfile == NULL) - VUT_Error(1, "Can't open format file (%s)", + VUT_Error(vut, 1, "Can't open format file (%s)", strerror(errno)); AN(fmtfile); fmtlen = getline(&fmt, &len, fmtfile); if (fmtlen == -1) { free(fmt); if (feof(fmtfile)) - VUT_Error(1, "Empty format file"); + VUT_Error(vut, 1, "Empty format file"); else - VUT_Error(1, "Can't read format from file (%s)", + VUT_Error(vut, 1, "Can't read format from file (%s)", strerror(errno)); } fclose(fmtfile); @@ -1216,12 +1216,12 @@ main(int argc, char * const *argv) usage(1); if (vut->D_opt && !CTX.w_arg) - VUT_Error(1, "Missing -w option"); + VUT_Error(vut, 1, "Missing -w option"); /* Check for valid grouping mode */ assert(vut->g_arg < VSL_g__MAX); if (vut->g_arg != VSL_g_vxid && vut->g_arg != VSL_g_request) - VUT_Error(1, "Invalid grouping mode: %s", + VUT_Error(vut, 1, "Invalid grouping mode: %s", VSLQ_grouping[vut->g_arg]); /* Prepare output format */ diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 7d02906..29fae97 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -293,7 +293,7 @@ main(int argc, char * const *argv) default: i = VSM_Arg(vd, opt, optarg); if (i < 0) - VUT_Error(1, "%s", VSM_Error(vd)); + VUT_Error(vut, 1, "%s", VSM_Error(vd)); if (!i) usage(1); } @@ -306,7 +306,7 @@ main(int argc, char * const *argv) curses = 1; if (VSM_Attach(vd, STDERR_FILENO)) - VUT_Error(1, "%s", VSM_Error(vd)); + VUT_Error(vut, 1, "%s", VSM_Error(vd)); if (curses) do_curses(vd, vsc, 1.0); diff --git a/include/vut.h b/include/vut.h index 2e3a3c7..1097700 100644 --- a/include/vut.h +++ b/include/vut.h @@ -34,6 +34,7 @@ struct vopt_spec; typedef void VUT_sighandler_f(int); typedef int VUT_cb_f(struct VUT *); +typedef void VUT_error_f(struct VUT *, int, const char *, va_list); struct VUT { const char *progname; @@ -60,13 +61,13 @@ struct VUT { /* Callback functions */ VUT_cb_f *idle_f; VUT_cb_f *sighup_f; + VUT_error_f *error_f; VSLQ_dispatch_f *dispatch_f; void *dispatch_priv; }; -//lint -sem(VUT_Error, r_no) -void VUT_Error(int status, const char *fmt, ...) - __v_printflike(2, 3) __attribute__((__noreturn__)); +void VUT_Error(struct VUT *, int status, const char *fmt, ...) + __v_printflike(3, 4); int VUT_Arg(struct VUT *, int opt, const char *arg); diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 6103e9c..fe8e815 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -63,10 +63,10 @@ static struct vpf_fh *pfh; static unsigned daemonized; static int -vut_daemon(void) +vut_daemon(struct VUT *vut) { if (daemonized) - VUT_Error(1, "Already running as a daemon"); + VUT_Error(vut, 1, "Already running as a daemon"); daemonized = 1; return (varnish_daemon(0, 0)); } @@ -100,21 +100,30 @@ vut_dispatch(struct VSL_data *vsl, struct VSL_transaction * const trans[], return (i); } -void -VUT_Error(int status, const char *fmt, ...) +//lint -sem(vut_error, r_no) +static void __attribute__((__noreturn__)) __match_proto__(VUT_error_f) +vut_error(struct VUT *vut, int status, const char *fmt, va_list ap) { - va_list ap; - assert(status != 0); + AN(vut); AN(fmt); - va_start(ap, fmt); vfprintf(stderr, fmt, ap); - va_end(ap); fprintf(stderr, "\n"); exit(status); } +void +VUT_Error(struct VUT *vut, int status, const char *fmt, ...) +{ + va_list ap; + + assert(status != 0); + va_start(ap, fmt); + vut_error(vut, status, fmt, ap); + va_end(ap); +} + int VUT_Arg(struct VUT *vut, int opt, const char *arg) { @@ -135,16 +144,16 @@ VUT_Arg(struct VUT *vut, int opt, const char *arg) AN(arg); vut->g_arg = VSLQ_Name2Grouping(arg, -1); if (vut->g_arg == -2) - VUT_Error(1, "Ambiguous grouping type: %s", arg); + VUT_Error(vut, 1, "Ambiguous grouping type: %s", arg); else if (vut->g_arg < 0) - VUT_Error(1, "Unknown grouping type: %s", arg); + VUT_Error(vut, 1, "Unknown grouping type: %s", arg); return (1); case 'k': /* Log transaction limit */ AN(arg); vut->k_arg = (int)strtol(arg, &p, 10); if (*p != '\0' || vut->k_arg <= 0) - VUT_Error(1, "-k: Invalid number '%s'", arg); + VUT_Error(vut, 1, "-k: Invalid number '%s'", arg); return (1); case 'n': /* Varnish instance name */ @@ -178,7 +187,7 @@ VUT_Arg(struct VUT *vut, int opt, const char *arg) AN(vut->vsl); i = VSL_Arg(vut->vsl, opt, arg); if (i < 0) - VUT_Error(1, "%s", VSL_Error(vut->vsl)); + VUT_Error(vut, 1, "%s", VSL_Error(vut->vsl)); return (i); } } @@ -203,10 +212,11 @@ VUT_Init(const char *progname, int argc, char * const *argv, vut->progname = progname; vut->g_arg = VSL_g_vxid; + vut->k_arg = -1; + vut->error_f = vut_error; AZ(vut->vsl); vut->vsl = VSL_New(); AN(vut->vsl); - vut->k_arg = -1; return (vut); } @@ -244,45 +254,45 @@ VUT_Setup(struct VUT *vut) /* Check input arguments (2 used for bug in FlexeLint) */ if ((vut->n_arg == NULL ? 0 : 2) + (vut->r_arg == NULL ? 0 : 2) > 2) - VUT_Error(1, "Only one of -n and -r options may be used"); + VUT_Error(vut, 1, "Only one of -n and -r options may be used"); /* Create and validate the query expression */ vut->vslq = VSLQ_New(vut->vsl, NULL, vut->g_arg, vut->q_arg); if (vut->vslq == NULL) - VUT_Error(1, "Query expression error:\n%s", + VUT_Error(vut, 1, "Query expression error:\n%s", VSL_Error(vut->vsl)); /* Setup input */ if (vut->r_arg) { c = VSL_CursorFile(vut->vsl, vut->r_arg, 0); if (c == NULL) - VUT_Error(1, "%s", VSL_Error(vut->vsl)); + VUT_Error(vut, 1, "%s", VSL_Error(vut->vsl)); VSLQ_SetCursor(vut->vslq, &c); AZ(c); } else { vut->vsm = VSM_New(); AN(vut->vsm); if (vut->n_arg && VSM_Arg(vut->vsm, 'n', vut->n_arg) <= 0) - VUT_Error(1, "%s", VSM_Error(vut->vsm)); + VUT_Error(vut, 1, "%s", VSM_Error(vut->vsm)); if (vut->t_arg && VSM_Arg(vut->vsm, 't', vut->t_arg) <= 0) - VUT_Error(1, "%s", VSM_Error(vut->vsm)); + VUT_Error(vut, 1, "%s", VSM_Error(vut->vsm)); if (VSM_Attach(vut->vsm, STDERR_FILENO)) - VUT_Error(1, "VSM: %s", VSM_Error(vut->vsm)); + VUT_Error(vut, 1, "VSM: %s", VSM_Error(vut->vsm)); // Cursor is handled in VUT_Main() } /* Open PID file */ if (vut->P_arg) { if (pfh != NULL) - VUT_Error(1, "PID file already created"); + VUT_Error(vut, 1, "PID file already created"); pfh = VPF_Open(vut->P_arg, 0644, NULL); if (pfh == NULL) - VUT_Error(1, "%s: %s", vut->P_arg, strerror(errno)); + VUT_Error(vut, 1, "%s: %s", vut->P_arg, strerror(errno)); } /* Daemon mode */ - if (vut->D_opt && vut_daemon() == -1) - VUT_Error(1, "Daemon mode: %s", strerror(errno)); + if (vut->D_opt && vut_daemon(vut) == -1) + VUT_Error(vut, 1, "Daemon mode: %s", strerror(errno)); /* Write PID and setup exit handler */ if (vut->P_arg) { From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:05 +0000 (UTC) Subject: [master] becd087 Slap a magic number in struct VUT Message-ID: <20170913222105.AB1ED97C2E@lists.varnish-cache.org> commit becd087db892b41c1326ca5c0d1f0de06ca7215c Author: Dridi Boukelmoune Date: Tue Sep 12 00:04:27 2017 +0200 Slap a magic number in struct VUT diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 60f46f9..bc0c352 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -122,7 +122,7 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); VUT_Signaled(vut, sig); } diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 979e598..18eec35 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -1117,7 +1117,7 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); VUT_Signaled(vut, sig); } diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 09d939f..1282806 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -45,6 +45,7 @@ #define VOPT_DEFINITION #define VOPT_INC "varnishtop_options.h" +#include "miniobj.h" #include "vcurses.h" #include "vapi/vsl.h" #include "vapi/vsm.h" @@ -190,7 +191,7 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); VUT_Signaled(vut, sig); } diff --git a/include/vut.h b/include/vut.h index 1097700..0d731cf 100644 --- a/include/vut.h +++ b/include/vut.h @@ -37,6 +37,8 @@ typedef int VUT_cb_f(struct VUT *); typedef void VUT_error_f(struct VUT *, int, const char *, va_list); struct VUT { + unsigned magic; +#define VUT_MAGIC 0xdf3b3de8 const char *progname; /* Options */ diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index fe8e815..9845470 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -87,8 +87,8 @@ vut_dispatch(struct VSL_data *vsl, struct VSL_transaction * const trans[], struct VUT *vut; int i; - vut = priv; - AN(vut); + CAST_OBJ_NOTNULL(vut, priv, VUT_MAGIC); + if (vut->k_arg == 0) return (-1); /* End of file */ AN(vut->dispatch_f); @@ -105,7 +105,7 @@ static void __attribute__((__noreturn__)) __match_proto__(VUT_error_f) vut_error(struct VUT *vut, int status, const char *fmt, va_list ap) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); AN(fmt); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); @@ -202,7 +202,7 @@ VUT_Init(const char *progname, int argc, char * const *argv, AN(argv); AN(voc); - vut = calloc(1, sizeof *vut); + ALLOC_OBJ(vut, VUT_MAGIC); AN(vut); if (argc == 2 && !strcmp(argv[1], "--synopsis")) @@ -235,7 +235,7 @@ void VUT_Signaled(struct VUT *vut, int sig) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); vut->sighup |= (sig == SIGHUP); vut->sigint |= (sig == SIGINT || sig == SIGTERM); vut->sigusr1 |= (sig == SIGUSR1); @@ -246,7 +246,7 @@ VUT_Setup(struct VUT *vut) { struct VSL_cursor *c; - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); AN(vut->vsl); AZ(vut->vsm); AZ(vut->vslq); @@ -307,11 +307,7 @@ VUT_Fini(struct VUT **vutp) { struct VUT *vut; - AN(vutp); - vut = *vutp; - *vutp = NULL; - - AN(vut); + TAKE_OBJ_NOTNULL(vut, vutp, VUT_MAGIC); AN(vut->progname); free(vut->n_arg); @@ -331,7 +327,7 @@ VUT_Fini(struct VUT **vutp) VSM_Destroy(&vut->vsm); memset(vut, 0, sizeof *vut); - free(vut); + FREE_OBJ(vut); } int @@ -341,7 +337,7 @@ VUT_Main(struct VUT *vut) int i = -1; int hascursor = -1; - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); AN(vut->vslq); while (!vut->sigint) { From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:05 +0000 (UTC) Subject: [master] 7ec0071 Promote VUT headers Message-ID: <20170913222105.CA6AA97C3C@lists.varnish-cache.org> commit 7ec0071d1e57bfdf0fa61785f47fbc601c62e8a6 Author: Dridi Boukelmoune Date: Tue Apr 18 09:35:22 2017 +0200 Promote VUT headers The corresponding symbols were already in libvarnishapi since 1.5! diff --git a/include/Makefile.am b/include/Makefile.am index 2feb37f..a77cae9 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -48,7 +48,9 @@ nobase_pkginclude_HEADERS = \ vapi/vsl_int.h \ vapi/voptget.h \ vapi/vapi_options.h \ - vcli.h + vcli.h \ + vut.h \ + vut_options.h # Headers for use with vmods nobase_pkginclude_HEADERS += \ @@ -95,9 +97,7 @@ nobase_noinst_HEADERS = \ vsub.h \ vss.h \ vtcp.h \ - vtree.h \ - vut.h \ - vut_options.h + vtree.h GENERATED_H = \ tbl/vrt_stv_var.h \ From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:05 +0000 (UTC) Subject: [master] 2b39b58 New autoconf macro for VUT manual boilerplate Message-ID: <20170913222105.E4BB297C41@lists.varnish-cache.org> commit 2b39b58a3871fc73cb15a218137bf825289a98ce Author: Dridi Boukelmoune Date: Tue Sep 12 20:28:51 2017 +0200 New autoconf macro for VUT manual boilerplate For out-of-tree utilities. diff --git a/varnish.m4 b/varnish.m4 index b56d2fc..c58392c 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -373,6 +373,123 @@ AC_DEFUN([VARNISH_VMODS], [ [_VARNISH_VMOD(_vmod_name)]) ]) +# _VARNISH_UTILITY(NAME) +# ---------------------- +AC_DEFUN([_VARNISH_UTILITY], [ + + VUT_RULES=" + +$1_synopsis.rst: $1 + \$(A""M_V_GEN) ./$1 --synopsis >$1_synopsis.rst + +$1_options.rst: $1 + \$(A""M_V_GEN) ./$1 --options >$1_options.rst + +$1.rst: $1_synopsis.rst $1_options.rst + +" + + AC_SUBST(m4_toupper(GENERATE_$1_DOCS), [$VUT_RULES]) + m4_ifdef([_AM_SUBST_NOTMAKE], + [_AM_SUBST_NOTMAKE(m4_toupper(GENERATE_$1_DOCS))]) + + AC_SUBST(m4_toupper(GENERATED_$1_DOCS), + ["$1_synopsis.rst $1_options.rst"]) +]) + +# VARNISH_UTILITIES(NAMES) +# ------------------------ +# Since: Varnish 5.2.0 +# +# To write programs that consume the VSM, and in particular the VSL, it is +# possible since Varnish 5.2.0 to use the VUT (Varnish UTility) API already +# used by varnishlog, varnishstat and the other utilities from the standard +# Varnish distribution. +# +# This API can optionally be used to generate part of the manual: the synopsis +# and the list of options. The generated RST files can then be included from +# the main RST file that is written manually. +# +# For example, if you define the following in configure.ac: +# +# VARNISH_UTILITIES([foo bar]) +# +# Two build rules will be available for use in Makefile.am for the programs +# foo and bar: +# +# bin_PROGRAMS = foo bar +# +# [...] +# +# @GENERATE_FOO_DOCS@ +# @GENERATE_BAR_DOCS@ +# +# If the API is used in a way that enables the generation of the synopsis and +# the list of options, they will automatically be regenerated whenever the foo +# and bar programs are rebuilt, and marked as dependencies for RST manuals +# named foo.rst and bar.rst. +# +# In the manual you can then include the generated documentation in the +# relevant sections: +# +# SYNOPSIS +# ======== +# +# .. include:: foo_synopsis.rst +# foo |synopsis| +# +# DESCRIPTION +# =========== +# +# [...] +# +# The following options are available: +# +# .. include:: foo_options.rst +# +# This however won't work in a VPATH build, so instead of authoring foo.rst +# and bar.rst, a better solution is to create foo.rst.in and bar.rst.in files +# and add them to the AC_CONFIG_FILES macro in configure.ac. For example, if +# foo.rst.in and bar.rst.in are located in the src/ directory: +# +# AC_CONFIG_FILES([ +# [...] +# src/foo.rst +# src/bar.rst +# ]) +# +# Then you can include the build directory, either relative or absolute, to +# the include directives: +# +# SYNOPSIS +# ======== +# +# .. include:: @builddir@/foo_synopsis.rst +# foo |synopsis| +# +# DESCRIPTION +# =========== +# +# [...] +# +# The following options are available: +# +# .. include:: @builddir@/foo_options.rst +# +# This will ensure that foo.rst and bar.rst always find the generated files +# when the source directory is different from the build directory. Finally, +# the generated files are exposed in a variable to help clean them: +# +# CLEANFILES += $(GENERATED_FOO_DOCS) $(GENERATED_BAR_DOCS) +# +# It is the maintainer's responsibility to build the actual manuals. +# +AC_DEFUN([VARNISH_UTILITIES], [ + m4_foreach([_vut_name], + m4_split(m4_normalize([$1])), + [_VARNISH_UTILITY(_vut_name)]) +]) + # VARNISH_PREREQ(MINIMUM-VERSION, [MAXIMUM-VERSION]) # -------------------------------------------------- # Since: Varnish 4.1.4 From dridi.boukelmoune at gmail.com Wed Sep 13 22:21:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 22:21:06 +0000 (UTC) Subject: [master] 65a453c What's new? VUT Message-ID: <20170913222106.0AE5B97C4E@lists.varnish-cache.org> commit 65a453c551e317a372569ff11fdeb5b9c8713b18 Author: Dridi Boukelmoune Date: Wed Sep 13 16:48:39 2017 +0200 What's new? VUT diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 7dced4d..b9585ce 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -156,9 +156,26 @@ does not require strict ABI compliance. .. _whatsnew_vut_5.2: -New VUT API ------------ - -XXX: document once merged +Added VUT API +------------- + +One way to extend Varnish is to write VSM clients, programs that tap +into the Varnish Shared Memory (VSM) usually via ``libvarnishapi`` or +community bindings for other languages than C. Varnish already ships +with VUTs (Varnish UTilities) that either process the Varnish Shared +Log (VSL) like ``varnishlog`` or ``varnishncsa`` or the Varnish Shared +Counters (VSC) like ``varnishstat``. + +Most of the setup for these programs is similar, and so they shared an +API that is now available outside of the Varnish source tree. The VUT +API has been cleaned up to remove assumptions made for our utilities. +It hides most of the complexity and redundancy of setting up a log +processor and helps you focus on your functionality. If you use +autotools for building, a new macro in ``varnish.m4`` removes some of +the boilerplate to generate part of the documentation. + +We hope that much like VMODs we will see new tools that take advantage +of this API to extend Varnish in new ways much like VMODs made it easy +to add new functionality to VCL. *EOF* From dridi.boukelmoune at gmail.com Wed Sep 13 23:10:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 23:10:06 +0000 (UTC) Subject: [master] 48158f9 Missing header Message-ID: <20170913231006.75786977A8@lists.varnish-cache.org> commit 48158f9094f855e748216054546d793af8c07283 Author: Dridi Boukelmoune Date: Thu Sep 14 01:07:51 2017 +0200 Missing header diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index bc0c352..e0a4846 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -32,6 +32,7 @@ #include "config.h" +#include #include #include #include From dridi.boukelmoune at gmail.com Wed Sep 13 23:25:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 23:25:04 +0000 (UTC) Subject: [master] 24441d0 Actually use the configured VUT error callback Message-ID: <20170913232504.12A6F97DB4@lists.varnish-cache.org> commit 24441d04ec51096a78d7e40e77f75c08a7d472bb Author: Dridi Boukelmoune Date: Thu Sep 14 01:23:03 2017 +0200 Actually use the configured VUT error callback diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 9845470..1438195 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -118,9 +118,12 @@ VUT_Error(struct VUT *vut, int status, const char *fmt, ...) { va_list ap; - assert(status != 0); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); + AN(vut->error_f); + AN(status); + va_start(ap, fmt); - vut_error(vut, status, fmt, ap); + vut->error_f(vut, status, fmt, ap); va_end(ap); } From dridi.boukelmoune at gmail.com Wed Sep 13 23:25:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 23:25:04 +0000 (UTC) Subject: [master] 2d01d74 Documentation placeholder for varnishd -l Message-ID: <20170913232504.27CD497DB7@lists.varnish-cache.org> commit 2d01d74ef6cb28f1c69ba6c88b3f32fc10390b82 Author: Dridi Boukelmoune Date: Thu Sep 14 01:24:21 2017 +0200 Documentation placeholder for varnishd -l diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index c932fca..f901330 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -149,6 +149,10 @@ Other changes * ``varnishd(1)``: + .. XXX phk, a word on -l changes and the implications on how the + working directory may grow in size? This may be a problem + when /var/lib/varnish is mounted in RAM. + * The default value of ``server.identity`` when the ``-i`` option is not set has been changed as noted above. From dridi.boukelmoune at gmail.com Wed Sep 13 23:52:03 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Sep 2017 23:52:03 +0000 (UTC) Subject: [master] 8e75286 Missing header Message-ID: <20170913235203.E6E42977F8@lists.varnish-cache.org> commit 8e752868b1f2282326854e2a33f0521157af0289 Author: Dridi Boukelmoune Date: Thu Sep 14 01:50:49 2017 +0200 Missing header diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index b8ebc19..4770249 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 29fae97..5b31ee9 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -32,6 +32,7 @@ #include "config.h" +#include #include #include #include diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 1282806..8dfa516 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include From geoff at uplex.de Thu Sep 14 06:32:07 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 06:32:07 +0000 (UTC) Subject: [master] 7c67ee9 Typos Message-ID: <20170914063207.204AD973D5@lists.varnish-cache.org> commit 7c67ee9e91271a234d8eb56b07c728c1b0596c44 Author: Geoff Simmons Date: Thu Sep 14 08:31:30 2017 +0200 Typos diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index f901330..8b23e6c 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -235,9 +235,9 @@ Other changes * Field specifiers (such as the 1 in ``Hit[1]``) are now limited to to 255, see :ref:`varnishncsa(1)`. -* The ``-N`` command-line option, which was previously availabe for +* The ``-N`` command-line option, which was previously available for ``varnishlog(1)``, ``varnishstat(1)``, ``varnishncsa(1)`` and - ``varnishhist(1)``, is not comaptible with the changed internal + ``varnishhist(1)``, is not compatible with the changed internal logging API, and has been retired. * *XXX: any other changes in the standard VUT tools* From geoff at uplex.de Thu Sep 14 06:37:03 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 06:37:03 +0000 (UTC) Subject: [master] 8a7eb32 VMOD blob: move the $ABI declaration to the bottom of the VCC file. Message-ID: <20170914063703.B0AD897686@lists.varnish-cache.org> commit 8a7eb321f5c21733add3d33dc1be420538be76d7 Author: Geoff Simmons Date: Thu Sep 14 08:35:40 2017 +0200 VMOD blob: move the $ABI declaration to the bottom of the VCC file. Like $Event, $ABI has the effect of making generated docs until the next $-directive disappear. diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 96dea4e..e1db306 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -7,7 +7,6 @@ # $Module blob 3 utilities for the VCL blob type -$ABI strict :: @@ -425,3 +424,5 @@ SEE ALSO * :ref:`varnishd(1)` * :ref:`vcl(7)` * :ref:`vmod_std(3)` + +$ABI strict From geoff at uplex.de Thu Sep 14 06:47:02 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 06:47:02 +0000 (UTC) Subject: [master] 4c48697 Editorial: change a section heading in Upgrading to 5.2. Message-ID: <20170914064702.E96C997B26@lists.varnish-cache.org> commit 4c48697a31f359934675fd5a5d991bff4c140882 Author: Geoff Simmons Date: Thu Sep 14 08:45:49 2017 +0200 Editorial: change a section heading in Upgrading to 5.2. server.identity is not a new VCL variable. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8b23e6c..364cc01 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -72,8 +72,8 @@ dashes in a vmod symbol. Long storage backend names used to be truncated due to a limitation in the VSC subsystem, this is no longer the case. -New VCL variables -~~~~~~~~~~~~~~~~~ +VCL variables +~~~~~~~~~~~~~ ``req.hash`` and ``bereq.hash`` ------------------------------- @@ -109,11 +109,11 @@ not set). See :ref:`varnishd(1)`. ``bereq.is_bgfetch`` -------------------- -``bereq.is_bgfetch`` is readable in backend contexts, and is true if -the fetch takes place in the background. That is, it is true if -Varnish found a response in the cache whose TTL was expired, but was -still in grace time. Varnish returns the stale cached response to the -client, and initiates the background fetch to refresh the cache +Added ``bereq.is_bgfetch``, which is readable in backend contexts, and +is true if the fetch takes place in the background. That is, it is +true if Varnish found a response in the cache whose TTL was expired, +but was still in grace time. Varnish returns the stale cached response +to the client, and initiates the background fetch to refresh the cache object. XXX: vcl_sub_XXX ... From phk at FreeBSD.org Thu Sep 14 07:15:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 07:15:06 +0000 (UTC) Subject: [master] 562e19c Make failure to submit results non-fatal. Message-ID: <20170914071506.AF404974D3@lists.varnish-cache.org> commit 562e19cfe7e2d327f5e61643553612ede2481ad9 Author: Poul-Henning Kamp Date: Thu Sep 14 07:14:21 2017 +0000 Make failure to submit results non-fatal. diff --git a/tools/vtest.sh b/tools/vtest.sh index 4bb8ffe..e990d10 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -283,5 +283,9 @@ do fi echo "VTEST END" >> ${VTEST_REPORT} pack > ${TMPDIR}/_report.tgz - submit ${TMPDIR}/_report.tgz + + submit ${TMPDIR}/_report.tgz || \ + sleep 300 || \ + submit ${TMPDIR}/_report.tgz || \ + true done From geoff at uplex.de Thu Sep 14 07:26:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 07:26:04 +0000 (UTC) Subject: [master] 7e2b6b3 Mention support for sanitizers in Upgrading to 5.2. Message-ID: <20170914072604.8527C97A0C@lists.varnish-cache.org> commit 7e2b6b3968ebc28800b64ee268ff16c48c75bae9 Author: Geoff Simmons Date: Thu Sep 14 09:24:39 2017 +0200 Mention support for sanitizers in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 364cc01..b28c328 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -265,7 +265,12 @@ Other changes it possible for VMOD authors to load their code into a debugger after a varnishd crash. See :ref:`ref_param_debug`. - * *XXX: anything else, such as sanitizer flags?* + * The project build tools now facilitate the use of sanitizer flags + (``-fsanitize`` for the compiler and ``ld``), for undefined + behavior, threads, addresses and memory. See the options + ``--enable-ubsan``, ``--enable-tsan``, ``--enable-asan`` and + ``--enable-msan`` for the ``configure`` script generated by + autoconf. * *XXX: ...* From geoff at uplex.de Thu Sep 14 08:01:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 08:01:04 +0000 (UTC) Subject: [master] f4eb483 Mention clarification of req.backend_hint and restarts as of 5.2. Message-ID: <20170914080104.E923497674@lists.varnish-cache.org> commit f4eb4832ec9c96836cabb06ad4c66e7f16b0481b Author: Geoff Simmons Date: Thu Sep 14 10:00:20 2017 +0200 Mention clarification of req.backend_hint and restarts as of 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index b28c328..196fcf0 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -116,6 +116,14 @@ but was still in grace time. Varnish returns the stale cached response to the client, and initiates the background fetch to refresh the cache object. +``req.backend_hint`` +-------------------- + +We have clarified what happens to ``req.backend_hint`` on a client +restart -- it gets reset to the default backend. So you might want to +make sure that the backend hint gets set the way you want in that +situation. + XXX: vcl_sub_XXX ... ~~~~~~~~~~~~~~~~~~~~ From geoff at uplex.de Thu Sep 14 08:10:06 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 08:10:06 +0000 (UTC) Subject: [master] 09b656f Document addition of counter req_dropped in 5.2. Message-ID: <20170914081006.41E0297AD1@lists.varnish-cache.org> commit 09b656fea23a263605ae215c264ccb60a95c5b97 Author: Geoff Simmons Date: Thu Sep 14 10:07:15 2017 +0200 Document addition of counter req_dropped in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 196fcf0..77a063d 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -201,6 +201,11 @@ Other changes * The ``MAIN.s_req`` statistic has been removed, as it was identical to ``MAIN.client_req``. + * Added the counter ``req_dropped``. Similar to ``sess_dropped``, + this is the number of times an HTTP/2 stream was refused because + the internal queue is full. See :ref:`varnish-counters(7)` and + :ref:`ref_param_thread_queue_limit`. + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: From geoff at uplex.de Thu Sep 14 08:16:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 08:16:04 +0000 (UTC) Subject: [master] 6e97427 Sanitizer support is not new in 5.2 after all. Message-ID: <20170914081604.DBCAE97E82@lists.varnish-cache.org> commit 6e974272f2c6a43fc85c4c76f646b875f10dae00 Author: Geoff Simmons Date: Thu Sep 14 10:15:09 2017 +0200 Sanitizer support is not new in 5.2 after all. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 77a063d..c66b488 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -278,13 +278,6 @@ Other changes it possible for VMOD authors to load their code into a debugger after a varnishd crash. See :ref:`ref_param_debug`. - * The project build tools now facilitate the use of sanitizer flags - (``-fsanitize`` for the compiler and ``ld``), for undefined - behavior, threads, addresses and memory. See the options - ``--enable-ubsan``, ``--enable-tsan``, ``--enable-asan`` and - ``--enable-msan`` for the ``configure`` script generated by - autoconf. - * *XXX: ...* * *XXX: other changes in tools and infrastructure in and around From geoff at uplex.de Thu Sep 14 08:25:06 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 08:25:06 +0000 (UTC) Subject: [master] b95d5c3 Document changed format for VCL_trace logs in 5.2. Message-ID: <20170914082506.2DA209723D@lists.varnish-cache.org> commit b95d5c3faae7242b92794d3b84149d0d887ea0cb Author: Geoff Simmons Date: Thu Sep 14 10:23:37 2017 +0200 Document changed format for VCL_trace logs in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index c66b488..1ecfe00 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -229,6 +229,11 @@ Other changes See :ref:`vsl(7)`. + * The output format of ``VCL_trace`` log records, which appear if + you have switched on the ``VCL_trace`` flag in the VSL mask, has + changed to include the VCL configuration name. See :ref:`vsl(7)` + and :ref:`ref_param_vsl_mask`. + * ``varnishtest(1)`` and ``vtc(7)``: * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* From dridi.boukelmoune at gmail.com Thu Sep 14 08:47:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 14 Sep 2017 08:47:06 +0000 (UTC) Subject: [master] 3327a1a Don't swallow RST with the $ABI stanza Message-ID: <20170914084706.1436897A3B@lists.varnish-cache.org> commit 3327a1a0fa9178e0f55c924432444c55ef184cea Author: Dridi Boukelmoune Date: Thu Sep 14 10:45:10 2017 +0200 Don't swallow RST with the $ABI stanza diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index b7f58e5..d2e7a30 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -484,6 +484,7 @@ class s_abi(stanza): err("Valid ABI types are 'strict' or 'vrt', got '%s'\n" % self.line[1]) strict_abi = self.line[1] == 'strict' + self.vcc.contents.append(self) class s_event(stanza): def parse(self): diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index e1db306..96dea4e 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -7,6 +7,7 @@ # $Module blob 3 utilities for the VCL blob type +$ABI strict :: @@ -424,5 +425,3 @@ SEE ALSO * :ref:`varnishd(1)` * :ref:`vcl(7)` * :ref:`vmod_std(3)` - -$ABI strict From geoff at uplex.de Thu Sep 14 08:55:07 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 08:55:07 +0000 (UTC) Subject: [master] 3696f77 Document deprecation of -p vsm_space in 5.2. Message-ID: <20170914085507.3320D97ECE@lists.varnish-cache.org> commit 3696f776da3d470a48047bfa6a3e41fdddde70d8 Author: Geoff Simmons Date: Thu Sep 14 10:54:24 2017 +0200 Document deprecation of -p vsm_space in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 1ecfe00..936764b 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -13,9 +13,11 @@ counters, but these should all be transparent at the user-level. varnishd parameters =================== -The :ref:`ref_param_cli_buffer` parameter is deprecated and -ignored. Memory for the CLI command buffer is now dynamically -allocated. +The :ref:`ref_param_vsm_space` and :ref:`ref_param_cli_buffer` +parameters are now deprecated and ignored. The updated logging +implementation manages space automatically, so it no longer needs +:ref:`ref_param_vsm_space`. Memory for the CLI command buffer is now +dynamically allocated. We have updated the documentation for :ref:`ref_param_send_timeout`, :ref:`ref_param_idle_send_timeout`, :ref:`ref_param_timeout_idle` and From geoff at uplex.de Thu Sep 14 09:31:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 09:31:04 +0000 (UTC) Subject: [master] 11661d9 Remove some of the XXX's in the release notes for 5.2. Message-ID: <20170914093104.CC03497D67@lists.varnish-cache.org> commit 11661d9dfac624fe638587bfec76cf53c095b86f Author: Geoff Simmons Date: Thu Sep 14 11:30:25 2017 +0200 Remove some of the XXX's in the release notes for 5.2. We seem to have most of it. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index b9585ce..8a125e9 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -63,16 +63,9 @@ conveniences were added like workspace manipulations. See :ref:`vmod_vtc(3)`. -XXX: Any other headline changes ... -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*XXX: ...* - News for authors of VMODs and Varnish API client applications ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*XXX: such news may include:* - .. _whatsnew_abi: $ABI [strict|vrt] diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 936764b..e6fc93f 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -37,11 +37,6 @@ Changes to VCL *XXX: ... or reassure that you probably don't have to do anything* *to migrate from 5.1 to 5.2* -XXX: headline changes ... -~~~~~~~~~~~~~~~~~~~~~~~~~ - -*XXX: the most important changes or additions first* - Consistent symbol names ~~~~~~~~~~~~~~~~~~~~~~~ @@ -126,16 +121,6 @@ restart -- it gets reset to the default backend. So you might want to make sure that the backend hint gets set the way you want in that situation. -XXX: vcl_sub_XXX ... -~~~~~~~~~~~~~~~~~~~~ - -*XXX: list changes by VCL sub* - -XXX: more VCL changes ... -~~~~~~~~~~~~~~~~~~~~~~~~~ - -*XXX: any more details and new features that VCL authors have to know* - vmod_std ~~~~~~~~ @@ -208,8 +193,6 @@ Other changes the internal queue is full. See :ref:`varnish-counters(7)` and :ref:`ref_param_thread_queue_limit`. - * *XXX: anything else? stats added, removed or changed?* - * ``varnishlog(1)``: * The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an @@ -248,8 +231,6 @@ Other changes * Added the feature switch ``ignore_unknown_macro`` for test cases, see :ref:`vtc(7)`. - * *XXX: ...* - * ``varnishncsa(1)`` * Field specifiers (such as the 1 in ``Hit[1]``) are now limited to @@ -260,10 +241,6 @@ Other changes ``varnishhist(1)``, is not compatible with the changed internal logging API, and has been retired. -* *XXX: any other changes in the standard VUT tools* - - * *XXX: ...* - * Changes for developers: * The VSM and VSC APIs for shared memory and statistics have @@ -284,12 +261,3 @@ Other changes up its copies of VMOD shared objects when it stops. This makes it possible for VMOD authors to load their code into a debugger after a varnishd crash. See :ref:`ref_param_debug`. - - * *XXX: ...* - -* *XXX: other changes in tools and infrastructure in and around - Varnish ...* - - * *XXX: anything new about project tools, VTEST & GCOV, etc?* - - * *XXX: ...* From phk at FreeBSD.org Thu Sep 14 09:32:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 09:32:05 +0000 (UTC) Subject: [master] 1b5e969 Fleshe out the -l XXX Message-ID: <20170914093205.12DB497F49@lists.varnish-cache.org> commit 1b5e969bb5edd7b489f0565db42b47e524fef82d Author: Poul-Henning Kamp Date: Thu Sep 14 09:31:21 2017 +0000 Fleshe out the -l XXX diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index e6fc93f..477efe4 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -144,9 +144,9 @@ Other changes * ``varnishd(1)``: - .. XXX phk, a word on -l changes and the implications on how the - working directory may grow in size? This may be a problem - when /var/lib/varnish is mounted in RAM. + * The total size of the shared memory space for logs and counters + no longer needs to be configured explicitly and therefore the + second subargument to ``-l`` is now ignored. * The default value of ``server.identity`` when the ``-i`` option is not set has been changed as noted above. From phk at FreeBSD.org Thu Sep 14 09:40:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 09:40:06 +0000 (UTC) Subject: [master] 71d8abb Amazing that neither Coverity or FlexeLint complained about the syslog-ism "%m" being used in vsnprintf() via VSB. Message-ID: <20170914094006.1B8DD97328@lists.varnish-cache.org> commit 71d8abbee9fcc2b3d7862268ea76b79b5a199cd8 Author: Poul-Henning Kamp Date: Thu Sep 14 09:37:57 2017 +0000 Amazing that neither Coverity or FlexeLint complained about the syslog-ism "%m" being used in vsnprintf() via VSB. That said, it would have been damn convenient of %m was also usable in *printf(3)... diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 4d23bba..f00e19a 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -622,7 +622,8 @@ Marg_connect(const struct vev *e, int what) M_fd = VTCP_connected(M_fd); if (M_fd < 0) { - MGT_Complain(C_INFO, "Could not connect to CLI-master: %m"); + MGT_Complain(C_INFO, "Could not connect to CLI-master: %s", + strerror(errno)); ma = VTAILQ_FIRST(&m_addr_list); AN(ma); VTAILQ_REMOVE(&m_addr_list, ma, list); From geoff at uplex.de Thu Sep 14 09:45:06 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 09:45:06 +0000 (UTC) Subject: [master] a1dcdd9 Intro sentences to "Changes to VCL" for 5.2. Message-ID: <20170914094506.EFB459761F@lists.varnish-cache.org> commit a1dcdd931f8f66fc206295684bc2fd1ddf748c63 Author: Geoff Simmons Date: Thu Sep 14 11:44:24 2017 +0200 Intro sentences to "Changes to VCL" for 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 477efe4..8c335e6 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -29,13 +29,8 @@ the notes about changes for developers below. Changes to VCL ============== -*XXX: intro paragraph* - -*XXX: emphasize what most likely needs to be done, if anything,* -*to migrate from 5.1 to 5.2* - -*XXX: ... or reassure that you probably don't have to do anything* -*to migrate from 5.1 to 5.2* +We have added a few new variables and clarified some matters. VCL +written for Varnish 5.1 should run without changes on 5.2. Consistent symbol names ~~~~~~~~~~~~~~~~~~~~~~~ From geoff at uplex.de Thu Sep 14 10:01:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 10:01:04 +0000 (UTC) Subject: [master] d0a3cec Minor polish in the release docs for 5.2. Message-ID: <20170914100104.BC12997E8E@lists.varnish-cache.org> commit d0a3cec11ce9de086d2a239135cdcdbd90ccc75d Author: Geoff Simmons Date: Thu Sep 14 11:59:53 2017 +0200 Minor polish in the release docs for 5.2. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 8a125e9..ebd421e 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -47,7 +47,7 @@ VMOD vtc -------- As long as we have had VMODs, we had an internal vmod called ``vmod_debug`` -which were used with ``varnishtest`` to exercise the VMOD related parts of +which was used with ``varnishtest`` to exercise the VMOD related parts of ``varnishd``. Over time this vmod grew other useful functions for writing test-cases. @@ -167,8 +167,6 @@ processor and helps you focus on your functionality. If you use autotools for building, a new macro in ``varnish.m4`` removes some of the boilerplate to generate part of the documentation. -We hope that much like VMODs we will see new tools that take advantage -of this API to extend Varnish in new ways much like VMODs made it easy -to add new functionality to VCL. - -*EOF* +We hope that we will see new tools that take advantage of this API to +extend Varnish in new ways, much like VMODs made it easy to add new +functionality to VCL. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8c335e6..686dde3 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -94,7 +94,7 @@ You can use :ref:`vmod_blob(3)` to work with the hashes:: If the ``-i`` option is not set in the invocation of ``varnishd``, then ``server.identity`` is set to the host name (as returned by -``gethostname(3)``). Previously, ``server.identity`` was set to the +``gethostname(3)``). Previously, ``server.identity`` defaulted to the value of the ``-n`` option (or the default instance name if ``-n`` was not set). See :ref:`varnishd(1)`. @@ -125,7 +125,7 @@ New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and -:ref:`vmod_vtc(3)`. See :ref:`whatsnew_new_vmods`. +:ref:`vmod_vtc(3)`. Read about them in :ref:`whatsnew_new_vmods`. Bans ~~~~ @@ -172,7 +172,7 @@ Other changes * In curses mode, the top two lines showing uptimes for the management and child processes show the text ``Not Running`` if - either or both of the processes are down. + one or both of the processes are down. * The interpretation of multiple ``-f`` options in the command line has changed slightly, see :ref:`varnishstat(1)`. @@ -193,7 +193,7 @@ Other changes * The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an additional field with the remaining TTL of the object at the time of the lookup. While this should greatly help troubleshooting, - this might break tools relying on those records to get the VXID of + it might break tools relying on those records to get the VXID of the object hit during lookup. Instead of using ``Hit``, such tools should now use ``Hit[1]``, From phk at FreeBSD.org Thu Sep 14 16:14:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 16:14:05 +0000 (UTC) Subject: [master] be1b87b Minor constification Message-ID: <20170914161405.A51D898868@lists.varnish-cache.org> commit be1b87bcdfea76eb18a04bb12b527e80cd8e2fe3 Author: Poul-Henning Kamp Date: Thu Sep 14 16:13:32 2017 +0000 Minor constification diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index baafa66..000d505 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -150,7 +150,7 @@ VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id) } struct vmod_priv * -VRT_priv_task(VRT_CTX, void *vmod_id) +VRT_priv_task(VRT_CTX, const void *vmod_id) { uintptr_t id; @@ -169,7 +169,7 @@ VRT_priv_task(VRT_CTX, void *vmod_id) } struct vmod_priv * -VRT_priv_top(VRT_CTX, void *vmod_id) +VRT_priv_top(VRT_CTX, const void *vmod_id) { uintptr_t id; diff --git a/include/vrt.h b/include/vrt.h index 9f1ad5e..3d59bfe 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -358,8 +358,8 @@ struct vclref * VRT_ref_vcl(VRT_CTX, const char *); void VRT_rel_vcl(VRT_CTX, struct vclref **); void VRT_priv_fini(const struct vmod_priv *p); -struct vmod_priv *VRT_priv_task(VRT_CTX, void *vmod_id); -struct vmod_priv *VRT_priv_top(VRT_CTX, void *vmod_id); +struct vmod_priv *VRT_priv_task(VRT_CTX, const void *vmod_id); +struct vmod_priv *VRT_priv_top(VRT_CTX, const void *vmod_id); /* Stevedore related functions */ int VRT_Stv(const char *nm); From phk at FreeBSD.org Thu Sep 14 16:24:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 16:24:05 +0000 (UTC) Subject: [master] 85eeae6 Make the (v)bprintf() macros also check for negative return values. Message-ID: <20170914162405.78E1E98CB2@lists.varnish-cache.org> commit 85eeae6b98f7a87000d5e85beb4f6d4bd55d6168 Author: Poul-Henning Kamp Date: Thu Sep 14 16:22:35 2017 +0000 Make the (v)bprintf() macros also check for negative return values. diff --git a/include/vdef.h b/include/vdef.h index af51c47..b7fee8b 100644 --- a/include/vdef.h +++ b/include/vdef.h @@ -38,15 +38,17 @@ /* Safe printf into a fixed-size buffer */ #define bprintf(buf, fmt, ...) \ do { \ - assert(snprintf(buf, sizeof buf, fmt, __VA_ARGS__) \ - < sizeof buf); \ + int ibprintf; \ + ibprintf = snprintf(buf, sizeof buf, fmt, __VA_ARGS__); \ + assert(ibprintf >= 0 && ibprintf < sizeof buf); \ } while (0) /* Safe printf into a fixed-size buffer */ #define vbprintf(buf, fmt, ap) \ do { \ - assert(vsnprintf(buf, sizeof buf, fmt, ap) \ - < sizeof buf); \ + int ivbprintf; \ + ivbprintf = vsnprintf(buf, sizeof buf, fmt, ap); \ + assert(ivbprintf >= 0 && ivbprintf < sizeof buf); \ } while (0) /* Close and discard filedescriptor */ From phk at FreeBSD.org Thu Sep 14 16:43:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 16:43:04 +0000 (UTC) Subject: [master] 9ad80c8 Slightly change VAS so that we always call a function on panic, and let that check if another function is desired. Message-ID: <20170914164304.D3A5C973B2@lists.varnish-cache.org> commit 9ad80c88f26d9a90d21b59f265d31be61ae545a0 Author: Poul-Henning Kamp Date: Thu Sep 14 16:42:13 2017 +0000 Slightly change VAS so that we always call a function on panic, and let that check if another function is desired. diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 0d329e1..6601b29 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -691,7 +691,7 @@ PAN_Init(void) { AZ(pthread_mutex_init(&panicstr_mtx, NULL)); - VAS_Fail = pan_ic; + VAS_Fail_Func = pan_ic; pan_vsb = &pan_vsb_storage; AN(heritage.panic_str); AN(heritage.panic_str_len); diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index df786e8..a764d1f 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -292,7 +292,7 @@ void vtc_loginit(char *buf, unsigned buflen) { - VAS_Fail = vtc_log_VAS_Fail; + VAS_Fail_Func = vtc_log_VAS_Fail; t0 = VTIM_mono(); vtclog_buf = buf; vtclog_left = buflen; diff --git a/include/vas.h b/include/vas.h index 591d99e..ec4adc5 100644 --- a/include/vas.h +++ b/include/vas.h @@ -46,9 +46,11 @@ enum vas_e { VAS_VCL, }; -typedef void vas_f(const char *, const char *, int, const char *, enum vas_e); +typedef void vas_f(const char *, const char *, int, const char *, enum vas_e) + __attribute__((__noreturn__)); -extern vas_f *VAS_Fail __attribute__((__noreturn__)); +extern vas_f *VAS_Fail_Func __attribute__((__noreturn__)); +extern vas_f VAS_Fail __attribute__((__noreturn__)); #ifdef WITHOUT_ASSERTS #define assert(e) ((void)(e)) diff --git a/lib/libvarnish/binary_heap.c b/lib/libvarnish/binary_heap.c index 9799276..beb9a64 100644 --- a/lib/libvarnish/binary_heap.c +++ b/lib/libvarnish/binary_heap.c @@ -470,7 +470,7 @@ vasfail(const char *func, const char *file, int line, abort(); } -vas_f *VAS_Fail = vasfail; +vas_f *VAS_Fail_Func = vasfail; struct foo { unsigned magic; diff --git a/lib/libvarnish/vas.c b/lib/libvarnish/vas.c index 0c857a0..3d7f631 100644 --- a/lib/libvarnish/vas.c +++ b/lib/libvarnish/vas.c @@ -38,35 +38,39 @@ #include "vas.h" -static void __attribute__((__noreturn__)) -VAS_Fail_default(const char *func, const char *file, int line, +vas_f *VAS_Fail_Func __attribute__((__noreturn__)); + +void __attribute__((__noreturn__)) +VAS_Fail(const char *func, const char *file, int line, const char *cond, enum vas_e kind) { int err = errno; - if (kind == VAS_MISSING) { - fprintf(stderr, - "Missing error handling code in %s(), %s line %d:\n" - " Condition(%s) not true.\n", - func, file, line, cond); - } else if (kind == VAS_INCOMPLETE) { - fprintf(stderr, - "Incomplete code in %s(), %s line %d:\n", - func, file, line); - } else if (kind == VAS_WRONG) { - fprintf(stderr, - "Wrong turn in %s(), %s line %d: %s\n", - func, file, line, cond); + if (VAS_Fail_Func != NULL) { + VAS_Fail_Func(func, file, line, cond, kind); } else { - fprintf(stderr, - "Assert error in %s(), %s line %d:\n" - " Condition(%s) not true.\n", - func, file, line, cond); + if (kind == VAS_MISSING) { + fprintf(stderr, + "Missing error handling code in %s(), %s line %d:\n" + " Condition(%s) not true.\n", + func, file, line, cond); + } else if (kind == VAS_INCOMPLETE) { + fprintf(stderr, + "Incomplete code in %s(), %s line %d:\n", + func, file, line); + } else if (kind == VAS_WRONG) { + fprintf(stderr, + "Wrong turn in %s(), %s line %d: %s\n", + func, file, line, cond); + } else { + fprintf(stderr, + "Assert error in %s(), %s line %d:\n" + " Condition(%s) not true.\n", + func, file, line, cond); + } + if (err) + fprintf(stderr, + " errno = %d (%s)\n", err, strerror(err)); } - if (err) - fprintf(stderr, - " errno = %d (%s)\n", err, strerror(err)); abort(); } - -vas_f *VAS_Fail __attribute__((__noreturn__)) = VAS_Fail_default; diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 7454f4f..4cc3b50 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -30,6 +30,7 @@ LIBVARNISHAPI_2.0 { global: # vas.c VAS_Fail; + VAS_Fail_Func; # vcli.c VCLI_AuthResponse; From phk at FreeBSD.org Thu Sep 14 16:44:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 16:44:05 +0000 (UTC) Subject: [master] 34ce7c8 OCD for PC-Lint-Plus Message-ID: <20170914164405.83AD59755C@lists.varnish-cache.org> commit 34ce7c8f19e16bfbad6b0f86fd9f64ead8ac2113 Author: Poul-Henning Kamp Date: Thu Sep 14 16:43:20 2017 +0000 OCD for PC-Lint-Plus diff --git a/include/vdef.h b/include/vdef.h index b7fee8b..70f8178 100644 --- a/include/vdef.h +++ b/include/vdef.h @@ -40,7 +40,7 @@ do { \ int ibprintf; \ ibprintf = snprintf(buf, sizeof buf, fmt, __VA_ARGS__); \ - assert(ibprintf >= 0 && ibprintf < sizeof buf); \ + assert(ibprintf >= 0 && ibprintf < (int)sizeof buf); \ } while (0) /* Safe printf into a fixed-size buffer */ @@ -48,7 +48,7 @@ do { \ int ivbprintf; \ ivbprintf = vsnprintf(buf, sizeof buf, fmt, ap); \ - assert(ivbprintf >= 0 && ivbprintf < sizeof buf); \ + assert(ivbprintf >= 0 && ivbprintf < (int)sizeof buf); \ } while (0) /* Close and discard filedescriptor */ From geoff at uplex.de Thu Sep 14 16:52:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 16:52:04 +0000 (UTC) Subject: [master] d1799b8 VMOD blob: use a DEFAULT value for the case ENUM. Message-ID: <20170914165204.819DA97A2D@lists.varnish-cache.org> commit d1799b8fee3d3d615229404b2ff131548dd561e2 Author: Geoff Simmons Date: Thu Sep 14 17:42:23 2017 +0200 VMOD blob: use a DEFAULT value for the case ENUM. DEFAULT is interpreted as LOWER for the HEX and URL encodings, and is the only legal value for all other encodings. diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index e4d963c..02d896d 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -54,13 +54,9 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="666f6f00626172")); - set resp.http.lc = - blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, - encoded="Don't care")); - - set resp.http.uc = - blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, - encoded="Don't care")); + set resp.http.pos = + blob.encode(IDENTITY, DEFAULT, blob.decode(IDENTITY, + encoded="foobar")); } } -start @@ -76,6 +72,52 @@ client c1 { expect resp.http.param == "The quick brown fox jumps over the lazy dog" expect resp.http.paramlist == "/The quick brown fox jumps over the lazy dog/" expect resp.http.truncated == "foo" - expect resp.http.lc == "Don't care" - expect resp.http.uc == "Don't care" + expect resp.http.pos == "foobar" } -run + +# Require case=DEFAULT + +server s1 -repeat 2 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + if (req.url == "/lc") { + set resp.http.lc = + blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, + encoded="foobar")); + } + elsif (req.url == "/uc") { + set resp.http.uc = + blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, + encoded="foobar")); + } + } +} + +client c1 { + txreq -url "/lc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.lc == +} -run + +client c1 { + txreq -url "/uc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.uc == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding IDENTITY$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding IDENTITY$" +} -start + +logexpect l1 -wait diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index 3209394..e545f1c 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -21,13 +21,9 @@ varnish v1 -vcl { blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded= req.http.pangram)); - set resp.http.b64lc = - blob.encode(BASE64, LOWER, blob.decode(IDENTITY, encoded= - req.http.pangram)); - - set resp.http.b64uc = - blob.encode(BASE64, UPPER, blob.decode(IDENTITY, encoded= - req.http.pangram)); + set resp.http.b64pos = + blob.encode(BASE64, DEFAULT, blob.decode(IDENTITY, encoded= + req.http.pangram)); set resp.http.b64hobbes = blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded= @@ -41,12 +37,8 @@ varnish v1 -vcl { blob.encode(BASE64URL, blob=blob.decode(IDENTITY, encoded=req.http.pangram)); - set resp.http.b64urllc = - blob.encode(BASE64URL, LOWER, - blob.decode(IDENTITY, encoded=req.http.pangram)); - - set resp.http.b64urluc = - blob.encode(BASE64URL, UPPER, + set resp.http.b64urlpos = + blob.encode(BASE64URL, DEFAULT, blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urlhobbes = @@ -61,12 +53,8 @@ varnish v1 -vcl { blob.encode(BASE64URLNOPAD, blob=blob.decode(IDENTITY, encoded=req.http.pangram)); - set resp.http.b64urlnopadlc = - blob.encode(BASE64URLNOPAD, LOWER, - blob.decode(IDENTITY, encoded=req.http.pangram)); - - set resp.http.b64urlnopaduc = - blob.encode(BASE64URLNOPAD, UPPER, + set resp.http.b64urlnopadpos = + blob.encode(BASE64URLNOPAD, DEFAULT, blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64nopadhobbes = @@ -87,15 +75,15 @@ varnish v1 -vcl { set resp.http.b64param = blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), - encoding=BASE64, case=LOWER); + encoding=BASE64, case=DEFAULT); set resp.http.b64urlparam = blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), - encoding=BASE64URL, case=UPPER); + encoding=BASE64URL, case=DEFAULT); set resp.http.b64urlnopadparam = blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), - encoding=BASE64URLNOPAD, case=LOWER); + encoding=BASE64URLNOPAD, case=DEFAULT); set resp.http.b64xcode = blob.transcode(IDENTITY, BASE64, @@ -115,18 +103,15 @@ client c1 { txreq -url "/" rxresp expect resp.http.b64 == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" - expect resp.http.b64lc == resp.http.b64 - expect resp.http.b64uc == resp.http.b64 + expect resp.http.b64pos == resp.http.b64 expect resp.http.b64hobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" expect resp.http.b64all == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" expect resp.http.b64url == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" - expect resp.http.b64urllc == resp.http.b64url - expect resp.http.b64urluc == resp.http.b64url + expect resp.http.b64urlpos == resp.http.b64url expect resp.http.b64urlhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" expect resp.http.b64urlall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" expect resp.http.b64urlnopad == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" - expect resp.http.b64urlnopadlc == resp.http.b64urlnopad - expect resp.http.b64urlnopaduc == resp.http.b64urlnopad + expect resp.http.b64urlnopadpos == resp.http.b64urlnopad expect resp.http.b64nopadhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" expect resp.http.b64nopadall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" expect resp.http.b64empty == "" @@ -339,3 +324,102 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "././"$} expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} } -run + +# Require case=DEFAULT + +server s1 -repeat 6 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + if (req.url == "/b64lc") { + set resp.http.b64lc = + blob.encode(BASE64, LOWER, blob.decode(IDENTITY, encoded="")); + } + elsif (req.url == "/b64uc") { + set resp.http.b64uc = + blob.encode(BASE64, UPPER, blob.decode(IDENTITY, encoded="")); + } + elsif (req.url == "/b64urllc") { + set resp.http.b64urllc = + blob.encode(BASE64URL, LOWER, blob.decode(IDENTITY, encoded="")); + } + elsif (req.url == "/b64urluc") { + set resp.http.b64urluc = + blob.encode(BASE64URL, UPPER, blob.decode(IDENTITY, encoded="")); + } + elsif (req.url == "/b64urlnopadlc") { + set resp.http.b64urlnopadlc = + blob.encode(BASE64URLNOPAD, LOWER, blob.decode(IDENTITY, + encoded="")); + } + elsif (req.url == "/b64urlnopaduc") { + set resp.http.b64urlnopaduc = + blob.encode(BASE64URLNOPAD, UPPER, blob.decode(IDENTITY, + encoded="")); + } + } +} + +client c1 { + txreq -url "/b64lc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64lc == +} -run + +client c1 { + txreq -url "/b64uc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64uc == +} -run + +client c1 { + txreq -url "/b64urllc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urllc == +} -run + +client c1 { + txreq -url "/b64urluc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urluc == +} -run + +client c1 { + txreq -url "/b64urlnopadlc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urlnopadlc == +} -run + +client c1 { + txreq -url "/b64urlnopaduc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urlnopaduc == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64URL" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64URL" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64URLNOPAD" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64URLNOPAD" +} -start + +logexpect l1 -wait diff --git a/bin/varnishtest/tests/m00043.vtc b/bin/varnishtest/tests/m00043.vtc index 7521255..9062314 100644 --- a/bin/varnishtest/tests/m00043.vtc +++ b/bin/varnishtest/tests/m00043.vtc @@ -1,9 +1,8 @@ varnishtest "VMOD blob blob object interface" -server s1 {} -start - -varnish v1 -arg "-i serverid" -vcl+backend { +varnish v1 -arg "-i serverid" -vcl { import blob; + backend b { .host = "${bad_ip}"; } sub vcl_init { new id = blob.blob(IDENTITY, @@ -93,8 +92,9 @@ client c1 { # run twice to test retrieving cached encodings client c1 -run -varnish v1 -vcl+backend { +varnish v1 -vcl { import blob; + backend b { .host = "${bad_ip}"; } sub vcl_init { new idempty = blob.blob(IDENTITY, ""); @@ -165,8 +165,9 @@ client c1 { # run twice to test retrieving cached encodings client c1 -run -varnish v1 -vcl+backend { +varnish v1 -vcl { import blob; + backend b { .host = "${bad_ip}"; } sub vcl_init { new b64 = blob.blob(BASE64, "L0hlbGxvIHdvcmxkLw=="); @@ -254,8 +255,9 @@ client c2 { # run twice client c2 -run -varnish v1 -vcl+backend { +varnish v1 -vcl { import blob; + backend b { .host = "${bad_ip}"; } sub vcl_init { new id = blob.blob(IDENTITY, @@ -332,6 +334,125 @@ client c3 -run varnish v1 -cliok "vcl.discard vcl1" varnish v1 -cliok "vcl.discard vcl2" +# Require case=DEFAULT in the .encode() method where necessary + +server s1 -repeat 8 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_init { + new b = blob.blob(IDENTITY, ""); + } + + sub vcl_deliver { + if (req.url == "/idlc") { + set resp.http.idlc = b.encode(IDENTITY, LOWER); + } + elsif (req.url == "/iduc") { + set resp.http.iduc = b.encode(IDENTITY, UPPER); + } + if (req.url == "/b64lc") { + set resp.http.b64lc = b.encode(BASE64, LOWER); + } + elsif (req.url == "/b64uc") { + set resp.http.b64uc = b.encode(BASE64, UPPER); + } + elsif (req.url == "/b64urllc") { + set resp.http.b64urllc = b.encode(BASE64URL, LOWER); + } + elsif (req.url == "/b64urluc") { + set resp.http.b64urluc = b.encode(BASE64URL, UPPER); + } + elsif (req.url == "/b64urlnopadlc") { + set resp.http.b64urlnopadlc = b.encode(BASE64URLNOPAD, LOWER); + } + elsif (req.url == "/b64urlnopaduc") { + set resp.http.b64urlnopaduc = b.encode(BASE64URLNOPAD, UPPER); + } + } +} + +client c1 { + txreq -url "/idlc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.idlc == +} -run + +client c1 { + txreq -url "/iduc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.iduc == +} -run + +client c1 { + txreq -url "/b64lc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64lc == +} -run + +client c1 { + txreq -url "/b64uc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64uc == +} -run + +client c1 { + txreq -url "/b64urllc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urllc == +} -run + +client c1 { + txreq -url "/b64urluc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urluc == +} -run + +client c1 { + txreq -url "/b64urlnopadlc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urlnopadlc == +} -run + +client c1 { + txreq -url "/b64urlnopaduc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urlnopaduc == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding IDENTITY$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding IDENTITY$" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64$" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64URL$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64URL$" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64URLNOPAD$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64URLNOPAD$" +} -start + +logexpect l1 -wait + varnish v1 -errvcl {vmod blob error: cannot create blob err, illegal encoding beginning with "g"} { import blob; backend b { .host="${bad_ip}"; } diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 96dea4e..3b90d3a 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -94,16 +94,19 @@ Empty strings are decoded into a "null blob" (of length 0), and conversely a null blob is encoded as the empty string. For encodings with ``HEX`` or ``URL``, you may also specify a ``case`` -ENUM with one of the values ``LOWER`` or ``UPPER`` to produce a string -with lower- or uppercase hex digits (in ``[a-f]`` or ``[A-F]``), -respectively. The default value for ``case`` is ``LOWER``. +ENUM with one of the values ``LOWER``, ``UPPER`` or ``DEFAULT`` to +produce a string with lower- or uppercase hex digits (in ``[a-f]`` or +``[A-F]``). The default value for ``case`` is ``DEFAULT``, which for +``HEX`` and ``URL`` means the same as ``LOWER``. The ``case`` ENUM is not relevant for decodings; ``HEX`` or ``URL`` strings to be decoded as BLOBs may have hex digits in either case, or -in mixed case. The ``case`` ENUM is also ignored for all other -encodings. You cannot, for example, produce an uppercase string by -using the IDENTITY scheme with ``case=UPPER``. To change the case of a -string, use the ``toupper`` or ``tolower`` functions from +in mixed case. + +The ``case`` ENUM MUST be set to ``DEFAULT`` for the other encodings +(BASE64* and IDENTITY). You cannot, for example, produce an uppercase +string by using the IDENTITY scheme with ``case=UPPER``. To change the +case of a string, use the ``toupper`` or ``tolower`` functions from :ref:`vmod_std(3)`. IDENTITY @@ -133,7 +136,7 @@ be written as:: set resp.http.Trunced-Foo2 = blob.encode(blob=blob.decode(HEX, encoded="666f6f00626172")); -The ``case`` ENUM is ignored for ``IDENTITY`` encodings. +The ``case`` ENUM MUST be set to ``DEFAULT`` for ``IDENTITY`` encodings. BASE64* ------- @@ -155,16 +158,17 @@ The ``BASE64URLNOPAD`` encoding uses the same alphabet as ``BASE6URL``, but leaves out the padding. Thus the length of an encoding with this scheme is not necessarily a mutltiple of four. -The ``case`` ENUM is ignored for for all of the ``BASE64*`` encodings. +The ``case`` ENUM MUST be set to ``DEFAULT`` for for all of the +``BASE64*`` encodings. HEX --- The ``HEX`` encoding scheme converts hex strings into blobs and vice versa. For encodings, you may use the ``case`` ENUM to specify upper- -or lowercase hex digits ``A`` through ``f`` (default ``LOWER``). A -prefix such as ``0x`` is not used for an encoding and is illegal for a -decoding. +or lowercase hex digits ``A`` through ``f`` (default ``DEFAULT``, +which means the same as ``LOWER``). A prefix such as ``0x`` is not +used for an encoding and is illegal for a decoding. If a hex string to be decoded has an odd number of digits, it is decoded as if a ``0`` is prepended to it; that is, the first digit is @@ -214,13 +218,15 @@ Example:: $Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER", BLOB blob) + ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT", BLOB blob) Returns a string representation of the BLOB ``blob`` as specifed by ``encoding``. ``case`` determines the case of hex digits for the ``HEX`` and ``URL`` encodings, and is ignored for the other encodings. -``encoding`` defaults to IDENTITY, and ``case`` defaults to LOWER. +``encoding`` defaults to IDENTITY, and ``case`` defaults to DEFAULT. +DEFAULT is interpreted as LOWER for the HEX and URL encodings, and is +the required value for the other encodings. Example:: @@ -242,8 +248,8 @@ $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER", INT length=0, - STRING_LIST encoded) + ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT", + INT length=0, STRING_LIST encoded) Translates from one encoding to another, by first decoding the string ``encoded`` according to the scheme ``decoding``, and then returning @@ -256,7 +262,8 @@ As with ``decode()``: If ``length`` > 0, only decode the first entire string. The default value of ``length`` is 0. ``decoding`` and ``encoding`` default to IDENTITY, and ``case`` -defaults to LOWER. +defaults to DEFAULT. DEFAULT is interpreted as LOWER for the HEX and +URL encodings, and is the required value for the other encodings. Example:: @@ -343,12 +350,12 @@ Example:: $Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER") + ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT") Returns an encoding of BLOB created by the constructor, according to the scheme ``encoding``. ``case`` determines the case of hex digits -for the ``HEX`` and ``URL`` encodings, and is ignored for other -encodings. +for the ``HEX`` and ``URL`` encodings, and MUST be set to ``DEFAULT`` +for the other encodings. Example:: @@ -378,10 +385,11 @@ not known until runtime. ERRORS ====== -The encoders, decoders and ``sub()`` may fail if there is -insufficient space to create the new blob or string. Decoders may also -fail if the encoded string is an illegal format for the decoding -scheme. +The encoders, decoders and ``sub()`` may fail if there is insufficient +space to create the new blob or string. Decoders may also fail if the +encoded string is an illegal format for the decoding scheme. Encoders +will fail for the ``IDENTITY`` and ``BASE64*`` encoding schemes if the +``case`` ENUM is not set to ``DEFAULT``. If any of the VMOD's methods, functions or constructor fail, then VCL failure is invoked, just as if ``return(fail)`` had been called in the diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 7ded3a8..7e58db1 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -159,6 +159,9 @@ static inline enum case_e parse_case(VCL_ENUM case_s) { switch(*case_s) { + case 'D': + AZ(strcmp(case_s + 1, "EFAULT")); + return DEFAULT; case 'L': AZ(strcmp(case_s + 1, "OWER")); return LOWER; @@ -170,6 +173,25 @@ parse_case(VCL_ENUM case_s) } } +static inline int +encodes_hex(enum encoding enc) +{ + return (enc == HEX || enc == URL); +} + +/* Require case DEFAULT for all encodings besides HEX and URL. */ + +static inline int +check_enc_case(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, enum encoding enc, + enum case_e kase) +{ + if (!encodes_hex(enc) && kase != DEFAULT) { + VERR(ctx, "case %s is illegal with encoding %s", case_s, encs); + return 0; + } + return 1; +} + /* Objects */ VCL_VOID __match_proto__(td_blob_blob__init) @@ -250,8 +272,12 @@ vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs, CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(b, VMOD_BLOB_MAGIC); + if (!check_enc_case(ctx, encs, case_s, enc, kase)) + return NULL; if (b->blob.len == 0) return ""; + if (kase == DEFAULT) + kase = LOWER; if (b->encoding[enc][kase] == NULL) { AZ(pthread_mutex_lock(&b->lock)); @@ -396,7 +422,6 @@ encode(VRT_CTX, enum encoding enc, enum case_e kase, VCL_BLOB b) struct wb_s wb; ssize_t len; - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AENC(enc); if (b == NULL) @@ -429,13 +454,11 @@ vmod_encode(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, VCL_BLOB b) { enum encoding enc = parse_encoding(encs); enum case_e kase = parse_case(case_s); - return encode(ctx, enc, kase, b); -} -static inline int -encodes_hex(enum encoding enc) -{ - return (enc == HEX || enc == URL); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (!check_enc_case(ctx, encs, case_s, enc, kase)) + return NULL; + return encode(ctx, enc, kase, b); } VCL_STRING __match_proto__(td_blob_transcode) @@ -455,6 +478,9 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, AENC(dec); AENC(enc); + if (!check_enc_case(ctx, encs, case_s, enc, kase)) + return NULL; + /* * Allocate space for the decoded blob on the stack * ignoring the limitation imposed by n diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h index 9cc1d45..04663e5 100644 --- a/lib/libvmod_blob/vmod_blob.h +++ b/lib/libvmod_blob/vmod_blob.h @@ -34,9 +34,14 @@ #define AENC(enc) assert((enc) > _INVALID && (enc) < __MAX_ENCODING) +/* + * The enums MUST appear in this order, since LOWER and UPPER are used to + * index the array of cached encodings for the blob object. + */ enum case_e { LOWER, UPPER, + DEFAULT, }; /* From geoff at uplex.de Thu Sep 14 16:58:04 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Sep 2017 16:58:04 +0000 (UTC) Subject: [master] dce629d VMOD blob: move $ABI directive again. Message-ID: <20170914165804.2604397EB2@lists.varnish-cache.org> commit dce629d8d18a757abc1e5592976504174a1e68ac Author: Geoff Simmons Date: Thu Sep 14 18:56:31 2017 +0200 VMOD blob: move $ABI directive again. So that part of the docs appear in the SYNOPSIS section. diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 3b90d3a..a462f3a 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -7,7 +7,6 @@ # $Module blob 3 utilities for the VCL blob type -$ABI strict :: @@ -28,6 +27,8 @@ $ABI strict BLOB .get() STRING .encode([ENUM encoding,] [ENUM case]) +$ABI strict + DESCRIPTION =========== From phk at FreeBSD.org Thu Sep 14 17:48:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 17:48:07 +0000 (UTC) Subject: [master] 21004be GCC doesn't like attributes on typedefs Message-ID: <20170914174807.67C4798FF3@lists.varnish-cache.org> commit 21004bed6f85f65aaaa892c01c96440a5a6d3730 Author: Poul-Henning Kamp Date: Thu Sep 14 17:46:39 2017 +0000 GCC doesn't like attributes on typedefs diff --git a/include/vas.h b/include/vas.h index ec4adc5..76bcb75 100644 --- a/include/vas.h +++ b/include/vas.h @@ -46,8 +46,7 @@ enum vas_e { VAS_VCL, }; -typedef void vas_f(const char *, const char *, int, const char *, enum vas_e) - __attribute__((__noreturn__)); +typedef void vas_f(const char *, const char *, int, const char *, enum vas_e); extern vas_f *VAS_Fail_Func __attribute__((__noreturn__)); extern vas_f VAS_Fail __attribute__((__noreturn__)); From phk at FreeBSD.org Thu Sep 14 21:16:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 21:16:05 +0000 (UTC) Subject: [master] 19ab697 Missing assert Message-ID: <20170914211605.1098C98085@lists.varnish-cache.org> commit 19ab69739aa980e433ac6cb6dc8be45a000fc129 Author: Poul-Henning Kamp Date: Thu Sep 14 20:37:11 2017 +0000 Missing assert diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index bba58b3..dc25ea4 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -624,6 +624,7 @@ MCF_DumpRstParam(void) t1 = strchr(p, '\t'); if (t1 != NULL && t1 < q) { t2 = strchr(t1 + 1, '\t'); + AN(t2); printf("\n\t*"); (void)fwrite(t1 + 1, (t2 - 1) - t1, 1, stdout); printf("*\n\t\t"); From phk at FreeBSD.org Thu Sep 14 21:16:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 14 Sep 2017 21:16:05 +0000 (UTC) Subject: [master] 748dd7e Add a couple of clarifying asserts Message-ID: <20170914211605.24C8C98088@lists.varnish-cache.org> commit 748dd7e60ee0b3ad15267127a55cc05e34821cbf Author: Poul-Henning Kamp Date: Thu Sep 14 21:04:11 2017 +0000 Add a couple of clarifying asserts diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 39cb394..43f89b2 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -566,6 +566,8 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) if (b0 == bn) return (0); + AN(b0); + AN(bn); /* * This loop is safe without locks, because we know we hold From geoff at uplex.de Fri Sep 15 06:45:06 2017 From: geoff at uplex.de (Geoff Simmons) Date: Fri, 15 Sep 2017 06:45:06 +0000 (UTC) Subject: [master] c53dad4 Remove the last XXX from the release docs for 5.2. Message-ID: <20170915064506.C915298648@lists.varnish-cache.org> commit c53dad4bb3474b5ad565d5ecc09c93e8ba563421 Author: Geoff Simmons Date: Fri Sep 15 08:43:42 2017 +0200 Remove the last XXX from the release docs for 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 686dde3..0b32705 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -216,8 +216,6 @@ Other changes * ``varnishtest(1)`` and ``vtc(7)``: - * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* - * When varnishtest is invoked with ``-L`` or ``-l``, Varnish instances started by a test do not clean up their copies of VMOD shared objects when they stop. See the note about ``vmod_so_keep`` From phk at FreeBSD.org Fri Sep 15 07:24:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 15 Sep 2017 07:24:05 +0000 (UTC) Subject: [master] 520338b Polish. Message-ID: <20170915072405.100AA982BE@lists.varnish-cache.org> commit 520338b17e30fa98e89c98b5edd623422aac9841 Author: Poul-Henning Kamp Date: Fri Sep 15 07:22:30 2017 +0000 Polish. Remove mention of http_CollectHdrSep(). diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index ebd421e..fb1d194 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -54,12 +54,14 @@ test-cases. We only distribute ``vmod_debug`` in source releases, because it has some pretty evil functionality, for instance ``debug.panic()``. -We have split the non-suicidal test-writing stuff from ``vmod_debug`` -into a new ``vmod_vtc``, which is included in binary releases from -now on, in order to make it easier for people to use ``varnishtest`` -to test local configurations, VMODs etc. The main highlight is that you -can now synchronize barriers with VCL code thanks to ``vmod_vtc``, other -conveniences were added like workspace manipulations. +We have taken the non-suicidal test-writing goodies out of +``vmod_debug`` and put them into a new ``vmod_vtc``, to make them +available to people using ``varnishtest`` to test local configurations, +VMODs etc. + +The hottest trick in ``vmod_vtc`` is that VTC-barriers can be +accessed from the VCL code, but there are other conveniences like +workspace manipulations etc. See :ref:`vmod_vtc(3)`. @@ -84,8 +86,7 @@ one or the other depended on how Varnish was built. VMOD authors can now specify whether a module complies to the VRT and only needs to be rebuilt when breaking changes are introduced by adding ``$ABI vrt`` to their VCC descriptor. The default value -is ``$ABI strict`` when omitted, and all VMODs from the standard -Varnish distribution have a strict requirement. +is ``$ABI strict`` when omitted. .. _whatsnew_vsm_vsc_5.2: @@ -102,8 +103,8 @@ file which is processed by the ``vsctool.py`` script into a .c and This means that statistics counters are now self-describing in shared memory, and ``varnishstat`` or other VSC-API using programs -have no compiled in knowledge about which counters exist or how -to treat them. +no longer have a compiled in list of which counters exist or how +to handle them. This paves the way for VMODs or maybe even VCL to define custom counters, and have them show up in varnishstat and @@ -120,7 +121,7 @@ In the new VSM-api once setup is done, VSM_Attach() latches on to a running varnishd master process and stays there. VSM_Status() updates the in-memory list of VSM segments, and -returns information about the master and worker proces: +returns status information about the master and worker proces: Are they running? Have they been restarted? Have VSM segments been added/deleted? @@ -143,10 +144,6 @@ VRT API changes outside of ``vcl_hit`` or ``vcl_miss``. It also returns the number of purged objects. -New ``http_CollectHdrSep`` function, ``http_*`` symbols and associated -data structures are part of the curated Varnish RunTime. Using them -does not require strict ABI compliance. - .. _whatsnew_vut_5.2: Added VUT API @@ -170,3 +167,5 @@ the boilerplate to generate part of the documentation. We hope that we will see new tools that take advantage of this API to extend Varnish in new ways, much like VMODs made it easy to add new functionality to VCL. + +*eof* diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 0b32705..9d02522 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -14,10 +14,12 @@ varnishd parameters =================== The :ref:`ref_param_vsm_space` and :ref:`ref_param_cli_buffer` -parameters are now deprecated and ignored. The updated logging -implementation manages space automatically, so it no longer needs -:ref:`ref_param_vsm_space`. Memory for the CLI command buffer is now -dynamically allocated. +parameters are now deprecated and ignored. They will be removed +in a future major release. + +The updated shared memory implementation manages space automatically, so +it no longer needs :ref:`ref_param_vsm_space`. Memory for the CLI +command buffer is now dynamically allocated. We have updated the documentation for :ref:`ref_param_send_timeout`, :ref:`ref_param_idle_send_timeout`, :ref:`ref_param_timeout_idle` and @@ -254,3 +256,5 @@ Other changes up its copies of VMOD shared objects when it stops. This makes it possible for VMOD authors to load their code into a debugger after a varnishd crash. See :ref:`ref_param_debug`. + +*eof* From hermunn at varnish-software.com Fri Sep 15 10:47:04 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 10:47:04 +0000 (UTC) Subject: [master] 5059999 Add changelog entry for pull 2382 and heading for 5.2.0 Message-ID: <20170915104704.A7BE598094@lists.varnish-cache.org> commit 5059999ba1b8ceb9a7be522986a141137afa4050 Author: P?l Hermunn Johansen Date: Fri Sep 15 12:02:55 2017 +0200 Add changelog entry for pull 2382 and heading for 5.2.0 diff --git a/doc/changes.rst b/doc/changes.rst index 9003c32..9b546b1 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -2,6 +2,14 @@ Varnish Cache Trunk (ongoing) ============================= +================================ +Varnish Cache 5.2.0 (2017-09-15) +================================ + +* The cli_buffer parameter has been deprecated (2382_) + +.. _2382: https://github.com/varnishcache/varnish-cache/pull/2382 + ================================== Varnish Cache 5.2-RC1 (2017-09-04) ================================== From fgsch at lodoss.net Fri Sep 15 10:57:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 15 Sep 2017 10:57:04 +0000 (UTC) Subject: [master] 283740a Spelling and cosmetic Message-ID: <20170915105704.38AC898547@lists.varnish-cache.org> commit 283740a7ae4cdce4071e7d94939d195249daa0a5 Author: Federico G. Schwindt Date: Fri Sep 15 11:55:49 2017 +0100 Spelling and cosmetic diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index fb1d194..43764b3 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -117,23 +117,23 @@ will have to be updated to match. The necessary changes mostly center around detecting if the varnishd management/worker process has restarted. -In the new VSM-api once setup is done, VSM_Attach() latches +In the new VSM-API once setup is done, VSM_Attach() latches on to a running varnishd master process and stays there. VSM_Status() updates the in-memory list of VSM segments, and -returns status information about the master and worker proces: +returns status information about the master and worker processes: Are they running? Have they been restarted? Have VSM segments been added/deleted? Each VSM segment is now a separate piece of shared memory -and the name of the segment can be much longer now. +and the name of the segment can be much longer. Before the actual shared memory can be accessed, the application must call VSM_Map() and when VSM_StillValid() indicates that the segment is no longer valid, VSM_Unmap() should be called to release the segment again. -All in all, this should be simpler and more robust now. +All in all, this should be simpler and more robust. .. _whatsnew_vrt_5.2: From hermunn at varnish-software.com Fri Sep 15 11:16:04 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:16:04 +0000 (UTC) Subject: [master] 8e0b7b2 Via: 1.1 varnish (Varnish/5.2) Message-ID: <20170915111604.E54FD98C2F@lists.varnish-cache.org> commit 8e0b7b20446f96cb66972f47e2c3d843aff79006 Author: P?l Hermunn Johansen Date: Fri Sep 15 13:14:38 2017 +0200 Via: 1.1 varnish (Varnish/5.2) diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 8a7b6de..0b56b80 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -148,7 +148,7 @@ cnt_deliver(struct worker *wrk, struct req *req) http_PrintfHeader(req->resp, "Age: %.0f", floor(fmax(0., req->t_prev - req->objcore->t_origin))); - http_SetHeader(req->resp, "Via: 1.1 varnish (Varnish/5.1)"); + http_SetHeader(req->resp, "Via: 1.1 varnish (Varnish/5.2)"); if (cache_param->http_gzip_support && ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) && From hermunn at varnish-software.com Fri Sep 15 11:17:11 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:11 +0000 (UTC) Subject: [5.2] c3f20d6 Remove unneeded #include Message-ID: <20170915111711.72D3898E1B@lists.varnish-cache.org> commit c3f20d637b2c09130bc417f90ae8f279f371f8f1 Author: Poul-Henning Kamp Date: Thu Sep 7 09:16:48 2017 +0000 Remove unneeded #include diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index cbbeb47..3d5a3ae 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -33,7 +33,6 @@ #endif #define COMMON_COMMON_H -#include #include #include From hermunn at varnish-software.com Fri Sep 15 11:17:11 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:11 +0000 (UTC) Subject: [5.2] 3b36ac8 Make VSC not own the VSM it operates on. Message-ID: <20170915111711.92CE598E1E@lists.varnish-cache.org> commit 3b36ac8e2795026969bca3c2e97d7f7733c86553 Author: Poul-Henning Kamp Date: Thu Sep 7 09:38:54 2017 +0000 Make VSC not own the VSM it operates on. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 1f24b25..88d2c66 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -74,7 +74,7 @@ do_xml_cb(void *priv, const struct VSC_point * const pt) } static void -do_xml(struct vsc *vsc) +do_xml(struct vsm *vsm, struct vsc *vsc) { char time_stamp[20]; time_t now; @@ -83,7 +83,7 @@ do_xml(struct vsc *vsc) now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf("\n", time_stamp); - (void)VSC_Iter(vsc, NULL, do_xml_cb, NULL); + (void)VSC_Iter(vsc, vsm, NULL, do_xml_cb, NULL); printf("\n"); } @@ -124,7 +124,7 @@ do_json_cb(void *priv, const struct VSC_point * const pt) } static void -do_json(struct vsc *vsc) +do_json(struct vsm *vsm, struct vsc *vsc) { char time_stamp[20]; time_t now; @@ -137,7 +137,7 @@ do_json(struct vsc *vsc) (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf(" \"timestamp\": \"%s\",\n", time_stamp); - (void)VSC_Iter(vsc, NULL, do_json_cb, &jp); + (void)VSC_Iter(vsc, vsm, NULL, do_json_cb, &jp); printf("\n}\n"); } @@ -194,15 +194,15 @@ do_once_cb(void *priv, const struct VSC_point * const pt) } static void -do_once(struct vsc *vsc) +do_once(struct vsm *vsm, struct vsc *vsc) { struct once_priv op; memset(&op, 0, sizeof op); op.pad = 18; - (void)VSC_Iter(vsc, NULL, do_once_cb_first, &op); - (void)VSC_Iter(vsc, NULL, do_once_cb, &op); + (void)VSC_Iter(vsc, vsm, NULL, do_once_cb_first, &op); + (void)VSC_Iter(vsc, vsm, NULL, do_once_cb, &op); } /*--------------------------------------------------------------------*/ @@ -226,13 +226,13 @@ do_list_cb(void *priv, const struct VSC_point * const pt) } static void -list_fields(struct vsc *vsc) +list_fields(struct vsm *vsm, struct vsc *vsc) { printf("Varnishstat -f option fields:\n"); printf("Field name Description\n"); printf("---------- -----------\n"); - (void)VSC_Iter(vsc, NULL, do_list_cb, NULL); + (void)VSC_Iter(vsc, vsm, NULL, do_list_cb, NULL); } /*--------------------------------------------------------------------*/ @@ -261,7 +261,7 @@ main(int argc, char * const *argv) VUT_Init(progname, argc, argv, &vopt_spec); vd = VSM_New(); AN(vd); - vsc = VSC_New(vd); + vsc = VSC_New(); AN(vsc); while ((opt = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { @@ -284,8 +284,11 @@ main(int argc, char * const *argv) case 'j': json = 1; break; + case 'f': + AN(VSC_Arg(vsc, opt, optarg)); + break; default: - i = VSC_Arg(vsc, opt, optarg); + i = VSM_Arg(vd, opt, optarg); if (i < 0) VUT_Error(1, "%s", VSM_Error(vd)); if (!i) @@ -305,13 +308,13 @@ main(int argc, char * const *argv) if (curses) do_curses(vd, vsc, 1.0); else if (xml) - do_xml(vsc); + do_xml(vd, vsc); else if (json) - do_json(vsc); + do_json(vd, vsc); else if (once) - do_once(vsc); + do_once(vd, vsc); else if (f_list) - list_fields(vsc); + list_fields(vd, vsc); else assert(0); diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 104af2b..f2e34bd 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -313,7 +313,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) } static void -build_pt_list(struct vsc *vsc, struct vsm_fantom *fantom) +build_pt_list(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *fantom) { struct pt_priv pt_priv; int i; @@ -334,7 +334,7 @@ build_pt_list(struct vsc *vsc, struct vsm_fantom *fantom) main_cache_hit = NULL; main_cache_miss = NULL; - (void)VSC_Iter(vsc, fantom, build_pt_list_cb, &pt_priv); + (void)VSC_Iter(vsc, vsm, fantom, build_pt_list_cb, &pt_priv); delete_pt_list(); AN(VTAILQ_EMPTY(&ptlist)); AZ(n_ptlist); @@ -1073,7 +1073,7 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED))) { init_hitrate(); delete_pt_list(); - build_pt_list(vsc, &f_iter); + build_pt_list(vsc, vd, &f_iter); initial = 0; } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 45218bc..e81c054 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -523,13 +523,13 @@ varnish_launch(struct varnish *v) v->vsm_vsc = VSM_New(); AN(v->vsm_vsc); - v->vsc = VSC_New(v->vsm_vsc); + v->vsc = VSC_New(); AN(v->vsc); - (void)VSC_Arg(v->vsc, 'n', v->workdir); + assert(VSM_Arg(v->vsm_vsc, 'n', v->workdir) > 0); AZ(VSM_Attach(v->vsm_vsc, -1)); v->vsm_vsl = VSM_New(); - (void)VSM_Arg(v->vsm_vsl, 'n', v->workdir); + assert(VSM_Arg(v->vsm_vsl, 'n', v->workdir) > 0); AZ(VSM_Attach(v->vsm_vsl, -1)); AZ(pthread_create(&v->tp_vsl, NULL, varnishlog_thread, v)); @@ -850,7 +850,7 @@ varnish_vsc(const struct varnish *v, const char *arg) dp.arg = arg; (void)VSM_Status(v->vsm_vsc); - (void)VSC_Iter(v->vsc, NULL, do_stat_dump_cb, &dp); + (void)VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_stat_dump_cb, &dp); } /********************************************************************** @@ -916,7 +916,7 @@ varnish_expect(const struct varnish *v, char * const *av) for (i = 0; i < 50; i++, (void)usleep(100000)) { (void)VSM_Status(v->vsm_vsc); - good = VSC_Iter(v->vsc, NULL, do_expect_cb, &sp); + good = VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_expect_cb, &sp); if (!good) { good = -2; continue; diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 97c85e1..986259b 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -45,7 +45,7 @@ struct vsm_fantom; * VSC level access functions */ -struct vsc *VSC_New(struct vsm *); +struct vsc *VSC_New(void); void VSC_Destroy(struct vsc **); int VSC_Arg(struct vsc *, char arg, const char *opt); @@ -84,7 +84,8 @@ void VSC_Destroy_Point(struct VSC_point **); typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt); -int VSC_Iter(struct vsc *, struct vsm_fantom *, VSC_iter_f *func, void *priv); +int VSC_Iter(struct vsc *, struct vsm *, struct vsm_fantom *, + VSC_iter_f *func, void *priv); /* * Iterate over all statistics counters, calling "func" for * each counter not suppressed by any "-f" arguments. diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index de998cf..47a5ccd 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -63,7 +63,6 @@ struct vsc { unsigned magic; #define VSC_MAGIC 0x3373554a - struct vsm *vsm; struct vsc_sf_head sf_list_include; struct vsc_sf_head sf_list_exclude; }; @@ -116,15 +115,13 @@ VSC_Destroy_Point(struct VSC_point **p) /*--------------------------------------------------------------------*/ struct vsc * -VSC_New(struct vsm *vsm) +VSC_New(void) { struct vsc *vsc; - AN(vsm); ALLOC_OBJ(vsc, VSC_MAGIC); if (vsc == NULL) return (vsc); - vsc->vsm = vsm; VTAILQ_INIT(&vsc->sf_list_include); VTAILQ_INIT(&vsc->sf_list_exclude); return (vsc); @@ -196,11 +193,7 @@ VSC_Arg(struct vsc *vsc, char arg, const char *opt) switch (arg) { case 'f': return (vsc_f_arg(vsc, opt)); - case 'n': - case 't': - return (VSM_Arg(vsc->vsm, arg, opt)); - default: - return (0); + default: return (0); } } @@ -345,7 +338,8 @@ vsc_iter_fantom(const struct vsc *vsc, const struct vsm_fantom *fantom, */ int __match_proto__() // We don't want vsc to be const -VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv) +VSC_Iter(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *f, + VSC_iter_f *func, void *priv) { struct vsm_fantom ifantom; uint64_t u; @@ -353,12 +347,13 @@ VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv) struct vsb *vsb; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + AN(vsm); vsb = VSB_new_auto(); AN(vsb); - VSM_FOREACH(&ifantom, vsc->vsm) { + VSM_FOREACH(&ifantom, vsm) { if (strcmp(ifantom.class, VSC_CLASS)) continue; - AZ(VSM_Map(vsc->vsm, &ifantom)); + AZ(VSM_Map(vsm, &ifantom)); u = vbe64dec(ifantom.b); if (u == 0) { VRMB(); @@ -370,7 +365,7 @@ VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv) if (f != NULL) { *f = ifantom; } else { - AZ(VSM_Unmap(vsc->vsm, &ifantom)); + AZ(VSM_Unmap(vsm, &ifantom)); } if (i) break; From hermunn at varnish-software.com Fri Sep 15 11:17:11 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:11 +0000 (UTC) Subject: [5.2] 888f254 No quoting needed. Message-ID: <20170915111711.C10E798E26@lists.varnish-cache.org> commit 888f2542b405665010e1df49c8880be903faae21 Author: Poul-Henning Kamp Date: Thu Sep 7 09:45:51 2017 +0000 No quoting needed. diff --git a/bin/varnishd/flint.sh b/bin/varnishd/flint.sh index 569fbbe..1de11ce 100755 --- a/bin/varnishd/flint.sh +++ b/bin/varnishd/flint.sh @@ -3,9 +3,9 @@ FLOPS=' -I../../lib/libvgz -DVARNISHD_IS_NOT_A_VMOD - -DVARNISH_STATE_DIR=\"foo\" - -DVARNISH_VMOD_DIR=\"foo\" - -DVARNISH_VCL_DIR=\"foo\" + -DVARNISH_STATE_DIR="foo" + -DVARNISH_VMOD_DIR="foo" + -DVARNISH_VCL_DIR="foo" cache/*.c common/*.c hash/*.c From hermunn at varnish-software.com Fri Sep 15 11:17:11 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:11 +0000 (UTC) Subject: [5.2] 8e63a9f Yeah, so I forgot: <> includes in .h files is still a bad idea. Message-ID: <20170915111711.DED7098E2B@lists.varnish-cache.org> commit 8e63a9f9cdf43272dddae62fe9cec49aefbc73ce Author: Poul-Henning Kamp Date: Thu Sep 7 10:04:33 2017 +0000 Yeah, so I forgot: <> includes in .h files is still a bad idea. diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 766201e..8695803 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -33,8 +33,6 @@ #endif #define MGT_MGT_H -#include - #include "common/common.h" #include "common/com_params.h" diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index 9284bd0..fa40577 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 907df0d..41456fd 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index f6aa212..d982511 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c index 3b7df19..ea5fff2 100644 --- a/bin/varnishd/mgt/mgt_jail.c +++ b/bin/varnishd/mgt/mgt_jail.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index d39a3d6..f4097d0 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index ac35a7e..74bec16 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 7615228..bba58b3 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 431e937..2bd7bb9 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -29,6 +29,8 @@ #include "config.h" +#include + #include "mgt/mgt.h" #include "mgt/mgt_param.h" diff --git a/bin/varnishd/mgt/mgt_param_tcp.c b/bin/varnishd/mgt/mgt_param_tcp.c index 1519d9d..70ababc 100644 --- a/bin/varnishd/mgt/mgt_param_tcp.c +++ b/bin/varnishd/mgt/mgt_param_tcp.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 49b9b5e..14bceac 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -42,6 +42,8 @@ #include "config.h" +#include + #include "mgt/mgt.h" #include "mgt/mgt_param.h" diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index fdd1d53..d5d5193 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_util.c b/bin/varnishd/mgt/mgt_util.c index 2431532..de31fda 100644 --- a/bin/varnishd/mgt/mgt_util.c +++ b/bin/varnishd/mgt/mgt_util.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 83887c2..641131a 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index afe8532..f8579c0 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index 4d04728..c4b0285 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -33,6 +33,7 @@ #include "config.h" +#include #include #include #include diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index d6ea9a4..5ee2ada 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include From hermunn at varnish-software.com Fri Sep 15 11:17:12 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:12 +0000 (UTC) Subject: [5.2] d9f0a3e Spell __FreeBSD_version correctly Message-ID: <20170915111712.0885498E2F@lists.varnish-cache.org> commit d9f0a3ebe1ef543adf418916a3a1c84ac0cff85a Author: Poul-Henning Kamp Date: Thu Sep 7 10:12:37 2017 +0000 Spell __FreeBSD_version correctly diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index d6c8921..3624c28 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -191,7 +191,7 @@ static struct cli_proto debug_cmds[] = { * XXX: Think more about which order we start things */ -#if defined(__FreeBSD__) && __FreeBSD__version >= 1000000 +#if defined(__FreeBSD__) && __FreeBSD_version >= 1000000 static void child_malloc_fail(void *p, const char *s) { @@ -208,7 +208,7 @@ child_main(void) setbuf(stdout, NULL); setbuf(stderr, NULL); printf("Child starts\n"); -#if defined(__FreeBSD__) && __FreeBSD__version >= 1000000 +#if defined(__FreeBSD__) && __FreeBSD_version >= 1000000 malloc_message = child_malloc_fail; #endif From hermunn at varnish-software.com Fri Sep 15 11:17:12 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:12 +0000 (UTC) Subject: [5.2] a02d6a0 Argument constification polishing Message-ID: <20170915111712.37C0F98E34@lists.varnish-cache.org> commit a02d6a0b3b1482410ea4dcda99280662c984039d Author: Poul-Henning Kamp Date: Thu Sep 7 10:52:41 2017 +0000 Argument constification polishing Helped by: PC-Lint-Plus-RC2 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 3f517e4..e3bc4d4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -849,7 +849,7 @@ void Lck_DestroyClass(struct VSC_lck **vsclck); #include "tbl/locks.h" /* cache_mempool.c */ -void MPL_AssertSane(void *item); +void MPL_AssertSane(const void *item); struct mempool * MPL_New(const char *name, volatile struct poolparam *pp, volatile unsigned *cur_size); void MPL_Destroy(struct mempool **mpp); diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index f86f648..91f5c08 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -517,7 +517,7 @@ VCA_DestroyPool(struct pool *pp) /*--------------------------------------------------------------------*/ -static void * +static void * __match_proto__() vca_acct(void *arg) { struct listen_sock *ls; @@ -573,7 +573,7 @@ vca_acct(void *arg) /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) ccf_start(struct cli *cli, const char * const *av, void *priv) { @@ -586,7 +586,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) ccf_listen_address(struct cli *cli, const char * const *av, void *priv) { struct listen_sock *ls; diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 1ec9ef5..64154f4 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -366,7 +366,7 @@ do_list(struct cli *cli, struct backend *b, void *priv) return (0); } -static void +static void __match_proto__(cli_func_t) cli_backend_list(struct cli *cli, const char * const *av, void *priv) { int probes = 0; @@ -412,7 +412,7 @@ do_set_health(struct cli *cli, struct backend *b, void *priv) return (0); } -static void +static void __match_proto__() cli_backend_set_health(struct cli *cli, const char * const *av, void *priv) { const char *ah; diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 55932e8..39cb394 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -616,7 +616,7 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) * CLI functions to add bans */ -static void +static void __match_proto__(cli_func_t) ccf_ban(struct cli *cli, const char * const *av, void *priv) { int narg, i; @@ -705,7 +705,7 @@ ban_render(struct cli *cli, const uint8_t *bs) } } -static void +static void __match_proto__(cli_func_t) ccf_ban_list(struct cli *cli, const char * const *av, void *priv) { struct ban *b, *bl; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index afa8959..9a2af88 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -223,7 +223,7 @@ VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp, int top) * Debugging aids */ -static void +static void __match_proto__(cli_func_t) debug_fragfetch(struct cli *cli, const char * const *av, void *priv) { (void)priv; diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 3624c28..8602fcf 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -154,7 +154,7 @@ VXID_Get(struct worker *wrk, uint32_t mask) * Dumb down the VXID allocation to make it predictable for * varnishtest cases */ -static void +static void __match_proto__(cli_func_t) cli_debug_xid(struct cli *cli, const char * const *av, void *priv) { (void)priv; diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 45197e8..98c22f0 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -337,7 +337,7 @@ MPL_Free(struct mempool *mpl, void *item) } void -MPL_AssertSane(void *item) +MPL_AssertSane(const void *item) { struct memitem *mi; mi = (void*)((uintptr_t)item - sizeof(*mi)); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 03b3911..0bf34f2 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -178,7 +178,7 @@ pool_mkpool(unsigned pool_no) * NB: be maintained for params which require action. */ -static void * +static void * __match_proto__() pool_poolherder(void *priv) { unsigned nwq; diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index 719df9f..cb73247 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -202,7 +202,7 @@ VMOD_Panic(struct vsb *vsb) /*---------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) ccf_debug_vmod(struct cli *cli, const char * const *av, void *priv) { struct vmod *v; diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index f29a815..b84eee1 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -128,7 +128,7 @@ hcb_is_y(uintptr_t u) } static uintptr_t -hcb_r_node(struct objhead *n) +hcb_r_node(const struct objhead *n) { AZ((uintptr_t)n & (HCB_BIT_NODE | HCB_BIT_Y)); @@ -145,7 +145,7 @@ hcb_l_node(uintptr_t u) } static uintptr_t -hcb_r_y(struct hcb_y *y) +hcb_r_y(const struct hcb_y *y) { CHECK_OBJ_NOTNULL(y, HCB_Y_MAGIC); @@ -273,7 +273,7 @@ hcb_insert(struct worker *wrk, struct hcb_root *root, const uint8_t *digest, /*--------------------------------------------------------------------*/ static void -hcb_delete(struct hcb_root *r, struct objhead *oh) +hcb_delete(struct hcb_root *r, const struct objhead *oh) { struct hcb_y *y; volatile uintptr_t *p; diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 41456fd..125cc31 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -209,7 +209,7 @@ MCH_Fd_Inherit(int fd, const char *what) * Listen to stdout+stderr from the child */ -static int +static int __match_proto__(vlu_f) child_line(void *priv, const char *p) { (void)priv; @@ -686,7 +686,7 @@ mch_cli_server_stop(struct cli *cli, const char * const *av, void *priv) } } -static void +static void __match_proto__(cli_func_t) mch_cli_server_status(struct cli *cli, const char * const *av, void *priv) { (void)av; diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index d982511..e845c63 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -69,7 +69,7 @@ static const char *secret_file; /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) mcf_banner(struct cli *cli, const char *const *av, void *priv) { @@ -97,7 +97,7 @@ static struct cli_proto cli_proto[] = { /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) mcf_panic(struct cli *cli, const char * const *av, void *priv) { @@ -114,7 +114,7 @@ static struct cli_proto cli_debug[] = { /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(cli_func_t) mcf_askchild(struct cli *cli, const char * const *av, void *priv) { int i; @@ -596,7 +596,7 @@ static double M_poll = 0.1; static VTAILQ_HEAD(,m_addr) m_addr_list = VTAILQ_HEAD_INITIALIZER(m_addr_list); -static void +static void __match_proto__(mgt_cli_close_f) Marg_closer(void *priv) { diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 74bec16..53db1ee 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -173,7 +173,7 @@ cli_check(const struct cli *cli) * This function is called when the CLI on stdin is closed. */ -static void +static void __match_proto__(mgt_cli_close_f) mgt_stdin_close(void *priv) { @@ -423,7 +423,7 @@ mgt_uptime(const struct vev *e, int what) /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(mgt_cli_close_f) mgt_I_close(void *priv) { (void)priv; diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index c4b0285..b1d0288 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -88,7 +88,7 @@ static struct cli_proto cli_stv[] = { /*-------------------------------------------------------------------- */ -static void +static void __match_proto__(storage_init_f) smp_fake_init(struct stevedore *parent, int ac, char * const *av) { diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index b4283f3..6c4d79e 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -72,7 +72,7 @@ static VTAILQ_HEAD(,smp_sc) silos = VTAILQ_HEAD_INITIALIZER(silos); */ static int -smp_appendban(struct smp_sc *sc, struct smp_signspace *spc, +smp_appendban(const struct smp_sc *sc, struct smp_signspace *spc, uint32_t len, const uint8_t *ban) { @@ -135,7 +135,7 @@ smp_banexport(const struct stevedore *stv, const uint8_t *bans, unsigned len) */ static int -smp_open_bans(struct smp_sc *sc, struct smp_signspace *spc) +smp_open_bans(const struct smp_sc *sc, struct smp_signspace *spc) { uint8_t *ptr, *pe; int i; @@ -630,7 +630,7 @@ debug_report_silo(struct cli *cli, const struct smp_sc *sc) } } -static void +static void __match_proto__(cli_func_t) debug_persistent(struct cli *cli, const char * const * av, void *priv) { struct smp_sc *sc; From hermunn at varnish-software.com Fri Sep 15 11:17:12 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:12 +0000 (UTC) Subject: [5.2] fe006c9 Add necessary include Message-ID: <20170915111712.5CF2798E3F@lists.varnish-cache.org> commit fe006c9ef1b9a4ff58d9845fa1e64769b6dbb4ed Author: Poul-Henning Kamp Date: Thu Sep 7 10:58:14 2017 +0000 Add necessary include diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c index eb40edf..bc8dabf 100644 --- a/bin/varnishd/common/common_vsc.c +++ b/bin/varnishd/common/common_vsc.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include #include From hermunn at varnish-software.com Fri Sep 15 11:17:12 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:12 +0000 (UTC) Subject: [5.2] 0f37f82 Add necessary include Message-ID: <20170915111712.86A0898E44@lists.varnish-cache.org> commit 0f37f82bdd84ebd5e8b2f0c456183222340e5899 Author: Poul-Henning Kamp Date: Thu Sep 7 11:05:03 2017 +0000 Add necessary include diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 125cc31..ebcaba5 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include From hermunn at varnish-software.com Fri Sep 15 11:17:12 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:12 +0000 (UTC) Subject: [5.2] f411f2a Remove old debug code Message-ID: <20170915111712.A4B2398E56@lists.varnish-cache.org> commit f411f2a8b0cfa2c02c097ff83c171baf5e3bf297 Author: Poul-Henning Kamp Date: Thu Sep 7 11:14:23 2017 +0000 Remove old debug code diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 4b3ffc4..ee70140 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -178,7 +178,6 @@ vwp_main(void *priv) if (vwp->pollfd[0].revents) v--; for (i = 1; i < vwp->hpoll;) { -VSL(SLT_Debug, vwp->pollfd[i].fd, "POLL loop i=%d revents=0x%x", i, vwp->pollfd[i].revents); assert(vwp->pollfd[i].fd != vwp->pipes[0]); wp = vwp->idx[i]; CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); From hermunn at varnish-software.com Fri Sep 15 11:17:12 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:12 +0000 (UTC) Subject: [5.2] 8ec02a5 Add necessary #include Message-ID: <20170915111713.0215198E67@lists.varnish-cache.org> commit 8ec02a5d675b106967305228a98ce9f640c3aa7e Author: Poul-Henning Kamp Date: Thu Sep 7 11:16:23 2017 +0000 Add necessary #include diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index d5d5193..2b9741e 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include From hermunn at varnish-software.com Fri Sep 15 11:17:13 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:13 +0000 (UTC) Subject: [5.2] 7cc5012 decorate with prototypes Message-ID: <20170915111713.2438898E7C@lists.varnish-cache.org> commit 7cc50127867d9900ae36e7aa30693e37d8fb14a7 Author: Poul-Henning Kamp Date: Thu Sep 7 12:34:36 2017 +0000 decorate with prototypes diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 88d2c66..7138ba4 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -52,7 +52,7 @@ static const char progname[] = "varnishstat"; /*--------------------------------------------------------------------*/ -static int +static int __match_proto__(VSC_iter_f) do_xml_cb(void *priv, const struct VSC_point * const pt) { uint64_t val; @@ -90,7 +90,7 @@ do_xml(struct vsm *vsm, struct vsc *vsc) /*--------------------------------------------------------------------*/ -static int +static int __match_proto__(VSC_iter_f) do_json_cb(void *priv, const struct VSC_point * const pt) { uint64_t val; @@ -149,7 +149,7 @@ struct once_priv { int pad; }; -static int +static int __match_proto__(VSC_iter_f) do_once_cb_first(void *priv, const struct VSC_point * const pt) { struct once_priv *op; @@ -166,7 +166,7 @@ do_once_cb_first(void *priv, const struct VSC_point * const pt) return (1); } -static int +static int __match_proto__(VSC_iter_f) do_once_cb(void *priv, const struct VSC_point * const pt) { struct once_priv *op; @@ -207,7 +207,7 @@ do_once(struct vsm *vsm, struct vsc *vsc) /*--------------------------------------------------------------------*/ -static int +static int __match_proto__(VSC_iter_f) do_list_cb(void *priv, const struct VSC_point * const pt) { int i; diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index f2e34bd..e61d2f7 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -255,7 +255,7 @@ struct pt_priv { unsigned n_ptlist; }; -static int +static int __match_proto__(VSC_iter_f) build_pt_list_cb(void *priv, const struct VSC_point *vpt) { struct pt_priv *pt_priv; From hermunn at varnish-software.com Fri Sep 15 11:17:13 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:13 +0000 (UTC) Subject: [5.2] e4de8fe First part of VSC API rework to capitalize on VSM improvements. Message-ID: <20170915111713.451B398E94@lists.varnish-cache.org> commit e4de8fec85df1cc2eccd449b8a203308ed008685 Author: Poul-Henning Kamp Date: Thu Sep 7 19:56:17 2017 +0000 First part of VSC API rework to capitalize on VSM improvements. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 7138ba4..c622cc7 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -42,8 +42,6 @@ #include "vapi/voptget.h" #include "vapi/vsl.h" #include "vdef.h" -#include "vnum.h" -#include "vtim.h" #include "vut.h" #include "varnishstat.h" @@ -83,7 +81,7 @@ do_xml(struct vsm *vsm, struct vsc *vsc) now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf("\n", time_stamp); - (void)VSC_Iter(vsc, vsm, NULL, do_xml_cb, NULL); + (void)VSC_Iter(vsc, vsm, NULL, do_xml_cb, NULL, NULL); printf("\n"); } @@ -137,7 +135,7 @@ do_json(struct vsm *vsm, struct vsc *vsc) (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf(" \"timestamp\": \"%s\",\n", time_stamp); - (void)VSC_Iter(vsc, vsm, NULL, do_json_cb, &jp); + (void)VSC_Iter(vsc, vsm, NULL, do_json_cb, NULL, &jp); printf("\n}\n"); } @@ -201,8 +199,8 @@ do_once(struct vsm *vsm, struct vsc *vsc) memset(&op, 0, sizeof op); op.pad = 18; - (void)VSC_Iter(vsc, vsm, NULL, do_once_cb_first, &op); - (void)VSC_Iter(vsc, vsm, NULL, do_once_cb, &op); + (void)VSC_Iter(vsc, vsm, NULL, do_once_cb_first, NULL, &op); + (void)VSC_Iter(vsc, vsm, NULL, do_once_cb, NULL, &op); } /*--------------------------------------------------------------------*/ @@ -232,7 +230,7 @@ list_fields(struct vsm *vsm, struct vsc *vsc) printf("Field name Description\n"); printf("---------- -----------\n"); - (void)VSC_Iter(vsc, vsm, NULL, do_list_cb, NULL); + (void)VSC_Iter(vsc, vsm, NULL, do_list_cb, NULL, NULL); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index e61d2f7..fcc96ef 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -31,7 +31,6 @@ * Statistics output program */ - #include "config.h" #include @@ -313,7 +312,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) } static void -build_pt_list(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *fantom) +build_pt_list(struct vsc *vsc, struct vsm *vsm) { struct pt_priv pt_priv; int i; @@ -334,7 +333,7 @@ build_pt_list(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *fantom) main_cache_hit = NULL; main_cache_miss = NULL; - (void)VSC_Iter(vsc, vsm, fantom, build_pt_list_cb, &pt_priv); + (void)VSC_Iter(vsc, vsm, NULL, build_pt_list_cb, NULL, &pt_priv); delete_pt_list(); AN(VTAILQ_EMPTY(&ptlist)); AZ(n_ptlist); @@ -1050,7 +1049,6 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) long t; int ch, initial = 1; double now; - struct vsm_fantom f_iter = VSM_FANTOM_NULL; interval = delay; @@ -1073,7 +1071,7 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED))) { init_hitrate(); delete_pt_list(); - build_pt_list(vsc, vd, &f_iter); + build_pt_list(vsc, vd); initial = 0; } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index e81c054..d63b37e 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -849,8 +849,7 @@ varnish_vsc(const struct varnish *v, const char *arg) dp.v = v; dp.arg = arg; (void)VSM_Status(v->vsm_vsc); - - (void)VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_stat_dump_cb, &dp); + (void)VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_stat_dump_cb, NULL, &dp); } /********************************************************************** @@ -915,8 +914,8 @@ varnish_expect(const struct varnish *v, char * const *av) good = 0; for (i = 0; i < 50; i++, (void)usleep(100000)) { (void)VSM_Status(v->vsm_vsc); - - good = VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_expect_cb, &sp); + good = VSC_Iter(v->vsc, v->vsm_vsc, + NULL, do_expect_cb, NULL, &sp); if (!good) { good = -2; continue; diff --git a/flint.lnt b/flint.lnt index f77c78b..3fa3bf4 100644 --- a/flint.lnt +++ b/flint.lnt @@ -27,6 +27,7 @@ /////////////////////////////////////////////////////////////////////// // General stylistic issues +-e663 // Suspicious array to pointer conversion -e574 // Signed-unsigned mix with relational -e641 // Converting enum '...' to int -e716 // while(1) ... diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 986259b..6f747f7 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -82,10 +82,11 @@ struct VSC_point *VSC_Clone_Point(const struct VSC_point * const); void VSC_Destroy_Point(struct VSC_point **); +typedef void *VSC_new_f(void *priv, const struct VSC_point *const pt); typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt); +typedef int VSC_destroy_f(void *priv, const struct VSC_point *const pt); -int VSC_Iter(struct vsc *, struct vsm *, struct vsm_fantom *, - VSC_iter_f *func, void *priv); +int VSC_Iter(struct vsc *, struct vsm *, VSC_new_f *, VSC_iter_f *, VSC_destroy_f *, void *priv); /* * Iterate over all statistics counters, calling "func" for * each counter not suppressed by any "-f" arguments. diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index b5d1b00..b89c90c 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -195,4 +195,5 @@ LIBVARNISHAPI_1.7 { VSM_Dup; VSC_New; VSC_Destroy; + VSC_Iter2; } LIBVARNISHAPI_1.0; diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 47a5ccd..6ccbc9d 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -59,12 +59,28 @@ struct vsc_sf { }; VTAILQ_HEAD(vsc_sf_head, vsc_sf); +struct vsc_pt { + struct VSC_point point; + char *name; +}; + +struct vsc_seg { + unsigned magic; +#define VSC_SEG_MAGIC 0x801177d4 + VTAILQ_ENTRY(vsc_seg) list; + struct vsm_fantom fantom[1]; + struct vjsn *vj; + unsigned npoints; + struct vsc_pt *points; +}; + struct vsc { unsigned magic; #define VSC_MAGIC 0x3373554a struct vsc_sf_head sf_list_include; struct vsc_sf_head sf_list_exclude; + VTAILQ_HEAD(,vsc_seg) segs; }; /*-------------------------------------------------------------------- @@ -81,8 +97,7 @@ static const struct VSC_level_desc * const levels[] = { #undef VSC_LEVEL_F }; -static const size_t nlevels = - sizeof(levels)/sizeof(*levels); +static const size_t nlevels = sizeof(levels)/sizeof(*levels); /*--------------------------------------------------------------------*/ @@ -124,6 +139,7 @@ VSC_New(void) return (vsc); VTAILQ_INIT(&vsc->sf_list_include); VTAILQ_INIT(&vsc->sf_list_exclude); + VTAILQ_INIT(&vsc->segs); return (vsc); } @@ -220,15 +236,20 @@ vsc_filter(const struct vsc *vsc, const char *nm) /*-------------------------------------------------------------------- */ +static void +vsc_clean_point(struct vsc_pt *point) +{ + REPLACE(point->name, NULL); +} + static int -vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, - const struct vjsn_val *vv, struct vsb *vsb, VSC_iter_f *func, void *priv) +vsc_fill_point(const struct vsc *vsc, const struct vsm_fantom *fantom, + const struct vjsn_val *vv, struct vsb *vsb, struct vsc_pt *point) { - struct VSC_point point; struct vjsn_val *vt; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); - memset(&point, 0, sizeof point); + memset(point, 0, sizeof *point); vt = vjsn_child(vv, "name"); AN(vt); @@ -241,13 +262,15 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, if (vsc_filter(vsc, VSB_data(vsb))) return (0); - point.name = VSB_data(vsb); + point->name = strdup(VSB_data(vsb)); + AN(point->name); + point->point.name = point->name; #define DOF(n, k) \ vt = vjsn_child(vv, k); \ AN(vt); \ assert(vt->type == VJSN_STRING); \ - point.n = vt->value; + point->point.n = vt->value; DOF(ctype, "ctype"); DOF(sdesc, "oneliner"); @@ -258,13 +281,13 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, assert(vt->type == VJSN_STRING); if (!strcmp(vt->value, "counter")) { - point.semantics = 'c'; + point->point.semantics = 'c'; } else if (!strcmp(vt->value, "gauge")) { - point.semantics = 'g'; + point->point.semantics = 'g'; } else if (!strcmp(vt->value, "bitmap")) { - point.semantics = 'b'; + point->point.semantics = 'b'; } else { - point.semantics = '?'; + point->point.semantics = '?'; } vt = vjsn_child(vv, "format"); @@ -272,15 +295,15 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, assert(vt->type == VJSN_STRING); if (!strcmp(vt->value, "integer")) { - point.format = 'i'; + point->point.format = 'i'; } else if (!strcmp(vt->value, "bytes")) { - point.format = 'B'; + point->point.format = 'B'; } else if (!strcmp(vt->value, "bitmap")) { - point.format = 'b'; + point->point.format = 'b'; } else if (!strcmp(vt->value, "duration")) { - point.format = 'd'; + point->point.format = 'd'; } else { - point.format = '?'; + point->point.format = '?'; } vt = vjsn_child(vv, "level"); @@ -288,11 +311,11 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, assert(vt->type == VJSN_STRING); if (!strcmp(vt->value, "info")) { - point.level = &level_info; + point->point.level = &level_info; } else if (!strcmp(vt->value, "diag")) { - point.level = &level_diag; + point->point.level = &level_diag; } else if (!strcmp(vt->value, "debug")) { - point.level = &level_debug; + point->point.level = &level_debug; } else { WRONG("Illegal level"); } @@ -300,80 +323,131 @@ vsc_iter_elem(const struct vsc *vsc, const struct vsm_fantom *fantom, vt = vjsn_child(vv, "index"); AN(vt); - point.ptr = (volatile void*) + point->point.ptr = (volatile void*) ((volatile char*)fantom->b + atoi(vt->value)); + return (1); +} + +static void +vsc_del_seg(struct vsm *vsm, struct vsc_seg *sp) +{ + unsigned u; - return (func(priv, &point)); + AN(vsm); + CHECK_OBJ_NOTNULL(sp, VSC_SEG_MAGIC); + AZ(VSM_Unmap(vsm, sp->fantom)); + vjsn_delete(&sp->vj); + for(u = 0; u < sp->npoints; u++) + vsc_clean_point(&sp->points[u]); + free(sp->points); + FREE_OBJ(sp); } -static int -vsc_iter_fantom(const struct vsc *vsc, const struct vsm_fantom *fantom, - struct vsb *vsb, VSC_iter_f *func, void *priv) +static struct vsc_seg * +vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp) { - int i = 0; + struct vsc_seg *sp; + uint64_t u; + unsigned j; const char *p; const char *e; - struct vjsn *vj; struct vjsn_val *vv, *vve; + struct vsb *vsb; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + AN(vsm); + + ALLOC_OBJ(sp, VSC_SEG_MAGIC); + AN(sp); + *sp->fantom = *fp; + AZ(VSM_Map(vsm, sp->fantom)); - p = (char*)fantom->b + 8 + vbe64dec(fantom->b); - assert (p < (char*)fantom->e); - vj = vjsn_parse(p, &e); + u = vbe64dec(sp->fantom->b); + if (u == 0) { + VRMB(); + usleep(100000); + u = vbe64dec(sp->fantom->b); + } + assert(u > 0); + p = (char*)sp->fantom->b + 8 + u; + assert (p < (char*)sp->fantom->e); + sp->vj = vjsn_parse(p, &e); XXXAZ(e); - AN(vj); - vve = vjsn_child(vj->value, "elem"); + vve = vjsn_child(sp->vj->value, "elements"); AN(vve); - VTAILQ_FOREACH(vv, &vve->children, list) { - i = vsc_iter_elem(vsc, fantom, vv, vsb, func, priv); - if (i) - break; + sp->npoints = strtoul(vve->value, NULL, 0); + sp->points = calloc(sp->npoints, sizeof *sp->points); + AN(sp->points); + vsb = VSB_new_auto(); + AN(vsb); + j = 0; + vve = vjsn_child(sp->vj->value, "elem"); + AN(vve); + VTAILQ_FOREACH(vv, &vve->children, list) + (void)vsc_fill_point(vsc, sp->fantom, vv, vsb, sp->points + j++); + VSB_destroy(&vsb); + AN(sp->vj); + return (sp); +} + +static int +vsc_iter_seg(const struct vsc_seg *sp, VSC_iter_f *fiter, void *priv) +{ + unsigned u; + int i = 0; + + CHECK_OBJ_NOTNULL(sp, VSC_SEG_MAGIC); + AN(fiter); + for(u = 0; u < sp->npoints; u++) { + if (sp->points[u].name != NULL) { + i = fiter(priv, &sp->points[u].point); + if (i) + break; + } } - vjsn_delete(&vj); return (i); } -/*-------------------------------------------------------------------- - */ - -int __match_proto__() // We don't want vsc to be const -VSC_Iter(struct vsc *vsc, struct vsm *vsm, struct vsm_fantom *f, - VSC_iter_f *func, void *priv) +int +VSC_Iter(struct vsc *vsc, struct vsm *vsm, + VSC_new_f *fnew, VSC_iter_f *fiter, VSC_destroy_f *fdestroy, void *priv) { - struct vsm_fantom ifantom; - uint64_t u; + struct vsm_fantom ifantom; + struct vsc_seg *sp, *sp2; int i = 0; - struct vsb *vsb; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); AN(vsm); - vsb = VSB_new_auto(); - AN(vsb); + (void)fnew; + (void)fdestroy; + sp = VTAILQ_FIRST(&vsc->segs); VSM_FOREACH(&ifantom, vsm) { if (strcmp(ifantom.class, VSC_CLASS)) continue; - AZ(VSM_Map(vsm, &ifantom)); - u = vbe64dec(ifantom.b); - if (u == 0) { - VRMB(); - usleep(100000); - u = vbe64dec(ifantom.b); + while (sp != NULL && + (strcmp(ifantom.ident, sp->fantom->ident) || + VSM_StillValid(vsm, sp->fantom) != VSM_valid)) { + sp2 = sp; + sp = VTAILQ_NEXT(sp, list); + VTAILQ_REMOVE(&vsc->segs, sp2, list); + vsc_del_seg(vsm, sp2); } - assert(u > 0); - i = vsc_iter_fantom(vsc, &ifantom, vsb, func, priv); - if (f != NULL) { - *f = ifantom; + if (sp != NULL) { + i = vsc_iter_seg(sp, fiter, priv); + sp = VTAILQ_NEXT(sp, list); } else { - AZ(VSM_Unmap(vsm, &ifantom)); + sp = vsc_add_seg(vsc, vsm, &ifantom); + VTAILQ_INSERT_TAIL(&vsc->segs, sp, list); + i = vsc_iter_seg(sp, fiter, priv); + sp = NULL; } if (i) break; } - VSB_destroy(&vsb); return (i); } + /*-------------------------------------------------------------------- */ @@ -397,4 +471,3 @@ VSC_ChangeLevel(const struct VSC_level_desc *old, int chg) i = 0; return (levels[i]); } - From hermunn at varnish-software.com Fri Sep 15 11:17:13 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:13 +0000 (UTC) Subject: [5.2] 631cf7d Try to get the VSM ownership right. Message-ID: <20170915111713.6AB9898EB9@lists.varnish-cache.org> commit 631cf7dfc141db9020d23e185947971fe998c4d3 Author: Poul-Henning Kamp Date: Thu Sep 7 22:05:41 2017 +0000 Try to get the VSM ownership right. The general rule is that if varnishd is started as root, you need to be root or in group "varnish" to access the shared memory. Fixes #2419 diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 8695803..ad6abe7 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -166,7 +166,6 @@ void mgt_SHM_static_alloc(const void *, ssize_t size, void mgt_SHM_Create(void); void mgt_SHM_Destroy(int keep); -extern struct vsmw *mgt_vsmw; void mgt_SHM_ChildNew(void); void mgt_SHM_ChildDestroy(void); diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index e845c63..d7fa6a6 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -504,9 +504,9 @@ mgt_cli_secret(const char *S_arg) char buf[BUFSIZ]; /* Save in shmem */ - VJ_master(JAIL_MASTER_FILE); mgt_SHM_static_alloc(S_arg, strlen(S_arg) + 1L, "Arg", "-S"); + VJ_master(JAIL_MASTER_FILE); fd = open(S_arg, O_RDONLY); if (fd < 0) { fprintf(stderr, "Can not open secret-file \"%s\"\n", S_arg); @@ -574,9 +574,7 @@ mgt_cli_telnet(const char *T_arg) if (VSB_len(vsb) == 0) ARGV_ERR("-T %s could not be listened on.\n", T_arg); /* Save in shmem */ - VJ_master(JAIL_MASTER_FILE); mgt_SHM_static_alloc(VSB_data(vsb), VSB_len(vsb) + 1, "Arg", "-T"); - VJ_master(JAIL_MASTER_LOW); VSB_destroy(&vsb); } diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 53db1ee..67492d6 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -839,10 +839,8 @@ main(int argc, char * const *argv) mgt_SHM_Init(); - VJ_master(JAIL_MASTER_FILE); mgt_SHM_static_alloc(i_arg, strlen(i_arg) + 1L, "Arg", "-i"); VSC_C_mgt = VSC_mgt_New(""); - VJ_master(JAIL_MASTER_LOW); if (M_arg != NULL) mgt_cli_master(M_arg); diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index 2b9741e..b81c8a5 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -47,7 +47,7 @@ #include "vsm_priv.h" #include "vsmw.h" -struct vsmw *mgt_vsmw; +static struct vsmw *mgt_vsmw; /*-------------------------------------------------------------------- */ @@ -90,13 +90,16 @@ mgt_shm_atexit(void) void mgt_SHM_Init(void) { + int fd; VJ_master(JAIL_MASTER_FILE); AZ(system("rm -rf " VSM_MGT_DIRNAME)); AZ(mkdir(VSM_MGT_DIRNAME, 0755)); - mgt_vsmw = VSMW_New(open(VSM_MGT_DIRNAME, O_RDONLY), 0640, "_.index"); - AN(mgt_vsmw); + fd = open(VSM_MGT_DIRNAME, O_RDONLY); + VJ_fix_vsm_dir(fd); VJ_master(JAIL_MASTER_LOW); + mgt_vsmw = VSMW_New(fd, 0640, "_.index"); + AN(mgt_vsmw); proc_vsmw = mgt_vsmw; @@ -119,7 +122,6 @@ mgt_SHM_ChildNew(void) MCH_Fd_Inherit(heritage.vsm_fd, "VSMW"); - VJ_master(JAIL_MASTER_FILE); heritage.param = VSMW_Allocf(mgt_vsmw, VSM_CLASS_PARAM, sizeof *heritage.param, ""); AN(heritage.param); @@ -129,7 +131,6 @@ mgt_SHM_ChildNew(void) heritage.panic_str = VSMW_Allocf(mgt_vsmw, "Panic", heritage.panic_str_len, ""); AN(heritage.panic_str); - VJ_master(JAIL_MASTER_LOW); } void From hermunn at varnish-software.com Fri Sep 15 11:17:13 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:13 +0000 (UTC) Subject: [5.2] b72f1c6 Rototill the last bit of the VSC-api and simplify varnishstat_curses accordingly. Message-ID: <20170915111713.8EB9298EDD@lists.varnish-cache.org> commit b72f1c645c40d7fdaf005170fe9b41854f0fcdcd Author: Poul-Henning Kamp Date: Fri Sep 8 08:50:44 2017 +0000 Rototill the last bit of the VSC-api and simplify varnishstat_curses accordingly. If somebody has time to push varnishstat in curses mode though the paces and check that everything works I'd appreciate it. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index c622cc7..d114281 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -81,7 +81,7 @@ do_xml(struct vsm *vsm, struct vsc *vsc) now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf("\n", time_stamp); - (void)VSC_Iter(vsc, vsm, NULL, do_xml_cb, NULL, NULL); + (void)VSC_Iter(vsc, vsm, do_xml_cb, NULL); printf("\n"); } @@ -135,7 +135,7 @@ do_json(struct vsm *vsm, struct vsc *vsc) (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); printf(" \"timestamp\": \"%s\",\n", time_stamp); - (void)VSC_Iter(vsc, vsm, NULL, do_json_cb, NULL, &jp); + (void)VSC_Iter(vsc, vsm, do_json_cb, &jp); printf("\n}\n"); } @@ -199,8 +199,8 @@ do_once(struct vsm *vsm, struct vsc *vsc) memset(&op, 0, sizeof op); op.pad = 18; - (void)VSC_Iter(vsc, vsm, NULL, do_once_cb_first, NULL, &op); - (void)VSC_Iter(vsc, vsm, NULL, do_once_cb, NULL, &op); + (void)VSC_Iter(vsc, vsm, do_once_cb_first, &op); + (void)VSC_Iter(vsc, vsm, do_once_cb, &op); } /*--------------------------------------------------------------------*/ @@ -230,7 +230,7 @@ list_fields(struct vsm *vsm, struct vsc *vsc) printf("Field name Description\n"); printf("---------- -----------\n"); - (void)VSC_Iter(vsc, vsm, NULL, do_list_cb, NULL, NULL); + (void)VSC_Iter(vsc, vsm, do_list_cb, NULL); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index fcc96ef..dec9c47 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -72,7 +72,7 @@ struct pt { #define PT_MAGIC 0x41698E4F VTAILQ_ENTRY(pt) list; - struct VSC_point *vpt; + const struct VSC_point *vpt; char seen; @@ -119,6 +119,7 @@ static int sample = 0; static int scale = 1; static double t_sample = 0.; static double interval = 1.; +static int vsm_status = 0; static void init_hitrate(void) @@ -226,130 +227,6 @@ build_pt_array(void) } static void -delete_pt_list(void) -{ - struct pt *pt; - unsigned i = 0; - - delete_pt_array(); - - while (!VTAILQ_EMPTY(&ptlist)) { - pt = VTAILQ_FIRST(&ptlist); - CHECK_OBJ_NOTNULL(pt, PT_MAGIC); - VTAILQ_REMOVE(&ptlist, pt, list); - VSC_Destroy_Point(&pt->vpt); - FREE_OBJ(pt); - i++; - } - assert(i == n_ptlist); - n_ptlist = 0; - - update_position(); -} - -struct pt_priv { - unsigned magic; -#define PT_PRIV_MAGIC 0x34ACBAD6 - VTAILQ_HEAD(, pt) ptlist; - unsigned n_ptlist; -}; - -static int __match_proto__(VSC_iter_f) -build_pt_list_cb(void *priv, const struct VSC_point *vpt) -{ - struct pt_priv *pt_priv; - struct pt *pt; - - if (vpt == NULL) - return (0); - - CAST_OBJ_NOTNULL(pt_priv, priv, PT_PRIV_MAGIC); - - AZ(strcmp(vpt->ctype, "uint64_t")); - - if (!strcmp(vpt->name, "MGT.uptime")) - mgt_uptime = vpt->ptr; - if (!strcmp(vpt->name, "MAIN.uptime")) - main_uptime = vpt->ptr; - if (!strcmp(vpt->name, "MAIN.cache_hit")) - main_cache_hit = vpt->ptr; - if (!strcmp(vpt->name, "MAIN.cache_miss")) - main_cache_miss = vpt->ptr; - - VTAILQ_FOREACH(pt, &ptlist, list) { - CHECK_OBJ_NOTNULL(pt, PT_MAGIC); - AN(pt->vpt->name); - if (strcmp(vpt->name, pt->vpt->name)) - continue; - VTAILQ_REMOVE(&ptlist, pt, list); - AN(n_ptlist); - n_ptlist--; - VSC_Destroy_Point(&pt->vpt); - pt->vpt = VSC_Clone_Point(vpt); - AN(pt->vpt); - VTAILQ_INSERT_TAIL(&pt_priv->ptlist, pt, list); - pt_priv->n_ptlist++; - return (0); - } - AZ(pt); - - ALLOC_OBJ(pt, PT_MAGIC); - AN(pt); - - pt->vpt = VSC_Clone_Point(vpt); - AN(pt->vpt); - - pt->last = *pt->vpt->ptr; - - pt->ma_10.nmax = 10; - pt->ma_100.nmax = 100; - pt->ma_1000.nmax = 1000; - - VTAILQ_INSERT_TAIL(&pt_priv->ptlist, pt, list); - pt_priv->n_ptlist++; - - return (0); -} - -static void -build_pt_list(struct vsc *vsc, struct vsm *vsm) -{ - struct pt_priv pt_priv; - int i; - struct pt *pt_current = NULL; - int current_line = 0; - - if (current < n_ptarray) { - pt_current = ptarray[current]; - current_line = current - page_start; - } - - pt_priv.magic = PT_PRIV_MAGIC; - VTAILQ_INIT(&pt_priv.ptlist); - pt_priv.n_ptlist = 0; - - mgt_uptime = NULL; - main_uptime = NULL; - main_cache_hit = NULL; - main_cache_miss = NULL; - - (void)VSC_Iter(vsc, vsm, NULL, build_pt_list_cb, NULL, &pt_priv); - delete_pt_list(); - AN(VTAILQ_EMPTY(&ptlist)); - AZ(n_ptlist); - VTAILQ_CONCAT(&ptlist, &pt_priv.ptlist, list); - n_ptlist = pt_priv.n_ptlist; - build_pt_array(); - - for (i = 0; pt_current != NULL && i < n_ptarray; i++) - if (ptarray[i] == pt_current) - break; - current = i; - page_start = current - current_line; - update_position(); -} - -static void sample_points(void) { struct pt *pt; @@ -528,11 +405,22 @@ print_duration(WINDOW *w, time_t t) } static void +running(WINDOW *w, time_t up, int flg) +{ + if (vsm_status & flg) { + print_duration(w_status, up); + } else { + wattron(w, A_STANDOUT); + wprintw(w, " Not Running"); + wattroff(w, A_STANDOUT); + } +} + +static void draw_status(void) { time_t up_mgt = 0; time_t up_chld = 0; - static const char discon[] = "*** DISCONNECTED ***"; AN(w_status); @@ -543,14 +431,12 @@ draw_status(void) if (main_uptime != NULL) up_chld = *main_uptime; - mvwprintw(w_status, 0, 0, "Uptime mgt: "); - print_duration(w_status, up_mgt); - mvwprintw(w_status, 1, 0, "Uptime child:"); - print_duration(w_status, up_chld); + mvwprintw(w_status, 0, 0, "Uptime mgt: "); + running(w_status, up_mgt, VSM_MGT_RUNNING); + mvwprintw(w_status, 1, 0, "Uptime child: "); + running(w_status, up_chld, VSM_WRK_RUNNING); - if (mgt_uptime == NULL) - mvwprintw(w_status, 0, COLS - strlen(discon), discon); - else if (COLS > 70) { + if (COLS > 70) { mvwprintw(w_status, 0, getmaxx(w_status) - 37, "Hitrate n: %8u %8u %8u", hitrate.hr_10.n, hitrate.hr_100.n, hitrate.hr_1000.n); @@ -1042,12 +928,62 @@ handle_keypress(int ch) redraw = 1; } +static void * __match_proto__(VSC_new_f) +newpt(void *priv, const struct VSC_point *const vpt) +{ + struct pt *pt; + + ALLOC_OBJ(pt, PT_MAGIC); + AN(pt); + AZ(priv); + pt->vpt = vpt; + pt->last = *pt->vpt->ptr; + pt->ma_10.nmax = 10; + pt->ma_100.nmax = 100; + pt->ma_1000.nmax = 1000; + + VTAILQ_INSERT_TAIL(&ptlist, pt, list); + n_ptlist++; + + AZ(strcmp(vpt->ctype, "uint64_t")); + + if (!strcmp(vpt->name, "MGT.uptime")) + mgt_uptime = vpt->ptr; + if (!strcmp(vpt->name, "MAIN.uptime")) + main_uptime = vpt->ptr; + if (!strcmp(vpt->name, "MAIN.cache_hit")) + main_cache_hit = vpt->ptr; + if (!strcmp(vpt->name, "MAIN.cache_miss")) + main_cache_miss = vpt->ptr; + return (pt); +} + +static void __match_proto__(VSC_destroy_f) +delpt(void *priv, const struct VSC_point *const vpt) +{ + struct pt *pt; + + AZ(priv); + CAST_OBJ_NOTNULL(pt, vpt->priv, PT_MAGIC); + VTAILQ_REMOVE(&ptlist, pt, list); + n_ptlist--; + FREE_OBJ(pt); + if (vpt->ptr == mgt_uptime) + mgt_uptime = NULL; + if (vpt->ptr == main_uptime) + main_uptime = NULL; + if (vpt->ptr == main_cache_hit) + main_cache_hit = NULL; + if (vpt->ptr == main_cache_miss) + main_cache_miss = NULL; +} + void -do_curses(struct vsm *vd, struct vsc *vsc, double delay) +do_curses(struct vsm *vsm, struct vsc *vsc, double delay) { struct pollfd pollfd; long t; - int ch, initial = 1; + int ch; double now; interval = delay; @@ -1066,13 +1002,17 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) make_windows(); doupdate(); + VSC_State(vsc, newpt, delpt, NULL); + + rebuild = 1; while (keep_running) { - if (initial || - (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED))) { + vsm_status = VSM_Status(vsm); + rebuild |= vsm_status & ~(VSM_MGT_RUNNING|VSM_WRK_RUNNING); + if (rebuild) { + (void)VSC_Iter(vsc, vsm, NULL, NULL); init_hitrate(); - delete_pt_list(); - build_pt_list(vsc, vd); - initial = 0; + build_pt_array(); + redraw = 1; } now = VTIM_mono(); @@ -1080,8 +1020,6 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) sample = 1; if (sample) sample_data(); - if (rebuild) - build_pt_array(); if (redraw) draw_screen(); @@ -1103,6 +1041,8 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay) break; } } - VSM_Destroy(&vd); + VSC_Destroy(&vsc); + AN(VTAILQ_EMPTY(&ptlist)); + VSM_Destroy(&vsm); AZ(endwin()); } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index d63b37e..965931c 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -849,7 +849,7 @@ varnish_vsc(const struct varnish *v, const char *arg) dp.v = v; dp.arg = arg; (void)VSM_Status(v->vsm_vsc); - (void)VSC_Iter(v->vsc, v->vsm_vsc, NULL, do_stat_dump_cb, NULL, &dp); + (void)VSC_Iter(v->vsc, v->vsm_vsc, do_stat_dump_cb, &dp); } /********************************************************************** @@ -914,8 +914,7 @@ varnish_expect(const struct varnish *v, char * const *av) good = 0; for (i = 0; i < 50; i++, (void)usleep(100000)) { (void)VSM_Status(v->vsm_vsc); - good = VSC_Iter(v->vsc, v->vsm_vsc, - NULL, do_expect_cb, NULL, &sp); + good = VSC_Iter(v->vsc, v->vsm_vsc, do_expect_cb, &sp); if (!good) { good = -2; continue; diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 6f747f7..969c243 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -41,25 +41,6 @@ struct vsm; struct vsc; struct vsm_fantom; -/*--------------------------------------------------------------------- - * VSC level access functions - */ - -struct vsc *VSC_New(void); -void VSC_Destroy(struct vsc **); - -int VSC_Arg(struct vsc *, char arg, const char *opt); - /* - * Handle standard stat-presenter arguments - * Return: - * -1 error, VSM_Error() returns diagnostic string - * 0 not handled - * 1 Handled. - */ - -struct VSC_level_desc; -struct VSC_point; - struct VSC_level_desc { const char *name; /* name */ const char *label; /* label */ @@ -71,50 +52,104 @@ struct VSC_point { const volatile uint64_t *ptr; /* field value */ const char *name; /* field name */ const char *ctype; /* C-type */ - int semantics; /* semantics */ - int format; /* display format */ + int semantics; /* semantics + * 'c' = Counter + * 'g' = Gauge + * 'b' = bitmap + * '?' = unknown + */ + int format; /* display format + * 'i' = integer + * 'B' = bytes + * 'b' = bitmap + * 'd' = duration + * '?' = unknown + */ const struct VSC_level_desc *level; /* verbosity level */ const char *sdesc; /* short description */ const char *ldesc; /* long description */ + void *priv; /* return val from VSC_new_f */ }; -struct VSC_point *VSC_Clone_Point(const struct VSC_point * const); - -void VSC_Destroy_Point(struct VSC_point **); +/*--------------------------------------------------------------------- + * Function pointers + */ typedef void *VSC_new_f(void *priv, const struct VSC_point *const pt); + /* + * priv is from VSC_State(). + * + * The return value is installed in pt->priv + */ + +typedef void VSC_destroy_f(void *priv, const struct VSC_point *const pt); + /* + * priv is from VSC_State(). + */ + typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt); -typedef int VSC_destroy_f(void *priv, const struct VSC_point *const pt); + /* + * priv is the argument to VSC_Iter() and not from VSC_State(). + * + * A non-zero return terminates the iteration + */ -int VSC_Iter(struct vsc *, struct vsm *, VSC_new_f *, VSC_iter_f *, VSC_destroy_f *, void *priv); +/*--------------------------------------------------------------------- + * VSC level access functions + */ + +struct vsc *VSC_New(void); /* - * Iterate over all statistics counters, calling "func" for - * each counter not suppressed by any "-f" arguments. + * Create a new VSC instance + */ + +void VSC_Destroy(struct vsc **); + /* + * Destroy a VSC instance * - * fantom points to a struct vsm_fantom. If non-NULL, it can be - * used with VSM_StillValid to check the validity of the points - * returned. + * If a destroy function was installed with VSC_State() + * it will be called for all remaining points + */ + +int VSC_Arg(struct vsc *, char arg, const char *opt); + /* + * Handle standard stat-presenter arguments + * 'f' - filter * - * The returned points are valid for at most 60 seconds after - * VSM_StillValid(,fantom) starts returning anything but - * VSM_valid, or until the next call to VSC_Iter. Using the point - * values after any of these events gives undefined behavior. + * Return: + * -1 error, VSM_Error() returns diagnostic string + * 0 not handled + * 1 Handled. + */ + +void VSC_State(struct vsc *, VSC_new_f *, VSC_destroy_f *, void *); + /* + * Install function pointers for create/destroy and their + * priv pointer. All arguments can be NULL. + */ + +int VSC_Iter(struct vsc *, struct vsm *, VSC_iter_f *, void *priv); + /* + * Iterate over all statistics counters, calling a function for + * each counter not suppressed by any "-f" arguments. * - * Func is called with pt == NULL, whenever VSM allocations - * change (child restart, allocations/deallocations) + * To discover new/deleted points, call VSM_Status() first. + * + * The returned points are valid until the next call to VSC_Iter() * * Arguments: * vd: The vsm context - * fantom: Pointer to a fantom. Can be NULL. * func: The callback function * priv: Passed as argument to func * * Returns: * !=0: func returned non-zero - * -1: No VSC's available * 0: Done */ const struct VSC_level_desc *VSC_ChangeLevel(const struct VSC_level_desc*, int); + /* + * Change a level up or down. + */ #endif /* VAPI_VSC_H_INCLUDED */ diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index b89c90c..aee341b 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -195,5 +195,5 @@ LIBVARNISHAPI_1.7 { VSM_Dup; VSC_New; VSC_Destroy; - VSC_Iter2; + VSC_State; } LIBVARNISHAPI_1.0; diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 6ccbc9d..417c834 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -69,7 +69,7 @@ struct vsc_seg { #define VSC_SEG_MAGIC 0x801177d4 VTAILQ_ENTRY(vsc_seg) list; struct vsm_fantom fantom[1]; - struct vjsn *vj; + struct vjsn *vj; unsigned npoints; struct vsc_pt *points; }; @@ -81,6 +81,10 @@ struct vsc { struct vsc_sf_head sf_list_include; struct vsc_sf_head sf_list_exclude; VTAILQ_HEAD(,vsc_seg) segs; + + VSC_new_f *fnew; + VSC_destroy_f *fdestroy; + void *priv; }; /*-------------------------------------------------------------------- @@ -101,34 +105,6 @@ static const size_t nlevels = sizeof(levels)/sizeof(*levels); /*--------------------------------------------------------------------*/ -struct VSC_point * -VSC_Clone_Point(const struct VSC_point * const vp) -{ - struct VSC_point *pt; - char *p; - - pt = calloc(sizeof *pt, 1); - AN(pt); - *pt = *vp; - p = strdup(pt->name); AN(p); pt->name = p; - p = strdup(pt->sdesc); AN(p); pt->sdesc = p; - p = strdup(pt->ldesc); AN(p); pt->ldesc = p; - return (pt); -} - -void -VSC_Destroy_Point(struct VSC_point **p) -{ - AN(p); - free(TRUST_ME((*p)->ldesc)); - free(TRUST_ME((*p)->sdesc)); - free(TRUST_ME((*p)->name)); - free(*p); - *p = NULL; -} - -/*--------------------------------------------------------------------*/ - struct vsc * VSC_New(void) { @@ -215,6 +191,18 @@ VSC_Arg(struct vsc *vsc, char arg, const char *opt) /*-------------------------------------------------------------------- */ +void +VSC_State(struct vsc *vsc, VSC_new_f *fn, VSC_destroy_f *fd, void *priv) +{ + + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); + vsc->fnew = fn; + vsc->fdestroy = fd; + vsc->priv = priv; +} + +/*-------------------------------------------------------------------- + */ static int vsc_filter(const struct vsc *vsc, const char *nm) @@ -329,16 +317,22 @@ vsc_fill_point(const struct vsc *vsc, const struct vsm_fantom *fantom, } static void -vsc_del_seg(struct vsm *vsm, struct vsc_seg *sp) +vsc_del_seg(const struct vsc *vsc, struct vsm *vsm, struct vsc_seg *sp) { unsigned u; + struct vsc_pt *pp; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); AN(vsm); CHECK_OBJ_NOTNULL(sp, VSC_SEG_MAGIC); AZ(VSM_Unmap(vsm, sp->fantom)); vjsn_delete(&sp->vj); - for(u = 0; u < sp->npoints; u++) - vsc_clean_point(&sp->points[u]); + pp = sp->points; + for(u = 0; u < sp->npoints; u++, pp++) { + if (vsc->fdestroy != NULL) + vsc->fdestroy(vsc->priv, &pp->point); + vsc_clean_point(pp); + } free(sp->points); FREE_OBJ(sp); } @@ -348,11 +342,11 @@ vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp) { struct vsc_seg *sp; uint64_t u; - unsigned j; const char *p; const char *e; struct vjsn_val *vv, *vve; struct vsb *vsb; + struct vsc_pt *pp; CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); AN(vsm); @@ -380,37 +374,41 @@ vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp) AN(sp->points); vsb = VSB_new_auto(); AN(vsb); - j = 0; vve = vjsn_child(sp->vj->value, "elem"); AN(vve); - VTAILQ_FOREACH(vv, &vve->children, list) - (void)vsc_fill_point(vsc, sp->fantom, vv, vsb, sp->points + j++); + pp = sp->points; + VTAILQ_FOREACH(vv, &vve->children, list) { + if (vsc_fill_point(vsc, sp->fantom, vv, vsb, pp) && + vsc->fnew != NULL) + pp->point.priv = vsc->fnew(vsc->priv, &pp->point); + pp++; + } VSB_destroy(&vsb); AN(sp->vj); return (sp); } static int -vsc_iter_seg(const struct vsc_seg *sp, VSC_iter_f *fiter, void *priv) +vsc_iter_seg(const struct vsc *vsc, const struct vsc_seg *sp, + VSC_iter_f *fiter, void *priv) { unsigned u; int i = 0; + struct vsc_pt *pp; + CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); CHECK_OBJ_NOTNULL(sp, VSC_SEG_MAGIC); AN(fiter); - for(u = 0; u < sp->npoints; u++) { - if (sp->points[u].name != NULL) { - i = fiter(priv, &sp->points[u].point); - if (i) - break; - } + pp = sp->points; + for(u = 0; u < sp->npoints && i == 0; u++, pp++) { + if (pp->name != NULL) + i = fiter(priv, &pp->point); } return (i); } int -VSC_Iter(struct vsc *vsc, struct vsm *vsm, - VSC_new_f *fnew, VSC_iter_f *fiter, VSC_destroy_f *fdestroy, void *priv) +VSC_Iter(struct vsc *vsc, struct vsm *vsm, VSC_iter_f *fiter, void *priv) { struct vsm_fantom ifantom; struct vsc_seg *sp, *sp2; @@ -418,8 +416,6 @@ VSC_Iter(struct vsc *vsc, struct vsm *vsm, CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); AN(vsm); - (void)fnew; - (void)fdestroy; sp = VTAILQ_FIRST(&vsc->segs); VSM_FOREACH(&ifantom, vsm) { if (strcmp(ifantom.class, VSC_CLASS)) @@ -430,20 +426,28 @@ VSC_Iter(struct vsc *vsc, struct vsm *vsm, sp2 = sp; sp = VTAILQ_NEXT(sp, list); VTAILQ_REMOVE(&vsc->segs, sp2, list); - vsc_del_seg(vsm, sp2); + vsc_del_seg(vsc, vsm, sp2); } if (sp != NULL) { - i = vsc_iter_seg(sp, fiter, priv); + if (fiter != NULL) + i = vsc_iter_seg(vsc, sp, fiter, priv); sp = VTAILQ_NEXT(sp, list); } else { sp = vsc_add_seg(vsc, vsm, &ifantom); VTAILQ_INSERT_TAIL(&vsc->segs, sp, list); - i = vsc_iter_seg(sp, fiter, priv); + if (fiter != NULL) + i = vsc_iter_seg(vsc, sp, fiter, priv); sp = NULL; } if (i) break; } + while (sp != NULL) { + sp2 = sp; + sp = VTAILQ_NEXT(sp, list); + VTAILQ_REMOVE(&vsc->segs, sp2, list); + vsc_del_seg(vsc, vsm, sp2); + } return (i); } diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 96c171b..50e1805 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -353,7 +354,7 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) retval |= VSM_MGT_CHANGED; vs->fd = openat(vs->dfd, "_.index", O_RDONLY); if (vs->fd < 0) - return (retval|VSM_NUKE_ALL); + return (retval|VSM_MGT_RESTARTED); AZ(fstat(vs->fd, &vs->fst)); @@ -376,17 +377,17 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) * XXX: be kill(pid,0)'ed for more rapid abandonment detection. */ i = sscanf(VSB_data(vsb), "# %ju %ju\n%n", &id1, &id2, &ac); - if (i != 2) { - retval |= VSM_MGT_RESTARTED; - return (retval|VSM_NUKE_ALL); + if (i != 2 || kill(id1, 0)) { + retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; + return (retval); } + retval |= VSM_MGT_RUNNING; if (id1 != vs->id1 || id2 != vs->id2) { - retval |= VSM_MGT_RESTARTED; + retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; vs->id1 = id1; vs->id2 = id2; } p = VSB_data(vsb) + ac; - retval |= VSM_MGT_RUNNING; VTAILQ_FOREACH(vg, &vs->segs, list) vg->markscan = 0; From hermunn at varnish-software.com Fri Sep 15 11:17:13 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:13 +0000 (UTC) Subject: [5.2] bc27a10 Only react on kill(2) if process doesn't exist. Message-ID: <20170915111713.ADB7998EF7@lists.varnish-cache.org> commit bc27a102fb2b5758a55dd9f6c5ceecfaa0b35e83 Author: Poul-Henning Kamp Date: Fri Sep 8 09:54:13 2017 +0000 Only react on kill(2) if process doesn't exist. diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 50e1805..ccb0dfb 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -377,7 +377,7 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) * XXX: be kill(pid,0)'ed for more rapid abandonment detection. */ i = sscanf(VSB_data(vsb), "# %ju %ju\n%n", &id1, &id2, &ac); - if (i != 2 || kill(id1, 0)) { + if (i != 2 || (kill(id1, 0) && errno == ESRCH)) { retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; return (retval); } From hermunn at varnish-software.com Fri Sep 15 11:17:13 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:13 +0000 (UTC) Subject: [5.2] 41b557f Change the jail-API so we can get the vsm dir permissions right. Message-ID: <20170915111713.CE05E98F0C@lists.varnish-cache.org> commit 41b557f57bdef25b58bc5179cd487f7107c89339 Author: Poul-Henning Kamp Date: Fri Sep 8 09:58:51 2017 +0000 Change the jail-API so we can get the vsm dir permissions right. Fixes #2419 diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index ad6abe7..f5ba1e3 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -99,11 +99,17 @@ enum jail_master_e { JAIL_MASTER_KILL, }; +enum jail_fixfd_e { + JAIL_FIXFD_FILE, + JAIL_FIXFD_VSMMGT, + JAIL_FIXFD_VSMWRK, +}; + typedef int jail_init_f(char **); typedef void jail_master_f(enum jail_master_e); typedef void jail_subproc_f(enum jail_subproc_e); typedef int jail_make_dir_f(const char *dname); -typedef void jail_fixfile_f(int fd); +typedef void jail_fixfd_f(int fd, enum jail_fixfd_e); struct jail_tech { unsigned magic; @@ -114,8 +120,7 @@ struct jail_tech { jail_subproc_f *subproc; jail_make_dir_f *make_workdir; jail_make_dir_f *make_vcldir; - jail_fixfile_f *vsm_file; - jail_fixfile_f *storage_file; + jail_fixfd_f *fixfd; }; void VJ_Init(const char *j_arg); @@ -123,8 +128,7 @@ void VJ_master(enum jail_master_e jme); void VJ_subproc(enum jail_subproc_e jse); int VJ_make_workdir(const char *dname); int VJ_make_vcldir(const char *dname); -void VJ_fix_vsm_dir(int fd); -void VJ_fix_storage_file(int fd); +void VJ_fix_fd(int fd, enum jail_fixfd_e); extern const struct jail_tech jail_tech_unix; extern const struct jail_tech jail_tech_solaris; diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c index ea5fff2..d241cf7 100644 --- a/bin/varnishd/mgt/mgt_jail.c +++ b/bin/varnishd/mgt/mgt_jail.c @@ -181,19 +181,10 @@ VJ_make_vcldir(const char *dname) } void -VJ_fix_storage_file(int fd) +VJ_fix_fd(int fd, enum jail_fixfd_e what) { CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC); - if (vjt->storage_file != NULL) - vjt->storage_file(fd); -} - -void -VJ_fix_vsm_dir(int fd) -{ - - CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC); - if (vjt->vsm_file != NULL) - vjt->vsm_file(fd); + if (vjt->fixfd != NULL) + vjt->fixfd(fd, what); } diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index f4097d0..4d4c56d 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -254,22 +254,27 @@ vju_make_vcldir(const char *dname) } -static void __match_proto__(jail_fixfile_f) -vju_vsm_dir(int fd) +static void __match_proto__(jail_fixfd_f) +vju_fixfd(int fd, enum jail_fixfd_e what) { /* Called under JAIL_MASTER_FILE */ - AZ(fchmod(fd, 0750)); - AZ(fchown(fd, vju_wrkuid, vju_wrkgid)); -} - -static void __match_proto__(jail_fixfile_f) -vju_storage_file(int fd) -{ - /* Called under JAIL_MASTER_STORAGE */ - - AZ(fchmod(fd, 0600)); - AZ(fchown(fd, vju_uid, vju_gid)); + switch (what) { + case JAIL_FIXFD_FILE: + AZ(fchmod(fd, 0750)); + AZ(fchown(fd, vju_wrkuid, vju_wrkgid)); + break; + case JAIL_FIXFD_VSMMGT: + AZ(fchmod(fd, 0750)); + AZ(fchown(fd, vju_uid, vju_gid)); + break; + case JAIL_FIXFD_VSMWRK: + AZ(fchmod(fd, 0750)); + AZ(fchown(fd, vju_wrkuid, vju_wrkgid)); + break; + default: + WRONG("Ain't Fixin'"); + } } const struct jail_tech jail_tech_unix = { @@ -278,7 +283,6 @@ const struct jail_tech jail_tech_unix = { .init = vju_init, .master = vju_master, .make_vcldir = vju_make_vcldir, - .vsm_file = vju_vsm_dir, - .storage_file = vju_storage_file, + .fixfd = vju_fixfd, .subproc = vju_subproc, }; diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index b81c8a5..6853a1f 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -96,7 +96,7 @@ mgt_SHM_Init(void) AZ(system("rm -rf " VSM_MGT_DIRNAME)); AZ(mkdir(VSM_MGT_DIRNAME, 0755)); fd = open(VSM_MGT_DIRNAME, O_RDONLY); - VJ_fix_vsm_dir(fd); + VJ_fix_fd(fd, JAIL_FIXFD_VSMMGT); VJ_master(JAIL_MASTER_LOW); mgt_vsmw = VSMW_New(fd, 0640, "_.index"); AN(mgt_vsmw); @@ -117,7 +117,7 @@ mgt_SHM_ChildNew(void) heritage.vsm_fd = open(VSM_CHILD_DIRNAME, O_RDONLY); assert(heritage.vsm_fd >= 0); - VJ_fix_vsm_dir(heritage.vsm_fd); + VJ_fix_fd(heritage.vsm_fd, JAIL_FIXFD_VSMWRK); VJ_master(JAIL_MASTER_LOW); MCH_Fd_Inherit(heritage.vsm_fd, "VSMW"); diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index 5ee2ada..d620447 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -84,7 +84,7 @@ STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx) VJ_master(JAIL_MASTER_STORAGE); fd = open(fn, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600); if (fd >= 0) { - VJ_fix_storage_file(fd); + VJ_fix_fd(fd, JAIL_FIXFD_FILE); *fdp = fd; *fnp = fn; VJ_master(JAIL_MASTER_LOW); @@ -123,7 +123,7 @@ STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx) ctx, fn); *fdp = fd; - VJ_fix_storage_file(fd); + VJ_fix_fd(fd, JAIL_FIXFD_FILE); VJ_master(JAIL_MASTER_LOW); return (retval); } From hermunn at varnish-software.com Fri Sep 15 11:17:13 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:13 +0000 (UTC) Subject: [5.2] 5cf7f33 Properly implement VSC_Destroy() Message-ID: <20170915111713.EE9DF98F17@lists.varnish-cache.org> commit 5cf7f3347bd572857cab8d0c0ba1320268f0ced5 Author: Poul-Henning Kamp Date: Fri Sep 8 11:36:59 2017 +0000 Properly implement VSC_Destroy() Fixes #2420 diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index dec9c47..fb492f7 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -1041,7 +1041,7 @@ do_curses(struct vsm *vsm, struct vsc *vsc, double delay) break; } } - VSC_Destroy(&vsc); + VSC_Destroy(&vsc, vsm); AN(VTAILQ_EMPTY(&ptlist)); VSM_Destroy(&vsm); AZ(endwin()); diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 965931c..6dfaae7 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -332,6 +332,10 @@ varnish_delete(struct varnish *v) vtc_logclose(v->vl); free(v->name); free(v->workdir); + if (v->vsc != NULL) + VSC_Destroy(&v->vsc, v->vsm_vsc); + if (v->vsm_vsc != NULL) + VSM_Destroy(&v->vsm_vsc); if (v->vsm_vsl != NULL) VSM_Destroy(&v->vsm_vsl); diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 969c243..88ac0b7 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -103,7 +103,7 @@ struct vsc *VSC_New(void); * Create a new VSC instance */ -void VSC_Destroy(struct vsc **); +void VSC_Destroy(struct vsc **, struct vsm *); /* * Destroy a VSC instance * diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 417c834..8ca2572 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -121,33 +121,6 @@ VSC_New(void) /*--------------------------------------------------------------------*/ -static void -vsc_delete_sf_list(struct vsc_sf_head *head) -{ - struct vsc_sf *sf; - - while (!VTAILQ_EMPTY(head)) { - sf = VTAILQ_FIRST(head); - CHECK_OBJ_NOTNULL(sf, VSC_SF_MAGIC); - VTAILQ_REMOVE(head, sf, list); - free(sf->pattern); - FREE_OBJ(sf); - } -} - -void -VSC_Destroy(struct vsc **vscp) -{ - struct vsc *vsc; - - TAKE_OBJ_NOTNULL(vsc, vscp, VSC_MAGIC); - vsc_delete_sf_list(&vsc->sf_list_include); - vsc_delete_sf_list(&vsc->sf_list_exclude); - FREE_OBJ(vsc); -} - -/*--------------------------------------------------------------------*/ - static int vsc_f_arg(struct vsc *vsc, const char *opt) { @@ -475,3 +448,36 @@ VSC_ChangeLevel(const struct VSC_level_desc *old, int chg) i = 0; return (levels[i]); } + +/*--------------------------------------------------------------------*/ + +static void +vsc_delete_sf_list(struct vsc_sf_head *head) +{ + struct vsc_sf *sf; + + while (!VTAILQ_EMPTY(head)) { + sf = VTAILQ_FIRST(head); + CHECK_OBJ_NOTNULL(sf, VSC_SF_MAGIC); + VTAILQ_REMOVE(head, sf, list); + free(sf->pattern); + FREE_OBJ(sf); + } +} + +void +VSC_Destroy(struct vsc **vscp, struct vsm *vsm) +{ + struct vsc *vsc; + struct vsc_seg *sp, *sp2; + + TAKE_OBJ_NOTNULL(vsc, vscp, VSC_MAGIC); + vsc_delete_sf_list(&vsc->sf_list_include); + vsc_delete_sf_list(&vsc->sf_list_exclude); + VTAILQ_FOREACH_SAFE(sp, &vsc->segs, list, sp2) { + VTAILQ_REMOVE(&vsc->segs, sp, list); + vsc_del_seg(vsc, vsm, sp); + } + FREE_OBJ(vsc); +} + From hermunn at varnish-software.com Fri Sep 15 11:17:14 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:14 +0000 (UTC) Subject: [5.2] 0a4222f Only use the kill(pid, 0) test to detect dead process if it has indicated the process was present at one point. Message-ID: <20170915111714.1ABC398F2B@lists.varnish-cache.org> commit 0a4222f72d3f0c66003a98a79442c69f199cb68e Author: Poul-Henning Kamp Date: Fri Sep 8 12:17:15 2017 +0000 Only use the kill(pid,0) test to detect dead process if it has indicated the process was present at one point. diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index ccb0dfb..e7cc519 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -120,6 +120,8 @@ struct vsm { int attached; double patience; + + int couldkill; }; /*--------------------------------------------------------------------*/ @@ -347,9 +349,11 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) closefd(&vs->fd); } - - if (vs->fd >= 0) - return (retval|VSM_MGT_RUNNING); + if (vs->fd >= 0) { + if (!vd->couldkill || !kill(vs->id1, 0)) + retval |= VSM_MGT_RUNNING; + return (retval); + } retval |= VSM_MGT_CHANGED; vs->fd = openat(vs->dfd, "_.index", O_RDONLY); @@ -377,7 +381,13 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) * XXX: be kill(pid,0)'ed for more rapid abandonment detection. */ i = sscanf(VSB_data(vsb), "# %ju %ju\n%n", &id1, &id2, &ac); - if (i != 2 || (kill(id1, 0) && errno == ESRCH)) { + if (i != 2) { + retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; + return (retval); + } + if (!kill(id1, 0)) { + vd->couldkill = 1; + } else if (vd->couldkill && errno == ESRCH) { retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; return (retval); } From hermunn at varnish-software.com Fri Sep 15 11:17:14 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:14 +0000 (UTC) Subject: [5.2] 2a89541 Make vxp_test at least compile, while pondering if it should be removed. Message-ID: <20170915111714.41A2698F47@lists.varnish-cache.org> commit 2a895415bc869a36d5e4fc0bd8cc6998a8568aa9 Author: Poul-Henning Kamp Date: Fri Sep 8 13:20:38 2017 +0000 Make vxp_test at least compile, while pondering if it should be removed. diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c index 0848ee3..527bbb7 100644 --- a/lib/libvarnishapi/vxp_lexer.c +++ b/lib/libvarnishapi/vxp_lexer.c @@ -173,6 +173,7 @@ vxp_Lexer(struct vxp *vxp) } #ifdef VXP_DEBUG +#include void vxp_PrintTokens(const struct vxp *vxp) { diff --git a/lib/libvarnishapi/vxp_test.c b/lib/libvarnishapi/vxp_test.c index bcca61b..4cc0f8d 100644 --- a/lib/libvarnishapi/vxp_test.c +++ b/lib/libvarnishapi/vxp_test.c @@ -34,6 +34,9 @@ #include #include "miniobj.h" +#include "vdef.h" +#include "vqueue.h" +#include "vre.h" #include "vas.h" #include "vsb.h" @@ -69,7 +72,7 @@ main(int argc, char * const *argv) vsb = VSB_new_auto(); AN(vsb); - vex = vex_New(q_arg, vsb); + vex = vex_New(q_arg, vsb, 0); if (vex == NULL) { VSB_finish(vsb); From hermunn at varnish-software.com Fri Sep 15 11:17:14 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:14 +0000 (UTC) Subject: [5.2] fb779c9 Add VSM_NOPID environment variable to disable pid-based tests Message-ID: <20170915111714.5FF6E98F63@lists.varnish-cache.org> commit fb779c9cf3ff04ee87de30027d33fdfce08dcbf2 Author: Nils Goroll Date: Fri Sep 8 17:09:48 2017 +0200 Add VSM_NOPID environment variable to disable pid-based tests varnishd writes its pids to vsm segments for vsm clients to determine if varnishd processes are alive. When running varnishd and vsm clients in different containers, the pid information has no relevance and may even be ambiguous across name spaces. Setting the environment variable VSM_NOPID for vsm clients disables use of pid information. Patch by phk diff --git a/doc/sphinx/reference/vsm.rst b/doc/sphinx/reference/vsm.rst index fbea284..a6a0713 100644 --- a/doc/sphinx/reference/vsm.rst +++ b/doc/sphinx/reference/vsm.rst @@ -102,3 +102,22 @@ a chance to discover the deallocation. The include file provides the supported API for accessing VSM files. + +VSM and Containers +------------------ + +The varnish way works great with single purpose containers. By sharing +the varnish working directory read-only, vsm clients can be run in +containers separate from those running varnishd instances on the same +host. + +When running varnishd and vsm clients in the same process namespace, +pid information can be used by vsm clients to determine if varnishd +processes are alive. + +But, when running varnishd and vsm clients in different containers, +the pid information has no relevance and may even be ambiguous across +name spaces. + +Thus, with such setups, the environment variable VSM_NOPID needs to be +set for vsm clients to disable use of pid information. diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index e7cc519..9d3ed85 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -191,6 +191,8 @@ VSM_New(void) vd->child = vsm_newset(VSM_CHILD_DIRNAME); vd->dfd = -1; vd->patience = 5; + if (getenv("VSM_NOPID") != NULL) + vd->couldkill = -1; return (vd); } @@ -350,7 +352,7 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) } if (vs->fd >= 0) { - if (!vd->couldkill || !kill(vs->id1, 0)) + if (vd->couldkill < 1 || !kill(vs->id1, 0)) retval |= VSM_MGT_RUNNING; return (retval); } @@ -385,9 +387,9 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; return (retval); } - if (!kill(id1, 0)) { + if (vd->couldkill >= 0 && !kill(id1, 0)) { vd->couldkill = 1; - } else if (vd->couldkill && errno == ESRCH) { + } else if (vd->couldkill > 0 && errno == ESRCH) { retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; return (retval); } From hermunn at varnish-software.com Fri Sep 15 11:17:14 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:14 +0000 (UTC) Subject: [5.2] 89f4c80 bring back mlock() of vsm mappings Message-ID: <20170915111714.84B9998F78@lists.varnish-cache.org> commit 89f4c80f9597896e617669a2a4d96633ee1c944f Author: Nils Goroll Date: Fri Sep 8 19:22:13 2017 +0200 bring back mlock() of vsm mappings It got lost during the new world order megacommit 74328de8eeb2703591fe59190f73fcabf057adbe diff --git a/lib/libvarnish/vsmw.c b/lib/libvarnish/vsmw.c index a5c7e3f..ee2a443 100644 --- a/lib/libvarnish/vsmw.c +++ b/lib/libvarnish/vsmw.c @@ -181,6 +181,7 @@ VSMW_Allocv(struct vsmw *vsmw, const char *class, size_t len, AZ(close(fd)); assert(seg->ptr != MAP_FAILED); + (void)mlock(seg->ptr, len); VTAILQ_INSERT_TAIL(&vsmw->segs, seg, list); fd = openat(vsmw->vdirfd, vsmw->idx, O_APPEND | O_WRONLY); From hermunn at varnish-software.com Fri Sep 15 11:17:14 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:14 +0000 (UTC) Subject: [5.2] c1473be Some progress with the vsm docs for new world order Message-ID: <20170915111714.A0FC998F83@lists.varnish-cache.org> commit c1473beaa4175ba702c474e5d12e3048785b6f66 Author: Nils Goroll Date: Fri Sep 8 19:35:53 2017 +0200 Some progress with the vsm docs for new world order This still needs more TLC! Please feel free to continue... diff --git a/doc/sphinx/reference/vsm.rst b/doc/sphinx/reference/vsm.rst index a6a0713..7771b01 100644 --- a/doc/sphinx/reference/vsm.rst +++ b/doc/sphinx/reference/vsm.rst @@ -6,26 +6,20 @@ Varnish uses shared memory to export parameters, logging and statistics, because it is faster and much more efficient than regular files. -"Varnish Shared Memory" or VSM, is the overall mechanism, which -manages a number of allocated "chunks" inside the same shared -memory file. - -Each Chunk is just a slap of memory, which has -a three-part name (class, type, ident) and a length. +"Varnish Shared Memory" or VSM, is the overall mechanism maintaining +sets of shared memory files, each consisting a chunk of memory +identified by a two-part name (class, ident). The Class indicates what type of data is stored in the chunk, for instance "Arg" for command line arguments useful for establishing an CLI connection to the varnishd, "Stat" for statistics counters (VSC) and "Log" for log records (VSL). -The type and ident name parts are mostly used with stats -counters, where they identify dynamic counters, such as: +The ident name part is mostly used with stats counters, where they +identify dynamic counters, such as: SMA.Transient.c_bytes -The size of the VSM is a parameter, but changes only take -effect when the child process is restarted. - Shared memory trickery ---------------------- @@ -67,13 +61,14 @@ off" period. The Varnish way: ---------------- -If varnishd starts, and finds a locked shared memory file, it will -exit with a message about using different -n arguments if you want -multiple instances of varnishd. +.. XXX: not yet up to date with VSM new world order + +When varnishd starts, it opens locked shared memory files, advising to +use different -n arguments if an attempt is made to run multiple +varnishd instances with the same name. -Otherwise, it will create a new shared memory file each time it -starts a child process, since that marks a clean break in operation -anyway. +Child processes each use their own shared memory files, since a worker +process restart marks a clean break in operation anyway. To the extent possible, old shared memory files are marked as abandoned by setting the alloc_seq field to zero, which should be @@ -107,17 +102,17 @@ VSM and Containers ------------------ The varnish way works great with single purpose containers. By sharing -the varnish working directory read-only, vsm clients can be run in +the varnish working directory read-only, vsm readers can be run in containers separate from those running varnishd instances on the same host. -When running varnishd and vsm clients in the same process namespace, -pid information can be used by vsm clients to determine if varnishd +When running varnishd and vsm readers in the same process namespace, +pid information can be used by vsm readers to determine if varnishd processes are alive. -But, when running varnishd and vsm clients in different containers, +But, when running varnishd and vsm readers in different containers, the pid information has no relevance and may even be ambiguous across name spaces. Thus, with such setups, the environment variable VSM_NOPID needs to be -set for vsm clients to disable use of pid information. +set for vsm readers to disable use of pid information. From hermunn at varnish-software.com Fri Sep 15 11:17:14 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:14 +0000 (UTC) Subject: [5.2] 9b08d11 Remove blob operations from vmod-debug Message-ID: <20170915111714.BF5DE98F91@lists.varnish-cache.org> commit 9b08d1123d7de2de7cd63334cf67b6d9ed05c769 Author: Federico G. Schwindt Date: Sun Sep 10 19:02:24 2017 +0200 Remove blob operations from vmod-debug Missed in 32877991. diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 5a3ce7e..324d389 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -64,14 +64,6 @@ $Function STRING test_priv_top(PRIV_TOP, STRING) Test function for TOP private pointers -$Function BLOB str2blob(STRING src="foo") - -Turn a string into a blob - -$Function STRING blob2hex(BLOB src) - -Hexdump a blob - $Function BACKEND no_backend() Fails at backend selection diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index f4fac46..09312cf 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -151,42 +151,6 @@ vmod_test_priv_vcl(VRT_CTX, struct vmod_priv *priv) assert(!strcmp(priv_vcl->foo, "FOO")); } -VCL_BLOB -vmod_str2blob(VRT_CTX, VCL_STRING s) -{ - struct vmod_priv *p; - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - WARN_RETIRED(); - p = (void*)WS_Alloc(ctx->ws, sizeof *p); - AN(p); - memset(p, 0, sizeof *p); - p->len = strlen(s); - p->priv = WS_Copy(ctx->ws, s, -1); - return (p); -} - -VCL_STRING -vmod_blob2hex(VRT_CTX, VCL_BLOB b) -{ - char *s, *p; - uint8_t *q; - int i; - - WARN_RETIRED(); - s = WS_Alloc(ctx->ws, b->len * 2 + 2); - AN(s); - p = s; - q = b->priv; - for (i = 0; i < b->len; i++) { - assert(snprintf(p, 3, "%02x", *q) == 2); - p += 2; - q += 1; - } - VRT_priv_fini(b); - return (s); -} - VCL_BACKEND vmod_no_backend(VRT_CTX) { From hermunn at varnish-software.com Fri Sep 15 11:17:14 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:14 +0000 (UTC) Subject: [5.2] eb95883 Update the travis-ci build Message-ID: <20170915111714.DFF9C98FA8@lists.varnish-cache.org> commit eb95883df22c37dfbefc92fe34da5c3d1d57bd25 Author: Federico G. Schwindt Date: Sun Sep 10 22:40:52 2017 +0200 Update the travis-ci build - Revert to previous trusty image (ref. google/sanitizers/issues/837) - Switch to xcode9 on osx - Scaffolding to get the sanitizer job using clang 5.0 - ASAN: Disable stack protector - ASAN: Ignore sigsegv and sigbus diff --git a/.travis.yml b/.travis.yml index 98239ec..a3b1cb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ --- sudo: required language: c +group: deprecated-2017Q3 matrix: include: - os: linux @@ -14,7 +15,7 @@ matrix: compiler: clang env: CLANG=4.0 - os: osx - osx_image: xcode8.3 + osx_image: xcode9 compiler: clang allow_failures: - os: osx @@ -28,16 +29,19 @@ before_install: brew update; brew install docutils nghttp2; fi - - if [[ "$CLANG" == "4.0" ]]; then + - if [[ -n "$CLANG" ]]; then wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -; sudo apt-add-repository -y - 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main'; + "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-$CLANG main"; + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA9EF27F; + sudo apt-add-repository -y + "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main"; sudo apt-get update; - sudo apt-get install -y clang-4.0 llvm-4.0; - export CC=clang-4.0; - export CONFIGURE_ARGS="--enable-developer-warnings --enable-debugging-symbols --enable-asan --enable-ubsan"; - export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1; + sudo apt-get install -y clang-$CLANG llvm-$CLANG; + export CC=clang-$CLANG; + export CONFIGURE_ARGS="--enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --enable-asan --enable-ubsan"; + export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0; export LSAN_OPTIONS=suppressions=$(pwd)/tools/lsan.suppr; export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,suppressions=$(pwd)/tools/ubsan.suppr; fi From hermunn at varnish-software.com Fri Sep 15 11:17:15 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:15 +0000 (UTC) Subject: [5.2] b196c77 Rewrite the .map file and only expose LIBVARNISHAPI_2.0 Message-ID: <20170915111715.0BB7B98FCE@lists.varnish-cache.org> commit b196c775c84d2a06cb3b4b159d37c066b1e61e3d Author: Poul-Henning Kamp Date: Sun Sep 10 21:37:20 2017 +0000 Rewrite the .map file and only expose LIBVARNISHAPI_2.0 diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index aee341b..37d8e72 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -26,174 +26,115 @@ * SUCH DAMAGE. */ -LIBVARNISHAPI_1.0 { - global: - # Functions - VSM_New; - VSM_Diag; - VSM_n_Arg; - VSM_Name; - VSM_Delete; - VSM_Open; - VSM_ReOpen; - VSM_Seq; - VSM_Head; - VSM_Find_Chunk; - VSM_Close; - VSM__iter0; - VSM__itern; - - VSC_Setup; - VSC_Arg; - VSC_Open; - VSC_Main; - VSC_Iter; - - VSL_Setup; - VSL_Open; - VSL_Arg; - VSL_H_Print; - VSL_Select; - VSL_NonBlocking; - VSL_Dispatch; - VSL_NextLog; - VSL_Matched; - - VCLI_WriteResult; - VCLI_ReadResult; - VCLI_AuthResponse; - - # Variables - VSL_tags; - local: +LIBVARNISHAPI_2.0 { + global: + # vas.c + VAS_Fail; + + # vcli.c + VCLI_AuthResponse; + VCLI_ReadResult; + VCLI_WriteResult; + + # vcs.c + VCS_Message; + + # vsb.c + VSB_bcat; + VSB_cat; + VSB_clear; + VSB_data; + VSB_delete; + VSB_destroy; + VSB_error; + VSB_finish; + VSB_indent; + VSB_len; + VSB_new; + VSB_printf; + VSB_putc; + VSB_quote; + VSB_quote_pfx; + VSB_vprintf; + + # vsc.c + VSC_Arg; + VSC_ChangeLevel; + VSC_Destroy; + VSC_Iter; + VSC_New; + VSC_State; + + # vsl*.c + VSLQ_Delete; + VSLQ_Dispatch; + VSLQ_Flush; + VSLQ_Name2Grouping; + VSLQ_New; + VSLQ_SetCursor; + VSLQ_grouping; + VSL_Arg; + VSL_Check; + VSL_CursorFile; + VSL_CursorVSM; + VSL_Delete; + VSL_DeleteCursor; + VSL_Error; + VSL_Glob2Tags; + VSL_List2Tags; + VSL_Match; + VSL_Name2Tag; + VSL_New; + VSL_Next; + VSL_Print; + VSL_PrintAll; + VSL_PrintTerse; + VSL_PrintTransactions; + VSL_ResetCursor; + VSL_ResetError; + VSL_Write; + VSL_WriteAll; + VSL_WriteOpen; + VSL_WriteTransactions; + VSL_tagflags; + VSL_tags; + + # vsm.c + VSM_Arg; + VSM_Attach; + VSM_Destroy; + VSM_Dup; + VSM_Error; + VSM_Get; + VSM_Map; + VSM_New; + VSM_ResetError; + VSM_Status; + VSM_StillValid; + VSM_Unmap; + VSM__iter0; + VSM__itern; + VSM_invalid; + VSM_valid; + # vtim.c + VTIM_format; + VTIM_mono; + VTIM_parse; + VTIM_real; + VTIM_sleep; + VTIM_timespec; + VTIM_timeval; + + # vut.c + VUT; + VUT_Arg; + VUT_Error; + VUT_Fini; + VUT_Init; + VUT_Main; + VUT_Setup; + VUT_g_Arg; + + local: *; }; - -LIBVARNISHAPI_1.1 { - global: - # Functions: - VSL_Name2Tag; - # Variables: -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.2 { - global: - # Functions: - VSL_NextSLT; - VSM_Error; - VSM_Get; - # Variables: -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.3 { - global: - # Functions: - VSM_Abandoned; - VSM_ResetError; - VSM_StillValid; - VSC_Mgt; - VSC_LevelDesc; - VSL_New; - VSL_Delete; - VSL_Error; - VSL_ResetError; - VSL_CursorVSM; - VSL_CursorFile; - VSL_DeleteCursor; - VSL_Next; - VSL_Match; - VSL_Print; - VSL_PrintTerse; - VSL_PrintAll; - VSL_PrintTransactions; - VSL_WriteOpen; - VSL_Write; - VSL_WriteAll; - VSL_WriteTransactions; - VSLQ_New; - VSLQ_Delete; - VSLQ_Dispatch; - VSLQ_Flush; - VSLQ_Name2Grouping; - VSL_Glob2Tags; - VSL_List2Tags; - VSM_N_Arg; - VSL_Check; - VSL_ResetCursor; - # Variables: - VSLQ_grouping; - VSL_tagflags; -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.4 { - global: - VNUM; - VSLQ_SetCursor; - VSM_IsOpen; -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.5 { - global: - VUT_Error; - VUT_g_Arg; - VUT_Arg; - VUT_Setup; - VUT_Init; - VUT_Fini; - VUT_Main; - VUT; - - VTIM_mono; - VTIM_real; - VTIM_sleep; - - VSB_new; - VSB_destroy; - VSB_error; - VSB_cat; - VSB_putc; - VSB_printf; - VSB_clear; - VSB_finish; - VSB_len; - VSB_data; - - VAS_Fail; - - VCS_Message; -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.6 { - global: - VTIM_format; - VSB_bcat; - VSB_quote; - VSB_vprintf; - VSB_delete; - VSB_indent; - VTIM_parse; - VTIM_timespec; - VTIM_timeval; -} LIBVARNISHAPI_1.0; - -LIBVARNISHAPI_1.7 { - global: - VSC_ChangeLevel; - VSM_invalid; - VSM_valid; - VSM_similar; - VSM_Start; - VSM_Destroy; - VSM_Map; - VSM_Unmap; - VSC_Destroy_Point; - VSC_Clone_Point; - VSM_Refresh; - VSM_Attach; - VSM_Status; - VSM_Arg; - VSM_Dup; - VSC_New; - VSC_Destroy; - VSC_State; -} LIBVARNISHAPI_1.0; From hermunn at varnish-software.com Fri Sep 15 11:17:15 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:15 +0000 (UTC) Subject: [5.2] c6be527 Fail the test if we panic when stopping the child Message-ID: <20170915111715.2EECC98FFC@lists.varnish-cache.org> commit c6be527fdc7cc1e9cc3c6f734bb9aad06bc82201 Author: Federico G. Schwindt Date: Mon Sep 11 01:53:10 2017 +0200 Fail the test if we panic when stopping the child diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index c7ee3c6..5853b70 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -38,4 +38,4 @@ client c1 { expect_close } -run -varnish v1 -cliok "panic.show" +varnish v1 -cliok "panic.clear" diff --git a/bin/varnishtest/tests/p00007.vtc b/bin/varnishtest/tests/p00007.vtc index 7cb0743..559f170 100644 --- a/bin/varnishtest/tests/p00007.vtc +++ b/bin/varnishtest/tests/p00007.vtc @@ -56,6 +56,8 @@ varnish v1 -cliok "debug.persistent s0 dump" # Panic worker so second segment does not get closed varnish v1 -clierr 400 "debug.panic.worker" +varnish v1 -cliok "panic.clear" + delay 0.5 # start again diff --git a/bin/varnishtest/tests/t02004.vtc b/bin/varnishtest/tests/t02004.vtc index 58e8743..24610d1 100644 --- a/bin/varnishtest/tests/t02004.vtc +++ b/bin/varnishtest/tests/t02004.vtc @@ -24,4 +24,4 @@ client c1 { expect_close } -run -varnish v1 -wait-stopped +varnish v1 -cliok "panic.clear" diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 6dfaae7..33cfcb9 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -137,8 +137,8 @@ wait_stopped(const struct varnish *v) char *r = NULL; enum VCLI_status_e st; + vtc_log(v->vl, 3, "wait-stopped"); while (1) { - vtc_log(v->vl, 3, "wait-stopped"); st = varnish_ask_cli(v, "status", &r); if (st != CLIS_OK) vtc_fatal(v->vl, @@ -600,26 +600,13 @@ varnish_start(struct varnish *v) static void varnish_stop(struct varnish *v) { - char *r = NULL; - if (v->cli_fd < 0) varnish_launch(v); if (vtc_error) return; vtc_log(v->vl, 2, "Stop"); (void)varnish_ask_cli(v, "stop", NULL); - while (1) { - (void)varnish_ask_cli(v, "status", &r); - AN(r); - if (!strcmp(r, "Child in state stopped")) { - free(r); - break; - } - free(r); - r = NULL; - (void)sleep (1); - /* XXX: should fail eventually */ - } + wait_stopped(v); } /********************************************************************** @@ -685,6 +672,9 @@ varnish_wait(struct varnish *v) /* Then stop it */ varnish_stop(v); + if (varnish_ask_cli(v, "panic.clear", NULL) != CLIS_CANT) + vtc_fatal(v->vl, "Unexpected panic"); + varnish_cleanup(v); } From hermunn at varnish-software.com Fri Sep 15 11:17:15 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:15 +0000 (UTC) Subject: [5.2] 777dcf7 Clean up and systematize our blessed vmod's Makefile.am Message-ID: <20170915111715.4A6D49801B@lists.varnish-cache.org> commit 777dcf72eb0a1060a1083ae3f5d78cabf4279551 Author: Poul-Henning Kamp Date: Mon Sep 11 07:39:39 2017 +0000 Clean up and systematize our blessed vmod's Makefile.am diff --git a/lib/libvmod_blob/Makefile.am b/lib/libvmod_blob/Makefile.am index b0de15f..bb7b363 100644 --- a/lib/libvmod_blob/Makefile.am +++ b/lib/libvmod_blob/Makefile.am @@ -1,4 +1,23 @@ # + +libvmod_blob_la_SOURCES = \ + vmod_blob.c \ + vmod_blob.h \ + id.c \ + base64.h \ + base64.c \ + hex.h \ + hex.c \ + url.c \ + wb.h \ + wb.c \ + parse_encoding.h \ + parse_encoding.c + +base64.o: base64.c base64.h + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -10,42 +29,34 @@ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_blob vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs = --strict + vmod_LTLIBRARIES = libvmod_blob.la libvmod_blob_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_blob_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ +libvmod_blob_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_blob_la_SOURCES = \ - vmod_blob.c \ - vmod_blob.h \ - id.c \ - base64.h \ - base64.c \ - hex.h \ - hex.c \ - url.c \ - wb.h \ - wb.c \ - parse_encoding.h \ - parse_encoding.c - nodist_libvmod_blob_la_SOURCES = \ vcc_if.c \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_blob_la_OBJECTS):vcc_if.h +$(libvmod_blob_la_OBJECTS): vcc_if.h vcc_if.h vmod_blob.rst vmod_blob.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc -base64.o: base64.c base64.h - EXTRA_DIST = vmod.vcc CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index 4376ef5..58bd825 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -1,4 +1,12 @@ # + +libvmod_debug_la_SOURCES = \ + vmod_debug.c \ + vmod_debug_obj.c \ + vmod_debug_dyn.c + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -9,27 +17,30 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_debug vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = +vmodtoolargs = --strict + noinst_LTLIBRARIES = libvmod_debug.la libvmod_debug_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_debug_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared -rpath /nowhere \ +libvmod_debug_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_debug_la_SOURCES = \ - vmod_debug.c \ - vmod_debug_obj.c \ - vmod_debug_dyn.c - nodist_libvmod_debug_la_SOURCES = \ vcc_if.c \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_debug_la_OBJECTS):vcc_if.h +$(libvmod_debug_la_OBJECTS): vcc_if.h vcc_if.h vmod_debug.rst vmod_debug.man.rst: vcc_if.c diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 324d389..2ed8a9e 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -37,8 +37,6 @@ of VMOD handling in Varnish. $Event event_function -You are not supposed to be able to see this text in the .RST - $Function VOID panic(STRING_LIST) Don't. diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index dfcbbee..23bcf94 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -1,22 +1,4 @@ # -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_directors -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict -vmod_LTLIBRARIES = libvmod_directors.la - -libvmod_directors_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_directors_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ - @SAN_LDFLAGS@ libvmod_directors_la_SOURCES = \ vdir.c \ @@ -35,19 +17,47 @@ libvmod_directors_la_SOURCES = \ shard_parse_vcc_enums.h \ shard_parse_vcc_enums.c +# Boilerplate, do not change + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmod_srcdir = $(top_srcdir)/lib/libvmod_directors +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict + +vmod_LTLIBRARIES = libvmod_directors.la + +libvmod_directors_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_directors_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ + @SAN_LDFLAGS@ + nodist_libvmod_directors_la_SOURCES = \ vcc_if.c \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_directors_la_OBJECTS):vcc_if.h +$(libvmod_directors_la_OBJECTS): vcc_if.h vcc_if.h vmod_directors.rst vmod_directors.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - EXTRA_DIST = vmod.vcc CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ diff --git a/lib/libvmod_purge/Makefile.am b/lib/libvmod_purge/Makefile.am index 4a1098b..44a69cb 100644 --- a/lib/libvmod_purge/Makefile.am +++ b/lib/libvmod_purge/Makefile.am @@ -1,5 +1,10 @@ # +libvmod_purge_la_SOURCES = \ + vmod_purge.c + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -11,16 +16,22 @@ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_purge vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs = --strict + vmod_LTLIBRARIES = libvmod_purge.la libvmod_purge_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_purge_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ +libvmod_purge_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_purge_la_SOURCES = vmod_purge.c - nodist_libvmod_purge_la_SOURCES = \ vcc_if.c \ vcc_if.h diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index ec9580c..2ddf28b 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -1,5 +1,13 @@ # +libvmod_std_la_SOURCES = \ + vmod_std.c \ + vmod_std_conversions.c \ + vmod_std_fileread.c \ + vmod_std_querysort.c + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -11,20 +19,22 @@ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_std vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs = --strict + vmod_LTLIBRARIES = libvmod_std.la libvmod_std_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_std_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared \ +libvmod_std_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_std_la_SOURCES = \ - vmod_std.c \ - vmod_std_conversions.c \ - vmod_std_fileread.c \ - vmod_std_querysort.c - nodist_libvmod_std_la_SOURCES = \ vcc_if.c \ vcc_if.h diff --git a/lib/libvmod_vtc/Makefile.am b/lib/libvmod_vtc/Makefile.am index 98baa91..fbf1d0d 100644 --- a/lib/libvmod_vtc/Makefile.am +++ b/lib/libvmod_vtc/Makefile.am @@ -1,4 +1,10 @@ # + +libvmod_vtc_la_SOURCES = \ + vmod_vtc.c + +# Boilerplate, do not change + AM_LDFLAGS = $(AM_LT_LDFLAGS) AM_CPPFLAGS = \ @@ -9,25 +15,29 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_vtc vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = +vmodtoolargs = --strict vmod_LTLIBRARIES = libvmod_vtc.la libvmod_vtc_la_CFLAGS = \ @SAN_CFLAGS@ -libvmod_vtc_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared -rpath /nowhere \ +libvmod_vtc_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -export-symbols-regex '^Vmod_std_Data' \ + -rpath /nowhere \ @SAN_LDFLAGS@ -libvmod_vtc_la_SOURCES = \ - vmod_vtc.c - nodist_libvmod_vtc_la_SOURCES = \ vcc_if.c \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_vtc_la_OBJECTS):vcc_if.h +$(libvmod_vtc_la_OBJECTS): vcc_if.h vcc_if.h vmod_vtc.rst vmod_vtc.man.rst: vcc_if.c From hermunn at varnish-software.com Fri Sep 15 11:17:15 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:15 +0000 (UTC) Subject: [5.2] d5763db Dont filter VMOD symbols just yet. Message-ID: <20170915111715.6854698034@lists.varnish-cache.org> commit d5763db173bb45cfc5ac6f6ac75bc8c23e3ae8c8 Author: Poul-Henning Kamp Date: Mon Sep 11 08:29:31 2017 +0000 Dont filter VMOD symbols just yet. diff --git a/lib/libvmod_blob/Makefile.am b/lib/libvmod_blob/Makefile.am index bb7b363..15522e1 100644 --- a/lib/libvmod_blob/Makefile.am +++ b/lib/libvmod_blob/Makefile.am @@ -41,7 +41,6 @@ libvmod_blob_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index 58bd825..d328960 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -31,7 +31,6 @@ libvmod_debug_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index 23bcf94..5910add 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -42,7 +42,6 @@ libvmod_directors_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_purge/Makefile.am b/lib/libvmod_purge/Makefile.am index 44a69cb..aa88be7 100644 --- a/lib/libvmod_purge/Makefile.am +++ b/lib/libvmod_purge/Makefile.am @@ -28,7 +28,6 @@ libvmod_purge_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index 2ddf28b..ba57322 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -31,7 +31,6 @@ libvmod_std_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_vtc/Makefile.am b/lib/libvmod_vtc/Makefile.am index fbf1d0d..45c141f 100644 --- a/lib/libvmod_vtc/Makefile.am +++ b/lib/libvmod_vtc/Makefile.am @@ -28,7 +28,6 @@ libvmod_vtc_la_LDFLAGS = \ -export-dynamic \ -avoid-version \ -shared \ - -export-symbols-regex '^Vmod_std_Data' \ -rpath /nowhere \ @SAN_LDFLAGS@ From hermunn at varnish-software.com Fri Sep 15 11:17:15 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:15 +0000 (UTC) Subject: [5.2] dc010c3 Update stale comment Message-ID: <20170915111715.871A698040@lists.varnish-cache.org> commit dc010c3b99eb6c8db2cbc22b9984858bb488e0cf Author: Dridi Boukelmoune Date: Fri Sep 8 15:24:48 2017 +0200 Update stale comment diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 2a2435c..55fa342 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -259,7 +259,7 @@ hsh_testmagic(void *result) /*--------------------------------------------------------------------- * Insert an object which magically appears out of nowhere or, more likely, * comes off some persistent storage device. - * Return it with a reference held. + * Insert it with a reference held. */ void From hermunn at varnish-software.com Fri Sep 15 11:17:15 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:15 +0000 (UTC) Subject: [5.2] 8469f33 Pack prototypes in the order they are used Message-ID: <20170915111715.9EA029804D@lists.varnish-cache.org> commit 8469f33885f1f6c7f2c6f2f20270b5a675b0f454 Author: Dridi Boukelmoune Date: Tue Apr 18 09:16:16 2017 +0200 Pack prototypes in the order they are used diff --git a/include/vut.h b/include/vut.h index 346d7bd..e47ff79 100644 --- a/include/vut.h +++ b/include/vut.h @@ -73,11 +73,9 @@ int VUT_g_Arg(const char *arg); int VUT_Arg(int opt, const char *arg); -void VUT_Setup(void); - void VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *); +void VUT_Setup(void); +int VUT_Main(void); void VUT_Fini(void); - -int VUT_Main(void); From hermunn at varnish-software.com Fri Sep 15 11:17:15 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:15 +0000 (UTC) Subject: [5.2] 72c3cbc Whitespace OCD Message-ID: <20170915111715.BB8C79806C@lists.varnish-cache.org> commit 72c3cbcbced39b07031bfa9bef9dc6109e8d989c Author: Dridi Boukelmoune Date: Tue Apr 18 09:17:28 2017 +0200 Whitespace OCD diff --git a/include/vut_options.h b/include/vut_options.h index 5e6d094..9f0ad78 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -29,7 +29,7 @@ /* VUT options */ -#define VUT_OPT_d \ +#define VUT_OPT_d \ VOPT("d", "[-d]", "Process old log entries and exit", \ "Process log records at the head of the log and exit." \ ) From hermunn at varnish-software.com Fri Sep 15 11:17:15 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:15 +0000 (UTC) Subject: [5.2] ec37d4c Simplify VUT options initialization Message-ID: <20170915111715.DA0A99809C@lists.varnish-cache.org> commit ec37d4c8c4ebb7be4ef34d022103a2b1ecb541e2 Author: Dridi Boukelmoune Date: Tue Apr 18 09:27:48 2017 +0200 Simplify VUT options initialization We don't need an indirection in a separate C file per VUT. diff --git a/bin/varnishhist/Makefile.am b/bin/varnishhist/Makefile.am index 281c05a..9c58a86 100644 --- a/bin/varnishhist/Makefile.am +++ b/bin/varnishhist/Makefile.am @@ -6,10 +6,10 @@ AM_CPPFLAGS = \ bin_PROGRAMS = varnishhist -varnishhist_SOURCES = varnishhist.c \ +varnishhist_SOURCES = \ + varnishhist.c \ varnishhist_options.h \ - varnishhist_profiles.h \ - varnishhist_options.c + varnishhist_profiles.h varnishhist_CFLAGS = \ @SAN_CFLAGS@ diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 27afddc..6dc3aa9 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -42,6 +42,9 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishhist_options.h" + #include "vdef.h" #include "vcurses.h" #include "vapi/vsl.h" diff --git a/bin/varnishhist/varnishhist_options.c b/bin/varnishhist/varnishhist_options.c deleted file mode 100644 index c4f5d27..0000000 --- a/bin/varnishhist/varnishhist_options.c +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2014 Varnish Software AS - * All rights reserved. - * - * Author: Martin Blix Grydeland - * - * 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. - * - * Option definitions for varnishhist - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishhist_options.h" -#include "vapi/voptget.h" diff --git a/bin/varnishlog/Makefile.am b/bin/varnishlog/Makefile.am index 28d5e67..9fccdc5 100644 --- a/bin/varnishlog/Makefile.am +++ b/bin/varnishlog/Makefile.am @@ -8,8 +8,7 @@ bin_PROGRAMS = varnishlog varnishlog_SOURCES = \ varnishlog.c \ - varnishlog_options.h \ - varnishlog_options.c + varnishlog_options.h varnishlog_CFLAGS = \ @SAN_CFLAGS@ diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 87f98a3..8018f7b 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -39,6 +39,10 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishlog_options.h" + +#include "vapi/vsm.h" #include "vapi/vsl.h" #include "vapi/voptget.h" #include "vas.h" diff --git a/bin/varnishlog/varnishlog_options.c b/bin/varnishlog/varnishlog_options.c deleted file mode 100644 index b12d3e4..0000000 --- a/bin/varnishlog/varnishlog_options.c +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS - * All rights reserved. - * - * Author: Martin Blix Grydeland - * - * 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. - * - * Option definitions for varnishlog - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishlog_options.h" -#include "vapi/voptget.h" diff --git a/bin/varnishncsa/Makefile.am b/bin/varnishncsa/Makefile.am index b970910..cbed83b 100644 --- a/bin/varnishncsa/Makefile.am +++ b/bin/varnishncsa/Makefile.am @@ -9,7 +9,6 @@ bin_PROGRAMS = varnishncsa varnishncsa_SOURCES = \ varnishncsa.c \ varnishncsa_options.h \ - varnishncsa_options.c \ base64.h \ base64.c diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 99413a1..0fa722f 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -53,6 +53,9 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishncsa_options.h" + #include "base64.h" #include "vapi/vsl.h" #include "vapi/voptget.h" diff --git a/bin/varnishncsa/varnishncsa_options.c b/bin/varnishncsa/varnishncsa_options.c deleted file mode 100644 index 44e3dfe..0000000 --- a/bin/varnishncsa/varnishncsa_options.c +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2013-2015 Varnish Software AS - * All rights reserved. - * - * Author: Martin Blix Grydeland - * - * 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. - * - * Option definitions for varnishlog - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishncsa_options.h" -#include "vapi/voptget.h" diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index 9e404bb..c13bcd3 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -10,8 +10,7 @@ varnishstat_SOURCES = \ varnishstat.h \ varnishstat.c \ varnishstat_curses.c \ - varnishstat_options.h \ - varnishstat_options.c + varnishstat_options.h varnishstat_CFLAGS = \ @SAN_CFLAGS@ diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index d114281..aa268c9 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -39,6 +39,9 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishstat_options.h" + #include "vapi/voptget.h" #include "vapi/vsl.h" #include "vdef.h" diff --git a/bin/varnishstat/varnishstat_options.c b/bin/varnishstat/varnishstat_options.c deleted file mode 100644 index 60b8d28..0000000 --- a/bin/varnishstat/varnishstat_options.c +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2016 Varnish Software AS - * All rights reserved. - * - * Author: Federico G. Schwindt - * - * 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. - * - * Option definitions for varnishstat - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishstat_options.h" -#include "vapi/voptget.h" diff --git a/bin/varnishtop/Makefile.am b/bin/varnishtop/Makefile.am index 68adae8..d6923c1 100644 --- a/bin/varnishtop/Makefile.am +++ b/bin/varnishtop/Makefile.am @@ -6,9 +6,9 @@ AM_CPPFLAGS = \ bin_PROGRAMS = varnishtop -varnishtop_SOURCES = varnishtop.c \ - varnishtop_options.h \ - varnishtop_options.c +varnishtop_SOURCES = \ + varnishtop.c \ + varnishtop_options.h varnishtop_CFLAGS = \ diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 1d7ebe0..07386ed 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -42,6 +42,9 @@ #include #include +#define VOPT_DEFINITION +#define VOPT_INC "varnishtop_options.h" + #include "vcurses.h" #include "vapi/vsl.h" #include "vapi/vsm.h" diff --git a/bin/varnishtop/varnishtop_options.c b/bin/varnishtop/varnishtop_options.c deleted file mode 100644 index 58d132e..0000000 --- a/bin/varnishtop/varnishtop_options.c +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2014 Varnish Software AS - * All rights reserved. - * - * Author: Martin Blix Grydeland - * - * 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. - * - * Option definitions for varnishtop - */ - -#include -#define VOPT_DEFINITION -#define VOPT_INC "varnishtop_options.h" -#include "vapi/voptget.h" From hermunn at varnish-software.com Fri Sep 15 11:17:16 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:16 +0000 (UTC) Subject: [5.2] 01c69ea Help flexelint find the path of this VUT_Arg call Message-ID: <20170915111716.052B9980B5@lists.varnish-cache.org> commit 01c69ea6cf3faece89318c7b8c4296f2189cbc46 Author: Dridi Boukelmoune Date: Tue Apr 25 09:40:48 2017 +0200 Help flexelint find the path of this VUT_Arg call diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 6dc3aa9..1a51afe 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -586,6 +586,8 @@ main(int argc, char **argv) if (!active_profile->name) VUT_Error(1, "-P: No such profile '%s'", profile); + assert(active_profile->VSL_arg == 'b' || + active_profile->VSL_arg == 'c'); assert(VUT_Arg(active_profile->VSL_arg, NULL)); match_tag = active_profile->tag; fnum = active_profile->field; From hermunn at varnish-software.com Fri Sep 15 11:17:16 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:16 +0000 (UTC) Subject: [5.2] f291a31 Assert when an optarg is expected Message-ID: <20170915111716.22834980CB@lists.varnish-cache.org> commit f291a31d539c96c3534ab8d185256ff0feecd200 Author: Dridi Boukelmoune Date: Tue Apr 25 09:41:59 2017 +0200 Assert when an optarg is expected diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 355299e..26f5673 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -153,6 +153,7 @@ VUT_Arg(int opt, const char *arg) return (1); case 'g': /* Grouping */ + AN(arg); return (VUT_g_Arg(arg)); case 'k': /* Log transaction limit */ @@ -163,18 +164,22 @@ VUT_Arg(int opt, const char *arg) return (1); case 'n': /* Varnish instance name */ + AN(arg); REPLACE(VUT.n_arg, arg); return (1); case 'P': /* PID file */ + AN(arg); REPLACE(VUT.P_arg, arg); return (1); case 'q': /* Query to use */ + AN(arg); REPLACE(VUT.q_arg, arg); return (1); case 'r': /* Binary file input */ + AN(arg); REPLACE(VUT.r_arg, arg); return (1); case 't': From hermunn at varnish-software.com Fri Sep 15 11:17:16 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:16 +0000 (UTC) Subject: [5.2] 055e285 Remove the VUT_g_Arg special case Message-ID: <20170915111716.3E0D5980D6@lists.varnish-cache.org> commit 055e285149a8750ef145664603db23440b8d3407 Author: Dridi Boukelmoune Date: Tue Sep 5 10:08:40 2017 +0200 Remove the VUT_g_Arg special case It's no longer used anyway, and was already called via the generic VUT_Arg function. diff --git a/include/vut.h b/include/vut.h index e47ff79..aab3608 100644 --- a/include/vut.h +++ b/include/vut.h @@ -69,8 +69,6 @@ extern struct VUT VUT; void VUT_Error(int status, const char *fmt, ...) __v_printflike(2, 3) __attribute__((__noreturn__)); -int VUT_g_Arg(const char *arg); - int VUT_Arg(int opt, const char *arg); void VUT_Init(const char *progname, int argc, char * const *argv, diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 37d8e72..e3e343d 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -133,7 +133,6 @@ LIBVARNISHAPI_2.0 { VUT_Init; VUT_Main; VUT_Setup; - VUT_g_Arg; local: *; diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 26f5673..9ce1af5 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -125,18 +125,6 @@ VUT_Error(int status, const char *fmt, ...) } int -VUT_g_Arg(const char *arg) -{ - - VUT.g_arg = VSLQ_Name2Grouping(arg, -1); - if (VUT.g_arg == -2) - VUT_Error(1, "Ambiguous grouping type: %s", arg); - else if (VUT.g_arg < 0) - VUT_Error(1, "Unknown grouping type: %s", arg); - return (1); -} - -int VUT_Arg(int opt, const char *arg) { int i; @@ -154,7 +142,12 @@ VUT_Arg(int opt, const char *arg) case 'g': /* Grouping */ AN(arg); - return (VUT_g_Arg(arg)); + VUT.g_arg = VSLQ_Name2Grouping(arg, -1); + if (VUT.g_arg == -2) + VUT_Error(1, "Ambiguous grouping type: %s", arg); + else if (VUT.g_arg < 0) + VUT_Error(1, "Unknown grouping type: %s", arg); + return (1); case 'k': /* Log transaction limit */ AN(arg); From hermunn at varnish-software.com Fri Sep 15 11:17:16 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:16 +0000 (UTC) Subject: [5.2] 7bdd212 Merge VUT signal handlers together Message-ID: <20170915111716.598CF980E4@lists.varnish-cache.org> commit 7bdd21216a70d378ae1bf05562dd5da5d0585cc2 Author: Dridi Boukelmoune Date: Fri Sep 8 15:29:57 2017 +0200 Merge VUT signal handlers together diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 9ce1af5..4057c3f 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -71,24 +71,12 @@ vut_vpf_remove(void) } static void -vut_sighup(int sig) +vut_signal(int sig) { - (void)sig; - VUT.sighup = 1; -} -static void -vut_sigint(int sig) -{ - (void)sig; - VUT.sigint = 1; -} - -static void -vut_sigusr1(int sig) -{ - (void)sig; - VUT.sigusr1 = 1; + VUT.sighup |= (sig == SIGHUP); + VUT.sigint |= (sig == SIGINT || sig == SIGTERM); + VUT.sigusr1 |= (sig == SIGUSR1); } static int __match_proto__(VSLQ_dispatch_f) @@ -255,10 +243,10 @@ VUT_Setup(void) } /* Signal handlers */ - (void)signal(SIGHUP, vut_sighup); - (void)signal(SIGINT, vut_sigint); - (void)signal(SIGTERM, vut_sigint); - (void)signal(SIGUSR1, vut_sigusr1); + (void)signal(SIGHUP, vut_signal); + (void)signal(SIGINT, vut_signal); + (void)signal(SIGTERM, vut_signal); + (void)signal(SIGUSR1, vut_signal); /* Open PID file */ if (VUT.P_arg) { From hermunn at varnish-software.com Fri Sep 15 11:17:16 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:16 +0000 (UTC) Subject: [5.2] 0efecdc Move the sigaltstack init to a generic THR_Init() and use it for all threads Message-ID: <20170915111716.7AB4698102@lists.varnish-cache.org> commit 0efecdc9cb25234560b9b397db27a53f226ca526 Author: Nils Goroll Date: Mon Sep 11 12:34:32 2017 +0200 Move the sigaltstack init to a generic THR_Init() and use it for all threads diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 91f5c08..8da85ae 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -524,6 +524,7 @@ vca_acct(void *arg) double t0, now; THR_SetName("cache-acceptor"); + THR_Init(); (void)arg; (void)vca_tcp_opt_init(); diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 8602fcf..684d456 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -113,6 +113,22 @@ THR_GetName(void) } /*-------------------------------------------------------------------- + * Generic setup all our threads should call + */ +#ifdef HAVE_SIGALTSTACK +#include +extern stack_t altstack; +#endif + +void +THR_Init(void) +{ +#ifdef HAVE_SIGALTSTACK + AZ(sigaltstack(&altstack, NULL)); +#endif +} + +/*-------------------------------------------------------------------- * VXID's are unique transaction numbers allocated with a minimum of * locking overhead via pools in the worker threads. * diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 98c22f0..0e05bcc 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -104,6 +104,7 @@ mpl_guard(void *priv) CAST_OBJ_NOTNULL(mpl, priv, MEMPOOL_MAGIC); THR_SetName(mpl->name); + THR_Init(); mpl_slp = 0.15; // random while (1) { VTIM_sleep(mpl_slp); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 0bf34f2..595e836 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -187,6 +187,7 @@ pool_poolherder(void *priv) void *rvp; THR_SetName("pool_poolherder"); + THR_Init(); (void)priv; nwq = 0; diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index 941d567..18bb141 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -88,6 +88,7 @@ void THR_SetBusyobj(const struct busyobj *); struct busyobj * THR_GetBusyobj(void); void THR_SetRequest(const struct req *); struct req * THR_GetRequest(void); +void THR_Init(void); /* cache_lck.c */ void LCK_Init(void); diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index cf2948b..8735929 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -41,11 +41,6 @@ #include "hash/hash_slinger.h" -#ifdef HAVE_SIGALTSTACK -#include -extern stack_t altstack; -#endif - static void Pool_Work_Thread(struct pool *pp, struct worker *wrk); /*-------------------------------------------------------------------- @@ -70,6 +65,7 @@ wrk_bgthread(void *arg) CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC); THR_SetName(bt->name); + THR_Init(); INIT_OBJ(&wrk, WORKER_MAGIC); memset(&ds, 0, sizeof ds); wrk.stats = &ds; @@ -406,9 +402,7 @@ pool_thread(void *priv) struct pool_info *pi; CAST_OBJ_NOTNULL(pi, priv, POOL_INFO_MAGIC); -#ifdef HAVE_SIGALTSTACK - AZ(sigaltstack(&altstack, NULL)); -#endif + THR_Init(); WRK_Thread(pi->qp, pi->stacksize, cache_param->workspace_thread); FREE_OBJ(pi); return (NULL); @@ -483,6 +477,7 @@ pool_herder(void *priv) CAST_OBJ_NOTNULL(pp, priv, POOL_MAGIC); THR_SetName("pool_herder"); + THR_Init(); while (!pp->die || pp->nthr > 0) { wthread_min = cache_param->wthread_min; diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 5c40597..358d2be 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -80,6 +80,7 @@ vwe_thread(void *priv) w = vwe->waiter; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-epoll"); + THR_Init(); now = VTIM_real(); while (1) { diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 5d06b2d..ff870e7 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -75,6 +75,7 @@ vwk_thread(void *priv) w = vwk->waiter; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-kqueue"); + THR_Init(); now = VTIM_real(); while (1) { diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index ee70140..52e4de3 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -161,6 +161,7 @@ vwp_main(void *priv) int i; THR_SetName("cache-poll"); + THR_Init(); CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC); w = vwp->waiter; diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index b7259bf..3a1dc49 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -152,6 +152,7 @@ vws_thread(void *priv) w = vws->waiter; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-ports"); + THR_Init(); now = VTIM_real(); From hermunn at varnish-software.com Fri Sep 15 11:17:16 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:16 +0000 (UTC) Subject: [5.2] c10c28b try to stabilize this test Message-ID: <20170915111716.9983898123@lists.varnish-cache.org> commit c10c28b8319592c83f668e291f11d26b4d707abf Author: Nils Goroll Date: Mon Sep 11 12:35:35 2017 +0200 try to stabilize this test diff --git a/bin/varnishtest/tests/p00007.vtc b/bin/varnishtest/tests/p00007.vtc index 559f170..6b9e1be 100644 --- a/bin/varnishtest/tests/p00007.vtc +++ b/bin/varnishtest/tests/p00007.vtc @@ -56,6 +56,8 @@ varnish v1 -cliok "debug.persistent s0 dump" # Panic worker so second segment does not get closed varnish v1 -clierr 400 "debug.panic.worker" +delay 0.5 + varnish v1 -cliok "panic.clear" delay 0.5 From hermunn at varnish-software.com Fri Sep 15 11:17:16 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:16 +0000 (UTC) Subject: [5.2] 1c97abb De-boilerplate the "normal" vmods in the tree. Message-ID: <20170915111716.C76A29815A@lists.varnish-cache.org> commit 1c97abbc172249ba659892c1f4c576515dc8e270 Author: Poul-Henning Kamp Date: Mon Sep 11 10:36:51 2017 +0000 De-boilerplate the "normal" vmods in the tree. There are undoubtedly better ways, but I couldn't find them... diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index ab78cff..b7f58e5 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -46,6 +46,49 @@ import random rstfmt = False strict_abi = True +AMBOILERPLATE=''' +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \\ + -I$(top_srcdir)/include \\ + -I$(top_srcdir)/bin/varnishd \\ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_XXX.la + +libvmod_XXX_la_CFLAGS = \\ + @SAN_CFLAGS@ + +libvmod_XXX_la_LDFLAGS = \\ + $(AM_LDFLAGS) \\ + $(VMOD_LDFLAGS) \\ + @SAN_LDFLAGS@ + +nodist_libvmod_XXX_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_XXX_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_XXX.rst vmod_XXX.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \\ + $(builddir)/vmod_XXX.rst \\ + $(builddir)/vmod_XXX.man.rst + +''' + ctypes = { 'ACL': "VCL_ACL", 'BACKEND': "VCL_BACKEND", @@ -701,6 +744,13 @@ class vcc(object): fo.close() + def amboilerplate(self): + fn = "automake_boilerplate.am" + self.commit_files.append(fn) + fo = open(fn + ".tmp", "w") + fo.write(AMBOILERPLATE.replace("XXX", self.modname)) + fo.close() + def hfile(self): fn = self.pfx + ".h" self.commit_files.append(fn) @@ -831,6 +881,8 @@ def runmain(inputvcc, rstdir, outputprefix): v.rstfile(man=True) v.hfile() v.cfile() + if opts.boilerplate: + v.amboilerplate() v.commit() @@ -838,6 +890,9 @@ if __name__ == "__main__": usagetext = "Usage: %prog [options] " oparser = optparse.OptionParser(usage=usagetext) + oparser.add_option('-b', '--boilerplate', action='store_true', + default=False, + help="Be strict when parsing the input file") oparser.add_option('-N', '--strict', action='store_true', default=False, help="Be strict when parsing the input file") oparser.add_option('-o', '--output', metavar="prefix", default='vcc_if', diff --git a/lib/libvmod_blob/Makefile.am b/lib/libvmod_blob/Makefile.am index 15522e1..7b5ce59 100644 --- a/lib/libvmod_blob/Makefile.am +++ b/lib/libvmod_blob/Makefile.am @@ -16,48 +16,5 @@ libvmod_blob_la_SOURCES = \ base64.o: base64.c base64.h -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_blob -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_blob.la - -libvmod_blob_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_blob_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_blob_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_blob_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_blob.rst vmod_blob.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_blob.rst \ - $(builddir)/vmod_blob.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am new file mode 100644 index 0000000..3b4ed7a --- /dev/null +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_blob.la + +libvmod_blob_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_blob_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_blob_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_blob_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_blob.rst vmod_blob.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_blob.rst \ + $(builddir)/vmod_blob.man.rst + diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index 5910add..ff0c244 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -17,48 +17,5 @@ libvmod_directors_la_SOURCES = \ shard_parse_vcc_enums.h \ shard_parse_vcc_enums.c -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_directors -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_directors.la - -libvmod_directors_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_directors_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_directors_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_directors_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_directors.rst vmod_directors.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_directors.rst \ - $(builddir)/vmod_directors.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am new file mode 100644 index 0000000..19e10a3 --- /dev/null +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_directors.la + +libvmod_directors_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_directors_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_directors_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_directors_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_directors.rst vmod_directors.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_directors.rst \ + $(builddir)/vmod_directors.man.rst + diff --git a/lib/libvmod_purge/Makefile.am b/lib/libvmod_purge/Makefile.am index aa88be7..38e1e58 100644 --- a/lib/libvmod_purge/Makefile.am +++ b/lib/libvmod_purge/Makefile.am @@ -3,48 +3,5 @@ libvmod_purge_la_SOURCES = \ vmod_purge.c -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_purge -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_purge.la - -libvmod_purge_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_purge_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_purge_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_purge_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_purge.rst vmod_purge.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_purge.rst \ - $(builddir)/vmod_purge.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am new file mode 100644 index 0000000..3a5b4a5 --- /dev/null +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_purge.la + +libvmod_purge_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_purge_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_purge_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_purge_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_purge.rst vmod_purge.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_purge.rst \ + $(builddir)/vmod_purge.man.rst + diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index ba57322..8bde752 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -6,48 +6,5 @@ libvmod_std_la_SOURCES = \ vmod_std_fileread.c \ vmod_std_querysort.c -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_std -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_std.la - -libvmod_std_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_std_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_std_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_std_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_std.rst vmod_std.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_std.rst \ - $(builddir)/vmod_std.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am new file mode 100644 index 0000000..66410b0 --- /dev/null +++ b/lib/libvmod_std/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_std.la + +libvmod_std_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_std_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_std_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_std_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_std.rst vmod_std.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_std.rst \ + $(builddir)/vmod_std.man.rst + diff --git a/lib/libvmod_vtc/Makefile.am b/lib/libvmod_vtc/Makefile.am index 45c141f..3575d7e 100644 --- a/lib/libvmod_vtc/Makefile.am +++ b/lib/libvmod_vtc/Makefile.am @@ -3,48 +3,5 @@ libvmod_vtc_la_SOURCES = \ vmod_vtc.c -# Boilerplate, do not change - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_vtc -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict - -vmod_LTLIBRARIES = libvmod_vtc.la - -libvmod_vtc_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_vtc_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ - -rpath /nowhere \ - @SAN_LDFLAGS@ - -nodist_libvmod_vtc_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -$(libvmod_vtc_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_vtc.rst vmod_vtc.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_vtc.rst \ - $(builddir)/vmod_vtc.man.rst +# Use vmodtool.py generated automake boilerplate +include $(srcdir)/automake_boilerplate.am diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am new file mode 100644 index 0000000..1eb8f6f --- /dev/null +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -0,0 +1,41 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_vtc.la + +libvmod_vtc_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_vtc_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_vtc_la_SOURCES = vcc_if.c vcc_if.h + +# BUILT_SOURCES is only a hack +# and dependency tracking does not help for the first build +$(libvmod_vtc_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_vtc.rst vmod_vtc.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_vtc.rst \ + $(builddir)/vmod_vtc.man.rst + From hermunn at varnish-software.com Fri Sep 15 11:17:16 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:16 +0000 (UTC) Subject: [5.2] 8602645 Now filter the vmods symbols, and make libvmod_debug exercise the $Event RST test again. Message-ID: <20170915111716.EAB8C98176@lists.varnish-cache.org> commit 8602645b28bf7d6c8aed1006e88af410861692dd Author: Poul-Henning Kamp Date: Mon Sep 11 11:18:47 2017 +0000 Now filter the vmods symbols, and make libvmod_debug exercise the $Event RST test again. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index b7f58e5..2325c50 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -68,6 +68,7 @@ libvmod_XXX_la_CFLAGS = \\ libvmod_XXX_la_LDFLAGS = \\ $(AM_LDFLAGS) \\ $(VMOD_LDFLAGS) \\ + -export-symbols-regex '^Vmod_XXX_Data' \\ @SAN_LDFLAGS@ nodist_libvmod_XXX_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 3b4ed7a..2971a68 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_blob_la_CFLAGS = \ libvmod_blob_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_blob_Data' \ @SAN_LDFLAGS@ nodist_libvmod_blob_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index d328960..a15b241 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -17,7 +17,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_debug vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict +vmodtoolargs = noinst_LTLIBRARIES = libvmod_debug.la @@ -27,10 +27,7 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module \ - -export-dynamic \ - -avoid-version \ - -shared \ + $(VMOD_LDFLAGS) \ -rpath /nowhere \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 2ed8a9e..324d389 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -37,6 +37,8 @@ of VMOD handling in Varnish. $Event event_function +You are not supposed to be able to see this text in the .RST + $Function VOID panic(STRING_LIST) Don't. diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index 19e10a3..b949004 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_directors_la_CFLAGS = \ libvmod_directors_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_directors_Data' \ @SAN_LDFLAGS@ nodist_libvmod_directors_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index 3a5b4a5..ef9f8a3 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_purge_la_CFLAGS = \ libvmod_purge_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_purge_Data' \ @SAN_LDFLAGS@ nodist_libvmod_purge_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 66410b0..8ad8dae 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_std_la_CFLAGS = \ libvmod_std_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_std_Data' \ @SAN_LDFLAGS@ nodist_libvmod_std_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 1eb8f6f..20e0848 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -20,6 +20,7 @@ libvmod_vtc_la_CFLAGS = \ libvmod_vtc_la_LDFLAGS = \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ + -export-symbols-regex '^Vmod_vtc_Data' \ @SAN_LDFLAGS@ nodist_libvmod_vtc_la_SOURCES = vcc_if.c vcc_if.h From hermunn at varnish-software.com Fri Sep 15 11:17:17 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:17 +0000 (UTC) Subject: [5.2] 279bc80 Ignore req.ttl when keeping track of epired objects Message-ID: <20170915111717.185FD98190@lists.varnish-cache.org> commit 279bc800716428eb559d8712691d73b2e018e42b Author: Dridi Boukelmoune Date: Mon Sep 11 13:03:52 2017 +0200 Ignore req.ttl when keeping track of epired objects The goal of `req.ttl` is to allow lower requirements for known transactions (since this has to be done in VCL) but objects with an age higher than `req.ttl` would always be considered expired during lookup even if their actual TTL (obj.ttl) is still positive. Ignoring `req.ttl` gives a better control over explicit refreshes made to optimize latency and greatly reduces the risk of running into #1799 (for a subset of use cases). Closes #2422 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 55fa342..2e9baf9 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -461,7 +461,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, *ocp = oc; return (HSH_HIT); } - if (oc->t_origin > exp_t_origin) { + if (EXP_Ttl(NULL, oc) < req->t_req && /* ignore req.ttl */ + oc->t_origin > exp_t_origin) { /* record the newest object */ exp_oc = oc; exp_t_origin = oc->t_origin; From hermunn at varnish-software.com Fri Sep 15 11:17:17 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:17 +0000 (UTC) Subject: [5.2] d4573ff Build generated sources before anything else Message-ID: <20170915111717.3D61A981A8@lists.varnish-cache.org> commit d4573ff5e3f7237879a6ead7c94eed9573de8251 Author: Nils Goroll Date: Mon Sep 11 14:52:07 2017 +0200 Build generated sources before anything else Works for all, check, install targets but not for individual targets, see ref: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html Fixes #2423 diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index c6228b8..55409d7 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -224,6 +224,7 @@ $(varnishd_OBJECTS): VSC_main.h EXTRA_DIST += main.vsc DISTCLEANFILES += VSC_main.c VSC_main.h +BUILT_SOURCES += VSC_main.c VSC_main.h nodist_varnishd_SOURCES += VSC_main.c ####################################################################### @@ -235,6 +236,7 @@ $(varnishd_OBJECTS): VSC_lck.h EXTRA_DIST += lck.vsc DISTCLEANFILES += VSC_lck.c VSC_lck.h +BUILT_SOURCES += VSC_lck.c VSC_lck.h nodist_varnishd_SOURCES += VSC_lck.c ####################################################################### @@ -246,6 +248,7 @@ $(varnishd_OBJECTS): VSC_vbe.h EXTRA_DIST += vbe.vsc DISTCLEANFILES += VSC_vbe.c VSC_vbe.h +BUILT_SOURCES += VSC_vbe.c VSC_vbe.h nodist_varnishd_SOURCES += VSC_vbe.c ####################################################################### @@ -257,6 +260,7 @@ $(varnishd_OBJECTS): VSC_sma.h EXTRA_DIST += sma.vsc DISTCLEANFILES += VSC_sma.c VSC_sma.h +BUILT_SOURCES += VSC_sma.c VSC_sma.h nodist_varnishd_SOURCES += VSC_sma.c ####################################################################### @@ -268,6 +272,7 @@ $(varnishd_OBJECTS): VSC_smf.h EXTRA_DIST += smf.vsc DISTCLEANFILES += VSC_smf.c VSC_smf.h +BUILT_SOURCES += VSC_smf.c VSC_smf.h nodist_varnishd_SOURCES += VSC_smf.c ####################################################################### @@ -279,6 +284,7 @@ $(varnishd_OBJECTS): VSC_mempool.h EXTRA_DIST += mempool.vsc DISTCLEANFILES += VSC_mempool.c VSC_mempool.h +BUILT_SOURCES += VSC_mempool.c VSC_mempool.h nodist_varnishd_SOURCES += VSC_mempool.c ####################################################################### @@ -290,5 +296,5 @@ $(varnishd_OBJECTS): VSC_mgt.h EXTRA_DIST += mgt.vsc DISTCLEANFILES += VSC_mgt.c VSC_mgt.h +BUILT_SOURCES += VSC_mgt.c VSC_mgt.h nodist_varnishd_SOURCES += VSC_mgt.c - From hermunn at varnish-software.com Fri Sep 15 11:17:17 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:17 +0000 (UTC) Subject: [5.2] 0477082 VMOD blob tests: add vcl.discard to test freeing cached encodings of blob objects. Message-ID: <20170915111717.682F0981BA@lists.varnish-cache.org> commit 047708222dc2cdf9a2d28be83b21f3fb1a8346b2 Author: Geoff Simmons Date: Mon Sep 11 15:22:06 2017 +0200 VMOD blob tests: add vcl.discard to test freeing cached encodings of blob objects. Revealed by GCOV. diff --git a/bin/varnishtest/tests/m00043.vtc b/bin/varnishtest/tests/m00043.vtc index 74763b5..7c3408a 100644 --- a/bin/varnishtest/tests/m00043.vtc +++ b/bin/varnishtest/tests/m00043.vtc @@ -269,6 +269,10 @@ client c3 { # run twice client c3 -run +# Discard to test object finalization +varnish v1 -cliok "vcl.discard vcl1" +varnish v1 -cliok "vcl.discard vcl2" + varnish v1 -errvcl {vmod blob error: cannot create blob err, illegal encoding beginning with "g"} { import blob; backend b { .host="${bad_ip}"; } diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index e936944..20e44b7 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -307,7 +307,7 @@ vmod_blob__fini(struct vmod_blob_blob **blobp) } for (int i = 0; i < __MAX_ENCODING; i++) if (b->encoding[i] != NULL && b->encoding[i][0] != '\0') { - free((void *) b->encoding[i]); + free(b->encoding[i]); b->encoding[i] = NULL; } AZ(pthread_mutex_destroy(&b->lock)); From hermunn at varnish-software.com Fri Sep 15 11:17:17 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:17 +0000 (UTC) Subject: [5.2] 84ca575 VMOD blob: correct a special case in object finalization. Message-ID: <20170915111717.86214981C7@lists.varnish-cache.org> commit 84ca5754fb86645a16d350b4425c9fe7e8433cd6 Author: Geoff Simmons Date: Mon Sep 11 15:28:18 2017 +0200 VMOD blob: correct a special case in object finalization. Don't attempt to free the static empty string that the VMOD assigns for empty encodings. diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 20e44b7..6bb37ed 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -306,7 +306,7 @@ vmod_blob__fini(struct vmod_blob_blob **blobp) b->blob.priv = NULL; } for (int i = 0; i < __MAX_ENCODING; i++) - if (b->encoding[i] != NULL && b->encoding[i][0] != '\0') { + if (b->encoding[i] != NULL && b->encoding[i] != empty) { free(b->encoding[i]); b->encoding[i] = NULL; } From hermunn at varnish-software.com Fri Sep 15 11:17:17 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:17 +0000 (UTC) Subject: [5.2] c9adafd Move the cli buffer to VSB (from stack) Message-ID: <20170915111717.A35C4981E0@lists.varnish-cache.org> commit c9adafd77786eca7f4c4e4ff4fd30abe8a50b369 Author: P?l Hermunn Johansen Date: Mon Sep 11 16:21:19 2017 +0200 Move the cli buffer to VSB (from stack) If the cli buffer is allocated on the stack, the mgt process will crash hard for big values of this parameter. Instead we allocate on the heap. The new cli buffer an "auto" VSB. This means that the varnish parameter cli_buffer is ignored from now on, and the manual marks it as deprecated. Closes: #2382 diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index d7fa6a6..ff60b2d 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -67,6 +67,8 @@ static int cli_i = -1, cli_o = -1; struct VCLS *mgt_cls; static const char *secret_file; +struct vsb *cli_buf = NULL; + /*--------------------------------------------------------------------*/ static void __match_proto__(cli_func_t) @@ -177,24 +179,30 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) int i, j; va_list ap; unsigned u; - char buf[mgt_param.cli_buffer], *p; + + if (cli_buf == NULL) { + cli_buf = VSB_new_auto(); + AN(cli_buf); + } else { + VSB_clear(cli_buf); + } if (resp != NULL) *resp = NULL; if (status != NULL) *status = 0; - if (cli_i < 0|| cli_o < 0) { + if (cli_i < 0 || cli_o < 0) { if (status != NULL) *status = CLIS_CANT; return (CLIS_CANT); } va_start(ap, fmt); - vbprintf(buf, fmt, ap); + AZ(VSB_vprintf(cli_buf, fmt, ap)); va_end(ap); - p = strchr(buf, '\0'); - assert(p != NULL && p > buf && p[-1] == '\n'); - i = p - buf; - j = write(cli_o, buf, i); + AZ(VSB_finish(cli_buf)); + i = VSB_len(cli_buf); + assert(i > 0 && VSB_data(cli_buf)[i - 1] == '\n'); + j = write(cli_o, VSB_data(cli_buf), i); if (j != i) { if (status != NULL) *status = CLIS_COMMS; diff --git a/bin/varnishtest/tests/r02382.vtc b/bin/varnishtest/tests/r02382.vtc new file mode 100644 index 0000000..7a398b3 --- /dev/null +++ b/bin/varnishtest/tests/r02382.vtc @@ -0,0 +1,21 @@ +varnishtest "Very very big cli_buffer" + +# If the cli_buffer is on the stack, setting it very big can crash varnish + +server s1 { + rxreq + expect req.url == "/1" + txresp +} -start + +varnish v1 -arg "-p cli_buffer=32M" -vcl+backend { +} -start + +varnish v1 -cliok "ping" + +delay .5 + +client c1 { + txreq -url /1 + rxresp +} -run diff --git a/include/tbl/params.h b/include/tbl/params.h index 91cfd66..837c62f 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -294,10 +294,8 @@ PARAM( /* units */ "bytes", /* flags */ 0, /* s-text */ - "Size of buffer for CLI command input.\n" - "You may need to increase this if you have big VCL files and use " - "the vcl.inline CLI command.\n" - "NB: Must be specified with -p to have effect.", + "DEPRECATED: This parameter is ignored.\n" + "Memory for the CLI command buffer is now dynamically allocated.", /* l-text */ "", /* func */ NULL ) From hermunn at varnish-software.com Fri Sep 15 11:17:17 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:17 +0000 (UTC) Subject: [5.2] 2680dc8 Test case for #2422 Message-ID: <20170915111717.C92A9981F7@lists.varnish-cache.org> commit 2680dc89321368d7786fe31fce3fe5b5d85b4347 Author: Dridi Boukelmoune Date: Mon Sep 11 17:23:30 2017 +0200 Test case for #2422 diff --git a/bin/varnishtest/tests/r02422.vtc b/bin/varnishtest/tests/r02422.vtc new file mode 100644 index 0000000..9c956f5 --- /dev/null +++ b/bin/varnishtest/tests/r02422.vtc @@ -0,0 +1,125 @@ +varnishtest "long polling and low latency using req.ttl" + +server s1 { + # s1 uses the etag as a version + rxreq + txresp -hdr "Etag: 5" + + rxreq + # wait until the new version is ready + delay 1 + txresp -hdr "Etag: 6" +} -start + +varnish v1 -cliok "param.set default_grace 0" +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.restarts > 0) { + set req.ttl = 1ms; + } + } + + sub vcl_hit { + if (req.http.If-None-Match == obj.http.ETag) { + return (restart); + } + } + + sub vcl_deliver { + set resp.http.Hit = obj.hits > 0; + } +} -start + +# synchronizes the setup of all clients +barrier b1 cond 2 + +# makes c1..cN send their requests simultaneously-ish +barrier b2 cond 7 + +client c0 { + # wait for all clients to be ready + barrier b1 sync + # send a "new client" request (no INM) + txreq + rxresp + expect resp.status == 200 + expect resp.http.ETag == 5 + expect resp.http.Hit == false + # let all other clients send their requests + barrier b2 sync +} -start + +client c1 { + # new client, immediate hit + barrier b2 sync + txreq + rxresp + expect resp.status == 200 + expect resp.http.ETag == 5 + expect resp.http.Hit == true +} -start + +client c2 { + # late client, immediate hit + barrier b2 sync + txreq -hdr "If-None-Match: 2" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 5 + expect resp.http.Hit == true +} -start + +client c3 { + # late client, immediate hit + barrier b2 sync + txreq -hdr "If-None-Match: 4" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 5 + expect resp.http.Hit == true +} -start + +client c4 { + # up-to-date client, long polling + barrier b2 sync + txreq -hdr "If-None-Match: 5" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 6 + expect resp.http.Hit == false +} -start + +client c5 { + # up-to-date client, long polling + barrier b2 sync + # wait to make sure c4 gets the miss + delay 0.2 + txreq -hdr "If-None-Match: 5" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 6 + expect resp.http.Hit == true +} -start + +client c6 { + # up-to-date client, long polling + barrier b2 sync + # wait to make sure c4 gets the miss + delay 0.2 + txreq -hdr "If-None-Match: 5" + rxresp + expect resp.status == 200 + expect resp.http.ETag == 6 + expect resp.http.Hit == true +} -start + +# start c0 +barrier b1 sync + +client c0 -wait +client c1 -wait +client c2 -wait +client c3 -wait +client c4 -wait +client c5 -wait +client c6 -wait From hermunn at varnish-software.com Fri Sep 15 11:17:17 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:17 +0000 (UTC) Subject: [5.2] 3ca7ea7 Staticize Message-ID: <20170915111717.ECF0098214@lists.varnish-cache.org> commit 3ca7ea7166f7fc69fa6663eb873a46d91f0addf5 Author: Dridi Boukelmoune Date: Mon Sep 11 17:30:19 2017 +0200 Staticize diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index ff60b2d..4d23bba 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -67,7 +67,7 @@ static int cli_i = -1, cli_o = -1; struct VCLS *mgt_cls; static const char *secret_file; -struct vsb *cli_buf = NULL; +static struct vsb *cli_buf = NULL; /*--------------------------------------------------------------------*/ From hermunn at varnish-software.com Fri Sep 15 11:17:18 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:18 +0000 (UTC) Subject: [5.2] 094de88 We don't actually have VMOD_LDFLAGS from varnish.m4 in our build. Message-ID: <20170915111718.1F50998228@lists.varnish-cache.org> commit 094de881e2e6e59fd00ffef90b3a00b71ad9151d Author: Poul-Henning Kamp Date: Mon Sep 11 19:58:26 2017 +0000 We don't actually have VMOD_LDFLAGS from varnish.m4 in our build. Spotted by: fgs diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 2325c50..3a4472c 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -67,7 +67,7 @@ libvmod_XXX_la_CFLAGS = \\ libvmod_XXX_la_LDFLAGS = \\ $(AM_LDFLAGS) \\ - $(VMOD_LDFLAGS) \\ + -module -export-dynamic -avoid-version -shared \\ -export-symbols-regex '^Vmod_XXX_Data' \\ @SAN_LDFLAGS@ diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 2971a68..ae78a9a 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_blob_la_CFLAGS = \ libvmod_blob_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_blob_Data' \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index a15b241..e5f13a2 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -27,8 +27,9 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -rpath /nowhere \ + -export-symbols-regex '^Vmod_debug_Data' \ @SAN_LDFLAGS@ nodist_libvmod_debug_la_SOURCES = \ diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index b949004..21a702d 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_directors_la_CFLAGS = \ libvmod_directors_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_directors_Data' \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index ef9f8a3..d8f3803 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_purge_la_CFLAGS = \ libvmod_purge_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_purge_Data' \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 8ad8dae..cbd9bc9 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_std_la_CFLAGS = \ libvmod_std_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_std_Data' \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 20e0848..7642a2d 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_vtc_la_CFLAGS = \ libvmod_vtc_la_LDFLAGS = \ $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ + -module -export-dynamic -avoid-version -shared \ -export-symbols-regex '^Vmod_vtc_Data' \ @SAN_LDFLAGS@ From hermunn at varnish-software.com Fri Sep 15 11:17:18 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:18 +0000 (UTC) Subject: [5.2] 1a20665 VMOD blob: remove the *UC and *LC encoding schemes. Message-ID: <20170915111718.5005B98240@lists.varnish-cache.org> commit 1a2066501ab8f704163faeea9290f9193966dcdf Author: Geoff Simmons Date: Mon Sep 11 22:14:33 2017 +0200 VMOD blob: remove the *UC and *LC encoding schemes. For HEX and URL, there is now an ENUM case in {LOWER, UPPER} to determine the case of hex digits produced for an encoding, default LOWER. diff --git a/bin/varnishtest/tests/b00051.vtc b/bin/varnishtest/tests/b00051.vtc index ffa5bc5..c6a0125 100644 --- a/bin/varnishtest/tests/b00051.vtc +++ b/bin/varnishtest/tests/b00051.vtc @@ -9,10 +9,10 @@ varnish v1 -vcl+backend { import blob; sub vcl_backend_response { - set beresp.http.bereq_hash = blob.encode(HEXLC, bereq.hash); + set beresp.http.bereq_hash = blob.encode(HEX, blob=bereq.hash); } sub vcl_deliver { - set resp.http.req_hash = blob.encode(HEXLC, req.hash); + set resp.http.req_hash = blob.encode(HEX, blob=req.hash); } } -start diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index cb15b5e..2340eda 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -10,29 +10,29 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.id = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, "The quick brown fox jumps over the lazy dog")); set resp.http.hobbes = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "")); set resp.http.empty = - blob.encode(IDENTITY, blob.decode(IDENTITY, "")); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, "")); set resp.http.undef = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, req.http.unset)); set resp.http.emptylist = - blob.encode(IDENTITY, blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, req.http.unset + "" + req.http.unset + "")); set resp.http.param = @@ -43,7 +43,7 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.paramlist = - blob.encode(IDENTITY, blob.decode(encoded= + blob.encode(IDENTITY, blob=blob.decode(encoded= "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + @@ -51,7 +51,13 @@ varnish v1 -vcl { decoding=IDENTITY)); set resp.http.truncated = - blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); + + set resp.http.lc = + blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, "Don't care")); + + set resp.http.uc = + blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, "Don't care")); } } -start @@ -67,4 +73,6 @@ client c1 { expect resp.http.param == "The quick brown fox jumps over the lazy dog" expect resp.http.paramlist == "/The quick brown fox jumps over the lazy dog/" expect resp.http.truncated == "foo" + expect resp.http.lc == "Don't care" + expect resp.http.uc == "Don't care" } -run diff --git a/bin/varnishtest/tests/m00034.vtc b/bin/varnishtest/tests/m00034.vtc index 24da94c..949df45 100644 --- a/bin/varnishtest/tests/m00034.vtc +++ b/bin/varnishtest/tests/m00034.vtc @@ -10,29 +10,29 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.id = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, "The quick brown fox jumps over the lazy dog")); set resp.http.hobbes = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = - blob.encode(IDENTITY, blob.decode_n(6, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(6, IDENTITY, "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "")); set resp.http.empty = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, "")); + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, "")); set resp.http.undef = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, req.http.unset)); set resp.http.emptylist = - blob.encode(IDENTITY, blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, req.http.unset + "" + req.http.unset + "")); set resp.http.param = @@ -43,7 +43,7 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.paramlist = - blob.encode(IDENTITY, blob.decode_n(encoded= + blob.encode(IDENTITY, blob=blob.decode_n(encoded= "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index b26d151..e1aa0ff 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -18,39 +18,51 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set req.http.b64all = {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; + set resp.http.hex = + blob.encode(HEX, blob=blob.decode(IDENTITY, req.http.pangram)); + set resp.http.hexlc = - blob.encode(HEXLC, - blob.decode(IDENTITY, req.http.pangram)); + blob.encode(HEX, LOWER, + blob.decode(IDENTITY, req.http.pangram)); set resp.http.hexuc = - blob.encode(HEXUC, - blob.decode(IDENTITY, req.http.pangram)); + blob.encode(HEX, UPPER, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.hobbes = + blob.encode(HEX, blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbeslc = - blob.encode(HEXLC, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, LOWER, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(HEXUC, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.all = + blob.encode(HEX, blob=blob.decode(BASE64, req.http.b64all)); set resp.http.all-lc = - blob.encode(HEXLC, blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, LOWER, blob.decode(BASE64, req.http.b64all)); set resp.http.all-uc = - blob.encode(HEXUC, blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, UPPER, blob.decode(BASE64, req.http.b64all)); + + set resp.http.empty = + blob.encode(HEX, blob=blob.decode(IDENTITY, "")); set resp.http.empty-lc = - blob.encode(HEXLC, blob.decode(IDENTITY, "")); + blob.encode(HEX, LOWER, blob.decode(IDENTITY, "")); set resp.http.empty-uc = - blob.encode(HEXUC, blob.decode(IDENTITY, "")); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, "")); set resp.http.hexlcparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=HEXLC); + case=LOWER, encoding=HEX); set resp.http.hexucparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=HEXUC); + case=UPPER, encoding=HEX); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); @@ -64,51 +76,51 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob.decode(HEX, req.http.hexucfoobar)); + blob=blob.decode(HEX, req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob.decode(HEX, req.http.hexlcfoobar)); + blob=blob.decode(HEX, req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob.decode(HEX, req.http.hexhobbesuc)); + blob=blob.decode(HEX, req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob.decode(HEX, req.http.hexhobbeslc)); + blob=blob.decode(HEX, req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode(HEX, req.http.hexalluc)); + blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode(HEX, req.http.hexalllc)); + blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob.decode(HEX, - req.http.hexallucodd)); + blob.encode(BASE64, blob=blob.decode(HEX, + req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob.decode(HEX, - req.http.hexalllcodd)); + blob.encode(BASE64, blob=blob.decode(HEX, + req.http.hexalllcodd)); set resp.http.decempty = - blob.encode(IDENTITY, blob.decode(HEX, "")); + blob.encode(IDENTITY, blob=blob.decode(HEX, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob.decode(HEX, "00")); + blob.encode(IDENTITY, blob=blob.decode(HEX, "00")); set resp.http.decemptynibble = - blob.encode(IDENTITY, blob.decode(HEX, "0")); + blob.encode(IDENTITY, blob=blob.decode(HEX, "0")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob.decode(HEX, req.http.unset + "" - + req.http.unset + "")); + blob=blob.decode(HEX, req.http.unset + "" + + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob.decode(HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(HEX, req.http.part1 + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; @@ -119,11 +131,11 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob.decode(HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(HEX, req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode(HEX, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode(HEX, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -134,14 +146,18 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { client c1 { txreq -url "/" rxresp - expect resp.http.hexlc == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" + expect resp.http.hex == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" + expect resp.http.hexlc == resp.http.hex expect resp.http.hexuc == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67" - expect resp.http.hobbeslc == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" + expect resp.http.hobbes == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" + expect resp.http.hobbeslc == resp.http.hobbes expect resp.http.hobbesuc == "4D616E2069732064697374696E677569736865642C206E6F74206F6E6C792062792068697320726561736F6E2C2062757420627920746869732073696E67756C61722070617373696F6E2066726F6D206F7468657220616E696D616C732C2077686963682069732061206C757374206F6620746865206D696E642C20746861742062792061207065727365766572616E6365206F662064656C6967687420696E2074686520636F6E74696E75656420616E6420696E6465666174696761626C652067656E65726174696F6E206F66206B6E6F776C656467652C2065786365656473207468652073686F727420766568656D656E6365206F6620616E79206361726E616C20706C6561737572652E" + expect resp.http.all == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" expect resp.http.all-uc == "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF" - expect resp.http.all-lc == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + expect resp.http.all-lc == resp.http.all + expect resp.http.empty == "" expect resp.http.empty-uc == "" - expect resp.http.empty-lc == "" + expect resp.http.empty-lc == resp.http.empty expect resp.http.hexlcparam == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" expect resp.http.hexucparam == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67" expect resp.http.decuc == "foo bar baz quux" @@ -174,7 +190,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { set req.http.foo = "123"; - set resp.http.badhex = blob.encode(HEXUC, + set resp.http.badhex = blob.encode(HEX, UPPER, blob.decode(HEX, "g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00036.vtc b/bin/varnishtest/tests/m00036.vtc index 21ff627..cf6335b 100644 --- a/bin/varnishtest/tests/m00036.vtc +++ b/bin/varnishtest/tests/m00036.vtc @@ -18,38 +18,41 @@ varnish v1 -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.hexlc = - blob.encode(HEXLC, - blob.decode_n(5, IDENTITY, req.http.pangram)); + blob.encode(HEX, + blob=blob.decode_n(5, IDENTITY, req.http.pangram)); set resp.http.hexuc = - blob.encode(HEXUC, - blob.decode_n(5, IDENTITY, req.http.pangram)); + blob.encode(HEX, UPPER, + blob.decode_n(5, IDENTITY, req.http.pangram)); set resp.http.hobbeslc = - blob.encode(HEXLC, blob.decode_n(5, IDENTITY, req.http.hobbes)); + blob.encode(HEX, + blob=blob.decode_n(5, IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(HEXUC, blob.decode_n(5, IDENTITY, req.http.hobbes)); + blob.encode(HEX, UPPER, + blob.decode_n(5, IDENTITY, req.http.hobbes)); set resp.http.all-lc = - blob.encode(HEXLC, blob.decode_n(8, BASE64, req.http.b64all)); + blob.encode(HEX, blob=blob.decode_n(8, BASE64, req.http.b64all)); set resp.http.all-uc = - blob.encode(HEXUC, blob.decode_n(8, BASE64, req.http.b64all)); + blob.encode(HEX, UPPER, + blob.decode_n(8, BASE64, req.http.b64all)); set resp.http.empty-lc = - blob.encode(HEXLC, blob.decode_n(5, IDENTITY, "")); + blob.encode(HEX, blob=blob.decode_n(5, IDENTITY, "")); set resp.http.empty-uc = - blob.encode(HEXUC, blob.decode_n(5, IDENTITY, "")); + blob.encode(HEX, UPPER, blob.decode_n(5, IDENTITY, "")); set resp.http.hexlcparam = blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), - encoding=HEXLC); + encoding=HEX, case=LOWER); set resp.http.hexucparam = blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), - encoding=HEXUC); + encoding=HEX, case=UPPER); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); @@ -63,51 +66,53 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob.decode_n(10, HEX, req.http.hexucfoobar)); + blob=blob.decode_n(10, HEX, req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob.decode_n(10, HEX, req.http.hexlcfoobar)); + blob=blob.decode_n(10, HEX, req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob.decode_n(12, HEX, req.http.hexhobbesuc)); + blob=blob.decode_n(12, HEX, req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob.decode_n(12, HEX, req.http.hexhobbeslc)); + blob=blob.decode_n(12, HEX, req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalluc)); + blob.encode(BASE64, + blob=blob.decode_n(12, HEX, req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode_n(12, HEX, req.http.hexalllc)); + blob.encode(BASE64, + blob=blob.decode_n(12, HEX, req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob.decode_n(11, HEX, - req.http.hexallucodd)); + blob.encode(BASE64, blob=blob.decode_n(11, HEX, + req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob.decode_n(11, HEX, - req.http.hexalllcodd)); + blob.encode(BASE64, blob=blob.decode_n(11, HEX, + req.http.hexalllcodd)); set resp.http.decempty = - blob.encode(IDENTITY, blob.decode_n(5, HEX, "")); + blob.encode(IDENTITY, blob=blob.decode_n(5, HEX, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob.decode_n(1, HEX, "00")); + blob.encode(IDENTITY, blob=blob.decode_n(1, HEX, "00")); set resp.http.decemptynibble = - blob.encode(IDENTITY, blob.decode_n(2, HEX, "0")); + blob.encode(IDENTITY, blob=blob.decode_n(2, HEX, "0")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob.decode_n(5, HEX, req.http.unset + "" - + req.http.unset + "")); + blob=blob.decode_n(5, HEX, req.http.unset + "" + + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob.decode_n(6, HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode_n(6, HEX, req.http.part1 + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; @@ -118,11 +123,12 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob.decode_n(30, HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode_n(30, HEX, req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode_n(20, HEX, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode_n(20, HEX, "" + + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -173,7 +179,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { set req.http.foo = "123"; - set resp.http.badhex = blob.encode(HEXUC, + set resp.http.badhex = blob.encode(HEX, UPPER, blob.decode_n(2, HEX, "g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index 13dc2d5..25a7dee 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -18,69 +18,93 @@ varnish v1 -vcl { {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set resp.http.b64 = - blob.encode(BASE64, blob.decode(IDENTITY, + blob.encode(BASE64, blob=blob.decode(IDENTITY, + req.http.pangram)); + + set resp.http.b64lc = + blob.encode(BASE64, LOWER, blob.decode(IDENTITY, + req.http.pangram)); + + set resp.http.b64uc = + blob.encode(BASE64, UPPER, blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64hobbes = - blob.encode(BASE64, blob.decode(IDENTITY, + blob.encode(BASE64, blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64all = - blob.encode(BASE64, blob.decode(HEX, req.http.hexall)); + blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexall)); set resp.http.b64url = blob.encode(BASE64URL, - blob.decode(IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64urllc = + blob.encode(BASE64URL, LOWER, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64urluc = + blob.encode(BASE64URL, UPPER, + blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64urlhobbes = blob.encode(BASE64URL, - blob.decode(IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64urlall = - blob.encode(BASE64URL, blob.decode(HEX, req.http.hexall)); + blob.encode(BASE64URL, blob=blob.decode(HEX, req.http.hexall)); set resp.http.b64urlnopad = blob.encode(BASE64URLNOPAD, - blob.decode(IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64urlnopadlc = + blob.encode(BASE64URLNOPAD, LOWER, + blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.b64urlnopaduc = + blob.encode(BASE64URLNOPAD, UPPER, + blob.decode(IDENTITY, req.http.pangram)); set resp.http.b64nopadhobbes = blob.encode(BASE64URLNOPAD, - blob.decode(IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.b64nopadall = blob.encode(BASE64URLNOPAD, - blob.decode(HEX, req.http.hexall)); + blob=blob.decode(HEX, req.http.hexall)); set resp.http.b64empty = - blob.encode(BASE64, blob.decode(IDENTITY, "")); + blob.encode(BASE64, blob=blob.decode(IDENTITY, "")); set resp.http.urlempty = - blob.encode(BASE64URL, blob.decode(IDENTITY, "")); + blob.encode(BASE64URL, blob=blob.decode(IDENTITY, "")); set resp.http.nopadempty = - blob.encode(BASE64URLNOPAD, blob.decode(IDENTITY, "")); + blob.encode(BASE64URLNOPAD, blob=blob.decode(IDENTITY, "")); set resp.http.b64param = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=BASE64); + encoding=BASE64, case=LOWER); set resp.http.b64urlparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=BASE64URL); + encoding=BASE64URL, case=UPPER); set resp.http.b64urlnopadparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=BASE64URLNOPAD); + encoding=BASE64URLNOPAD, case=LOWER); set resp.http.b64xcode = - blob.transcode(IDENTITY, BASE64, req.url + "Hello world" + - req.url); + blob.transcode(IDENTITY, BASE64, + encoded=req.url + "Hello world" + req.url); set resp.http.b64urlxcode = - blob.transcode(IDENTITY, BASE64URL, req.url + "Hello world" + - req.url); + blob.transcode(IDENTITY, BASE64URL, + encoded=req.url + "Hello world" + req.url); set resp.http.b64urlnopadxcode = blob.transcode(IDENTITY, BASE64URLNOPAD, - req.url + "Hello world" + req.url); + encoded=req.url + "Hello world" + req.url); } } -start @@ -88,12 +112,18 @@ client c1 { txreq -url "/" rxresp expect resp.http.b64 == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" + expect resp.http.b64lc == resp.http.b64 + expect resp.http.b64uc == resp.http.b64 expect resp.http.b64hobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" expect resp.http.b64all == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" expect resp.http.b64url == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" + expect resp.http.b64urllc == resp.http.b64url + expect resp.http.b64urluc == resp.http.b64url expect resp.http.b64urlhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" expect resp.http.b64urlall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" expect resp.http.b64urlnopad == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + expect resp.http.b64urlnopadlc == resp.http.b64urlnopad + expect resp.http.b64urlnopaduc == resp.http.b64urlnopad expect resp.http.b64nopadhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" expect resp.http.b64nopadall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" expect resp.http.b64empty == "" @@ -126,66 +156,66 @@ varnish v1 -vcl { set req.http.allurl = {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; - set resp.http.dec = blob.encode(IDENTITY, + set resp.http.dec = blob.encode(IDENTITY, blob= blob.decode(BASE64, req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, - blob.decode(BASE64, req.http.pangram)); + blob=blob.decode(BASE64, req.http.pangram)); set resp.http.b64dechobbes = blob.encode(IDENTITY, - blob.decode(BASE64, req.http.hobbes)); + blob=blob.decode(BASE64, req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEXLC, blob.decode(BASE64, req.http.all)); + blob.encode(HEX, blob=blob.decode(BASE64, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob.decode(BASE64URL, + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEXLC, - blob.decode(BASE64URL, req.http.allurl)); + blob.encode(HEX, + blob=blob.decode(BASE64URL, req.http.allurl)); set resp.http.nopaddechobbes = - blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, req.http.hobbesnopad)); set resp.http.nopaddecall = - blob.encode(HEXLC, - blob.decode(BASE64URLNOPAD, req.http.allurl)); + blob.encode(HEX, + blob=blob.decode(BASE64URLNOPAD, req.http.allurl)); set resp.http.b64empty = - blob.encode(IDENTITY, blob.decode(BASE64, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64, "")); set resp.http.urlempty = - blob.encode(IDENTITY, blob.decode(BASE64URL, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, "")); set resp.http.nopadempty = - blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, "")); set resp.http.emptypieces = - blob.encode(IDENTITY, + blob.encode(IDENTITY, blob= blob.decode(BASE64, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, - blob.decode(BASE64, req.http.foobarbazquux)); + blob=blob.decode(BASE64, req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces - = blob.encode(IDENTITY, blob.decode(BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces - = blob.encode(IDENTITY, blob.decode(BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, resp.http.l + "0hlbGxvIHdvcmxkLw" + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces - = blob.encode(IDENTITY, blob.decode(BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad)); @@ -197,21 +227,21 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, - blob.decode(BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, "L0hlbGxvIHdvcmxkLw")); set resp.http.decnopad2pieces - = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces - = blob.encode(IDENTITY, blob.decode(BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, - blob.decode(BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); @@ -258,15 +288,15 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/base64") { set resp.http.bad64 = blob.encode(IDENTITY, - blob.decode(BASE64, "-_-_" + req.http.foo)); + blob=blob.decode(BASE64, "-_-_" + req.http.foo)); } elsif (req.url == "/base64url") { set resp.http.badurl = blob.encode(IDENTITY, - blob.decode(BASE64URL, "+/+/" + req.http.foo)); + blob=blob.decode(BASE64URL, "+/+/" + req.http.foo)); } elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, - blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); + blob=blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00038.vtc b/bin/varnishtest/tests/m00038.vtc index 894618d..4e7e334 100644 --- a/bin/varnishtest/tests/m00038.vtc +++ b/bin/varnishtest/tests/m00038.vtc @@ -22,82 +22,80 @@ varnish v1 -vcl { set resp.http.dec = blob.encode(IDENTITY, - blob.decode_n(8, BASE64, + blob=blob.decode_n(8, BASE64, req.http.foobarbazquux)); set resp.http.deceq = blob.encode(IDENTITY, - blob.decode_n(20, BASE64, + blob=blob.decode_n(20, BASE64, req.http.foobarbazquux)); set resp.http.declong = blob.encode(IDENTITY, - blob.decode_n(30, BASE64, + blob=blob.decode_n(30, BASE64, req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, - blob.decode_n(12, BASE64, req.http.pangram)); + blob=blob.decode_n(12, BASE64, req.http.pangram)); set resp.http.b64dechobbes = blob.encode(IDENTITY, - blob.decode_n(24, BASE64, req.http.hobbes)); + blob=blob.decode_n(24, BASE64, req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEXLC, blob.decode_n(128, BASE64, - req.http.all)); + blob.encode(HEX, blob=blob.decode_n(128, BASE64, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob.decode_n(180, BASE64URL, + blob.encode(IDENTITY, blob=blob.decode_n(180, BASE64URL, req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEXLC, - blob.decode_n(256, BASE64URL, + blob.encode(HEX, + blob=blob.decode_n(256, BASE64URL, req.http.allurl)); set resp.http.nopaddechobbes = blob.encode(IDENTITY, - blob.decode_n(500, BASE64URLNOPAD, + blob=blob.decode_n(500, BASE64URLNOPAD, req.http.hobbesnopad)); set resp.http.nopaddecall = - blob.encode(HEXLC, - blob.decode_n(256, BASE64URLNOPAD, - req.http.allurl)); + blob.encode(HEX, blob=blob.decode_n(256, BASE64URLNOPAD, + req.http.allurl)); set resp.http.b64empty = - blob.encode(IDENTITY, blob.decode_n(0, BASE64, "")); + blob.encode(IDENTITY, blob=blob.decode_n(0, BASE64, "")); set resp.http.urlempty = - blob.encode(IDENTITY, blob.decode_n(1, BASE64URL, "")); + blob.encode(IDENTITY, blob=blob.decode_n(1, BASE64URL, "")); set resp.http.nopadempty = blob.encode(IDENTITY, - blob.decode_n(0, BASE64URLNOPAD, "")); + blob=blob.decode_n(0, BASE64URLNOPAD, "")); set resp.http.emptypieces = blob.encode(IDENTITY, - blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset + blob=blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, - blob.decode_n(20, BASE64, + blob=blob.decode_n(20, BASE64, req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces - = blob.encode(IDENTITY, blob.decode_n(8, BASE64, + = blob.encode(IDENTITY, blob=blob.decode_n(8, BASE64, resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces - = blob.encode(IDENTITY, blob.decode_n(12, BASE64, + = blob.encode(IDENTITY, blob=blob.decode_n(12, BASE64, resp.http.l + "0hlbGxvIHdvcmxkLw" + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces - = blob.encode(IDENTITY, blob.decode_n(16, BASE64, + = blob.encode(IDENTITY, blob=blob.decode_n(16, BASE64, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad)); @@ -109,21 +107,21 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, - blob.decode_n(18, BASE64URLNOPAD, - "L0hlbGxvIHdvcmxkLw")); + blob=blob.decode_n(18, BASE64URLNOPAD, + "L0hlbGxvIHdvcmxkLw")); set resp.http.decnopad2pieces - = blob.encode(IDENTITY, blob.decode_n(19, BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode_n(19, BASE64URLNOPAD, resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces - = blob.encode(IDENTITY, blob.decode_n(18, BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode_n(18, BASE64URLNOPAD, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, - blob.decode_n(60, BASE64URLNOPAD, + blob=blob.decode_n(60, BASE64URLNOPAD, "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); @@ -172,16 +170,16 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/base64") { set resp.http.bad64 = blob.encode(IDENTITY, - blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); + blob=blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); } elsif (req.url == "/base64url") { set resp.http.badurl = blob.encode(IDENTITY, - blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); + blob=blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); } elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, - blob.decode_n(8, BASE64URLNOPAD, - "TWFu" + req.http.foo)); + blob=blob.decode_n(8, BASE64URLNOPAD, + "TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index 8048ccf..440c7ed 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -21,62 +21,117 @@ varnish v1 -vcl { set req.http.b64all = {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; + set resp.http.url = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.pangram)); + set resp.http.urllc = - blob.encode(URLLC, - blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.pangram)); set resp.http.urluc = - blob.encode(URLUC, - blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.pangram)); + + set resp.http.hobbes = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbeslc = - blob.encode(URLLC, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(URLUC, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.hobbes)); + + set resp.http.umlauts = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.umlauts)); set resp.http.umlautslc = - blob.encode(URLLC, - blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.umlauts)); set resp.http.umlautsuc = - blob.encode(URLUC, - blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.umlauts)); + + set resp.http.phk = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.phkspeak)); set resp.http.phklc = - blob.encode(URLLC, - blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.phkspeak)); set resp.http.phkuc = - blob.encode(URLUC, - blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.phkspeak)); + + set resp.http.utf8 = + blob.encode(URL, blob=blob.decode(IDENTITY, req.http.utf8)); set resp.http.utf8lc = - blob.encode(URLLC, blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.utf8)); set resp.http.utf8uc = - blob.encode(URLUC, blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.utf8)); + + set resp.http.all = + blob.encode(URL, blob=blob.decode(BASE64, req.http.b64all)); set resp.http.all-lc = - blob.encode(URLLC, blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, LOWER, blob.decode(BASE64, req.http.b64all)); set resp.http.all-uc = - blob.encode(URLUC, blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, UPPER, blob.decode(BASE64, req.http.b64all)); + + set resp.http.empty = + blob.encode(URL, blob=blob.decode(IDENTITY, "")); set resp.http.empty-lc = - blob.encode(URLLC, blob.decode(IDENTITY, "")); + blob.encode(URL, LOWER, blob.decode(IDENTITY, "")); set resp.http.empty-uc = - blob.encode(URLUC, blob.decode(IDENTITY, "")); + blob.encode(URL, UPPER, blob.decode(IDENTITY, "")); set resp.http.urllcparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=URLLC); + encoding=URL, case=LOWER); set resp.http.urlucparam = blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), - encoding=URLUC); + encoding=URL, case=UPPER); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.url == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.urllc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.urluc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.hobbes == "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." + expect resp.http.hobbeslc == "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." + expect resp.http.hobbesuc == "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." + expect resp.http.umlauts == "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger" + expect resp.http.umlautslc == "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger" + expect resp.http.umlautsuc == "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger" + expect resp.http.phk == "sm%c3%a5b%c3%b8rnsp%c3%a6dagog" + expect resp.http.phklc == "sm%c3%a5b%c3%b8rnsp%c3%a6dagog" + expect resp.http.phkuc == "sm%C3%A5b%C3%B8rnsp%C3%A6dagog" + expect resp.http.utf8 == "%e6%97%a5%e6%89%bc%e8%aa%9e" + expect resp.http.utf8lc == "%e6%97%a5%e6%89%bc%e8%aa%9e" + expect resp.http.utf8uc == "%E6%97%A5%E6%89%BC%E8%AA%9E" + expect resp.http.all == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.all-lc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.all-uc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" + expect resp.http.empty == "" + expect resp.http.empty-uc == "" + expect resp.http.empty-lc == "" + expect resp.http.urllcparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.urlucparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" +} -run + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { set req.http.urllcfoobar = "foo%3abar%3abaz%3aquux"; set req.http.urlucfoobar = "foo%3Abar%3Abaz%3Aquux"; set req.http.urlmixedfoobar = "foo%3Abar%3abaz%3Aquux"; @@ -93,68 +148,68 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlucfoobar)); + blob=blob.decode(URL, req.http.urlucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urllcfoobar)); + blob=blob.decode(URL, req.http.urllcfoobar)); set resp.http.decmixed = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlmixedfoobar)); + blob=blob.decode(URL, req.http.urlmixedfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlhobbesuc)); + blob=blob.decode(URL, req.http.urlhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlhobbeslc)); + blob=blob.decode(URL, req.http.urlhobbeslc)); set resp.http.decumlautsuc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlucumlauts)); + blob=blob.decode(URL, req.http.urlucumlauts)); set resp.http.decumlautslc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urllcumlauts)); + blob=blob.decode(URL, req.http.urllcumlauts)); set resp.http.decphkuc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlucphk)); + blob=blob.decode(URL, req.http.urlucphk)); set resp.http.decphklc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urllcphk)); + blob=blob.decode(URL, req.http.urllcphk)); set resp.http.decutf8uc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urlucutf8)); + blob=blob.decode(URL, req.http.urlucutf8)); set resp.http.decutf8lc = blob.encode(IDENTITY, - blob.decode(URL, req.http.urllcutf8)); + blob=blob.decode(URL, req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(BASE64, blob.decode(URL, req.http.urlalluc)); + blob.encode(BASE64, blob=blob.decode(URL, req.http.urlalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob.decode(URL, req.http.urlalllc)); + blob.encode(BASE64, blob=blob.decode(URL, req.http.urlalllc)); set resp.http.decempty = - blob.encode(IDENTITY, blob.decode(URL, "")); + blob.encode(IDENTITY, blob=blob.decode(URL, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob.decode(URL, "%00")); + blob.encode(IDENTITY, blob=blob.decode(URL, "%00")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob.decode(URL, req.http.unset + "" + blob=blob.decode(URL, req.http.unset + "" + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob.decode(URL, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(URL, req.http.part1 + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; @@ -165,37 +220,21 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob.decode(URL, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(URL, req.http.part1 + "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob.decode(URL, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode(URL, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 + req.http.unset + "" + req.http.unset)); } -} -start +} client c1 { txreq -url "/" rxresp - expect resp.http.urllc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" - expect resp.http.urluc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" - expect resp.http.hobbeslc == "Man%20is%20distinguished%2c%20not%20only%20by%20his%20reason%2c%20but%20by%20this%20singular%20passion%20from%20other%20animals%2c%20which%20is%20a%20lust%20of%20the%20mind%2c%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2c%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." - expect resp.http.hobbesuc == "Man%20is%20distinguished%2C%20not%20only%20by%20his%20reason%2C%20but%20by%20this%20singular%20passion%20from%20other%20animals%2C%20which%20is%20a%20lust%20of%20the%20mind%2C%20that%20by%20a%20perseverance%20of%20delight%20in%20the%20continued%20and%20indefatigable%20generation%20of%20knowledge%2C%20exceeds%20the%20short%20vehemence%20of%20any%20carnal%20pleasure." - expect resp.http.umlautslc == "%c3%9cbergr%c3%b6%c3%9fentr%c3%a4ger" - expect resp.http.umlautsuc == "%C3%9Cbergr%C3%B6%C3%9Fentr%C3%A4ger" - expect resp.http.phklc == "sm%c3%a5b%c3%b8rnsp%c3%a6dagog" - expect resp.http.phkuc == "sm%C3%A5b%C3%B8rnsp%C3%A6dagog" - expect resp.http.utf8lc == "%e6%97%a5%e6%89%bc%e8%aa%9e" - expect resp.http.utf8uc == "%E6%97%A5%E6%89%BC%E8%AA%9E" - expect resp.http.all-lc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" - expect resp.http.all-uc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" - expect resp.http.empty-uc == "" - expect resp.http.empty-lc == "" - expect resp.http.urllcparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" - expect resp.http.urlucparam == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" expect resp.http.decuc == "foo:bar:baz:quux" expect resp.http.declc == "foo:bar:baz:quux" expect resp.http.decmixed == "foo:bar:baz:quux" @@ -231,18 +270,18 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { set resp.http.bad - = blob.encode(URLUC, blob.decode(URL, "%")); + = blob.encode(URL, UPPER, blob.decode(URL, "%")); } elsif (req.url == "/percent-two") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode(URL, "%2")); } elsif (req.url == "/percent-q") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode(URL, "%q")); } elsif (req.url == "/percent-two-q") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode(URL, "%2q")); } } diff --git a/bin/varnishtest/tests/m00040.vtc b/bin/varnishtest/tests/m00040.vtc index b3c87b3..2355ca9 100644 --- a/bin/varnishtest/tests/m00040.vtc +++ b/bin/varnishtest/tests/m00040.vtc @@ -25,69 +25,67 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob.decode_n(9, URL, req.http.urlucfoobar)); + blob=blob.decode_n(9, URL, req.http.urlucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob.decode_n(12, URL, req.http.urllcfoobar)); + blob=blob.decode_n(12, URL, req.http.urllcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob.decode_n(27, URL, req.http.urlhobbesuc)); + blob=blob.decode_n(27, URL, req.http.urlhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob.decode_n(27, URL, req.http.urlhobbeslc)); + blob=blob.decode_n(27, URL, req.http.urlhobbeslc)); set resp.http.decumlautsuc = blob.encode(IDENTITY, - blob.decode_n(17, URL, - req.http.urlucumlauts)); + blob=blob.decode_n(17, URL, req.http.urlucumlauts)); set resp.http.decumlautslc = blob.encode(IDENTITY, - blob.decode_n(25, URL, - req.http.urllcumlauts)); + blob=blob.decode_n(25, URL, req.http.urllcumlauts)); set resp.http.decphkuc = blob.encode(IDENTITY, - blob.decode_n(18, URL, req.http.urlucphk)); + blob=blob.decode_n(18, URL, req.http.urlucphk)); set resp.http.decphklc = blob.encode(IDENTITY, - blob.decode_n(30, URL, req.http.urllcphk)); + blob=blob.decode_n(30, URL, req.http.urllcphk)); set resp.http.decutf8uc = blob.encode(IDENTITY, - blob.decode_n(9, URL, req.http.urlucutf8)); + blob=blob.decode_n(9, URL, req.http.urlucutf8)); set resp.http.decutf8lc = blob.encode(IDENTITY, - blob.decode_n(18, URL, req.http.urllcutf8)); + blob=blob.decode_n(18, URL, req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(HEXLC, - blob.decode_n(252, URL, req.http.urlalluc)); + blob.encode(HEX, + blob=blob.decode_n(252, URL, req.http.urlalluc)); set resp.http.decalllc = - blob.encode(HEXUC, - blob.decode_n(252, URL, req.http.urlalllc)); + blob.encode(HEX, UPPER, + blob.decode_n(252, URL, req.http.urlalllc)); set resp.http.decempty = - blob.encode(IDENTITY, blob.decode_n(10, URL, "")); + blob.encode(IDENTITY, blob=blob.decode_n(10, URL, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob.decode_n(3, URL, "%00")); + blob.encode(IDENTITY, blob=blob.decode_n(3, URL, "%00")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob.decode_n(1, URL, req.http.unset + "" + blob=blob.decode_n(1, URL, req.http.unset + "" + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = blob.encode(IDENTITY, - blob.decode_n(6, URL, req.http.part1 + + blob=blob.decode_n(6, URL, req.http.part1 + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; @@ -99,13 +97,13 @@ varnish v1 -vcl { set resp.http.dec3pieces = blob.encode(IDENTITY, - blob.decode_n(18, URL, req.http.part1 + blob=blob.decode_n(18, URL, req.http.part1 + "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, - blob.decode_n(24, URL, "" + req.http.unset + blob=blob.decode_n(24, URL, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -149,20 +147,20 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode_n(1, URL, "%20")); } elsif (req.url == "/percent-two") { - set resp.http.bad = blob.encode(URLUC, + set resp.http.bad = blob.encode(URL, UPPER, blob.decode_n(2, URL, "%20")); } elsif (req.url == "/comma") { - set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%2c%q")); + set resp.http.good = blob.encode(IDENTITY, blob= + blob.decode_n(3, URL, "%2c%q")); } elsif (req.url == "/colon") { - set resp.http.good = blob.encode(IDENTITY, - blob.decode_n(3, URL, "%3a%2q")); + set resp.http.good = blob.encode(IDENTITY, blob= + blob.decode_n(3, URL, "%3a%2q")); } } } diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index c350ee1..cfed6ae 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -33,97 +33,186 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { = blob.transcode(encoded=req.http.hobbes, encoding=BASE64); set resp.http.id2b64nopad - = blob.transcode(IDENTITY, BASE64URLNOPAD, req.http.hobbes); + = blob.transcode(IDENTITY, BASE64URLNOPAD, encoded=req.http.hobbes); + + set resp.http.id2hex + = blob.transcode(IDENTITY, HEX, encoded=req.http.hobbes); set resp.http.id2hexuc - = blob.transcode(IDENTITY, HEXUC, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, UPPER, req.http.hobbes); set resp.http.id2hexlc - = blob.transcode(IDENTITY, HEXLC, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, LOWER, req.http.hobbes); + + set resp.http.id2url + = blob.transcode(IDENTITY, URL, encoded=req.http.foobar); set resp.http.id2urluc - = blob.transcode(IDENTITY, URLUC, req.http.foobar); + = blob.transcode(IDENTITY, URL, UPPER, req.http.foobar); set resp.http.id2urllc - = blob.transcode(IDENTITY, URLLC, req.http.foobar); + = blob.transcode(IDENTITY, URL, LOWER, req.http.foobar); set resp.http.b642id - = blob.transcode(BASE64, IDENTITY, req.http.hobbesb64); + = blob.transcode(BASE64, IDENTITY, encoded=req.http.hobbesb64); set resp.http.hex2id - = blob.transcode(HEX, IDENTITY, req.http.hexhobbes); + = blob.transcode(HEX, IDENTITY, encoded=req.http.hexhobbes); set resp.http.hexalldown2b64 - = blob.transcode(HEX, BASE64, req.http.hexalldown); + = blob.transcode(HEX, BASE64, encoded=req.http.hexalldown); set resp.http.hexalldown2b64url - = blob.transcode(HEX, BASE64URL, req.http.hexalldown); + = blob.transcode(HEX, BASE64URL, encoded=req.http.hexalldown); set resp.http.hexalldown2b64nopad - = blob.transcode(HEX, BASE64URLNOPAD, req.http.hexalldown); + = blob.transcode(HEX, BASE64URLNOPAD, encoded=req.http.hexalldown); set resp.http.hexallup2b64 - = blob.transcode(HEX, BASE64, req.http.hexallup); + = blob.transcode(HEX, BASE64, encoded=req.http.hexallup); set resp.http.hexallup2b64url - = blob.transcode(HEX, BASE64URL, req.http.hexallup); + = blob.transcode(HEX, BASE64URL, encoded=req.http.hexallup); set resp.http.hexallup2b64nopad - = blob.transcode(HEX, BASE64URLNOPAD, req.http.hexallup); + = blob.transcode(HEX, BASE64URLNOPAD, encoded=req.http.hexallup); + + set resp.http.hexalldown2url + = blob.transcode(HEX, URL, encoded=req.http.hexalldown); set resp.http.hexalldown2urluc - = blob.transcode(HEX, URLUC, req.http.hexalldown); + = blob.transcode(HEX, URL, UPPER, req.http.hexalldown); set resp.http.hexalldown2urllc - = blob.transcode(HEX, URLLC, req.http.hexalldown); + = blob.transcode(HEX, URL, LOWER, req.http.hexalldown); + + set resp.http.hexallup2url + = blob.transcode(HEX, URL, encoded=req.http.hexallup); set resp.http.hexallup2urluc - = blob.transcode(HEX, URLUC, req.http.hexallup); + = blob.transcode(HEX, URL, UPPER, req.http.hexallup); set resp.http.hexallup2urllc - = blob.transcode(HEX, URLLC, req.http.hexallup); + = blob.transcode(HEX, URL, LOWER, req.http.hexallup); + + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.id2id == "Hello world" + expect resp.http.id2b64 == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" + expect resp.http.id2b64nopad == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" + expect resp.http.id2hex == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" + expect resp.http.id2hexuc == "4D616E2069732064697374696E677569736865642C206E6F74206F6E6C792062792068697320726561736F6E2C2062757420627920746869732073696E67756C61722070617373696F6E2066726F6D206F7468657220616E696D616C732C2077686963682069732061206C757374206F6620746865206D696E642C20746861742062792061207065727365766572616E6365206F662064656C6967687420696E2074686520636F6E74696E75656420616E6420696E6465666174696761626C652067656E65726174696F6E206F66206B6E6F776C656467652C2065786365656473207468652073686F727420766568656D656E6365206F6620616E79206361726E616C20706C6561737572652E" + expect resp.http.id2hexlc == resp.http.id2hex + expect resp.http.id2url == "foo%3abar%3abaz%3aquux" + expect resp.http.id2urluc == "foo%3Abar%3Abaz%3Aquux" + expect resp.http.id2urllc == resp.http.id2url + expect resp.http.b642id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.hex2id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." + expect resp.http.hexalldown2b64 == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.hexalldown2b64url == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" + expect resp.http.hexalldown2b64nopad == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" + expect resp.http.hexallup2b64 == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + expect resp.http.hexallup2b64url == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w==" + expect resp.http.hexallup2b64nopad == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w" + expect resp.http.hexalldown2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" + expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" + expect resp.http.hexalldown2urllc == resp.http.hexalldown2url + expect resp.http.hexallup2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.hexallup2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" + expect resp.http.hexallup2urllc == resp.http.hexallup2url +} -run + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.foobar = "foo:bar:baz:quux"; + set req.http.hobbes = +{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}; + set req.http.hobbesb64 = +{"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}; + set req.http.hexhobbes = "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e"; + set req.http.hexalldown = +{"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; + set req.http.hexallup = +{"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"}; + set req.http.b64all = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; + set req.http.b64allurl = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; + + set resp.http.b64all2hex + = blob.transcode(BASE64, HEX, encoded=req.http.b64all); set resp.http.b64all2hexuc - = blob.transcode(BASE64, HEXUC, req.http.b64all); + = blob.transcode(BASE64, HEX, UPPER, req.http.b64all); set resp.http.b64all2hexlc - = blob.transcode(BASE64, HEXLC, req.http.b64all); + = blob.transcode(BASE64, HEX, LOWER, req.http.b64all); + + set resp.http.b64allurl2hex + = blob.transcode(BASE64URL, HEX, encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc - = blob.transcode(BASE64URL, HEXUC, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, UPPER, req.http.b64allurl); set resp.http.b64allurl2hexlc - = blob.transcode(BASE64URL, HEXLC, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, LOWER, req.http.b64allurl); + + set resp.http.b64all2url + = blob.transcode(BASE64, URL, encoded=req.http.b64all); set resp.http.b64all2urluc - = blob.transcode(BASE64, URLUC, req.http.b64all); + = blob.transcode(BASE64, URL, UPPER, req.http.b64all); set resp.http.b64all2urllc - = blob.transcode(BASE64, URLLC, req.http.b64all); + = blob.transcode(BASE64, URL, LOWER, req.http.b64all); + + set resp.http.b64allurl2url + = blob.transcode(BASE64URL, URL, encoded=req.http.b64allurl); set resp.http.b64allurl2urluc - = blob.transcode(BASE64URL, URLUC, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, UPPER, req.http.b64allurl); set resp.http.b64allurl2urllc - = blob.transcode(BASE64URL, URLLC, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, LOWER, req.http.b64allurl); + + set resp.http.hexuc2hex + = blob.transcode(HEX, HEX, encoded="0123456789ABCDEF"); set resp.http.hexuc2hexuc - = blob.transcode(HEX, HEXUC, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, UPPER, "0123456789ABCDEF"); set resp.http.hexlc2hexlc - = blob.transcode(HEX, HEXLC, "0123456789abcdef"); + = blob.transcode(HEX, HEX, LOWER, "0123456789abcdef"); + + set resp.http.hexlc2hex + = blob.transcode(HEX, HEX, encoded="0123456789abcdef"); set resp.http.hexuc2hexlc - = blob.transcode(HEX, HEXLC, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, LOWER, "0123456789ABCDEF"); set resp.http.hexlc2hexuc - = blob.transcode(HEX, HEXUC, "0123456789abcdef"); + = blob.transcode(HEX, HEX, UPPER, "0123456789abcdef"); + + set resp.http.hexmix2hex + = blob.transcode(HEX, HEX, encoded="0123456789ABCdef"); set resp.http.hexmix2hexuc - = blob.transcode(HEX, HEXUC, "0123456789ABCdef"); + = blob.transcode(HEX, HEX, UPPER, "0123456789ABCdef"); set resp.http.hexmix2hexlc - = blob.transcode(HEX, HEXLC, "0123456789abcDEF"); + = blob.transcode(HEX, HEX, LOWER, "0123456789abcDEF"); set req.http.hexpart1 = "01234567"; set req.http.hexpart2 = "89abcdef"; @@ -132,62 +221,50 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { + req.http.unset + "" + req.http.hexpart1 + "" + req.http.unset + "" + req.http.unset + req.http.hexpart2, decoding=HEX, - encoding=HEXUC); + encoding=HEX, case=UPPER); set resp.http.b642b64 - = blob.transcode(BASE64, BASE64, + = blob.transcode(BASE64, BASE64, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789+/"); set resp.http.b64url2b64url = - blob.transcode(BASE64URL, BASE64URL, + blob.transcode(BASE64URL, BASE64URL, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); set resp.http.b64urlnopad2b64urlnopad = - blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, + blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); } -} -start +} client c1 { txreq rxresp - expect resp.http.id2id == "Hello world" - expect resp.http.id2b64 == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" - expect resp.http.id2b64nopad == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" - expect resp.http.id2hexuc == "4D616E2069732064697374696E677569736865642C206E6F74206F6E6C792062792068697320726561736F6E2C2062757420627920746869732073696E67756C61722070617373696F6E2066726F6D206F7468657220616E696D616C732C2077686963682069732061206C757374206F6620746865206D696E642C20746861742062792061207065727365766572616E6365206F662064656C6967687420696E2074686520636F6E74696E75656420616E6420696E6465666174696761626C652067656E65726174696F6E206F66206B6E6F776C656467652C2065786365656473207468652073686F727420766568656D656E6365206F6620616E79206361726E616C20706C6561737572652E" - expect resp.http.id2hexlc == "4d616e2069732064697374696e677569736865642c206e6f74206f6e6c792062792068697320726561736f6e2c2062757420627920746869732073696e67756c61722070617373696f6e2066726f6d206f7468657220616e696d616c732c2077686963682069732061206c757374206f6620746865206d696e642c20746861742062792061207065727365766572616e6365206f662064656c6967687420696e2074686520636f6e74696e75656420616e6420696e6465666174696761626c652067656e65726174696f6e206f66206b6e6f776c656467652c2065786365656473207468652073686f727420766568656d656e6365206f6620616e79206361726e616c20706c6561737572652e" - expect resp.http.id2urluc == "foo%3Abar%3Abaz%3Aquux" - expect resp.http.id2urllc == "foo%3abar%3abaz%3aquux" - expect resp.http.b642id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." - expect resp.http.hex2id == "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." - expect resp.http.hexalldown2b64 == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" - expect resp.http.hexalldown2b64url == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" - expect resp.http.hexalldown2b64nopad == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" - expect resp.http.hexallup2b64 == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" - expect resp.http.hexallup2b64url == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w==" - expect resp.http.hexallup2b64nopad == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w" - expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" - expect resp.http.hexalldown2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" - expect resp.http.hexallup2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" - expect resp.http.hexallup2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.b64all2hex == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" expect resp.http.b64all2hexuc == "0000000410410820820C30C31041041451451861861C71C720820824924928A28A2CB2CB30C30C34D34D38E38E3CF3CF4104104514514924924D34D35145145555555965965D75D761861865965969A69A6DB6DB71C71C75D75D79E79E7DF7DF8208208618618A28A28E38E39249249659659A69A69E79E7A28A28A69A69AAAAAAAEBAEBB2CB2CB6DB6DBAEBAEBEFBEFC30C30C71C71CB2CB2CF3CF3D34D34D75D75DB6DB6DF7DF7E38E38E79E79EBAEBAEFBEFBF3CF3CF7DF7DFBEFBEFFFFFF" - expect resp.http.b64all2hexlc == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.b64all2hexlc == resp.http.b64all2hex + expect resp.http.b64allurl2hex == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" expect resp.http.b64allurl2hexuc == "0000000410410820820C30C31041041451451861861C71C720820824924928A28A2CB2CB30C30C34D34D38E38E3CF3CF4104104514514924924D34D35145145555555965965D75D761861865965969A69A6DB6DB71C71C75D75D79E79E7DF7DF8208208618618A28A28E38E39249249659659A69A69E79E7A28A28A69A69AAAAAAAEBAEBB2CB2CB6DB6DBAEBAEBEFBEFC30C30C71C71CB2CB2CF3CF3D34D34D75D75DB6DB6DF7DF7E38E38E79E79EBAEBAEFBEFBF3CF3CF7DF7DFBEFBEFFFFFF" - expect resp.http.b64allurl2hexlc == "0000000410410820820c30c31041041451451861861c71c720820824924928a28a2cb2cb30c30c34d34d38e38e3cf3cf4104104514514924924d34d35145145555555965965d75d761861865965969a69a6db6db71c71c75d75d79e79e7df7df8208208618618a28a28e38e39249249659659a69a69e79e7a28a28a69a69aaaaaaaebaebb2cb2cb6db6dbaebaebefbefc30c30c71c71cb2cb2cf3cf3d34d34d75d75db6db6df7df7e38e38e79e79ebaebaefbefbf3cf3cf7df7dfbefbeffffff" + expect resp.http.b64allurl2hexlc == resp.http.b64allurl2hex + expect resp.http.b64all2url == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" expect resp.http.b64all2urluc == "%00%00%00%04%10A%08%20%82%0C0%C3%10A%04%14QE%18a%86%1Cq%C7%20%82%08%24%92I%28%A2%8A%2C%B2%CB0%C3%0C4%D3M8%E3%8E%3C%F3%CFA%04%10E%14QI%24%92M4%D3QE%14UUUYe%96%5Du%D7a%86%18e%96Yi%A6%9Am%B6%DBq%C7%1Cu%D7%5Dy%E7%9E%7D%F7%DF%82%08%20%86%18a%8A%28%A2%8E8%E3%92I%24%96Ye%9Ai%A6%9Ey%E7%A2%8A%28%A6%9Ai%AA%AA%AA%AE%BA%EB%B2%CB%2C%B6%DBm%BA%EB%AE%BE%FB%EF%C3%0C0%C7%1Cq%CB%2C%B2%CF%3C%F3%D3M4%D7%5Du%DBm%B6%DF%7D%F7%E3%8E8%E7%9Ey%EB%AE%BA%EF%BE%FB%F3%CF%3C%F7%DF%7D%FB%EF%BE%FF%FF%FF" - expect resp.http.b64all2urllc == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" + expect resp.http.b64all2urllc == resp.http.b64all2url + expect resp.http.b64allurl2url == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" expect resp.http.b64allurl2urluc == "%00%00%00%04%10A%08%20%82%0C0%C3%10A%04%14QE%18a%86%1Cq%C7%20%82%08%24%92I%28%A2%8A%2C%B2%CB0%C3%0C4%D3M8%E3%8E%3C%F3%CFA%04%10E%14QI%24%92M4%D3QE%14UUUYe%96%5Du%D7a%86%18e%96Yi%A6%9Am%B6%DBq%C7%1Cu%D7%5Dy%E7%9E%7D%F7%DF%82%08%20%86%18a%8A%28%A2%8E8%E3%92I%24%96Ye%9Ai%A6%9Ey%E7%A2%8A%28%A6%9Ai%AA%AA%AA%AE%BA%EB%B2%CB%2C%B6%DBm%BA%EB%AE%BE%FB%EF%C3%0C0%C7%1Cq%CB%2C%B2%CF%3C%F3%D3M4%D7%5Du%DBm%B6%DF%7D%F7%E3%8E8%E7%9Ey%EB%AE%BA%EF%BE%FB%F3%CF%3C%F7%DF%7D%FB%EF%BE%FF%FF%FF" - expect resp.http.b64allurl2urllc == "%00%00%00%04%10A%08%20%82%0c0%c3%10A%04%14QE%18a%86%1cq%c7%20%82%08%24%92I%28%a2%8a%2c%b2%cb0%c3%0c4%d3M8%e3%8e%3c%f3%cfA%04%10E%14QI%24%92M4%d3QE%14UUUYe%96%5du%d7a%86%18e%96Yi%a6%9am%b6%dbq%c7%1cu%d7%5dy%e7%9e%7d%f7%df%82%08%20%86%18a%8a%28%a2%8e8%e3%92I%24%96Ye%9ai%a6%9ey%e7%a2%8a%28%a6%9ai%aa%aa%aa%ae%ba%eb%b2%cb%2c%b6%dbm%ba%eb%ae%be%fb%ef%c3%0c0%c7%1cq%cb%2c%b2%cf%3c%f3%d3M4%d7%5du%dbm%b6%df%7d%f7%e3%8e8%e7%9ey%eb%ae%ba%ef%be%fb%f3%cf%3c%f7%df%7d%fb%ef%be%ff%ff%ff" + expect resp.http.b64allurl2urllc == resp.http.b64all2urllc + expect resp.http.hexlc2hex == "0123456789abcdef" expect resp.http.hexuc2hexuc == "0123456789ABCDEF" - expect resp.http.hexlc2hexlc == "0123456789abcdef" - expect resp.http.hexuc2hexlc == "0123456789abcdef" + expect resp.http.hexlc2hexlc == resp.http.hexlc2hex + expect resp.http.hexuc2hex == "0123456789abcdef" + expect resp.http.hexuc2hexlc == resp.http.hexuc2hex expect resp.http.hexlc2hexuc == "0123456789ABCDEF" + expect resp.http.hexmix2hex == "0123456789abcdef" expect resp.http.hexmix2hexuc == "0123456789ABCDEF" - expect resp.http.hexmix2hexlc == "0123456789abcdef" + expect resp.http.hexmix2hexlc == resp.http.hexmix2hex expect resp.http.hexparam == "0123456789ABCDEF" expect resp.http.b642b64 == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" expect resp.http.b64url2b64url == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" @@ -212,70 +289,84 @@ varnish v1 -vcl { set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id - = blob.transcode(URL, IDENTITY, req.http.urlhobbesuc); + = blob.transcode(URL, IDENTITY, encoded=req.http.urlhobbesuc); set resp.http.urllc2id - = blob.transcode(URL, IDENTITY, req.http.urlhobbeslc); + = blob.transcode(URL, IDENTITY, encoded=req.http.urlhobbeslc); set resp.http.urlalldownuc2b64 - = blob.transcode(URL, BASE64, req.http.urlalldownuc); + = blob.transcode(URL, BASE64, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64url - = blob.transcode(URL, BASE64URL, req.http.urlalldownuc); + = blob.transcode(URL, BASE64URL, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64nopad - = blob.transcode(URL, BASE64URLNOPAD, req.http.urlalldownuc); + = blob.transcode(URL, BASE64URLNOPAD, + encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2b64 - = blob.transcode(URL, BASE64, req.http.urlalldownlc); + = blob.transcode(URL, BASE64, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64url - = blob.transcode(URL, BASE64URL, req.http.urlalldownlc); + = blob.transcode(URL, BASE64URL, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64nopad - = blob.transcode(URL, BASE64URLNOPAD, req.http.urlalldownlc); + = blob.transcode(URL, BASE64URLNOPAD, + encoded=req.http.urlalldownlc); set resp.http.urlallupuc2b64 - = blob.transcode(URL, BASE64, req.http.urlallupuc); + = blob.transcode(URL, BASE64, encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64url - = blob.transcode(URL, BASE64URL, req.http.urlallupuc); + = blob.transcode(URL, BASE64URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64nopad - = blob.transcode(URL, BASE64URLNOPAD, req.http.urlallupuc); + = blob.transcode(URL, BASE64URLNOPAD, encoded=req.http.urlallupuc); set resp.http.urlalluplc2b64 - = blob.transcode(URL, BASE64, req.http.urlalluplc); + = blob.transcode(URL, BASE64, encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64url - = blob.transcode(URL, BASE64URL, req.http.urlalluplc); + = blob.transcode(URL, BASE64URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64nopad - = blob.transcode(URL, BASE64URLNOPAD, req.http.urlalluplc); + = blob.transcode(URL, BASE64URLNOPAD, encoded=req.http.urlalluplc); - set resp.http.urlalldownuc2urluc - = blob.transcode(URL, URLUC, req.http.urlalldownuc); + set resp.http.urlalldownuc2url + = blob.transcode(URL, URL, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urllc - = blob.transcode(URL, URLLC, req.http.urlalldownuc); + = blob.transcode(URL, URL, LOWER, req.http.urlalldownuc); - set resp.http.urlalldownlc2urluc - = blob.transcode(URL, URLUC, req.http.urlalldownlc); + set resp.http.urlalldownuc2urluc + = blob.transcode(URL, URL, UPPER, req.http.urlalldownuc); + + set resp.http.urlalldownlc2url + = blob.transcode(URL, URL, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urllc - = blob.transcode(URL, URLLC, req.http.urlalldownlc); + = blob.transcode(URL, URL, LOWER, req.http.urlalldownlc); + + set resp.http.urlalldownlc2urluc + = blob.transcode(URL, URL, UPPER, req.http.urlalldownlc); + + set resp.http.urlallupuc2url + = blob.transcode(URL, URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urluc - = blob.transcode(URL, URLUC, req.http.urlallupuc); + = blob.transcode(URL, URL, UPPER, req.http.urlallupuc); set resp.http.urlallupuc2urllc - = blob.transcode(URL, URLLC, req.http.urlallupuc); + = blob.transcode(URL, URL, LOWER, req.http.urlallupuc); + + set resp.http.urlalluplc2url + = blob.transcode(URL, URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urluc - = blob.transcode(URL, URLUC, req.http.urlalluplc); + = blob.transcode(URL, URL, UPPER, req.http.urlalluplc); set resp.http.urlalluplc2urllc - = blob.transcode(URL, URLLC, req.http.urlalluplc); + = blob.transcode(URL, URL, LOWER, req.http.urlalluplc); } } @@ -297,14 +388,18 @@ client c1 { expect resp.http.urlalluplc2b64 == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" expect resp.http.urlalluplc2b64url == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w==" expect resp.http.urlalluplc2b64nopad == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w" + expect resp.http.urlalldownuc2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" expect resp.http.urlalldownuc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" - expect resp.http.urlalldownuc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" + expect resp.http.urlalldownuc2urllc == resp.http.urlalldownuc2url + expect resp.http.urlalldownlc2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" expect resp.http.urlalldownlc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba%60_%5E%5D%5C%5BZYXWVUTSRQPONMLKJIHGFEDCBA%40%3F%3E%3D%3C%3B%3A9876543210%2F.-%2C%2B%2A%29%28%27%26%25%24%23%22%21%20%1F%1E%1D%1C%1B%1A%19%18%17%16%15%14%13%12%11%10%0F%0E%0D%0C%0B%0A%09%08%07%06%05%04%03%02%01%00" - expect resp.http.urlalldownlc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00" + expect resp.http.urlalldownlc2urllc == resp.http.urlalldownlc2url expect resp.http.urlallupuc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" expect resp.http.urlalluplc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF" - expect resp.http.urlallupuc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" - expect resp.http.urlalluplc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.urlallupuc2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.urlallupuc2urllc == resp.http.urlallupuc2url + expect resp.http.urlalluplc2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff" + expect resp.http.urlalluplc2urllc == resp.http.urlalluplc2url } -run # Decode failures @@ -321,53 +416,53 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/1") { set resp.http.bad - = blob.transcode(HEX, IDENTITY, "0x123456"); + = blob.transcode(HEX, IDENTITY, encoded="0x123456"); } elsif (req.url == "/2") { set resp.http.bad = blob.transcode(BASE64, IDENTITY, - "-_-_" + req.http.foo); + encoded="-_-_" + req.http.foo); } elsif (req.url == "/3") { set resp.http.bad = blob.transcode(BASE64URL, IDENTITY, - "+/+/" + req.http.foo); + encoded="+/+/" + req.http.foo); } elsif (req.url == "/4") { set resp.http.bad = blob.transcode(BASE64URLNOPAD, IDENTITY, - "TWFu" + req.http.foo); + encoded="TWFu" + req.http.foo); } elsif (req.url == "/5") { set resp.http.bad = blob.transcode(BASE64, BASE64, - "_-_-" + req.http.foo); + encoded="_-_-" + req.http.foo); } elsif (req.url == "/6") { set resp.http.bad = blob.transcode(BASE64URL, BASE64URL, - "/+/+" + req.http.foo); + encoded="/+/+" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad = blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, - "Zm9v" + req.http.foo); + encoded="Zm9v" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad - = blob.transcode(URL, IDENTITY, "%"); + = blob.transcode(URL, IDENTITY, encoded="%"); } elsif (req.url == "/9") { set resp.http.bad - = blob.transcode(URL, IDENTITY, "%2"); + = blob.transcode(URL, IDENTITY, encoded="%2"); } elsif (req.url == "/10") { set resp.http.bad - = blob.transcode(URL, IDENTITY, "%q"); + = blob.transcode(URL, IDENTITY, encoded="%q"); } elsif (req.url == "/11") { set resp.http.bad - = blob.transcode(URL, IDENTITY, "%2q"); + = blob.transcode(URL, IDENTITY, encoded="%2q"); } } } diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index 37ed285..4a96c0f 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -20,109 +20,187 @@ varnish v1 -vcl { {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set req.http.hexallup = {"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"}; - set req.http.b64all = -{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; - set req.http.b64allurl = -{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; set resp.http.id2id - = blob.transcode_n(5, IDENTITY, IDENTITY, "Hello world"); + = blob.transcode_n(5, IDENTITY, IDENTITY, encoded="Hello world"); set resp.http.id2b64 - = blob.transcode_n(5, IDENTITY, BASE64, req.http.hobbes); + = blob.transcode_n(5, IDENTITY, BASE64, encoded=req.http.hobbes); set resp.http.id2b64nopad - = blob.transcode_n(5, IDENTITY, BASE64URLNOPAD, req.http.hobbes); + = blob.transcode_n(5, IDENTITY, BASE64URLNOPAD, + encoded=req.http.hobbes); + + set resp.http.id2hex + = blob.transcode_n(5, IDENTITY, HEX, encoded=req.http.hobbes); set resp.http.id2hexuc - = blob.transcode_n(5, IDENTITY, HEXUC, req.http.hobbes); + = blob.transcode_n(5, IDENTITY, HEX, UPPER, req.http.hobbes); set resp.http.id2hexlc - = blob.transcode_n(5, IDENTITY, HEXLC, req.http.hobbes); + = blob.transcode_n(5, IDENTITY, HEX, LOWER, req.http.hobbes); + + set resp.http.id2url + = blob.transcode_n(5, IDENTITY, URL, encoded=req.http.foobar); set resp.http.id2urluc - = blob.transcode_n(5, IDENTITY, URLUC, req.http.foobar); + = blob.transcode_n(5, IDENTITY, URL, UPPER, req.http.foobar); set resp.http.id2urllc - = blob.transcode_n(5, IDENTITY, URLLC, req.http.foobar); + = blob.transcode_n(5, IDENTITY, URL, LOWER, req.http.foobar); set resp.http.b642id - = blob.transcode_n(8, BASE64, IDENTITY, req.http.hobbesb64); + = blob.transcode_n(8, BASE64, IDENTITY, encoded=req.http.hobbesb64); set resp.http.hex2id - = blob.transcode_n(12, HEX, IDENTITY, req.http.hexhobbes); + = blob.transcode_n(12, HEX, IDENTITY, encoded=req.http.hexhobbes); set resp.http.hexalldown2b64 - = blob.transcode_n(12, HEX, BASE64, req.http.hexalldown); + = blob.transcode_n(12, HEX, BASE64, encoded=req.http.hexalldown); set resp.http.hexalldown2b64url - = blob.transcode_n(12, HEX, BASE64URL, req.http.hexalldown); + = blob.transcode_n(12, HEX, BASE64URL, encoded=req.http.hexalldown); set resp.http.hexalldown2b64nopad - = blob.transcode_n(10, HEX, BASE64URLNOPAD, req.http.hexalldown); + = blob.transcode_n(10, HEX, BASE64URLNOPAD, + encoded=req.http.hexalldown); set resp.http.hexallup2b64 - = blob.transcode_n(12, HEX, BASE64, req.http.hexallup); + = blob.transcode_n(12, HEX, BASE64, encoded=req.http.hexallup); set resp.http.hexallup2b64url - = blob.transcode_n(10, HEX, BASE64URL, req.http.hexallup); + = blob.transcode_n(10, HEX, BASE64URL, encoded=req.http.hexallup); set resp.http.hexallup2b64nopad - = blob.transcode_n(10, HEX, BASE64URLNOPAD, req.http.hexallup); + = blob.transcode_n(10, HEX, BASE64URLNOPAD, + encoded=req.http.hexallup); + + set resp.http.hexalldown2url + = blob.transcode_n(12, HEX, URL, encoded=req.http.hexalldown); set resp.http.hexalldown2urluc - = blob.transcode_n(12, HEX, URLUC, req.http.hexalldown); + = blob.transcode_n(12, HEX, URL, UPPER, req.http.hexalldown); set resp.http.hexalldown2urllc - = blob.transcode_n(12, HEX, URLLC, req.http.hexalldown); + = blob.transcode_n(12, HEX, URL, LOWER, req.http.hexalldown); + + set resp.http.hexallup2url + = blob.transcode_n(12, HEX, URL, encoded=req.http.hexallup); set resp.http.hexallup2urluc - = blob.transcode_n(12, HEX, URLUC, req.http.hexallup); + = blob.transcode_n(12, HEX, URL, UPPER, req.http.hexallup); set resp.http.hexallup2urllc - = blob.transcode_n(12, HEX, URLLC, req.http.hexallup); + = blob.transcode_n(12, HEX, URL, LOWER, req.http.hexallup); + + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.id2id == "Hello" + expect resp.http.id2b64 == "TWFuIGk=" + expect resp.http.id2b64nopad == "TWFuIGk" + expect resp.http.id2hex == "4d616e2069" + expect resp.http.id2hexuc == "4D616E2069" + expect resp.http.id2hexlc == resp.http.id2hex + expect resp.http.id2url == "foo%3ab" + expect resp.http.id2urluc == "foo%3Ab" + expect resp.http.id2urllc == resp.http.id2url + expect resp.http.b642id == "Man is" + expect resp.http.hex2id == "Man is" + expect resp.http.hexalldown2b64 == "//79/Pv6" + expect resp.http.hexalldown2b64url == "__79_Pv6" + expect resp.http.hexalldown2b64nopad == "__79_Ps" + expect resp.http.hexallup2b64 == "AAECAwQF" + expect resp.http.hexallup2b64url == "AAECAwQ=" + expect resp.http.hexallup2b64nopad == "AAECAwQ" + expect resp.http.hexalldown2url == "%ff%fe%fd%fc%fb%fa" + expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA" + expect resp.http.hexalldown2urllc == resp.http.hexalldown2url + expect resp.http.hexallup2url == "%00%01%02%03%04%05" + expect resp.http.hexallup2urllc == resp.http.hexallup2url + expect resp.http.hexallup2urllc == resp.http.hexallup2url +} -run + +varnish v1 -vcl { + import blob; + import std; + backend b { .host = "${bad_ip}"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set req.http.b64all = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999++++////"}; + set req.http.b64allurl = +{"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; + + set resp.http.b64all2hex + = blob.transcode_n(8, BASE64, HEX, encoded=req.http.b64all); set resp.http.b64all2hexuc - = blob.transcode_n(8, BASE64, HEXUC, req.http.b64all); + = blob.transcode_n(8, BASE64, HEX, UPPER, req.http.b64all); set resp.http.b64all2hexlc - = blob.transcode_n(8, BASE64, HEXLC, req.http.b64all); + = blob.transcode_n(8, BASE64, HEX, LOWER, req.http.b64all); + + set resp.http.b64allurl2hex + = blob.transcode_n(8, BASE64URL, HEX, encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc - = blob.transcode_n(8, BASE64URL, HEXUC, req.http.b64allurl); + = blob.transcode_n(8, BASE64URL, HEX, UPPER, req.http.b64allurl); set resp.http.b64allurl2hexlc - = blob.transcode_n(8, BASE64URL, HEXLC, req.http.b64allurl); + = blob.transcode_n(8, BASE64URL, HEX, LOWER, req.http.b64allurl); + + set resp.http.b64all2url + = blob.transcode_n(8, BASE64, URL, encoded=req.http.b64all); set resp.http.b64all2urluc - = blob.transcode_n(8, BASE64, URLUC, req.http.b64all); + = blob.transcode_n(8, BASE64, URL, UPPER, req.http.b64all); set resp.http.b64all2urllc - = blob.transcode_n(8, BASE64, URLLC, req.http.b64all); + = blob.transcode_n(8, BASE64, URL, LOWER, req.http.b64all); + + set resp.http.b64allurl2url + = blob.transcode_n(8, BASE64URL, URL, encoded=req.http.b64allurl); set resp.http.b64allurl2urluc - = blob.transcode_n(8, BASE64URL, URLUC, req.http.b64allurl); + = blob.transcode_n(8, BASE64URL, URL, UPPER, req.http.b64allurl); set resp.http.b64allurl2urllc - = blob.transcode_n(8, BASE64URL, URLLC, req.http.b64allurl); + = blob.transcode_n(8, BASE64URL, URL, LOWER, req.http.b64allurl); + + set resp.http.hexuc2hex + = blob.transcode_n(10, HEX, HEX, encoded="0123456789ABCDEF"); set resp.http.hexuc2hexuc - = blob.transcode_n(10, HEX, HEXUC, "0123456789ABCDEF"); + = blob.transcode_n(10, HEX, HEX, UPPER, "0123456789ABCDEF"); + + set resp.http.hexlc2hex + = blob.transcode_n(10, HEX, HEX, encoded="0123456789abcdef"); set resp.http.hexlc2hexlc - = blob.transcode_n(10, HEX, HEXLC, "0123456789abcdef"); + = blob.transcode_n(10, HEX, HEX, LOWER, "0123456789abcdef"); set resp.http.hexuc2hexlc - = blob.transcode_n(9, HEX, HEXLC, "0123456789ABCDEF"); + = blob.transcode_n(9, HEX, HEX, LOWER, "0123456789ABCDEF"); set resp.http.hexlc2hexuc - = blob.transcode_n(9, HEX, HEXUC, "0123456789abcdef"); + = blob.transcode_n(9, HEX, HEX, UPPER, "0123456789abcdef"); + + set resp.http.hexmix2hex + = blob.transcode_n(13, HEX, HEX, encoded="0123456789abcDEF"); set resp.http.hexmix2hexuc - = blob.transcode_n(15, HEX, HEXUC, "0123456789ABCdef"); + = blob.transcode_n(15, HEX, HEX, UPPER, "0123456789ABCdef"); set resp.http.hexmix2hexlc - = blob.transcode_n(13, HEX, HEXLC, "0123456789abcDEF"); + = blob.transcode_n(13, HEX, HEX, LOWER, "0123456789abcDEF"); set req.http.hexpart1 = "01234567"; set req.http.hexpart2 = "89abcdef"; @@ -131,62 +209,49 @@ varnish v1 -vcl { + req.http.unset + "" + req.http.hexpart1 + "" + req.http.unset + "" + req.http.unset + req.http.hexpart2, decoding=HEX, - encoding=HEXUC, n=10); + encoding=HEX, n=10, case=UPPER); set resp.http.b642b64 - = blob.transcode_n(36, BASE64, BASE64, + = blob.transcode_n(36, BASE64, BASE64, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789+/"); set resp.http.b64url2b64url = - blob.transcode_n(34, BASE64URL, BASE64URL, + blob.transcode_n(34, BASE64URL, BASE64URL, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); set resp.http.b64urlnopad2b64urlnopad = - blob.transcode_n(34, BASE64URLNOPAD, BASE64URLNOPAD, + blob.transcode_n(34, BASE64URLNOPAD, BASE64URLNOPAD, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); } -} -start +} client c1 { txreq rxresp - expect resp.http.id2id == "Hello" - expect resp.http.id2b64 == "TWFuIGk=" - expect resp.http.id2b64nopad == "TWFuIGk" - expect resp.http.id2hexuc == "4D616E2069" - expect resp.http.id2hexlc == "4d616e2069" - expect resp.http.id2urluc == "foo%3Ab" - expect resp.http.id2urllc == "foo%3ab" - expect resp.http.b642id == "Man is" - expect resp.http.hex2id == "Man is" - expect resp.http.hexalldown2b64 == "//79/Pv6" - expect resp.http.hexalldown2b64url == "__79_Pv6" - expect resp.http.hexalldown2b64nopad == "__79_Ps" - expect resp.http.hexallup2b64 == "AAECAwQF" - expect resp.http.hexallup2b64url == "AAECAwQ=" - expect resp.http.hexallup2b64nopad == "AAECAwQ" - expect resp.http.hexalldown2urluc == "%FF%FE%FD%FC%FB%FA" - expect resp.http.hexalldown2urllc == "%ff%fe%fd%fc%fb%fa" - expect resp.http.hexallup2urluc == "%00%01%02%03%04%05" - expect resp.http.hexallup2urllc == "%00%01%02%03%04%05" - expect resp.http.b64all2hexuc == "000000041041" - expect resp.http.b64all2hexlc == "000000041041" - expect resp.http.b64allurl2hexuc == "000000041041" - expect resp.http.b64allurl2hexlc == "000000041041" - expect resp.http.b64all2urluc == "%00%00%00%04%10A" - expect resp.http.b64all2urllc == "%00%00%00%04%10A" - expect resp.http.b64allurl2urluc == "%00%00%00%04%10A" - expect resp.http.b64allurl2urllc == "%00%00%00%04%10A" - expect resp.http.hexuc2hexuc == "0123456789" - expect resp.http.hexlc2hexlc == "0123456789" + expect resp.http.b64all2hex == "000000041041" + expect resp.http.b64all2hexuc == resp.http.b64all2hex + expect resp.http.b64all2hexlc == resp.http.b64all2hex + expect resp.http.b64allurl2hex == "000000041041" + expect resp.http.b64allurl2hexuc == resp.http.b64allurl2hex + expect resp.http.b64allurl2hexlc == resp.http.b64allurl2hex + expect resp.http.b64all2url == "%00%00%00%04%10A" + expect resp.http.b64all2urluc == resp.http.b64all2url + expect resp.http.b64all2urllc == resp.http.b64all2url + expect resp.http.b64allurl2url == "%00%00%00%04%10A" + expect resp.http.b64allurl2urluc == resp.http.b64allurl2url + expect resp.http.b64allurl2urllc == resp.http.b64allurl2url + expect resp.http.hexuc2hex == "0123456789" + expect resp.http.hexlc2hex == resp.http.hexuc2hex + expect resp.http.hexlc2hexlc == resp.http.hexuc2hex expect resp.http.hexuc2hexlc == "0012345678" - expect resp.http.hexlc2hexuc == "0012345678" + expect resp.http.hexlc2hexuc == resp.http.hexuc2hexlc + expect resp.http.hexmix2hex == "00123456789abc" expect resp.http.hexmix2hexuc == "00123456789ABCDE" - expect resp.http.hexmix2hexlc == "00123456789abc" + expect resp.http.hexmix2hexlc == resp.http.hexmix2hex expect resp.http.hexparam == "0123456789" expect resp.http.b642b64 == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij" expect resp.http.b64url2b64url == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefeQ==" @@ -211,74 +276,88 @@ varnish v1 -vcl { set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id - = blob.transcode_n(27, URL, IDENTITY, req.http.urlhobbesuc); + = blob.transcode_n(27, URL, IDENTITY, encoded=req.http.urlhobbesuc); set resp.http.urllc2id - = blob.transcode_n(63, URL, IDENTITY, req.http.urlhobbeslc); + = blob.transcode_n(63, URL, IDENTITY, encoded=req.http.urlhobbeslc); set resp.http.urlalldownuc2b64 - = blob.transcode_n(18, URL, BASE64, req.http.urlalldownuc); + = blob.transcode_n(18, URL, BASE64, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64url - = blob.transcode_n(15, URL, BASE64URL, req.http.urlalldownuc); + = blob.transcode_n(15, URL, BASE64URL, + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64nopad = blob.transcode_n(15, URL, BASE64URLNOPAD, - req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2b64 - = blob.transcode_n(18, URL, BASE64, req.http.urlalldownlc); + = blob.transcode_n(18, URL, BASE64, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64url - = blob.transcode_n(15, URL, BASE64URL, req.http.urlalldownlc); + = blob.transcode_n(15, URL, BASE64URL, + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64nopad = blob.transcode_n(15, URL, BASE64URLNOPAD, - req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlallupuc2b64 - = blob.transcode_n(36, URL, BASE64, req.http.urlallupuc); + = blob.transcode_n(36, URL, BASE64, encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64url - = blob.transcode_n(33, URL, BASE64URL, req.http.urlallupuc); + = blob.transcode_n(33, URL, BASE64URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64nopad = blob.transcode_n(33, URL, BASE64URLNOPAD, - req.http.urlallupuc); + encoded=req.http.urlallupuc); set resp.http.urlalluplc2b64 - = blob.transcode_n(36, URL, BASE64, req.http.urlalluplc); + = blob.transcode_n(36, URL, BASE64, encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64url - = blob.transcode_n(33, URL, BASE64URL, req.http.urlalluplc); + = blob.transcode_n(33, URL, BASE64URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64nopad = blob.transcode_n(33, URL, BASE64URLNOPAD, - req.http.urlalluplc); + encoded=req.http.urlalluplc); + + set resp.http.urlalldownuc2url + = blob.transcode_n(423, URL, URL, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urluc - = blob.transcode_n(423, URL, URLUC, req.http.urlalldownuc); + = blob.transcode_n(423, URL, URL, UPPER, req.http.urlalldownuc); set resp.http.urlalldownuc2urllc - = blob.transcode_n(423, URL, URLLC, req.http.urlalldownuc); + = blob.transcode_n(423, URL, URL, LOWER, req.http.urlalldownuc); + + set resp.http.urlalldownlc2url + = blob.transcode_n(423, URL, URL, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urluc - = blob.transcode_n(423, URL, URLUC, req.http.urlalldownlc); + = blob.transcode_n(423, URL, URL, UPPER, req.http.urlalldownlc); set resp.http.urlalldownlc2urllc - = blob.transcode_n(423, URL, URLLC, req.http.urlalldownlc); + = blob.transcode_n(423, URL, URL, LOWER, req.http.urlalldownlc); + + set resp.http.urlallupuc2url + = blob.transcode_n(197, URL, URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urluc - = blob.transcode_n(197, URL, URLUC, req.http.urlallupuc); + = blob.transcode_n(197, URL, URL, UPPER, req.http.urlallupuc); set resp.http.urlallupuc2urllc - = blob.transcode_n(197, URL, URLLC, req.http.urlallupuc); + = blob.transcode_n(197, URL, URL, LOWER, req.http.urlallupuc); + + set resp.http.urlalluplc2url + = blob.transcode_n(197, URL, URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urluc - = blob.transcode_n(197, URL, URLUC, req.http.urlalluplc); + = blob.transcode_n(197, URL, URL, UPPER, req.http.urlalluplc); set resp.http.urlalluplc2urllc - = blob.transcode_n(197, URL, URLLC, req.http.urlalluplc); + = blob.transcode_n(197, URL, URL, LOWER, req.http.urlalluplc); } } @@ -300,14 +379,18 @@ client c1 { expect resp.http.urlalluplc2b64 == "AAECAwQFBgcICQoL" expect resp.http.urlalluplc2b64url == "AAECAwQFBgcICQo=" expect resp.http.urlalluplc2b64nopad == "AAECAwQFBgcICQo" + expect resp.http.urlalldownuc2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" expect resp.http.urlalldownuc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba" - expect resp.http.urlalldownuc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" + expect resp.http.urlalldownuc2urllc == resp.http.urlalldownuc2url + expect resp.http.urlalldownlc2url == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" expect resp.http.urlalldownlc2urluc == "%FF%FE%FD%FC%FB%FA%F9%F8%F7%F6%F5%F4%F3%F2%F1%F0%EF%EE%ED%EC%EB%EA%E9%E8%E7%E6%E5%E4%E3%E2%E1%E0%DF%DE%DD%DC%DB%DA%D9%D8%D7%D6%D5%D4%D3%D2%D1%D0%CF%CE%CD%CC%CB%CA%C9%C8%C7%C6%C5%C4%C3%C2%C1%C0%BF%BE%BD%BC%BB%BA%B9%B8%B7%B6%B5%B4%B3%B2%B1%B0%AF%AE%AD%AC%AB%AA%A9%A8%A7%A6%A5%A4%A3%A2%A1%A0%9F%9E%9D%9C%9B%9A%99%98%97%96%95%94%93%92%91%90%8F%8E%8D%8C%8B%8A%89%88%87%86%85%84%83%82%81%80%7F~%7D%7C%7Bzyxwvutsrqponmlkjihgfedcba" - expect resp.http.urlalldownlc2urllc == "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba" + expect resp.http.urlalldownlc2urllc == resp.http.urlalldownlc2url + expect resp.http.urlallupuc2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" + expect resp.http.urlalluplc2url == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" expect resp.http.urlallupuc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" expect resp.http.urlalluplc2urluc == "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" - expect resp.http.urlallupuc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" - expect resp.http.urlalluplc2urllc == "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" + expect resp.http.urlallupuc2urllc == resp.http.urlallupuc2url + expect resp.http.urlalluplc2urllc == resp.http.urlalluplc2url } -run # Decode failures @@ -324,55 +407,57 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/1") { set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, "%2c%q"); + = blob.transcode_n(3, URL, IDENTITY, + encoded="%2c%q"); } elsif (req.url == "/2") { set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, "%3a%2q"); + = blob.transcode_n(3, URL, IDENTITY, + encoded="%3a%2q"); } elsif (req.url == "/3") { set resp.http.bad = blob.transcode_n(8, HEX, IDENTITY, - "0x123456"); + encoded="0x123456"); } elsif (req.url == "/4") { set resp.http.bad = blob.transcode_n(4, BASE64, IDENTITY, - "-_-_" + req.http.foo); + encoded="-_-_" + req.http.foo); } elsif (req.url == "/5") { set resp.http.bad = blob.transcode_n(4, BASE64URL, IDENTITY, - "+/+/" + req.http.foo); + encoded="+/+/" + req.http.foo); } elsif (req.url == "/6") { set resp.http.bad = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, - "TWFu" + req.http.foo); + encoded="TWFu" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad = blob.transcode_n(4, BASE64, BASE64, - "_-_-" + req.http.foo); + encoded="_-_-" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad = blob.transcode_n(4, BASE64URL, BASE64URL, - "/+/+" + req.http.foo); + encoded="/+/+" + req.http.foo); } elsif (req.url == "/9") { set resp.http.bad = blob.transcode_n(8, BASE64URLNOPAD, - BASE64URLNOPAD, - "Zm9v" + req.http.foo); + BASE64URLNOPAD, + encoded="Zm9v" + req.http.foo); } elsif (req.url == "/10") { set resp.http.bad - = blob.transcode_n(1, URL, IDENTITY, "%20"); + = blob.transcode_n(1, URL, IDENTITY, encoded="%20"); } elsif (req.url == "/11") { set resp.http.bad - = blob.transcode_n(2, URL, IDENTITY, "%20"); + = blob.transcode_n(2, URL, IDENTITY, encoded="%20"); } } } diff --git a/bin/varnishtest/tests/m00043.vtc b/bin/varnishtest/tests/m00043.vtc index 7c3408a..7521255 100644 --- a/bin/varnishtest/tests/m00043.vtc +++ b/bin/varnishtest/tests/m00043.vtc @@ -33,50 +33,32 @@ varnish v1 -arg "-i serverid" -vcl+backend { } sub vcl_synth { - set resp.http.id = blob.encode(IDENTITY, id.get()); - set resp.http.idpieces = blob.encode(IDENTITY, idpieces.get()); - set resp.http.idparam = blob.encode(IDENTITY, idparam.get()); - set resp.http.idempty = blob.encode(IDENTITY, idempty.get()); - set resp.http.hexuc = blob.encode(IDENTITY, hexuc.get()); - set resp.http.hexlc = blob.encode(IDENTITY, hexlc.get()); - set resp.http.hexmix = blob.encode(IDENTITY, hexmix.get()); - set resp.http.b64 = blob.encode(IDENTITY, b64.get()); - set resp.http.b64nopad = blob.encode(IDENTITY, b64nopad.get()); + set resp.http.id = blob.encode(IDENTITY, blob=id.get()); + set resp.http.idpieces = blob.encode(IDENTITY, blob=idpieces.get()); + set resp.http.idparam = blob.encode(IDENTITY, blob=idparam.get()); + set resp.http.idempty = blob.encode(IDENTITY, blob=idempty.get()); + set resp.http.hexuc = blob.encode(IDENTITY, blob=hexuc.get()); + set resp.http.hexlc = blob.encode(IDENTITY, blob=hexlc.get()); + set resp.http.hexmix = blob.encode(IDENTITY, blob=hexmix.get()); + set resp.http.b64 = blob.encode(IDENTITY, blob=b64.get()); + set resp.http.b64nopad = blob.encode(IDENTITY, blob=b64nopad.get()); set resp.http.allhex2b64func = blob.encode(BASE64, - hexall.get()); - set resp.http.allb642hexlcfunc = blob.encode(HEXLC, - b64all.get()); + blob=hexall.get()); + set resp.http.allb642hexlcfunc = blob.encode(HEX, + blob=b64all.get()); set resp.http.allhex2b64meth = hexall.encode(BASE64); - set resp.http.allb642hexlcmeth = b64all.encode(HEXLC); + set resp.http.allb642hexmeth = b64all.encode(HEX); + set resp.http.allb642hexlcmeth = b64all.encode(HEX, LOWER); set resp.http.id2id = id.encode(IDENTITY); set resp.http.id2b64 = id.encode(BASE64); set resp.http.id2b64url = id.encode(BASE64URL); set resp.http.id2b64urlnopad = id.encode(BASE64URLNOPAD); - set resp.http.id2hexuc = id.encode(HEXUC); - set resp.http.id2hexlc = id.encode(HEXLC); + set resp.http.id2hex = id.encode(HEX); + set resp.http.id2hexuc = id.encode(HEX, UPPER); + set resp.http.id2hexlc = id.encode(HEX, LOWER); - set resp.http.emptyid = idempty.encode(IDENTITY); - set resp.http.emptyb64 = idempty.encode(BASE64); - set resp.http.emptyb64url = idempty.encode(BASE64URL); - set resp.http.emptyb64urlnopad = idempty.encode(BASE64URLNOPAD); - set resp.http.emptyhexuc = idempty.encode(HEXUC); - set resp.http.emptyhexlc = idempty.encode(HEXLC); - - set resp.http.hexuc2id = hexuc.encode(IDENTITY); - set resp.http.hexuc2b64 = hexuc.encode(BASE64); - set resp.http.hexuc2b64url = hexuc.encode(BASE64URL); - set resp.http.hexuc2b64nopad = hexuc.encode(BASE64URLNOPAD); - set resp.http.hexuc2hexuc = hexuc.encode(HEXUC); - set resp.http.hexuc2hexlc = hexuc.encode(HEXLC); - - set resp.http.hexlc2id = hexlc.encode(IDENTITY); - set resp.http.hexlc2b64 = hexlc.encode(BASE64); - set resp.http.hexlc2b64url = hexlc.encode(BASE64URL); - set resp.http.hexlc2b64nopad = hexlc.encode(BASE64URLNOPAD); - set resp.http.hexlc2hexuc = hexlc.encode(HEXUC); - set resp.http.hexlc2hexlc = hexlc.encode(HEXLC); } } -start @@ -96,35 +78,88 @@ client c1 { expect resp.http.allhex2b64func == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" expect resp.http.allb642hexlcfunc == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" expect resp.http.allhex2b64meth == "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" - expect resp.http.allb642hexlcmeth == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + expect resp.http.allb642hexmeth == "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + expect resp.http.allb642hexlcmeth == resp.http.allb642hexmeth expect resp.http.id2id == "The quick brown fox jumps over the lazy dog" expect resp.http.id2b64 == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" expect resp.http.id2b64url == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" expect resp.http.id2b64urlnopad == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" + expect resp.http.id2hex == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" expect resp.http.id2hexuc == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67" - expect resp.http.id2hexlc == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67" + expect resp.http.id2hexlc == resp.http.id2hex +} -run + +# run twice to test retrieving cached encodings +client c1 -run + +varnish v1 -vcl+backend { + import blob; + sub vcl_init { + new idempty = blob.blob(IDENTITY, ""); + + new hexuc = blob.blob(HEX, "666F6F206261722062617A2071757578"); + new hexlc = blob.blob(HEX, "666f6f206261722062617a2071757578"); + } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.emptyid = idempty.encode(IDENTITY); + set resp.http.emptyb64 = idempty.encode(BASE64); + set resp.http.emptyb64url = idempty.encode(BASE64URL); + set resp.http.emptyb64urlnopad = idempty.encode(BASE64URLNOPAD); + set resp.http.emptyhex = idempty.encode(HEX); + set resp.http.emptyhexuc = idempty.encode(HEX, UPPER); + set resp.http.emptyhexlc = idempty.encode(HEX, LOWER); + + set resp.http.hexuc2id = hexuc.encode(IDENTITY); + set resp.http.hexuc2b64 = hexuc.encode(BASE64); + set resp.http.hexuc2b64url = hexuc.encode(BASE64URL); + set resp.http.hexuc2b64nopad = hexuc.encode(BASE64URLNOPAD); + set resp.http.hexuc2hex = hexuc.encode(HEX); + set resp.http.hexuc2hexuc = hexuc.encode(HEX, UPPER); + set resp.http.hexuc2hexlc = hexuc.encode(HEX, LOWER); + + set resp.http.hexlc2id = hexlc.encode(IDENTITY); + set resp.http.hexlc2b64 = hexlc.encode(BASE64); + set resp.http.hexlc2b64url = hexlc.encode(BASE64URL); + set resp.http.hexlc2b64nopad = hexlc.encode(BASE64URLNOPAD); + set resp.http.hexlc2hex = hexlc.encode(HEX); + set resp.http.hexlc2hexuc = hexlc.encode(HEX, UPPER); + set resp.http.hexlc2hexlc = hexlc.encode(HEX, LOWER); + } +} + +client c1 { + txreq + rxresp expect resp.http.emptyid == "" expect resp.http.emptyb64 == "" expect resp.http.emptyb64url == "" expect resp.http.emptyb64urlnopad == "" + expect resp.http.emptyhex == "" expect resp.http.emptyhexuc == "" - expect resp.http.emptyhexlc == "" + expect resp.http.emptyhexlc == resp.http.emptyhex expect resp.http.hexuc2id == "foo bar baz quux" expect resp.http.hexuc2b64 == "Zm9vIGJhciBiYXogcXV1eA==" expect resp.http.hexuc2b64url == "Zm9vIGJhciBiYXogcXV1eA==" expect resp.http.hexuc2b64nopad == "Zm9vIGJhciBiYXogcXV1eA" + expect resp.http.hexuc2hex == "666f6f206261722062617a2071757578" expect resp.http.hexuc2hexuc == "666F6F206261722062617A2071757578" - expect resp.http.hexuc2hexlc == "666f6f206261722062617a2071757578" + expect resp.http.hexuc2hexlc == resp.http.hexuc2hex expect resp.http.hexlc2id == "foo bar baz quux" expect resp.http.hexlc2b64 == "Zm9vIGJhciBiYXogcXV1eA==" expect resp.http.hexlc2b64url == "Zm9vIGJhciBiYXogcXV1eA==" expect resp.http.hexlc2b64nopad == "Zm9vIGJhciBiYXogcXV1eA" + expect resp.http.hexlc2hex == "666f6f206261722062617a2071757578" expect resp.http.hexlc2hexuc == "666F6F206261722062617A2071757578" - expect resp.http.hexlc2hexlc == "666f6f206261722062617a2071757578" + expect resp.http.hexlc2hexlc == resp.http.hexlc2hex } -run # run twice to test retrieving cached encodings @@ -148,28 +183,34 @@ varnish v1 -vcl+backend { set resp.http.b642b64 = b64.encode(BASE64); set resp.http.b642b64url = b64.encode(BASE64URL); set resp.http.b642b64nopad = b64.encode(BASE64URLNOPAD); - set resp.http.b642hexuc = b64.encode(HEXUC); - set resp.http.b642hexlc = b64.encode(HEXLC); - set resp.http.b642urluc = b64.encode(URLUC); - set resp.http.b642urllc = b64.encode(URLLC); + set resp.http.b642hex = b64.encode(HEX); + set resp.http.b642hexuc = b64.encode(HEX, UPPER); + set resp.http.b642hexlc = b64.encode(HEX, LOWER); + set resp.http.b642url = b64.encode(URL); + set resp.http.b642urluc = b64.encode(URL, UPPER); + set resp.http.b642urllc = b64.encode(URL, LOWER); set resp.http.b64url2id = b64url.encode(IDENTITY); set resp.http.b64url2b64 = b64url.encode(BASE64); set resp.http.b64url2b64url = b64url.encode(BASE64URL); set resp.http.b64url2b64nopad = b64url.encode(BASE64URLNOPAD); - set resp.http.b64url2hexuc = b64url.encode(HEXUC); - set resp.http.b64url2hexlc = b64url.encode(HEXLC); - set resp.http.b64url2urluc = b64url.encode(URLUC); - set resp.http.b64url2urllc = b64url.encode(URLLC); + set resp.http.b64url2hex = b64url.encode(HEX); + set resp.http.b64url2hexuc = b64url.encode(HEX, UPPER); + set resp.http.b64url2hexlc = b64url.encode(HEX, LOWER); + set resp.http.b64url2url = b64url.encode(URL); + set resp.http.b64url2urluc = b64url.encode(URL, UPPER); + set resp.http.b64url2urllc = b64url.encode(URL, LOWER); set resp.http.b64nopad2id = b64nopad.encode(IDENTITY); set resp.http.b64nopad2b64 = b64nopad.encode(BASE64); set resp.http.b64nopad2b64url = b64nopad.encode(BASE64URL); set resp.http.b64nopad2b64nopad = b64nopad.encode(BASE64URLNOPAD); - set resp.http.b64nopad2hexuc = b64nopad.encode(HEXUC); - set resp.http.b64nopad2hexlc = b64nopad.encode(HEXLC); - set resp.http.b64nopad2urluc = b64nopad.encode(URLUC); - set resp.http.b64nopad2urllc = b64nopad.encode(URLLC); + set resp.http.b64nopad2hex = b64nopad.encode(HEX); + set resp.http.b64nopad2hexuc = b64nopad.encode(HEX, UPPER); + set resp.http.b64nopad2hexlc = b64nopad.encode(HEX, LOWER); + set resp.http.b64nopad2url = b64nopad.encode(URL); + set resp.http.b64nopad2urluc = b64nopad.encode(URL, UPPER); + set resp.http.b64nopad2urllc = b64nopad.encode(URL, LOWER); } } @@ -180,28 +221,34 @@ client c2 { expect resp.http.b642b64 == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b642b64url == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b642b64nopad == "L0hlbGxvIHdvcmxkLw" + expect resp.http.b642hex == "2f48656c6c6f20776f726c642f" expect resp.http.b642hexuc == "2F48656C6C6F20776F726C642F" - expect resp.http.b642hexlc == "2f48656c6c6f20776f726c642f" + expect resp.http.b642hexlc == resp.http.b642hex + expect resp.http.b642url == "%2fHello%20world%2f" expect resp.http.b642urluc == "%2FHello%20world%2F" - expect resp.http.b642urllc == "%2fHello%20world%2f" + expect resp.http.b642urllc == resp.http.b642url expect resp.http.b64url2id == "/Hello world/" expect resp.http.b64url2b64 == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b64url2b64url == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b64url2b64nopad == "L0hlbGxvIHdvcmxkLw" + expect resp.http.b64url2hex == "2f48656c6c6f20776f726c642f" expect resp.http.b64url2hexuc == "2F48656C6C6F20776F726C642F" - expect resp.http.b64url2hexlc == "2f48656c6c6f20776f726c642f" + expect resp.http.b64url2hexlc == resp.http.b64url2hex + expect resp.http.b64url2url == "%2fHello%20world%2f" expect resp.http.b64url2urluc == "%2FHello%20world%2F" - expect resp.http.b64url2urllc == "%2fHello%20world%2f" + expect resp.http.b64url2urllc == resp.http.b64url2url expect resp.http.b64nopad2id == "/Hello world/" expect resp.http.b64nopad2b64 == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b64nopad2b64url == "L0hlbGxvIHdvcmxkLw==" expect resp.http.b64nopad2b64nopad == "L0hlbGxvIHdvcmxkLw" + expect resp.http.b64nopad2hex == "2f48656c6c6f20776f726c642f" expect resp.http.b64nopad2hexuc == "2F48656C6C6F20776F726C642F" - expect resp.http.b64nopad2hexlc == "2f48656c6c6f20776f726c642f" + expect resp.http.b64nopad2hexlc == resp.http.b64nopad2hex + expect resp.http.b64nopad2url == "%2fHello%20world%2f" expect resp.http.b64nopad2urluc == "%2FHello%20world%2F" - expect resp.http.b64nopad2urllc == "%2fHello%20world%2f" + expect resp.http.b64nopad2urllc == resp.http.b64nopad2url } -run # run twice @@ -224,46 +271,58 @@ varnish v1 -vcl+backend { } sub vcl_synth { - set resp.http.id2urluc = id.encode(URLUC); - set resp.http.id2urllc = id.encode(URLLC); - set resp.http.emptyurluc = idempty.encode(URLUC); - set resp.http.emptyurllc = idempty.encode(URLLC); - set resp.http.url = blob.encode(IDENTITY, url.get()); - set resp.http.hexuc2urluc = hexuc.encode(URLUC); - set resp.http.hexuc2urllc = hexuc.encode(URLLC); - set resp.http.hexlc2urluc = hexlc.encode(URLUC); - set resp.http.hexlc2urllc = hexlc.encode(URLLC); + set resp.http.id2url = id.encode(URL); + set resp.http.id2urluc = id.encode(URL, UPPER); + set resp.http.id2urllc = id.encode(URL, LOWER); + set resp.http.emptyurl = idempty.encode(URL); + set resp.http.emptyurluc = idempty.encode(URL, UPPER); + set resp.http.emptyurllc = idempty.encode(URL, LOWER); + set resp.http.url = blob.encode(IDENTITY, blob=url.get()); + set resp.http.hexuc2url = hexuc.encode(URL); + set resp.http.hexuc2urluc = hexuc.encode(URL, UPPER); + set resp.http.hexuc2urllc = hexuc.encode(URL, LOWER); + set resp.http.hexlc2url = hexlc.encode(URL); + set resp.http.hexlc2urluc = hexlc.encode(URL, UPPER); + set resp.http.hexlc2urllc = hexlc.encode(URL, LOWER); set resp.http.url2id = url.encode(IDENTITY); set resp.http.url2b64 = url.encode(BASE64); set resp.http.url2b64url = url.encode(BASE64URL); set resp.http.url2b64nopad = url.encode(BASE64URLNOPAD); - set resp.http.url2hexuc = url.encode(HEXUC); - set resp.http.url2hexlc = url.encode(HEXLC); - set resp.http.url2urluc = url.encode(URLUC); - set resp.http.url2urllc = url.encode(URLLC); + set resp.http.url2hex = url.encode(HEX); + set resp.http.url2hexuc = url.encode(HEX, UPPER); + set resp.http.url2hexlc = url.encode(HEX, LOWER); + set resp.http.url2url = url.encode(URL); + set resp.http.url2urluc = url.encode(URL, UPPER); + set resp.http.url2urllc = url.encode(URL, LOWER); } } client c3 { txreq rxresp + expect resp.http.id2url == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" expect resp.http.id2urluc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" - expect resp.http.id2urllc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog" + expect resp.http.id2urllc == resp.http.id2url + expect resp.http.emptyurl == "" expect resp.http.emptyurluc == "" - expect resp.http.emptyurllc == "" + expect resp.http.emptyurllc == resp.http.emptyurl + expect resp.http.hexuc2url == "foo%20bar%20baz%20quux" expect resp.http.hexuc2urluc == "foo%20bar%20baz%20quux" - expect resp.http.hexuc2urllc == "foo%20bar%20baz%20quux" + expect resp.http.hexuc2urllc == resp.http.hexuc2url + expect resp.http.hexlc2url == "foo%20bar%20baz%20quux" expect resp.http.hexlc2urluc == "foo%20bar%20baz%20quux" - expect resp.http.hexlc2urllc == "foo%20bar%20baz%20quux" + expect resp.http.hexlc2urllc == resp.http.hexlc2url expect resp.http.url == "foo:bar:baz:quux" expect resp.http.url2id == "foo:bar:baz:quux" expect resp.http.url2b64 == "Zm9vOmJhcjpiYXo6cXV1eA==" expect resp.http.url2b64url == "Zm9vOmJhcjpiYXo6cXV1eA==" expect resp.http.url2b64nopad == "Zm9vOmJhcjpiYXo6cXV1eA" + expect resp.http.url2hex == "666f6f3a6261723a62617a3a71757578" expect resp.http.url2hexuc == "666F6F3A6261723A62617A3A71757578" - expect resp.http.url2hexlc == "666f6f3a6261723a62617a3a71757578" + expect resp.http.url2hexlc == resp.http.url2hexlc + expect resp.http.url2url == "foo%3abar%3abaz%3aquux" expect resp.http.url2urluc == "foo%3Abar%3Abaz%3Aquux" - expect resp.http.url2urllc == "foo%3abar%3abaz%3aquux" + expect resp.http.url2urllc == resp.http.url2url } -run # run twice diff --git a/bin/varnishtest/tests/m00044.vtc b/bin/varnishtest/tests/m00044.vtc index 20b6b51..ba4b757 100644 --- a/bin/varnishtest/tests/m00044.vtc +++ b/bin/varnishtest/tests/m00044.vtc @@ -20,7 +20,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { sub vcl_deliver { # The .get() method retrieves the BLOB from an object. set resp.http.MyBlob-As-Hex - = blob.encode(blob=myblob.get(), encoding=HEXLC); + = blob.encode(blob=myblob.get(), encoding=HEX); # The .encode() method efficiently retrieves an encoding. set resp.http.YourBlob-As-Base64 = yourblob.encode(BASE64); @@ -29,19 +29,20 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # vice versa at runtime. set resp.http.Base64-Encoded = blob.encode(BASE64, - blob.decode(HEX, req.http.Hex-Encoded)); + blob=blob.decode(HEX, req.http.Hex-Encoded)); } sub vcl_recv { # transcode() converts from one encoding to another. set req.http.Hex-Encoded - = blob.transcode(decoding=BASE64, encoding=HEXUC, encoded="YmF6"); + = blob.transcode(decoding=BASE64, encoding=HEX, case=UPPER, + encoded="YmF6"); # transcode() can replace other specific encoding/deconding # vmods - e.g. vmod_urlcode set req.url = blob.transcode(encoded=req.url, decoding=URL); set req.http.url_urlcoded - = blob.transcode(encoded=req.url, encoding=URLLC); + = blob.transcode(encoded=req.url, encoding=URL); } # get output from recv sub vcl_deliver { @@ -52,7 +53,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # IDENTITY sub vcl_deliver { set resp.http.Trunced-Foo1 - = blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + = blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); set resp.http.Trunced-Foo2 = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); } @@ -63,21 +64,21 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { set resp.http.First = "abc"; set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode( - HEXLC, - blob.decode(HEX, resp.http.First + resp.http.Second)); + HEX, + blob=blob.decode(HEX, resp.http.First + resp.http.Second)); } ############################################################ # encode - also contains decode examples sub vcl_deliver { set resp.http.encode1 - = blob.encode(HEXLC, blob.decode(BASE64, "Zm9vYmFyYmF6")); + = blob.encode(HEX, blob=blob.decode(BASE64, "Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 = blob.encode(blob=blob.decode(encoded="Zm9vYmFyYmF6", decoding=BASE64), - encoding=HEXLC); + encoding=HEX); # convert blob to string set resp.http.encode3 @@ -87,7 +88,8 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { ############################################################ # transcode sub vcl_deliver { - set resp.http.Hex2Base64-1 = blob.transcode(HEX, BASE64, "666f6f"); + set resp.http.Hex2Base64-1 + = blob.transcode(HEX, BASE64, encoded="666f6f"); # same with named parameters set resp.http.Hex2Base64-2 @@ -100,7 +102,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # replacement for urlcode.encode("foo bar") set resp.http.urlencoded - = blob.transcode(encoded="foo bar", encoding=URLLC); + = blob.transcode(encoded="foo bar", encoding=URL); } ############################################################ diff --git a/bin/varnishtest/tests/m00045.vtc b/bin/varnishtest/tests/m00045.vtc index 654b16a..83697a7 100644 --- a/bin/varnishtest/tests/m00045.vtc +++ b/bin/varnishtest/tests/m00045.vtc @@ -183,19 +183,21 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.up03 - = blob.encode(BASE64, blob.subblob(up07.get(), 4B)); + = blob.encode(BASE64, blob=blob.subblob(up07.get(), 4B)); set resp.http.down07060504 - = blob.encode(BASE64, blob.subblob(down07.get(), 4B)); + = blob.encode(BASE64, blob=blob.subblob(down07.get(), 4B)); set resp.http.up04050607 - = blob.encode(BASE64, blob.subblob(up07.get(), 4B, 4B)); + = blob.encode(BASE64, + blob=blob.subblob(up07.get(), 4B, 4B)); set resp.http.down03 - = blob.encode(BASE64, blob.subblob(down07.get(), 4B, 4B)); + = blob.encode(BASE64, + blob=blob.subblob(down07.get(), 4B, 4B)); set resp.http.up07 - = blob.encode(BASE64, blob.subblob(up07.get(), 8B)); + = blob.encode(BASE64, blob=blob.subblob(up07.get(), 8B)); set resp.http.down07 - = blob.encode(BASE64, blob.subblob(down07.get(), 8B)); + = blob.encode(BASE64, blob=blob.subblob(down07.get(), 8B)); set resp.http.zerobytes - = blob.encode(BASE64, blob.subblob(down07.get(), 0B)); + = blob.encode(BASE64, blob=blob.subblob(down07.get(), 0B)); set resp.http.zerolen = blob.length(blob.subblob(down07.get(), 0B)); } @@ -231,16 +233,17 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/empty") { - set resp.http.empty = blob.encode(BASE64, + set resp.http.empty = blob.encode(BASE64, blob= blob.subblob(empty.get(), 1B)); } elsif (req.url == "/toolong") { set resp.http.toolong - = blob.encode(BASE64, blob.subblob(up07.get(), 9B)); + = blob.encode(BASE64, + blob=blob.subblob(up07.get(), 9B)); } elsif (req.url == "/badoffset") { set resp.http.badoffset = blob.encode(BASE64, - blob.subblob(up07.get(), 4B, 5B)); + blob=blob.subblob(up07.get(), 4B, 5B)); } } } diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index ba2dd54..6c8ea69 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -222,7 +222,7 @@ varnish v1 -errvcl {'req.hash': Not available in method 'vcl_recv'.} { import blob; backend b { .host = "127.0.0.1"; } sub vcl_recv { - blob.encode(HEXLC, req.hash); + blob.encode(HEX, LOWER, req.hash); } } @@ -230,7 +230,7 @@ varnish v1 -errvcl {'req.hash': Not available in method 'vcl_hash'.} { import blob; backend b { .host = "127.0.0.1"; } sub vcl_hash { - blob.encode(HEXLC, req.hash); + blob.encode(HEX, LOWER, req.hash); } } diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c index d06e323..a46d88c 100644 --- a/lib/libvmod_blob/base64.c +++ b/lib/libvmod_blob/base64.c @@ -80,15 +80,16 @@ decode(char *restrict *restrict dest, char *restrict const buf, } ssize_t -base64_encode(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const inbuf, - const size_t inlength) +base64_encode(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const inbuf, const size_t inlength) { const struct b64_alphabet *alpha = &b64_alphabet[enc]; char *p = buf; const uint8_t *in = (const uint8_t *)inbuf; const uint8_t * const end = in + inlength; + (void) kase; AN(buf); AN(alpha); if (in == NULL || inlength == 0) diff --git a/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c index 0195123..b65b07e 100644 --- a/lib/libvmod_blob/hex.c +++ b/lib/libvmod_blob/hex.c @@ -75,21 +75,21 @@ hex2byte(const unsigned char hi, const unsigned char lo) } ssize_t -hex_encode(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const in, - const size_t inlen) +hex_encode(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen) { char *p = buf; const char *alphabet = hex_alphabet[0]; AN(buf); - assert(enc == HEXUC || enc == HEXLC); + assert(enc == HEX); if (in == NULL || inlen == 0) return 0; if (buflen < hex_encode_l(inlen)) return -1; - if (enc != HEXLC) + if (kase == UPPER) alphabet = hex_alphabet[1]; for (int i = 0; i < inlen; i++) { diff --git a/lib/libvmod_blob/id.c b/lib/libvmod_blob/id.c index 3a32061..34bb34b 100644 --- a/lib/libvmod_blob/id.c +++ b/lib/libvmod_blob/id.c @@ -50,11 +50,12 @@ id_decode_l(size_t l) } ssize_t -id_encode(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const in, - const size_t inlen) +id_encode(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen) { (void) enc; + (void) kase; AN(buf); if (buflen < inlen + 1) diff --git a/lib/libvmod_blob/parse_encoding.c b/lib/libvmod_blob/parse_encoding.c index b18185f..2f7a538 100644 --- a/lib/libvmod_blob/parse_encoding.c +++ b/lib/libvmod_blob/parse_encoding.c @@ -17,9 +17,9 @@ parse_encoding (const char *m) { switch (m[0]) { case 'B': goto _0B; // BASE64, BASE64URL, BASE64URLNOPAD - case 'H': goto _0H; // HEX, HEXLC, HEXUC + case 'H': goto _0H; // HEX case 'I': goto _0I; // IDENTITY - case 'U': goto _0U; // URL, URLLC, URLUC + case 'U': goto _0U; // URL default: goto invalid; } _0B: @@ -85,39 +85,11 @@ parse_encoding (const char *m) { } goto invalid; _0H: - switch (m[1]) { - case 'E': goto _1HE; // HEX, HEXLC, HEXUC - default: goto invalid; - } - _1HE: - switch (m[2]) { - case 'X': goto _2HEX; // HEX, HEXLC, HEXUC - default: goto invalid; - } - _2HEX: //HEX - if (term(m[3])) { + if ((m[1] == 'E') && (m[2] == 'X') && (term(m[3]))) { r = HEX; goto ok; } - switch (m[3]) { - case 'L': goto _3HEXL; // HEXLC - case 'U': goto _3HEXU; // HEXUC - default: goto invalid; - } - _3HEXL: - //HEXLC - if ((m[4] == 'C') && (term(m[5]))) { - r = HEXLC; - goto ok; - } - goto invalid; - _3HEXU: - //HEXUC - if ((m[4] == 'C') && (term(m[5]))) { - r = HEXUC; - goto ok; - } goto invalid; _0I: //IDENTITY @@ -127,39 +99,11 @@ parse_encoding (const char *m) { } goto invalid; _0U: - switch (m[1]) { - case 'R': goto _1UR; // URL, URLLC, URLUC - default: goto invalid; - } - _1UR: - switch (m[2]) { - case 'L': goto _2URL; // URL, URLLC, URLUC - default: goto invalid; - } - _2URL: //URL - if (term(m[3])) { + if ((m[1] == 'R') && (m[2] == 'L') && (term(m[3]))) { r = URL; goto ok; } - switch (m[3]) { - case 'L': goto _3URLL; // URLLC - case 'U': goto _3URLU; // URLUC - default: goto invalid; - } - _3URLL: - //URLLC - if ((m[4] == 'C') && (term(m[5]))) { - r = URLLC; - goto ok; - } - goto invalid; - _3URLU: - //URLUC - if ((m[4] == 'C') && (term(m[5]))) { - r = URLUC; - goto ok; - } goto invalid; ok: return r; diff --git a/lib/libvmod_blob/parse_encoding.h b/lib/libvmod_blob/parse_encoding.h index 6d6068b..472ebf8 100644 --- a/lib/libvmod_blob/parse_encoding.h +++ b/lib/libvmod_blob/parse_encoding.h @@ -14,11 +14,7 @@ enum encoding { BASE64URL, BASE64URLNOPAD, HEX, - HEXUC, - HEXLC, URL, - URLLC, - URLUC, __MAX_ENCODING }; diff --git a/lib/libvmod_blob/url.c b/lib/libvmod_blob/url.c index 7368030..deb7355 100644 --- a/lib/libvmod_blob/url.c +++ b/lib/libvmod_blob/url.c @@ -79,20 +79,20 @@ isoutofrange(const uint8_t c) } ssize_t -url_encode(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const in, - const size_t inlen) +url_encode(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen) { char *p = buf; const char * const end = buf + buflen; const char *alphabet = hex_alphabet[0]; AN(buf); - assert(enc == URLUC || enc == URLLC); + assert(enc == URL); if (in == NULL || inlen == 0) return 0; - if (enc != URLLC) + if (kase == UPPER) alphabet = hex_alphabet[1]; for (int i = 0; i < inlen; i++) { diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index aa88db4..a5553c6 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -11,13 +11,13 @@ $Module blob 3 utilities for the VCL blob type :: # binary-to-text encodings - STRING blob.encode(ENUM encoding, BLOB blob) - BLOB blob.decode(ENUM decoding, STRING_LIST encoded) - BLOB blob.decode_n(INT n, ENUM decoding, STRING_LIST encoded) - STRING blob.transcode(ENUM decoding, ENUM encoding, + STRING blob.encode([ENUM encoding,] [ENUM case,] BLOB blob) + BLOB blob.decode([ENUM decoding,] STRING_LIST encoded) + BLOB blob.decode_n(INT n, [ENUM decoding,] STRING_LIST encoded) + STRING blob.transcode([ENUM decoding,] [ENUM encoding,] [ENUM case,] STRING_LIST encoded) - STRING blob.transcode_n(INT n, ENUM decoding, ENUM encoding, - STRING_LIST encoded) + STRING blob.transcode_n(INT n, [ENUM decoding,] [ENUM encoding,] + [ENUM case,] STRING_LIST encoded) # other utilities BOOL blob.same(BLOB, BLOB) @@ -26,9 +26,9 @@ $Module blob 3 utilities for the VCL blob type BLOB blob.subblob(BLOB, BYTES length [, BYTES offset]) # blob object - new OBJ = blob.blob(ENUM decoding, STRING_LIST encoded) + new OBJ = blob.blob([ENUM decoding,] STRING_LIST encoded) BLOB .get() - STRING .encode(ENUM encoding) + STRING .encode([ENUM encoding,] [ENUM case]) DESCRIPTION =========== @@ -47,7 +47,7 @@ Examples:: sub vcl_deliver { # The .get() method retrieves the BLOB from an object. set resp.http.MyBlob-As-Hex - = blob.encode(blob=myblob.get(), encoding=HEXLC); + = blob.encode(blob=myblob.get(), encoding=HEX); # The .encode() method efficiently retrieves an encoding. set resp.http.YourBlob-As-Base64 = yourblob.encode(BASE64); @@ -56,21 +56,22 @@ Examples:: # vice versa at runtime. set resp.http.Base64-Encoded = blob.encode(BASE64, - blob.decode(HEX, req.http.Hex-Encoded)); + blob=blob.decode(HEX, req.http.Hex-Encoded)); } sub vcl_recv { # transcode() converts from one encoding to another. + # case=UPPER specifies upper-case hex digits A-F. set req.http.Hex-Encoded - = blob.transcode(decoding=BASE64, encoding=HEXUC, - encoded="YmF6"); + = blob.transcode(decoding=BASE64, encoding=HEX, + case=UPPER, encoded="YmF6"); # transcode() from URL to IDENTITY effects a URL decode. set req.url = blob.transcode(encoded=req.url, decoding=URL); # transcode() from IDENTITY to URL effects a URL encode. set req.http.url_urlcoded - = blob.transcode(encoded=req.url, encoding=URLLC); + = blob.transcode(encoded=req.url, encoding=URL); } ENCODING SCHEMES @@ -81,7 +82,7 @@ constructor, methods and functions. Decodings convert a (possibly concatenated) string into a blob, while encodings convert a blob into a string. -ENUM values for a decoding can be one of: +ENUM values for an encoding scheme can be one of: * ``IDENTITY`` * ``BASE64`` @@ -90,20 +91,22 @@ ENUM values for a decoding can be one of: * ``HEX`` * ``URL`` -An encoding can be one of: - -* ``IDENTITY`` -* ``BASE64`` -* ``BASE64URL`` -* ``BASE64URLNOPAD`` -* ``HEXUC`` -* ``HEXLC`` -* ``URLUC`` -* ``URLLC`` - Empty strings are decoded into a "null blob" (of length 0), and conversely a null blob is encoded as the empty string. +For encodings with ``HEX`` or ``URL``, you may also specify a ``case`` +ENUM with one of the values ``LOWER`` or ``UPPER`` to produce a string +with lower- or uppercase hex digits (in ``[a-f]`` or ``[A-F]``), +respectively. The default value for ``case`` is ``LOWER``. + +The ``case`` ENUM is not relevant for decodings; ``HEX`` or ``URL`` +strings to be decoded as BLOBs may have hex digits in either case, or +in mixed case. The ``case`` ENUM is also ignored for all other +encodings. You cannot, for example, produce an uppercase string by +using the IDENTITY scheme with ``case=UPPER``. To change the case of a +string, use the ``toupper`` or ``tolower`` functions from +:ref:`vmod_std(3)`. + IDENTITY -------- @@ -120,7 +123,7 @@ blob. For example:: # Decode from the hex encoding for "foo\0bar". # The header will be seen as "foo". set resp.http.Trunced-Foo1 - = blob.encode(IDENTITY, blob.decode(HEX, "666f6f00626172")); + = blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); IDENTITY is the default encoding and decoding. So the above can also be written as:: @@ -130,6 +133,8 @@ be written as:: set resp.http.Trunced-Foo2 = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); +The ``case`` ENUM is ignored for ``IDENTITY`` encodings. + BASE64* ------- @@ -150,14 +155,16 @@ The ``BASE64URLNOPAD`` encoding uses the same alphabet as ``BASE6URL``, but leaves out the padding. Thus the length of an encoding with this scheme is not necessarily a mutltiple of four. -HEX* ----- +The ``case`` ENUM is ignored for for all of the ``BASE64*`` encodings. + +HEX +--- -The ``HEX`` decoding converts a hex string, which may contain upper- -or lowercase characters for hex digits ``A`` through ``f``, into a -blob. The ``HEXUC`` or ``HEXLC`` encodings convert a blob into a hex -string with upper- and lowercase digits, respectively. A prefix such -as ``0x`` is not used for any of these schemes. +The ``HEX`` encoding scheme converts hex strings into blobs and vice +versa. For encodings, you may use the ``case`` ENUM to specify upper- +or lowercase hex digits ``A`` through ``f`` (default ``LOWER``). A +prefix such as ``0x`` is not used for an encoding and is illegal for a +decoding. If a hex string to be decoded has an odd number of digits, it is decoded as if a ``0`` is prepended to it; that is, the first digit is @@ -168,18 +175,18 @@ byte. For example:: set resp.http.First = "abc"; set resp.http.Second = "def0"; set resp.http.Hex-Decoded - = blob.encode(HEXLC, blob.decode(HEX, - resp.http.First + resp.http.Second)); + = blob.encode(HEX, blob=blob.decode(HEX, + resp.http.First + resp.http.Second)); -URL* ----- +URL +--- The ``URL`` decoding replaces any ``%<2-hex-digits>`` substrings with the binary value of the hexadecimal number after the % sign. -The ``URLLC`` and ``URLUC`` encodings implement "percent encoding" as per -RFC3986, the hexadecimal characters A-F being output in lower- and -uppercase, respectively. +The ``URL`` encoding implements "percent encoding" as per RFC3986. The +``case`` ENUM determines the case of the hex digits, but does not +affect alphabetic characters that are not percent-encoded. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", STRING_LIST encoded) @@ -187,7 +194,7 @@ $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, Returns the BLOB derived from the string ``encoded`` according to the scheme specified by ``decoding``. -``decoding`` defaults to IDENTITY +``decoding`` defaults to IDENTITY. Example:: @@ -209,24 +216,25 @@ the encoded string. If ``n`` is greater than the length of the string, then return the same result as ``decode()``. $Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", - BLOB blob) + HEX, URL} encoding="IDENTITY", + ENUM {LOWER, UPPER} case="LOWER", BLOB blob) Returns a string representation of the BLOB ``blob`` as specifed by -``encoding``. +``encoding``. ``case`` determines the case of hex digits for the +``HEX`` and ``URL`` encodings, and is ignored for the other encodings. -``encoding`` defaults to IDENTITY +``encoding`` defaults to IDENTITY, and ``case`` defaults to LOWER. Example:: set resp.http.encode1 - = blob.encode(HEXLC, blob.decode(BASE64, "Zm9vYmFyYmF6")); + = blob.encode(HEX, blob=blob.decode(BASE64, "Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 = blob.encode(blob=blob.decode(encoded="Zm9vYmFyYmF6", decoding=BASE64), - encoding=HEXLC); + encoding=HEX); # convert blob to string set resp.http.encode3 @@ -235,28 +243,32 @@ Example:: $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + HEX, URL} encoding="IDENTITY", + ENUM {LOWER, UPPER} case="LOWER", STRING_LIST encoded) Translates from one encoding to another, by first decoding the string ``encoded`` according to the scheme ``decoding``, and then returning the encoding of the resulting blob according to the scheme -``encoding``. +``encoding``. ``case`` determines the case of hex digits for the +``HEX`` and ``URL`` encodings, and is ignored for other encodings. -``decoding`` and ``encoding`` default to IDENTITY +``decoding`` and ``encoding`` default to IDENTITY, and ``case`` +defaults to LOWER. Example:: - set resp.http.Hex2Base64-1 = blob.transcode(HEX, BASE64, "666f6f"); + set resp.http.Hex2Base64-1 + = blob.transcode(HEX, BASE64, encoded="666f6f"); # same with named parameters set resp.http.Hex2Base64-2 - = blob.transcode(encoded="666f6f", + = blob.transcode(encoded="666f6f", encoding=BASE64, decoding=HEX); # URL decode -- recall that IDENTITY is the default encoding. set resp.http.urldecoded - = blob.transcode(encoded="foo%20bar", decoding=URLLC); + = blob.transcode(encoded="foo%20bar", decoding=URL); # URL encode set resp.http.urlencoded @@ -266,7 +278,8 @@ $Function STRING transcode_n(INT n, ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEXUC, HEXLC, URLUC, URLLC} encoding="IDENTITY", + HEX, URL} encoding="IDENTITY", + ENUM {LOWER, UPPER} case="LOWER", STRING_LIST encoded) Same as ``transcode()``, but only from the first ``n`` characters of @@ -336,11 +349,14 @@ Example:: set resp.http.The-Stringblob = blob.encode(blob=stringblob.get()); -$Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXUC, - HEXLC, URLUC, URLLC} encoding="IDENTITY") +$Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, + URL} encoding="IDENTITY", + ENUM {LOWER, UPPER} case="LOWER") Returns an encoding of BLOB created by the constructor, according to -the scheme ``encoding``. +the scheme ``encoding``. ``case`` determines the case of hex digits +for the ``HEX`` and ``URL`` encodings, and is ignored for other +encodings. Example:: @@ -350,11 +366,11 @@ Example:: # blob as base64 set resp.http.The-Blob-b64 = theblob1.encode(BASE64); -For any ``blob`` object and encoding ``ENC``, encodings via the ``.encode()`` -method and the ``encode()`` function are equal:: +For any ``blob`` object, encoding ``ENC`` and case ``CASE``, encodings +via the ``.encode()`` method and the ``encode()`` function are equal:: # Always true: - blob.encode(ENC, blob.get()) == blob.encode(ENC) + blob.encode(ENC, CASE, blob.get()) == blob.encode(ENC, CASE) But the object method is more efficient -- the encoding is computed once and cached (with allocation in heap memory), and the cached @@ -416,3 +432,4 @@ SEE ALSO * :ref:`varnishd(1)` * :ref:`vcl(7)` +* :ref:`vmod_std(3)` diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 6bb37ed..850f975 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -42,7 +42,7 @@ struct vmod_blob_blob { unsigned magic; #define VMOD_BLOB_MAGIC 0xfade4fa9 struct vmod_priv blob; - char *encoding[__MAX_ENCODING]; + char *encoding[__MAX_ENCODING][2]; pthread_mutex_t lock; }; @@ -51,18 +51,6 @@ struct vmod_blob_blob { .decode = base64_decode, \ .encode = base64_encode -#define HEX_FUNCS \ - .decode_l = hex_decode_l, \ - .decode = hex_decode, \ - .encode_l = hex_encode_l, \ - .encode = hex_encode - -#define URL_FUNCS \ - .decode_l = url_decode_l, \ - .decode = url_decode, \ - .encode_l = url_encode_l, \ - .encode = url_encode - static const struct vmod_blob_fptr { len_f *const decode_l; decode_f *const decode; @@ -95,28 +83,20 @@ static const struct vmod_blob_fptr { .encode_l = base64nopad_encode_l }, [HEX] = { - HEX_FUNCS - }, - [HEXUC] = { - HEX_FUNCS - }, - [HEXLC] = { - HEX_FUNCS + .decode_l = hex_decode_l, + .decode = hex_decode, + .encode_l = hex_encode_l, + .encode = hex_encode }, [URL] = { - URL_FUNCS - }, - [URLUC] = { - URL_FUNCS + .decode_l = url_decode_l, + .decode = url_decode, + .encode_l = url_encode_l, + .encode = url_encode }, - [URLLC] = { - URL_FUNCS - } }; #undef B64_FUNCS -#undef HEX_FUNCS -#undef URL_FUNCS #define ERR(ctx, msg) \ VRT_fail((ctx), "vmod blob error: " msg) @@ -175,6 +155,21 @@ err_decode(VRT_CTX, const char *enc) } } +static inline enum case_e +parse_case(VCL_ENUM case_s) +{ + switch(*case_s) { + case 'L': + AZ(strcmp(case_s + 1, "OWER")); + return LOWER; + case 'U': + AZ(strcmp(case_s + 1, "PPER")); + return UPPER; + default: + WRONG("illegal case enum"); + } +} + /* Objects */ VCL_VOID __match_proto__(td_blob_blob__init) @@ -245,10 +240,12 @@ vmod_blob_get(VRT_CTX, struct vmod_blob_blob *b) } VCL_STRING __match_proto__(td_blob_blob_encode) -vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs) +vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs, + VCL_ENUM case_s) { enum encoding enc = parse_encoding(encs); AENC(enc); + enum case_e kase = parse_case(case_s); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(b, VMOD_BLOB_MAGIC); @@ -256,29 +253,29 @@ vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs) if (b->blob.len == 0) return ""; - if (b->encoding[enc] == NULL) { + if (b->encoding[enc][kase] == NULL) { AZ(pthread_mutex_lock(&b->lock)); - if (b->encoding[enc] == NULL) { + if (b->encoding[enc][kase] == NULL) { ssize_t len = func[enc].encode_l(b->blob.len); assert(len >= 0); if (len == 0) - b->encoding[enc] = empty; + b->encoding[enc][kase] = empty; else { - b->encoding[enc] = malloc(len); - if (b->encoding[enc] == NULL) + b->encoding[enc][kase] = malloc(len); + if (b->encoding[enc][kase] == NULL) ERRNOMEM(ctx, "cannot encode"); else { - char *s = b->encoding[enc]; + char *s = b->encoding[enc][kase]; len = func[enc].encode( - enc, s, len, + enc, kase, s, len, b->blob.priv, b->blob.len); assert(len >= 0); if (len == 0) { free(s); - b->encoding[enc] = empty; + b->encoding[enc][kase] = empty; } else s[len] = '\0'; @@ -287,7 +284,7 @@ vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs) } AZ(pthread_mutex_unlock(&b->lock)); } - return b->encoding[enc]; + return b->encoding[enc][kase]; } VCL_VOID __match_proto__(td_blob_blob__fini) @@ -306,9 +303,12 @@ vmod_blob__fini(struct vmod_blob_blob **blobp) b->blob.priv = NULL; } for (int i = 0; i < __MAX_ENCODING; i++) - if (b->encoding[i] != NULL && b->encoding[i] != empty) { - free(b->encoding[i]); - b->encoding[i] = NULL; + for (int j = 0; j < 2; j++) { + char *s = b->encoding[i][j]; + if (s != NULL && s != empty) { + free(s); + b->encoding[i][j] = NULL; + } } AZ(pthread_mutex_destroy(&b->lock)); FREE_OBJ(b); @@ -413,7 +413,7 @@ vmod_decode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *p, ...) } static VCL_STRING -encode(VRT_CTX, enum encoding enc, VCL_BLOB b) +encode(VRT_CTX, enum encoding enc, enum case_e kase, VCL_BLOB b) { struct wb_s wb; ssize_t len; @@ -430,7 +430,7 @@ encode(VRT_CTX, enum encoding enc, VCL_BLOB b) return NULL; } - len = func[enc].encode(enc, + len = func[enc].encode(enc, kase, wb_buf(&wb), wb_space(&wb), b->priv, b->len); if (len == -1) { @@ -447,18 +447,26 @@ encode(VRT_CTX, enum encoding enc, VCL_BLOB b) } VCL_STRING __match_proto__(td_blob_encode) -vmod_encode(VRT_CTX, VCL_ENUM encs, VCL_BLOB b) +vmod_encode(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, VCL_BLOB b) { enum encoding enc = parse_encoding(encs); - return encode(ctx, enc, b); + enum case_e kase = parse_case(case_s); + return encode(ctx, enc, kase, b); +} + +static inline int +encodes_hex(enum encoding enc) +{ + return (enc == HEX || enc == URL); } static VCL_STRING -transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, +transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, const char *restrict const p, va_list ap) { enum encoding dec = parse_encoding(decs); enum encoding enc = parse_encoding(encs); + enum case_e kase = parse_case(case_s); va_list aq; struct vmod_priv b; VCL_STRING r; @@ -497,8 +505,11 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, * If the encoding and decoding are the same, and the decoding was * legal, just return the string, if there was only one in the * STRING_LIST, or else the concatenated string. + * For encodings with hex digits, we cannot assume the same result. + * since the call may specify upper- or lower-case that differs + * from the encoded string. */ - if (n == -1 && enc == dec) { + if (n == -1 && enc == dec && !encodes_hex(enc)) { const char *q, *pp = p; va_copy(aq, ap); q = find_nonempty_va(&pp, ap); @@ -514,19 +525,19 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, return r; } - r = encode(ctx, enc, &b); + r = encode(ctx, enc, kase, &b); return (r); } VCL_STRING __match_proto__(td_blob_transcode) -vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, +vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, const char *p, ...) { va_list ap; VCL_STRING r; va_start(ap, p); - r = transcode(ctx, -1, decs, encs, p, ap); + r = transcode(ctx, -1, decs, encs, case_s, p, ap); va_end(ap); return (r); @@ -534,13 +545,13 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_STRING __match_proto__(td_blob_transcode_n) vmod_transcode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, - const char *p, ...) + VCL_ENUM case_s, const char *p, ...) { va_list ap; VCL_STRING r; va_start(ap, p); - r = transcode(ctx, n, decs, encs, p, ap); + r = transcode(ctx, n, decs, encs, case_s, p, ap); va_end(ap); return (r); diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h index 3953035..9cc1d45 100644 --- a/lib/libvmod_blob/vmod_blob.h +++ b/lib/libvmod_blob/vmod_blob.h @@ -34,6 +34,11 @@ #define AENC(enc) assert((enc) > _INVALID && (enc) < __MAX_ENCODING) +enum case_e { + LOWER, + UPPER, +}; + /* * Length estimate interface */ @@ -46,6 +51,7 @@ size_t len_f(size_t); * encoding. * * enc: encoding enum (from parse_encoding.h) + * kase: case enum (for encodings with hex digits) * buf: destination of the encoded string * buflen: maximum length available at buf * in: source of data to be encoded @@ -65,9 +71,9 @@ size_t len_f(size_t); * include any terminating null byte) */ typedef -ssize_t encode_f(const enum encoding enc, char *restrict const buf, - const size_t buflen, const char *restrict const in, - const size_t inlen); +ssize_t encode_f(const enum encoding enc, const enum case_e kase, + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen); /* * General interface for a decoder: decode the concatenation of strings From hermunn at varnish-software.com Fri Sep 15 11:17:18 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:18 +0000 (UTC) Subject: [5.2] 95df549 The -C mode failed to clean up its random workdirectory because of _.pid Message-ID: <20170915111718.744AD98259@lists.varnish-cache.org> commit 95df549c16b82d0367fbca23bebd82a642ce5158 Author: Poul-Henning Kamp Date: Mon Sep 11 20:58:27 2017 +0000 The -C mode failed to clean up its random workdirectory because of _.pid diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 67492d6..8a5f918 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -243,6 +243,7 @@ mgt_Cflag_atexit(void) if (getpid() != mgt_pid) return; (void)rmdir("vmod_cache"); + (void)unlink("_.pid"); (void)rmdir(Cn_arg); } From hermunn at varnish-software.com Fri Sep 15 11:17:18 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:18 +0000 (UTC) Subject: [5.2] a0920f0 Give up filtering VMOD exported symbols, it breaks at least arm64/FreeBSD Message-ID: <20170915111718.92AE898267@lists.varnish-cache.org> commit a0920f09f32535d52df54fd5be98d2d15ee3f012 Author: Poul-Henning Kamp Date: Mon Sep 11 21:52:30 2017 +0000 Give up filtering VMOD exported symbols, it breaks at least arm64/FreeBSD diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 3a4472c..30a5928 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -68,7 +68,6 @@ libvmod_XXX_la_CFLAGS = \\ libvmod_XXX_la_LDFLAGS = \\ $(AM_LDFLAGS) \\ -module -export-dynamic -avoid-version -shared \\ - -export-symbols-regex '^Vmod_XXX_Data' \\ @SAN_LDFLAGS@ nodist_libvmod_XXX_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index ae78a9a..9871b3f 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_blob_la_CFLAGS = \ libvmod_blob_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_blob_Data' \ @SAN_LDFLAGS@ nodist_libvmod_blob_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index e5f13a2..5b0195a 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -28,8 +28,6 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -rpath /nowhere \ - -export-symbols-regex '^Vmod_debug_Data' \ @SAN_LDFLAGS@ nodist_libvmod_debug_la_SOURCES = \ diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index 21a702d..f30062d 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_directors_la_CFLAGS = \ libvmod_directors_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_directors_Data' \ @SAN_LDFLAGS@ nodist_libvmod_directors_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index d8f3803..9671d53 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_purge_la_CFLAGS = \ libvmod_purge_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_purge_Data' \ @SAN_LDFLAGS@ nodist_libvmod_purge_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index cbd9bc9..259476e 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_std_la_CFLAGS = \ libvmod_std_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_std_Data' \ @SAN_LDFLAGS@ nodist_libvmod_std_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 7642a2d..545bb56 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -20,7 +20,6 @@ libvmod_vtc_la_CFLAGS = \ libvmod_vtc_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ - -export-symbols-regex '^Vmod_vtc_Data' \ @SAN_LDFLAGS@ nodist_libvmod_vtc_la_SOURCES = vcc_if.c vcc_if.h From hermunn at varnish-software.com Fri Sep 15 11:17:18 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:18 +0000 (UTC) Subject: [5.2] e49bca5 Arg... Deleted one line too much here... Message-ID: <20170915111718.B1A4898272@lists.varnish-cache.org> commit e49bca5331e1362613d8720af640de6c6a7c2992 Author: Poul-Henning Kamp Date: Mon Sep 11 22:25:00 2017 +0000 Arg... Deleted one line too much here... diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index 5b0195a..3fb7d98 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -28,6 +28,7 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ -module -export-dynamic -avoid-version -shared \ + -rpath /nowhere @SAN_LDFLAGS@ nodist_libvmod_debug_la_SOURCES = \ From hermunn at varnish-software.com Fri Sep 15 11:17:18 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:18 +0000 (UTC) Subject: [5.2] 6621dc2 Put the calloc(3) arguments in the right order Message-ID: <20170915111718.E26EC9828D@lists.varnish-cache.org> commit 6621dc2b06e6d5d15452b1ea785af926b94459c2 Author: Dridi Boukelmoune Date: Tue Sep 12 00:21:03 2017 +0200 Put the calloc(3) arguments in the right order This is mostly a mechanical patch. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 8da85ae..79d5e41 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -150,7 +150,7 @@ vca_tcp_opt_init(void) for (n = 0; n < n_tcp_opts; n++) { to = &tcp_opts[n]; if (to->ptr == NULL) - to->ptr = calloc(to->sz, 1); + to->ptr = calloc(1, to->sz); AN(to->ptr); if (!strcmp(to->strname, "SO_LINGER")) { assert(to->sz == sizeof linger); @@ -212,7 +212,7 @@ vca_tcp_opt_test(int sock) for (n = 0; n < n_tcp_opts; n++) { to = &tcp_opts[n]; to->need = 1; - ptr = calloc(to->sz, 1); + ptr = calloc(1, to->sz); AN(ptr); l = to->sz; i = getsockopt(sock, to->level, to->optname, ptr, &l); diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 0e05bcc..160d1da 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -78,7 +78,7 @@ mpl_alloc(const struct mempool *mpl) CHECK_OBJ_NOTNULL(mpl, MEMPOOL_MAGIC); tsz = *mpl->cur_size; - mi = calloc(tsz, 1); + mi = calloc(1, tsz); AN(mi); mi->magic = MEMITEM_MAGIC; mi->size = tsz; diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index e89e411..87db657 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -93,7 +93,7 @@ hcl_start(void) unsigned u; lck_hcl = Lck_CreateClass("hcl"); - hcl_head = calloc(sizeof *hcl_head, hcl_nhash); + hcl_head = calloc(hcl_nhash, sizeof *hcl_head); XXXAN(hcl_head); for (u = 0; u < hcl_nhash; u++) { diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 1a51afe..417c97e 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -596,8 +596,8 @@ main(int argc, char **argv) hist_range = hist_high - hist_low; hist_buckets = hist_range * HIST_RES; - bucket_hit = calloc(sizeof *bucket_hit, hist_buckets); - bucket_miss = calloc(sizeof *bucket_miss, hist_buckets); + bucket_hit = calloc(hist_buckets, sizeof *bucket_hit); + bucket_miss = calloc(hist_buckets, sizeof *bucket_miss); if (timebend > 0) t0 = VTIM_mono(); diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 7645faa..c65139b 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -745,7 +745,7 @@ cmd_http_gunzip(CMD_ARGS) vz.avail_in = hp->bodyl; l = hp->bodyl * 10; - p = calloc(l, 1); + p = calloc(1, l); AN(p); vz.next_out = TRUST_ME(p); @@ -790,7 +790,7 @@ gzip_body(const struct http *hp, const char *txt, char **body, int *bodylen) memset(&vz, 0, sizeof vz); l = strlen(txt); - *body = calloc(l + OVERHEAD, 1); + *body = calloc(1, l + OVERHEAD); AN(*body); vz.next_in = TRUST_ME(txt); diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 07386ed..39600ce 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -158,7 +158,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], VRB_INSERT(t_order, &h_order, tp); } else { ntop++; - tp = calloc(sizeof *tp, 1); + tp = calloc(1, sizeof *tp); assert(tp != NULL); tp->hash = u; tp->count = 1.0; diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 910d613..3b63f56 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -386,7 +386,7 @@ In the common case where a private data structure is allocated with malloc would look like this:: if (priv->priv == NULL) { - priv->priv = calloc(sizeof(struct myfoo), 1); + priv->priv = calloc(1, sizeof(struct myfoo)); AN(priv->priv); priv->free = free; /* free(3) */ mystate = priv->priv; diff --git a/include/miniobj.h b/include/miniobj.h index 13aa3a6..b714c70 100644 --- a/include/miniobj.h +++ b/include/miniobj.h @@ -19,7 +19,7 @@ #define ALLOC_OBJ(to, type_magic) \ do { \ - (to) = calloc(sizeof *(to), 1); \ + (to) = calloc(1, sizeof *(to)); \ if ((to) != NULL) \ (to)->magic = (type_magic); \ } while (0) diff --git a/include/vbm.h b/include/vbm.h index f56447d..9dcc3d0 100644 --- a/include/vbm.h +++ b/include/vbm.h @@ -121,7 +121,7 @@ vbit_new(unsigned initial) { struct vbitmap *vb; - vb = calloc(sizeof *vb, 1); + vb = calloc(1, sizeof *vb); assert(vb != NULL); vb->flags |= VBITMAP_FL_MALLOC; if (initial == 0) diff --git a/lib/libvarnish/binary_heap.c b/lib/libvarnish/binary_heap.c index e3bd2eb..9799276 100644 --- a/lib/libvarnish/binary_heap.c +++ b/lib/libvarnish/binary_heap.c @@ -207,7 +207,7 @@ binheap_new(void *priv, binheap_cmp_t *cmp_f, binheap_update_t *update_f) struct binheap *bh; unsigned u; - bh = calloc(sizeof *bh, 1); + bh = calloc(1, sizeof *bh); if (bh == NULL) return (bh); bh->priv = priv; @@ -224,7 +224,7 @@ binheap_new(void *priv, binheap_cmp_t *cmp_f, binheap_update_t *update_f) bh->update = update_f; bh->next = ROOT_IDX; bh->rows = 16; /* A tiny-ish number */ - bh->array = calloc(sizeof *bh->array, bh->rows); + bh->array = calloc(bh->rows, sizeof *bh->array); assert(bh->array != NULL); binheap_addrow(bh); A(bh, ROOT_IDX) = NULL; diff --git a/lib/libvarnish/vav.c b/lib/libvarnish/vav.c index 51a7ef6..4c4a779 100644 --- a/lib/libvarnish/vav.c +++ b/lib/libvarnish/vav.c @@ -112,7 +112,7 @@ VAV_BackSlashDecode(const char *s, const char *e) if (e == NULL) e = strchr(s, '\0'); assert(e != NULL); - p = calloc((e - s) + 1L, 1); + p = calloc(1, (e - s) + 1L); if (p == NULL) return (p); for (r = p, q = s; q < e; ) { @@ -142,7 +142,7 @@ VAV_Parse(const char *s, int *argc, int flag) assert(s != NULL); nargv = 1; largv = 16; - argv = calloc(sizeof *argv, largv); + argv = calloc(largv, sizeof *argv); if (argv == NULL) return (NULL); diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c index 7c8011f..88f7057 100644 --- a/lib/libvarnish/vev.c +++ b/lib/libvarnish/vev.c @@ -156,7 +156,7 @@ vev_get_sig(int sig) if (sig < vev_nsig) return (0); - os = calloc(sizeof *os, (sig + 1L)); + os = calloc((sig + 1L), sizeof *os); if (os == NULL) return (ENOMEM); @@ -192,7 +192,7 @@ vev_new_base(void) { struct vev_base *evb; - evb = calloc(sizeof *evb, 1); + evb = calloc(1, sizeof *evb); if (evb == NULL) return (evb); evb->lpfd = BINHEAP_NOIDX + 1; @@ -230,7 +230,7 @@ vev_new(void) { struct vev *e; - e = calloc(sizeof *e, 1); + e = calloc(1, sizeof *e); if (e != NULL) { e->fd = -1; } diff --git a/lib/libvarnish/vfil.c b/lib/libvarnish/vfil.c index 6df5af6..64f3c56 100644 --- a/lib/libvarnish/vfil.c +++ b/lib/libvarnish/vfil.c @@ -275,7 +275,7 @@ VFIL_allocate(int fd, off_t size, int insist) bufsiz = 64 * 1024; else bufsiz = size; - buf = calloc(bufsiz, 1); + buf = calloc(1, bufsiz); AN(buf); assert(lseek(fd, 0, SEEK_SET) == 0); for (l = 0; l < size; l += l2) { diff --git a/lib/libvarnishapi/vxp.c b/lib/libvarnishapi/vxp.c index ae86282..039fafe 100644 --- a/lib/libvarnishapi/vxp.c +++ b/lib/libvarnishapi/vxp.c @@ -143,7 +143,7 @@ vxp_DoFree(struct vxp *vxp, void *p) { struct membit *mb; - mb = calloc(sizeof *mb, 1); + mb = calloc(1, sizeof *mb); AN(mb); mb->ptr = p; VTAILQ_INSERT_TAIL(&vxp->membits, mb, list); @@ -154,7 +154,7 @@ vxp_Alloc(struct vxp *vxp, unsigned len) { void *p; - p = calloc(len, 1); + p = calloc(1, len); AN(p); vxp_DoFree(vxp, p); return (p); diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index a8d0352..468a4c5 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -77,7 +77,7 @@ TlAlloc(struct vcc *tl, unsigned len) void *p; (void)tl; - p = calloc(len, 1); + p = calloc(1, len); assert(p != NULL); return (p); } @@ -418,7 +418,7 @@ vcc_new_source(const char *b, const char *e, const char *name) if (e == NULL) e = strchr(b, '\0'); - sp = calloc(sizeof *sp, 1); + sp = calloc(1, sizeof *sp); assert(sp != NULL); sp->name = strdup(name); AN(sp->name); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 5aa28a7..52159cb 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -608,7 +608,7 @@ vcc_func(struct vcc *tl, struct expr **e, const char *spec, AN(rfmt); VTAILQ_INIT(&head); while (*p != '\0') { - fa = calloc(sizeof *fa, 1); + fa = calloc(1, sizeof *fa); AN(fa); VTAILQ_INSERT_TAIL(&head, fa, list); if (!memcmp(p, "PRIV_", 5)) { From hermunn at varnish-software.com Fri Sep 15 11:17:19 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:19 +0000 (UTC) Subject: [5.2] 14578e5 VMOD blob: remove the decode_n() and transcode_n() functions. Message-ID: <20170915111719.18159982A0@lists.varnish-cache.org> commit 14578e5a9298712e339b14502cef30dd7646466a Author: Geoff Simmons Date: Tue Sep 12 00:40:15 2017 +0200 VMOD blob: remove the decode_n() and transcode_n() functions. decode() and transcode() now have an optional parameter length; if length > 0, decode that many characters from the encoded string. References #2421 diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index 2340eda..81b654d 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -11,29 +11,29 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.id = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, - "The quick brown fox jumps over the lazy dog")); + encoded="The quick brown fox jumps over the lazy dog")); set resp.http.hobbes = - blob.encode(IDENTITY, blob=blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, encoded= {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = - blob.encode(IDENTITY, blob=blob.decode(IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, encoded= "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "")); set resp.http.empty = - blob.encode(IDENTITY, blob=blob.decode(IDENTITY, "")); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, encoded="")); set resp.http.undef = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, - req.http.unset)); + encoded=req.http.unset)); set resp.http.emptylist = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, - req.http.unset + "" + req.http.unset + "")); + encoded=req.http.unset + "" + req.http.unset + "")); set resp.http.param = blob.encode(blob= @@ -51,13 +51,16 @@ varnish v1 -vcl { decoding=IDENTITY)); set resp.http.truncated = - blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); + blob.encode(IDENTITY, + blob=blob.decode(HEX, encoded="666f6f00626172")); set resp.http.lc = - blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, "Don't care")); + blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, + encoded="Don't care")); set resp.http.uc = - blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, "Don't care")); + blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, + encoded="Don't care")); } } -start diff --git a/bin/varnishtest/tests/m00034.vtc b/bin/varnishtest/tests/m00034.vtc index 949df45..95ea934 100644 --- a/bin/varnishtest/tests/m00034.vtc +++ b/bin/varnishtest/tests/m00034.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob IDENTITY decode_n()" +varnishtest "VMOD blob IDENTITY decode() n chars" varnish v1 -vcl { import blob; @@ -10,45 +10,47 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.id = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, - "The quick brown fox jumps over the lazy dog")); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, + encoded="The quick brown fox jumps over the lazy dog")); set resp.http.hobbes = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, + encoded= {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = - blob.encode(IDENTITY, blob=blob.decode_n(6, IDENTITY, - "" + req.http.unset + req.url + + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=6, + encoded="" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "")); set resp.http.empty = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, "")); + blob.encode(IDENTITY, + blob=blob.decode(IDENTITY, length=5, encoded="")); set resp.http.undef = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, - req.http.unset)); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, + encoded=req.http.unset)); set resp.http.emptylist = - blob.encode(IDENTITY, blob=blob.decode_n(5, IDENTITY, - req.http.unset + "" + req.http.unset + "")); + blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, + encoded=req.http.unset + "" + req.http.unset + "")); set resp.http.param = blob.encode(blob= - blob.decode_n(encoded= + blob.decode(encoded= "The quick brown fox jumps over the lazy dog", - n=7, decoding=IDENTITY), + length=7, decoding=IDENTITY), encoding=IDENTITY); set resp.http.paramlist = - blob.encode(IDENTITY, blob=blob.decode_n(encoded= + blob.encode(IDENTITY, blob=blob.decode(encoded= "" + req.http.unset + req.url + "The quick brown fox jumps over " + req.http.unset + "" + req.http.unset + "" + "the lazy dog" + req.url + req.http.unset + "", - decoding=IDENTITY, n=37)); + decoding=IDENTITY, length=37)); } } -start diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index e1aa0ff..6190914 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -19,49 +19,56 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.hex = - blob.encode(HEX, blob=blob.decode(IDENTITY, req.http.pangram)); + blob.encode(HEX, blob=blob.decode(IDENTITY, + encoded=req.http.pangram)); set resp.http.hexlc = blob.encode(HEX, LOWER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.hexuc = blob.encode(HEX, UPPER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.hobbes = - blob.encode(HEX, blob=blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, blob=blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.hobbeslc = - blob.encode(HEX, LOWER, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, LOWER, blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(HEX, UPPER, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.all = - blob.encode(HEX, blob=blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, blob=blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.all-lc = - blob.encode(HEX, LOWER, blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, LOWER, blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.all-uc = - blob.encode(HEX, UPPER, blob.decode(BASE64, req.http.b64all)); + blob.encode(HEX, UPPER, blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.empty = - blob.encode(HEX, blob=blob.decode(IDENTITY, "")); + blob.encode(HEX, blob=blob.decode(IDENTITY, encoded="")); set resp.http.empty-lc = - blob.encode(HEX, LOWER, blob.decode(IDENTITY, "")); + blob.encode(HEX, LOWER, blob.decode(IDENTITY, encoded="")); set resp.http.empty-uc = - blob.encode(HEX, UPPER, blob.decode(IDENTITY, "")); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, encoded="")); set resp.http.hexlcparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), case=LOWER, encoding=HEX); set resp.http.hexucparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), case=UPPER, encoding=HEX); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; @@ -76,52 +83,55 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.hexucfoobar)); + blob=blob.decode(HEX, encoded=req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.hexlcfoobar)); + blob=blob.decode(HEX, encoded=req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.hexhobbesuc)); + blob=blob.decode(HEX, encoded=req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.hexhobbeslc)); + blob=blob.decode(HEX, encoded=req.http.hexhobbeslc)); set resp.http.decalluc = - blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexalluc)); + blob.encode(BASE64, blob=blob.decode(HEX, + encoded=req.http.hexalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexalllc)); + blob.encode(BASE64, blob=blob.decode(HEX, + encoded=req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob=blob.decode(HEX, - req.http.hexallucodd)); + blob.encode(BASE64, + blob=blob.decode(HEX, encoded=req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob=blob.decode(HEX, - req.http.hexalllcodd)); + blob.encode(BASE64, + blob=blob.decode(HEX, encoded=req.http.hexalllcodd)); set resp.http.decempty = - blob.encode(IDENTITY, blob=blob.decode(HEX, "")); + blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob=blob.decode(HEX, "00")); + blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="00")); set resp.http.decemptynibble = - blob.encode(IDENTITY, blob=blob.decode(HEX, "0")); + blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="0")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob=blob.decode(HEX, req.http.unset + "" - + req.http.unset + "")); + blob=blob.decode(HEX, encoded=req.http.unset + "" + + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob=blob.decode(HEX, req.http.part1 + - "F6F206261722062617A2071757578")); + blob.encode(IDENTITY, blob=blob.decode(HEX, + encoded=req.http.part1 + + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; set resp.http.dec3param = @@ -131,11 +141,13 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob=blob.decode(HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(HEX, + encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob=blob.decode(HEX, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode(HEX, encoded= + "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -191,7 +203,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { set req.http.foo = "123"; set resp.http.badhex = blob.encode(HEX, UPPER, - blob.decode(HEX, "g" + req.http.foo)); + blob.decode(HEX, encoded="g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00036.vtc b/bin/varnishtest/tests/m00036.vtc index cf6335b..635d726 100644 --- a/bin/varnishtest/tests/m00036.vtc +++ b/bin/varnishtest/tests/m00036.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob hex decode_n()" +varnishtest "VMOD blob hex decode() n chars" varnish v1 -vcl { import blob; @@ -19,40 +19,45 @@ varnish v1 -vcl { set resp.http.hexlc = blob.encode(HEX, - blob=blob.decode_n(5, IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, 5, + encoded=req.http.pangram)); set resp.http.hexuc = blob.encode(HEX, UPPER, - blob.decode_n(5, IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, 5, encoded=req.http.pangram)); set resp.http.hobbeslc = blob.encode(HEX, - blob=blob.decode_n(5, IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, 5, + encoded=req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEX, UPPER, - blob.decode_n(5, IDENTITY, req.http.hobbes)); + blob.decode(IDENTITY, 5, encoded=req.http.hobbes)); set resp.http.all-lc = - blob.encode(HEX, blob=blob.decode_n(8, BASE64, req.http.b64all)); + blob.encode(HEX, blob=blob.decode(BASE64, 8, + encoded=req.http.b64all)); set resp.http.all-uc = blob.encode(HEX, UPPER, - blob.decode_n(8, BASE64, req.http.b64all)); + blob.decode(BASE64, 8, encoded=req.http.b64all)); set resp.http.empty-lc = - blob.encode(HEX, blob=blob.decode_n(5, IDENTITY, "")); + blob.encode(HEX, blob=blob.decode(IDENTITY, 5, encoded="")); set resp.http.empty-uc = - blob.encode(HEX, UPPER, blob.decode_n(5, IDENTITY, "")); + blob.encode(HEX, UPPER, blob.decode(IDENTITY, 5, encoded="")); set resp.http.hexlcparam = - blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), - encoding=HEX, case=LOWER); + blob.encode(blob=blob.decode(IDENTITY, 5, + encoded=req.http.pangram), + encoding=HEX, case=LOWER); set resp.http.hexucparam = - blob.encode(blob=blob.decode_n(5, IDENTITY, req.http.pangram), - encoding=HEX, case=UPPER); + blob.encode(blob=blob.decode(IDENTITY, 5, + encoded=req.http.pangram), + encoding=HEX, case=UPPER); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); @@ -66,68 +71,74 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob=blob.decode_n(10, HEX, req.http.hexucfoobar)); + blob=blob.decode(HEX, 10, + encoded=req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob=blob.decode_n(10, HEX, req.http.hexlcfoobar)); + blob=blob.decode(HEX, 10, + encoded=req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob=blob.decode_n(12, HEX, req.http.hexhobbesuc)); + blob=blob.decode(HEX, 12, + encoded=req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob=blob.decode_n(12, HEX, req.http.hexhobbeslc)); + blob=blob.decode(HEX, 12, + encoded=req.http.hexhobbeslc)); set resp.http.decalluc = blob.encode(BASE64, - blob=blob.decode_n(12, HEX, req.http.hexalluc)); + blob=blob.decode(HEX, 12, encoded=req.http.hexalluc)); set resp.http.decalllc = blob.encode(BASE64, - blob=blob.decode_n(12, HEX, req.http.hexalllc)); + blob=blob.decode(HEX, 12, encoded=req.http.hexalllc)); set resp.http.decallucodd = - blob.encode(BASE64, blob=blob.decode_n(11, HEX, - req.http.hexallucodd)); + blob.encode(BASE64, blob=blob.decode(HEX, 11, + encoded=req.http.hexallucodd)); set resp.http.decalllcodd = - blob.encode(BASE64, blob=blob.decode_n(11, HEX, - req.http.hexalllcodd)); + blob.encode(BASE64, blob=blob.decode(HEX, 11, + encoded=req.http.hexalllcodd)); set resp.http.decempty = - blob.encode(IDENTITY, blob=blob.decode_n(5, HEX, "")); + blob.encode(IDENTITY, blob=blob.decode(HEX, 5, encoded="")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob=blob.decode_n(1, HEX, "00")); + blob.encode(IDENTITY, blob=blob.decode(HEX, 1, encoded="00")); set resp.http.decemptynibble = - blob.encode(IDENTITY, blob=blob.decode_n(2, HEX, "0")); + blob.encode(IDENTITY, blob=blob.decode(HEX, 2, encoded="0")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob=blob.decode_n(5, HEX, req.http.unset + "" + blob=blob.decode(HEX, 5, encoded=req.http.unset + "" + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob=blob.decode_n(6, HEX, req.http.part1 + - "F6F206261722062617A2071757578")); + blob.encode(IDENTITY, blob=blob.decode(HEX, 6, + encoded=req.http.part1 + + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; set resp.http.dec3param = - blob.encode(blob=blob.decode_n(encoded=req.http.part1 + + blob.encode(blob=blob.decode(encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2, - decoding=HEX,n=8), + decoding=HEX, length=8), encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob=blob.decode_n(30, HEX, req.http.part1 + + blob.encode(IDENTITY, blob=blob.decode(HEX, 30, + encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob=blob.decode_n(20, HEX, "" + blob.encode(IDENTITY, blob=blob.decode(HEX, 20, encoded="" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" @@ -180,7 +191,8 @@ varnish v1 -vcl+backend { sub vcl_deliver { set req.http.foo = "123"; set resp.http.badhex = blob.encode(HEX, UPPER, - blob.decode_n(2, HEX, "g" + req.http.foo)); + blob.decode(HEX, 2, + encoded="g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index 25a7dee..e8ee70a 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -18,80 +18,83 @@ varnish v1 -vcl { {"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}; set resp.http.b64 = - blob.encode(BASE64, blob=blob.decode(IDENTITY, + blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded= req.http.pangram)); set resp.http.b64lc = - blob.encode(BASE64, LOWER, blob.decode(IDENTITY, + blob.encode(BASE64, LOWER, blob.decode(IDENTITY, encoded= req.http.pangram)); set resp.http.b64uc = - blob.encode(BASE64, UPPER, blob.decode(IDENTITY, + blob.encode(BASE64, UPPER, blob.decode(IDENTITY, encoded= req.http.pangram)); set resp.http.b64hobbes = - blob.encode(BASE64, blob=blob.decode(IDENTITY, + blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded= req.http.hobbes)); set resp.http.b64all = - blob.encode(BASE64, blob=blob.decode(HEX, req.http.hexall)); + blob.encode(BASE64, blob=blob.decode(HEX, + encoded=req.http.hexall)); set resp.http.b64url = blob.encode(BASE64URL, - blob=blob.decode(IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urllc = blob.encode(BASE64URL, LOWER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urluc = blob.encode(BASE64URL, UPPER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urlhobbes = blob.encode(BASE64URL, - blob=blob.decode(IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, encoded=req.http.hobbes)); set resp.http.b64urlall = - blob.encode(BASE64URL, blob=blob.decode(HEX, req.http.hexall)); + blob.encode(BASE64URL, blob=blob.decode(HEX, + encoded=req.http.hexall)); set resp.http.b64urlnopad = blob.encode(BASE64URLNOPAD, - blob=blob.decode(IDENTITY, req.http.pangram)); + blob=blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urlnopadlc = blob.encode(BASE64URLNOPAD, LOWER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urlnopaduc = blob.encode(BASE64URLNOPAD, UPPER, - blob.decode(IDENTITY, req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64nopadhobbes = blob.encode(BASE64URLNOPAD, - blob=blob.decode(IDENTITY, req.http.hobbes)); + blob=blob.decode(IDENTITY, encoded=req.http.hobbes)); set resp.http.b64nopadall = blob.encode(BASE64URLNOPAD, - blob=blob.decode(HEX, req.http.hexall)); + blob=blob.decode(HEX, encoded=req.http.hexall)); set resp.http.b64empty = - blob.encode(BASE64, blob=blob.decode(IDENTITY, "")); + blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded="")); set resp.http.urlempty = - blob.encode(BASE64URL, blob=blob.decode(IDENTITY, "")); + blob.encode(BASE64URL, blob=blob.decode(IDENTITY, encoded="")); set resp.http.nopadempty = - blob.encode(BASE64URLNOPAD, blob=blob.decode(IDENTITY, "")); + blob.encode(BASE64URLNOPAD, + blob=blob.decode(IDENTITY, encoded="")); set resp.http.b64param = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=BASE64, case=LOWER); set resp.http.b64urlparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=BASE64URL, case=UPPER); set resp.http.b64urlnopadparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=BASE64URLNOPAD, case=LOWER); set resp.http.b64xcode = @@ -157,66 +160,71 @@ varnish v1 -vcl { {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; set resp.http.dec = blob.encode(IDENTITY, blob= - blob.decode(BASE64, req.http.foobarbazquux)); + blob.decode(BASE64, + encoded=req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, - blob=blob.decode(BASE64, req.http.pangram)); + blob=blob.decode(BASE64, encoded=req.http.pangram)); set resp.http.b64dechobbes = blob.encode(IDENTITY, - blob=blob.decode(BASE64, req.http.hobbes)); + blob=blob.decode(BASE64, encoded=req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEX, blob=blob.decode(BASE64, req.http.all)); + blob.encode(HEX, blob=blob.decode(BASE64, encoded=req.http.all)); set resp.http.urldechobbes = blob.encode(IDENTITY, blob=blob.decode(BASE64URL, - req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.urldecall = blob.encode(HEX, - blob=blob.decode(BASE64URL, req.http.allurl)); + blob=blob.decode(BASE64URL, encoded=req.http.allurl)); set resp.http.nopaddechobbes = - blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, - req.http.hobbesnopad)); + blob.encode(IDENTITY, + blob=blob.decode(BASE64URLNOPAD, + encoded=req.http.hobbesnopad)); set resp.http.nopaddecall = blob.encode(HEX, - blob=blob.decode(BASE64URLNOPAD, req.http.allurl)); + blob=blob.decode(BASE64URLNOPAD, + encoded=req.http.allurl)); set resp.http.b64empty = - blob.encode(IDENTITY, blob=blob.decode(BASE64, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64, encoded="")); set resp.http.urlempty = - blob.encode(IDENTITY, blob=blob.decode(BASE64URL, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, encoded="")); set resp.http.nopadempty = - blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, "")); + blob.encode(IDENTITY, + blob=blob.decode(BASE64URLNOPAD, encoded="")); set resp.http.emptypieces = blob.encode(IDENTITY, blob= - blob.decode(BASE64, req.http.unset + "" + req.http.unset + blob.decode(BASE64, encoded=req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, - blob=blob.decode(BASE64, req.http.foobarbazquux)); + blob=blob.decode(BASE64, + encoded=req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw==")); + encoded=resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64, - resp.http.l + "0hlbGxvIHdvcmxkLw" + encoded=resp.http.l + "0hlbGxvIHdvcmxkLw" + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64, - resp.http.l + "0hlb" + resp.http.mid1 + encoded=resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad)); @@ -226,22 +234,22 @@ varnish v1 -vcl { + resp.http.pad, decoding=BASE64), encoding=IDENTITY); - set resp.http.decnopad = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, - "L0hlbGxvIHdvcmxkLw")); + set resp.http.decnopad + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, + encoded="L0hlbGxvIHdvcmxkLw")); set resp.http.decnopad2pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, - resp.http.l + "0hlbGxvIHdvcmxkLw")); + encoded=resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, - resp.http.l + "0hlb" + resp.http.mid1 - + "H" + resp.http.mid2 + "kLw")); + encoded=resp.http.l + "0hlb" + resp.http.mid1 + + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, encoded= "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); @@ -288,15 +296,16 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/base64") { set resp.http.bad64 = blob.encode(IDENTITY, - blob=blob.decode(BASE64, "-_-_" + req.http.foo)); + blob=blob.decode(BASE64, encoded="-_-_" + req.http.foo)); } elsif (req.url == "/base64url") { set resp.http.badurl = blob.encode(IDENTITY, - blob=blob.decode(BASE64URL, "+/+/" + req.http.foo)); + blob=blob.decode(BASE64URL, encoded="+/+/" + req.http.foo)); } elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, "TWFu" + req.http.foo)); + blob=blob.decode(BASE64URLNOPAD, + encoded="TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00038.vtc b/bin/varnishtest/tests/m00038.vtc index 4e7e334..a585981 100644 --- a/bin/varnishtest/tests/m00038.vtc +++ b/bin/varnishtest/tests/m00038.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob base64 decode_n()" +varnishtest "VMOD blob base64 decode() n chars" varnish v1 -vcl { import blob; @@ -22,106 +22,105 @@ varnish v1 -vcl { set resp.http.dec = blob.encode(IDENTITY, - blob=blob.decode_n(8, BASE64, - req.http.foobarbazquux)); + blob=blob.decode(BASE64, 8, + req.http.foobarbazquux)); set resp.http.deceq = blob.encode(IDENTITY, - blob=blob.decode_n(20, BASE64, - req.http.foobarbazquux)); + blob=blob.decode(BASE64, 20, + req.http.foobarbazquux)); set resp.http.declong = blob.encode(IDENTITY, - blob=blob.decode_n(30, BASE64, - req.http.foobarbazquux)); + blob=blob.decode(BASE64, 30, + req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, - blob=blob.decode_n(12, BASE64, req.http.pangram)); + blob=blob.decode(BASE64, 12, req.http.pangram)); set resp.http.b64dechobbes = blob.encode(IDENTITY, - blob=blob.decode_n(24, BASE64, req.http.hobbes)); + blob=blob.decode(BASE64, 24, req.http.hobbes)); set resp.http.b64decall = - blob.encode(HEX, blob=blob.decode_n(128, BASE64, req.http.all)); + blob.encode(HEX, blob=blob.decode(BASE64, 128, req.http.all)); set resp.http.urldechobbes = - blob.encode(IDENTITY, blob=blob.decode_n(180, BASE64URL, - req.http.hobbes)); + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, 180, + req.http.hobbes)); set resp.http.urldecall = - blob.encode(HEX, - blob=blob.decode_n(256, BASE64URL, + blob.encode(HEX, blob=blob.decode(BASE64URL, 256, req.http.allurl)); set resp.http.nopaddechobbes = blob.encode(IDENTITY, - blob=blob.decode_n(500, BASE64URLNOPAD, - req.http.hobbesnopad)); + blob=blob.decode(BASE64URLNOPAD, 500, + req.http.hobbesnopad)); set resp.http.nopaddecall = - blob.encode(HEX, blob=blob.decode_n(256, BASE64URLNOPAD, + blob.encode(HEX, blob=blob.decode(BASE64URLNOPAD, 256, req.http.allurl)); set resp.http.b64empty = - blob.encode(IDENTITY, blob=blob.decode_n(0, BASE64, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64, 0, "")); set resp.http.urlempty = - blob.encode(IDENTITY, blob=blob.decode_n(1, BASE64URL, "")); + blob.encode(IDENTITY, blob=blob.decode(BASE64URL, 1, "")); set resp.http.nopadempty = blob.encode(IDENTITY, - blob=blob.decode_n(0, BASE64URLNOPAD, "")); + blob=blob.decode(BASE64URLNOPAD, 0, "")); set resp.http.emptypieces = blob.encode(IDENTITY, - blob=blob.decode_n(0, BASE64, req.http.unset + "" + req.http.unset + blob=blob.decode(BASE64, 0, req.http.unset + "" + req.http.unset + "" + req.http.unset + "")); set resp.http.decenc = blob.encode(BASE64, - blob=blob.decode_n(20, BASE64, - req.http.foobarbazquux)); + blob=blob.decode(BASE64, 20, + req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces - = blob.encode(IDENTITY, blob=blob.decode_n(8, BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, 8, resp.http.l + "0hlbGxvIHdvcmxkLw==")); set resp.http.pad = "=="; set resp.http.dec3pieces - = blob.encode(IDENTITY, blob=blob.decode_n(12, BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, 12, resp.http.l + "0hlbGxvIHdvcmxkLw" + resp.http.pad)); set resp.http.mid1 = "GxvI"; set resp.http.mid2 = "dvcmx"; set resp.http.dec7pieces - = blob.encode(IDENTITY, blob=blob.decode_n(16, BASE64, + = blob.encode(IDENTITY, blob=blob.decode(BASE64, 16, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw" + resp.http.pad)); set resp.http.dec7param - = blob.encode(blob=blob.decode_n(encoded=resp.http.l + = blob.encode(blob=blob.decode(encoded=resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 - + "kLw" + resp.http.pad, decoding=BASE64, n=20), - encoding=IDENTITY); + + "kLw" + resp.http.pad, decoding=BASE64, + length=20), encoding=IDENTITY); set resp.http.decnopad = blob.encode(IDENTITY, - blob=blob.decode_n(18, BASE64URLNOPAD, - "L0hlbGxvIHdvcmxkLw")); + blob=blob.decode(BASE64URLNOPAD, 18, + "L0hlbGxvIHdvcmxkLw")); set resp.http.decnopad2pieces - = blob.encode(IDENTITY, blob=blob.decode_n(19, BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, 19, resp.http.l + "0hlbGxvIHdvcmxkLw")); set resp.http.decnopad6pieces - = blob.encode(IDENTITY, blob=blob.decode_n(18, BASE64URLNOPAD, + = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, 18, resp.http.l + "0hlb" + resp.http.mid1 + "H" + resp.http.mid2 + "kLw")); set resp.http.decnopadlong = blob.encode(IDENTITY, - blob=blob.decode_n(60, BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, 60, "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" )); @@ -170,16 +169,16 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/base64") { set resp.http.bad64 = blob.encode(IDENTITY, - blob=blob.decode_n(8, BASE64, "-_-_" + req.http.foo)); + blob=blob.decode(BASE64, 8, "-_-_" + req.http.foo)); } elsif (req.url == "/base64url") { set resp.http.badurl = blob.encode(IDENTITY, - blob=blob.decode_n(8, BASE64URL, "+/+/" + req.http.foo)); + blob=blob.decode(BASE64URL, 8, "+/+/" + req.http.foo)); } elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, - blob=blob.decode_n(8, BASE64URLNOPAD, - "TWFu" + req.http.foo)); + blob=blob.decode(BASE64URLNOPAD, 8, + "TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index 440c7ed..2149585 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -22,74 +22,92 @@ varnish v1 -vcl { {"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="}; set resp.http.url = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.pangram)); set resp.http.urllc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.pangram)); set resp.http.urluc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.pangram)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.pangram)); set resp.http.hobbes = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.hobbeslc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.hobbesuc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.hobbes)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.hobbes)); set resp.http.umlauts = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.umlauts)); set resp.http.umlautslc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.umlauts)); set resp.http.umlautsuc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.umlauts)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.umlauts)); set resp.http.phk = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.phkspeak)); set resp.http.phklc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.phkspeak)); set resp.http.phkuc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.phkspeak)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.phkspeak)); set resp.http.utf8 = - blob.encode(URL, blob=blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, blob=blob.decode(IDENTITY, + encoded=req.http.utf8)); set resp.http.utf8lc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, LOWER, blob.decode(IDENTITY, + encoded=req.http.utf8)); set resp.http.utf8uc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, req.http.utf8)); + blob.encode(URL, UPPER, blob.decode(IDENTITY, + encoded=req.http.utf8)); set resp.http.all = - blob.encode(URL, blob=blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, blob=blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.all-lc = - blob.encode(URL, LOWER, blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, LOWER, blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.all-uc = - blob.encode(URL, UPPER, blob.decode(BASE64, req.http.b64all)); + blob.encode(URL, UPPER, blob.decode(BASE64, + encoded=req.http.b64all)); set resp.http.empty = - blob.encode(URL, blob=blob.decode(IDENTITY, "")); + blob.encode(URL, blob=blob.decode(IDENTITY, encoded="")); set resp.http.empty-lc = - blob.encode(URL, LOWER, blob.decode(IDENTITY, "")); + blob.encode(URL, LOWER, blob.decode(IDENTITY, encoded="")); set resp.http.empty-uc = - blob.encode(URL, UPPER, blob.decode(IDENTITY, "")); + blob.encode(URL, UPPER, blob.decode(IDENTITY, encoded="")); set resp.http.urllcparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=URL, case=LOWER); set resp.http.urlucparam = - blob.encode(blob=blob.decode(IDENTITY, req.http.pangram), + blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), encoding=URL, case=UPPER); } } -start @@ -148,69 +166,73 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlucfoobar)); + blob=blob.decode(URL, encoded=req.http.urlucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urllcfoobar)); + blob=blob.decode(URL, encoded=req.http.urllcfoobar)); set resp.http.decmixed = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlmixedfoobar)); + blob=blob.decode(URL, + encoded=req.http.urlmixedfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlhobbesuc)); + blob=blob.decode(URL, encoded=req.http.urlhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlhobbeslc)); + blob=blob.decode(URL, encoded=req.http.urlhobbeslc)); set resp.http.decumlautsuc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlucumlauts)); + blob=blob.decode(URL, encoded=req.http.urlucumlauts)); set resp.http.decumlautslc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urllcumlauts)); + blob=blob.decode(URL, encoded=req.http.urllcumlauts)); set resp.http.decphkuc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlucphk)); + blob=blob.decode(URL, encoded=req.http.urlucphk)); set resp.http.decphklc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urllcphk)); + blob=blob.decode(URL, encoded=req.http.urllcphk)); set resp.http.decutf8uc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urlucutf8)); + blob=blob.decode(URL, encoded=req.http.urlucutf8)); set resp.http.decutf8lc = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.urllcutf8)); + blob=blob.decode(URL, encoded=req.http.urllcutf8)); set resp.http.decalluc = - blob.encode(BASE64, blob=blob.decode(URL, req.http.urlalluc)); + blob.encode(BASE64, blob=blob.decode(URL, + encoded=req.http.urlalluc)); set resp.http.decalllc = - blob.encode(BASE64, blob=blob.decode(URL, req.http.urlalllc)); + blob.encode(BASE64, blob=blob.decode(URL, + encoded=req.http.urlalllc)); set resp.http.decempty = - blob.encode(IDENTITY, blob=blob.decode(URL, "")); + blob.encode(IDENTITY, blob=blob.decode(URL, encoded="")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob=blob.decode(URL, "%00")); + blob.encode(IDENTITY, blob=blob.decode(URL, encoded="%00")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob=blob.decode(URL, req.http.unset + "" + blob=blob.decode(URL, encoded=req.http.unset + "" + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = - blob.encode(IDENTITY, blob=blob.decode(URL, req.http.part1 + - "20bar%20baz%20quux")); + blob.encode(IDENTITY, blob=blob.decode(URL, + encoded=req.http.part1 + + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = @@ -220,11 +242,12 @@ varnish v1 -vcl { encoding=IDENTITY); set resp.http.dec3pieces = - blob.encode(IDENTITY, blob=blob.decode(URL, req.http.part1 + - "20bar%20baz%2" + req.http.part2)); + blob.encode(IDENTITY, blob=blob.decode(URL, encoded= + req.http.part1 + "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = - blob.encode(IDENTITY, blob=blob.decode(URL, "" + req.http.unset + blob.encode(IDENTITY, blob=blob.decode(URL, encoded= + "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -270,19 +293,20 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { set resp.http.bad - = blob.encode(URL, UPPER, blob.decode(URL, "%")); + = blob.encode(URL, UPPER, blob.decode(URL, + encoded="%")); } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode(URL, "%2")); + blob.decode(URL, encoded="%2")); } elsif (req.url == "/percent-q") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode(URL, "%q")); + blob.decode(URL, encoded="%q")); } elsif (req.url == "/percent-two-q") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode(URL, "%2q")); + blob.decode(URL, encoded="%2q")); } } } diff --git a/bin/varnishtest/tests/m00040.vtc b/bin/varnishtest/tests/m00040.vtc index 2355ca9..2177f8a 100644 --- a/bin/varnishtest/tests/m00040.vtc +++ b/bin/varnishtest/tests/m00040.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob decode_n() with URL" +varnishtest "VMOD blob decode() n chars with URL" varnish v1 -vcl { import blob; @@ -25,85 +25,85 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, - blob=blob.decode_n(9, URL, req.http.urlucfoobar)); + blob=blob.decode(URL, 9, req.http.urlucfoobar)); set resp.http.declc = blob.encode(IDENTITY, - blob=blob.decode_n(12, URL, req.http.urllcfoobar)); + blob=blob.decode(URL, 12, req.http.urllcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, - blob=blob.decode_n(27, URL, req.http.urlhobbesuc)); + blob=blob.decode(URL, 27, req.http.urlhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, - blob=blob.decode_n(27, URL, req.http.urlhobbeslc)); + blob=blob.decode(URL, 27, req.http.urlhobbeslc)); set resp.http.decumlautsuc = blob.encode(IDENTITY, - blob=blob.decode_n(17, URL, req.http.urlucumlauts)); + blob=blob.decode(URL, 17, req.http.urlucumlauts)); set resp.http.decumlautslc = blob.encode(IDENTITY, - blob=blob.decode_n(25, URL, req.http.urllcumlauts)); + blob=blob.decode(URL, 25, req.http.urllcumlauts)); set resp.http.decphkuc = blob.encode(IDENTITY, - blob=blob.decode_n(18, URL, req.http.urlucphk)); + blob=blob.decode(URL, 18, req.http.urlucphk)); set resp.http.decphklc = blob.encode(IDENTITY, - blob=blob.decode_n(30, URL, req.http.urllcphk)); + blob=blob.decode(URL, 30, req.http.urllcphk)); set resp.http.decutf8uc = blob.encode(IDENTITY, - blob=blob.decode_n(9, URL, req.http.urlucutf8)); + blob=blob.decode(URL, 9, req.http.urlucutf8)); set resp.http.decutf8lc = blob.encode(IDENTITY, - blob=blob.decode_n(18, URL, req.http.urllcutf8)); + blob=blob.decode(URL, 18, req.http.urllcutf8)); set resp.http.decalluc = blob.encode(HEX, - blob=blob.decode_n(252, URL, req.http.urlalluc)); + blob=blob.decode(URL, 252, req.http.urlalluc)); set resp.http.decalllc = blob.encode(HEX, UPPER, - blob.decode_n(252, URL, req.http.urlalllc)); + blob.decode(URL, 252, req.http.urlalllc)); set resp.http.decempty = - blob.encode(IDENTITY, blob=blob.decode_n(10, URL, "")); + blob.encode(IDENTITY, blob=blob.decode(URL, 10, "")); set resp.http.decemptybyte = - blob.encode(IDENTITY, blob=blob.decode_n(3, URL, "%00")); + blob.encode(IDENTITY, blob=blob.decode(URL, 3, "%00")); set resp.http.decemptypieces = blob.encode(IDENTITY, - blob=blob.decode_n(1, URL, req.http.unset + "" - + req.http.unset + "")); + blob=blob.decode(URL, 1, req.http.unset + "" + + req.http.unset + "")); set req.http.part1 = "foo%"; set resp.http.dec2pieces = blob.encode(IDENTITY, - blob=blob.decode_n(6, URL, req.http.part1 + - "20bar%20baz%20quux")); + blob=blob.decode(URL, 6, req.http.part1 + + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = - blob.encode(blob=blob.decode_n(encoded=req.http.part1 + + blob.encode(blob=blob.decode(encoded=req.http.part1 + "20bar%20baz%2" + req.http.part2, - decoding=URL, n=12), + decoding=URL, length=12), encoding=IDENTITY); set resp.http.dec3pieces = blob.encode(IDENTITY, - blob=blob.decode_n(18, URL, req.http.part1 - + "20bar%20baz%2" - + req.http.part2)); + blob=blob.decode(URL, 18, req.http.part1 + + "20bar%20baz%2" + + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, - blob=blob.decode_n(24, URL, "" + req.http.unset + blob=blob.decode(URL, 24, "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -148,19 +148,19 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/percent") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode_n(1, URL, "%20")); + blob.decode(URL, 1, "%20")); } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URL, UPPER, - blob.decode_n(2, URL, "%20")); + blob.decode(URL, 2, "%20")); } elsif (req.url == "/comma") { set resp.http.good = blob.encode(IDENTITY, blob= - blob.decode_n(3, URL, "%2c%q")); + blob.decode(URL, 3, "%2c%q")); } elsif (req.url == "/colon") { set resp.http.good = blob.encode(IDENTITY, blob= - blob.decode_n(3, URL, "%3a%2q")); + blob.decode(URL, 3, "%3a%2q")); } } } diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index cfed6ae..4056d9c 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -39,19 +39,19 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { = blob.transcode(IDENTITY, HEX, encoded=req.http.hobbes); set resp.http.id2hexuc - = blob.transcode(IDENTITY, HEX, UPPER, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, UPPER, encoded=req.http.hobbes); set resp.http.id2hexlc - = blob.transcode(IDENTITY, HEX, LOWER, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, LOWER, encoded=req.http.hobbes); set resp.http.id2url = blob.transcode(IDENTITY, URL, encoded=req.http.foobar); set resp.http.id2urluc - = blob.transcode(IDENTITY, URL, UPPER, req.http.foobar); + = blob.transcode(IDENTITY, URL, UPPER, encoded=req.http.foobar); set resp.http.id2urllc - = blob.transcode(IDENTITY, URL, LOWER, req.http.foobar); + = blob.transcode(IDENTITY, URL, LOWER, encoded=req.http.foobar); set resp.http.b642id = blob.transcode(BASE64, IDENTITY, encoded=req.http.hobbesb64); @@ -81,19 +81,19 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { = blob.transcode(HEX, URL, encoded=req.http.hexalldown); set resp.http.hexalldown2urluc - = blob.transcode(HEX, URL, UPPER, req.http.hexalldown); + = blob.transcode(HEX, URL, UPPER, encoded=req.http.hexalldown); set resp.http.hexalldown2urllc - = blob.transcode(HEX, URL, LOWER, req.http.hexalldown); + = blob.transcode(HEX, URL, LOWER, encoded=req.http.hexalldown); set resp.http.hexallup2url = blob.transcode(HEX, URL, encoded=req.http.hexallup); set resp.http.hexallup2urluc - = blob.transcode(HEX, URL, UPPER, req.http.hexallup); + = blob.transcode(HEX, URL, UPPER, encoded=req.http.hexallup); set resp.http.hexallup2urllc - = blob.transcode(HEX, URL, LOWER, req.http.hexallup); + = blob.transcode(HEX, URL, LOWER, encoded=req.http.hexallup); } } -start @@ -155,64 +155,64 @@ varnish v1 -vcl { = blob.transcode(BASE64, HEX, encoded=req.http.b64all); set resp.http.b64all2hexuc - = blob.transcode(BASE64, HEX, UPPER, req.http.b64all); + = blob.transcode(BASE64, HEX, UPPER, encoded=req.http.b64all); set resp.http.b64all2hexlc - = blob.transcode(BASE64, HEX, LOWER, req.http.b64all); + = blob.transcode(BASE64, HEX, LOWER, encoded=req.http.b64all); set resp.http.b64allurl2hex = blob.transcode(BASE64URL, HEX, encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc - = blob.transcode(BASE64URL, HEX, UPPER, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, UPPER, encoded=req.http.b64allurl); set resp.http.b64allurl2hexlc - = blob.transcode(BASE64URL, HEX, LOWER, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, LOWER, encoded=req.http.b64allurl); set resp.http.b64all2url = blob.transcode(BASE64, URL, encoded=req.http.b64all); set resp.http.b64all2urluc - = blob.transcode(BASE64, URL, UPPER, req.http.b64all); + = blob.transcode(BASE64, URL, UPPER, encoded=req.http.b64all); set resp.http.b64all2urllc - = blob.transcode(BASE64, URL, LOWER, req.http.b64all); + = blob.transcode(BASE64, URL, LOWER, encoded=req.http.b64all); set resp.http.b64allurl2url = blob.transcode(BASE64URL, URL, encoded=req.http.b64allurl); set resp.http.b64allurl2urluc - = blob.transcode(BASE64URL, URL, UPPER, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, UPPER, encoded=req.http.b64allurl); set resp.http.b64allurl2urllc - = blob.transcode(BASE64URL, URL, LOWER, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, LOWER, encoded=req.http.b64allurl); set resp.http.hexuc2hex = blob.transcode(HEX, HEX, encoded="0123456789ABCDEF"); set resp.http.hexuc2hexuc - = blob.transcode(HEX, HEX, UPPER, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, UPPER, encoded="0123456789ABCDEF"); set resp.http.hexlc2hexlc - = blob.transcode(HEX, HEX, LOWER, "0123456789abcdef"); + = blob.transcode(HEX, HEX, LOWER, encoded="0123456789abcdef"); set resp.http.hexlc2hex = blob.transcode(HEX, HEX, encoded="0123456789abcdef"); set resp.http.hexuc2hexlc - = blob.transcode(HEX, HEX, LOWER, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, LOWER, encoded="0123456789ABCDEF"); set resp.http.hexlc2hexuc - = blob.transcode(HEX, HEX, UPPER, "0123456789abcdef"); + = blob.transcode(HEX, HEX, UPPER, encoded="0123456789abcdef"); set resp.http.hexmix2hex = blob.transcode(HEX, HEX, encoded="0123456789ABCdef"); set resp.http.hexmix2hexuc - = blob.transcode(HEX, HEX, UPPER, "0123456789ABCdef"); + = blob.transcode(HEX, HEX, UPPER, encoded="0123456789ABCdef"); set resp.http.hexmix2hexlc - = blob.transcode(HEX, HEX, LOWER, "0123456789abcDEF"); + = blob.transcode(HEX, HEX, LOWER, encoded="0123456789abcDEF"); set req.http.hexpart1 = "01234567"; set req.http.hexpart2 = "89abcdef"; @@ -336,37 +336,37 @@ varnish v1 -vcl { = blob.transcode(URL, URL, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urllc - = blob.transcode(URL, URL, LOWER, req.http.urlalldownuc); + = blob.transcode(URL, URL, LOWER, encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urluc - = blob.transcode(URL, URL, UPPER, req.http.urlalldownuc); + = blob.transcode(URL, URL, UPPER, encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2url = blob.transcode(URL, URL, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urllc - = blob.transcode(URL, URL, LOWER, req.http.urlalldownlc); + = blob.transcode(URL, URL, LOWER, encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urluc - = blob.transcode(URL, URL, UPPER, req.http.urlalldownlc); + = blob.transcode(URL, URL, UPPER, encoded=req.http.urlalldownlc); set resp.http.urlallupuc2url = blob.transcode(URL, URL, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urluc - = blob.transcode(URL, URL, UPPER, req.http.urlallupuc); + = blob.transcode(URL, URL, UPPER, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urllc - = blob.transcode(URL, URL, LOWER, req.http.urlallupuc); + = blob.transcode(URL, URL, LOWER, encoded=req.http.urlallupuc); set resp.http.urlalluplc2url = blob.transcode(URL, URL, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urluc - = blob.transcode(URL, URL, UPPER, req.http.urlalluplc); + = blob.transcode(URL, URL, UPPER, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urllc - = blob.transcode(URL, URL, LOWER, req.http.urlalluplc); + = blob.transcode(URL, URL, LOWER, encoded=req.http.urlalluplc); } } diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index 4a96c0f..ecd8b44 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob test transcode_n()" +varnishtest "VMOD blob test transcode() n chars" varnish v1 -vcl { import blob; @@ -22,76 +22,83 @@ varnish v1 -vcl { {"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"}; set resp.http.id2id - = blob.transcode_n(5, IDENTITY, IDENTITY, encoded="Hello world"); + = blob.transcode(IDENTITY, IDENTITY, length=5, + encoded="Hello world"); set resp.http.id2b64 - = blob.transcode_n(5, IDENTITY, BASE64, encoded=req.http.hobbes); + = blob.transcode(IDENTITY, BASE64, length=5, + encoded=req.http.hobbes); set resp.http.id2b64nopad - = blob.transcode_n(5, IDENTITY, BASE64URLNOPAD, - encoded=req.http.hobbes); + = blob.transcode(IDENTITY, BASE64URLNOPAD, length=5, + encoded=req.http.hobbes); set resp.http.id2hex - = blob.transcode_n(5, IDENTITY, HEX, encoded=req.http.hobbes); + = blob.transcode(IDENTITY, HEX, length=5, encoded=req.http.hobbes); set resp.http.id2hexuc - = blob.transcode_n(5, IDENTITY, HEX, UPPER, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, UPPER, 5, req.http.hobbes); set resp.http.id2hexlc - = blob.transcode_n(5, IDENTITY, HEX, LOWER, req.http.hobbes); + = blob.transcode(IDENTITY, HEX, LOWER, 5, req.http.hobbes); set resp.http.id2url - = blob.transcode_n(5, IDENTITY, URL, encoded=req.http.foobar); + = blob.transcode(IDENTITY, URL, length=5, encoded=req.http.foobar); set resp.http.id2urluc - = blob.transcode_n(5, IDENTITY, URL, UPPER, req.http.foobar); + = blob.transcode(IDENTITY, URL, UPPER, 5, req.http.foobar); set resp.http.id2urllc - = blob.transcode_n(5, IDENTITY, URL, LOWER, req.http.foobar); + = blob.transcode(IDENTITY, URL, LOWER, 5, req.http.foobar); set resp.http.b642id - = blob.transcode_n(8, BASE64, IDENTITY, encoded=req.http.hobbesb64); + = blob.transcode(BASE64, IDENTITY, length=8, + encoded=req.http.hobbesb64); set resp.http.hex2id - = blob.transcode_n(12, HEX, IDENTITY, encoded=req.http.hexhobbes); + = blob.transcode(HEX, IDENTITY, length=12, + encoded=req.http.hexhobbes); set resp.http.hexalldown2b64 - = blob.transcode_n(12, HEX, BASE64, encoded=req.http.hexalldown); + = blob.transcode(HEX, BASE64, length=12, + encoded=req.http.hexalldown); set resp.http.hexalldown2b64url - = blob.transcode_n(12, HEX, BASE64URL, encoded=req.http.hexalldown); + = blob.transcode(HEX, BASE64URL, length=12, + encoded=req.http.hexalldown); set resp.http.hexalldown2b64nopad - = blob.transcode_n(10, HEX, BASE64URLNOPAD, - encoded=req.http.hexalldown); + = blob.transcode(HEX, BASE64URLNOPAD, length=10, + encoded=req.http.hexalldown); set resp.http.hexallup2b64 - = blob.transcode_n(12, HEX, BASE64, encoded=req.http.hexallup); + = blob.transcode(HEX, BASE64, length=12, encoded=req.http.hexallup); set resp.http.hexallup2b64url - = blob.transcode_n(10, HEX, BASE64URL, encoded=req.http.hexallup); + = blob.transcode(HEX, BASE64URL, length=10, + encoded=req.http.hexallup); set resp.http.hexallup2b64nopad - = blob.transcode_n(10, HEX, BASE64URLNOPAD, - encoded=req.http.hexallup); + = blob.transcode(HEX, BASE64URLNOPAD, length=10, + encoded=req.http.hexallup); set resp.http.hexalldown2url - = blob.transcode_n(12, HEX, URL, encoded=req.http.hexalldown); + = blob.transcode(HEX, URL, length=12, encoded=req.http.hexalldown); set resp.http.hexalldown2urluc - = blob.transcode_n(12, HEX, URL, UPPER, req.http.hexalldown); + = blob.transcode(HEX, URL, UPPER, 12, req.http.hexalldown); set resp.http.hexalldown2urllc - = blob.transcode_n(12, HEX, URL, LOWER, req.http.hexalldown); + = blob.transcode(HEX, URL, LOWER, 12, req.http.hexalldown); set resp.http.hexallup2url - = blob.transcode_n(12, HEX, URL, encoded=req.http.hexallup); + = blob.transcode(HEX, URL, length=12, encoded=req.http.hexallup); set resp.http.hexallup2urluc - = blob.transcode_n(12, HEX, URL, UPPER, req.http.hexallup); + = blob.transcode(HEX, URL, UPPER, 12, req.http.hexallup); set resp.http.hexallup2urllc - = blob.transcode_n(12, HEX, URL, LOWER, req.http.hexallup); + = blob.transcode(HEX, URL, LOWER, 12, req.http.hexallup); } } -start @@ -140,89 +147,91 @@ varnish v1 -vcl { {"AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZaaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz0000111122223333444455556666777788889999----____"}; set resp.http.b64all2hex - = blob.transcode_n(8, BASE64, HEX, encoded=req.http.b64all); + = blob.transcode(BASE64, HEX, length=8, encoded=req.http.b64all); set resp.http.b64all2hexuc - = blob.transcode_n(8, BASE64, HEX, UPPER, req.http.b64all); + = blob.transcode(BASE64, HEX, UPPER, 8, req.http.b64all); set resp.http.b64all2hexlc - = blob.transcode_n(8, BASE64, HEX, LOWER, req.http.b64all); + = blob.transcode(BASE64, HEX, LOWER, 8, req.http.b64all); set resp.http.b64allurl2hex - = blob.transcode_n(8, BASE64URL, HEX, encoded=req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, length=8, + encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc - = blob.transcode_n(8, BASE64URL, HEX, UPPER, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, UPPER, 8, req.http.b64allurl); set resp.http.b64allurl2hexlc - = blob.transcode_n(8, BASE64URL, HEX, LOWER, req.http.b64allurl); + = blob.transcode(BASE64URL, HEX, LOWER, 8, req.http.b64allurl); set resp.http.b64all2url - = blob.transcode_n(8, BASE64, URL, encoded=req.http.b64all); + = blob.transcode(BASE64, URL, length=8, encoded=req.http.b64all); set resp.http.b64all2urluc - = blob.transcode_n(8, BASE64, URL, UPPER, req.http.b64all); + = blob.transcode(BASE64, URL, UPPER, 8, req.http.b64all); set resp.http.b64all2urllc - = blob.transcode_n(8, BASE64, URL, LOWER, req.http.b64all); + = blob.transcode(BASE64, URL, LOWER, 8, req.http.b64all); set resp.http.b64allurl2url - = blob.transcode_n(8, BASE64URL, URL, encoded=req.http.b64allurl); + = blob.transcode(BASE64URL, URL, length=8, + encoded=req.http.b64allurl); set resp.http.b64allurl2urluc - = blob.transcode_n(8, BASE64URL, URL, UPPER, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, UPPER, 8, req.http.b64allurl); set resp.http.b64allurl2urllc - = blob.transcode_n(8, BASE64URL, URL, LOWER, req.http.b64allurl); + = blob.transcode(BASE64URL, URL, LOWER, 8, req.http.b64allurl); set resp.http.hexuc2hex - = blob.transcode_n(10, HEX, HEX, encoded="0123456789ABCDEF"); + = blob.transcode(HEX, HEX, length=10, encoded="0123456789ABCDEF"); set resp.http.hexuc2hexuc - = blob.transcode_n(10, HEX, HEX, UPPER, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, UPPER, 10, "0123456789ABCDEF"); set resp.http.hexlc2hex - = blob.transcode_n(10, HEX, HEX, encoded="0123456789abcdef"); + = blob.transcode(HEX, HEX, length=10, encoded="0123456789abcdef"); set resp.http.hexlc2hexlc - = blob.transcode_n(10, HEX, HEX, LOWER, "0123456789abcdef"); + = blob.transcode(HEX, HEX, LOWER, 10, "0123456789abcdef"); set resp.http.hexuc2hexlc - = blob.transcode_n(9, HEX, HEX, LOWER, "0123456789ABCDEF"); + = blob.transcode(HEX, HEX, LOWER, 9, "0123456789ABCDEF"); set resp.http.hexlc2hexuc - = blob.transcode_n(9, HEX, HEX, UPPER, "0123456789abcdef"); + = blob.transcode(HEX, HEX, UPPER, 9, "0123456789abcdef"); set resp.http.hexmix2hex - = blob.transcode_n(13, HEX, HEX, encoded="0123456789abcDEF"); + = blob.transcode(HEX, HEX, length=13, encoded="0123456789abcDEF"); set resp.http.hexmix2hexuc - = blob.transcode_n(15, HEX, HEX, UPPER, "0123456789ABCdef"); + = blob.transcode(HEX, HEX, UPPER, 15, "0123456789ABCdef"); set resp.http.hexmix2hexlc - = blob.transcode_n(13, HEX, HEX, LOWER, "0123456789abcDEF"); + = blob.transcode(HEX, HEX, LOWER, 13, "0123456789abcDEF"); set req.http.hexpart1 = "01234567"; set req.http.hexpart2 = "89abcdef"; set resp.http.hexparam - = blob.transcode_n(encoded="" + req.http.unset + "" + = blob.transcode(encoded="" + req.http.unset + "" + req.http.unset + "" + req.http.hexpart1 + "" + req.http.unset + "" + req.http.unset + req.http.hexpart2, decoding=HEX, - encoding=HEX, n=10, case=UPPER); + encoding=HEX, length=10, case=UPPER); set resp.http.b642b64 - = blob.transcode_n(36, BASE64, BASE64, encoded= + = blob.transcode(BASE64, BASE64, length=36, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789+/"); set resp.http.b64url2b64url = - blob.transcode_n(34, BASE64URL, BASE64URL, encoded= + blob.transcode(BASE64URL, BASE64URL, length=34, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); set resp.http.b64urlnopad2b64urlnopad = - blob.transcode_n(34, BASE64URLNOPAD, BASE64URLNOPAD, encoded= + blob.transcode(BASE64URLNOPAD, BASE64URLNOPAD, length=34, encoded= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef" + "ghijklmnopqrstuvwxyz0123456789-_"); @@ -276,88 +285,98 @@ varnish v1 -vcl { set req.http.urlalldownlc = "%ff%fe%fd%fc%fb%fa%f9%f8%f7%f6%f5%f4%f3%f2%f1%f0%ef%ee%ed%ec%eb%ea%e9%e8%e7%e6%e5%e4%e3%e2%e1%e0%df%de%dd%dc%db%da%d9%d8%d7%d6%d5%d4%d3%d2%d1%d0%cf%ce%cd%cc%cb%ca%c9%c8%c7%c6%c5%c4%c3%c2%c1%c0%bf%be%bd%bc%bb%ba%b9%b8%b7%b6%b5%b4%b3%b2%b1%b0%af%ae%ad%ac%ab%aa%a9%a8%a7%a6%a5%a4%a3%a2%a1%a0%9f%9e%9d%9c%9b%9a%99%98%97%96%95%94%93%92%91%90%8f%8e%8d%8c%8b%8a%89%88%87%86%85%84%83%82%81%80%7f~%7d%7c%7bzyxwvutsrqponmlkjihgfedcba%60_%5e%5d%5c%5bZYXWVUTSRQPONMLKJIHGFEDCBA%40%3f%3e%3d%3c%3b%3a9876543210%2f.-%2c%2b%2a%29%28%27%26%25%24%23%22%21%20%1f%1e%1d%1c%1b%1a%19%18%17%16%15%14%13%12%11%10%0f%0e%0d%0c%0b%0a%09%08%07%06%05%04%03%02%01%00"; set resp.http.urluc2id - = blob.transcode_n(27, URL, IDENTITY, encoded=req.http.urlhobbesuc); + = blob.transcode(URL, IDENTITY, length=27, + encoded=req.http.urlhobbesuc); set resp.http.urllc2id - = blob.transcode_n(63, URL, IDENTITY, encoded=req.http.urlhobbeslc); + = blob.transcode(URL, IDENTITY, length=63, + encoded=req.http.urlhobbeslc); set resp.http.urlalldownuc2b64 - = blob.transcode_n(18, URL, BASE64, encoded=req.http.urlalldownuc); + = blob.transcode(URL, BASE64, length=18, + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64url - = blob.transcode_n(15, URL, BASE64URL, - encoded=req.http.urlalldownuc); + = blob.transcode(URL, BASE64URL, length=15, + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64nopad - = blob.transcode_n(15, URL, BASE64URLNOPAD, - encoded=req.http.urlalldownuc); + = blob.transcode(URL, BASE64URLNOPAD, length=15, + encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2b64 - = blob.transcode_n(18, URL, BASE64, encoded=req.http.urlalldownlc); + = blob.transcode(URL, BASE64, length=18, + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64url - = blob.transcode_n(15, URL, BASE64URL, - encoded=req.http.urlalldownlc); + = blob.transcode(URL, BASE64URL, length=15, + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64nopad - = blob.transcode_n(15, URL, BASE64URLNOPAD, - encoded=req.http.urlalldownlc); + = blob.transcode(URL, BASE64URLNOPAD, length=15, + encoded=req.http.urlalldownlc); set resp.http.urlallupuc2b64 - = blob.transcode_n(36, URL, BASE64, encoded=req.http.urlallupuc); + = blob.transcode(URL, BASE64, length=36, + encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64url - = blob.transcode_n(33, URL, BASE64URL, encoded=req.http.urlallupuc); + = blob.transcode(URL, BASE64URL, length=33, + encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64nopad - = blob.transcode_n(33, URL, BASE64URLNOPAD, - encoded=req.http.urlallupuc); + = blob.transcode(URL, BASE64URLNOPAD, length=33, + encoded=req.http.urlallupuc); set resp.http.urlalluplc2b64 - = blob.transcode_n(36, URL, BASE64, encoded=req.http.urlalluplc); + = blob.transcode(URL, BASE64, length=36, + encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64url - = blob.transcode_n(33, URL, BASE64URL, encoded=req.http.urlalluplc); + = blob.transcode(URL, BASE64URL, length=33, + encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64nopad - = blob.transcode_n(33, URL, BASE64URLNOPAD, - encoded=req.http.urlalluplc); + = blob.transcode(URL, BASE64URLNOPAD, length=33, + encoded=req.http.urlalluplc); set resp.http.urlalldownuc2url - = blob.transcode_n(423, URL, URL, encoded=req.http.urlalldownuc); + = blob.transcode(URL, URL, length=423, + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urluc - = blob.transcode_n(423, URL, URL, UPPER, req.http.urlalldownuc); + = blob.transcode(URL, URL, UPPER, 423, req.http.urlalldownuc); set resp.http.urlalldownuc2urllc - = blob.transcode_n(423, URL, URL, LOWER, req.http.urlalldownuc); + = blob.transcode(URL, URL, LOWER, 423, req.http.urlalldownuc); set resp.http.urlalldownlc2url - = blob.transcode_n(423, URL, URL, encoded=req.http.urlalldownlc); + = blob.transcode(URL, URL, length=423, + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urluc - = blob.transcode_n(423, URL, URL, UPPER, req.http.urlalldownlc); + = blob.transcode(URL, URL, UPPER, 423, req.http.urlalldownlc); set resp.http.urlalldownlc2urllc - = blob.transcode_n(423, URL, URL, LOWER, req.http.urlalldownlc); + = blob.transcode(URL, URL, LOWER, 423, req.http.urlalldownlc); set resp.http.urlallupuc2url - = blob.transcode_n(197, URL, URL, encoded=req.http.urlallupuc); + = blob.transcode(URL, URL, length=197, encoded=req.http.urlallupuc); set resp.http.urlallupuc2urluc - = blob.transcode_n(197, URL, URL, UPPER, req.http.urlallupuc); + = blob.transcode(URL, URL, UPPER, 197, req.http.urlallupuc); set resp.http.urlallupuc2urllc - = blob.transcode_n(197, URL, URL, LOWER, req.http.urlallupuc); + = blob.transcode(URL, URL, LOWER, 197, req.http.urlallupuc); set resp.http.urlalluplc2url - = blob.transcode_n(197, URL, URL, encoded=req.http.urlalluplc); + = blob.transcode(URL, URL, length=197, encoded=req.http.urlalluplc); set resp.http.urlalluplc2urluc - = blob.transcode_n(197, URL, URL, UPPER, req.http.urlalluplc); + = blob.transcode(URL, URL, UPPER, 197, req.http.urlalluplc); set resp.http.urlalluplc2urllc - = blob.transcode_n(197, URL, URL, LOWER, req.http.urlalluplc); + = blob.transcode(URL, URL, LOWER, 197, req.http.urlalluplc); } } @@ -407,57 +426,59 @@ varnish v1 -vcl+backend { set req.http.foo = "AAA="; if (req.url == "/1") { set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, - encoded="%2c%q"); + = blob.transcode(URL, IDENTITY, length=3, + encoded="%2c%q"); } elsif (req.url == "/2") { set resp.http.good - = blob.transcode_n(3, URL, IDENTITY, - encoded="%3a%2q"); + = blob.transcode(URL, IDENTITY, length=3, + encoded="%3a%2q"); } elsif (req.url == "/3") { set resp.http.bad - = blob.transcode_n(8, HEX, IDENTITY, - encoded="0x123456"); + = blob.transcode(HEX, IDENTITY, length=8, + encoded="0x123456"); } elsif (req.url == "/4") { set resp.http.bad - = blob.transcode_n(4, BASE64, IDENTITY, - encoded="-_-_" + req.http.foo); + = blob.transcode(BASE64, IDENTITY, length=4, + encoded="-_-_" + req.http.foo); } elsif (req.url == "/5") { set resp.http.bad - = blob.transcode_n(4, BASE64URL, IDENTITY, - encoded="+/+/" + req.http.foo); + = blob.transcode(BASE64URL, IDENTITY, length=4, + encoded="+/+/" + req.http.foo); } elsif (req.url == "/6") { set resp.http.bad - = blob.transcode_n(8, BASE64URLNOPAD, IDENTITY, - encoded="TWFu" + req.http.foo); + = blob.transcode(BASE64URLNOPAD, IDENTITY, length=8, + encoded="TWFu" + req.http.foo); } elsif (req.url == "/7") { set resp.http.bad - = blob.transcode_n(4, BASE64, BASE64, - encoded="_-_-" + req.http.foo); + = blob.transcode(BASE64, BASE64, length=4, + encoded="_-_-" + req.http.foo); } elsif (req.url == "/8") { set resp.http.bad - = blob.transcode_n(4, BASE64URL, BASE64URL, - encoded="/+/+" + req.http.foo); + = blob.transcode(BASE64URL, BASE64URL, length=4, + encoded="/+/+" + req.http.foo); } elsif (req.url == "/9") { set resp.http.bad - = blob.transcode_n(8, BASE64URLNOPAD, - BASE64URLNOPAD, - encoded="Zm9v" + req.http.foo); + = blob.transcode(BASE64URLNOPAD, + BASE64URLNOPAD, length=8, + encoded="Zm9v" + req.http.foo); } elsif (req.url == "/10") { set resp.http.bad - = blob.transcode_n(1, URL, IDENTITY, encoded="%20"); + = blob.transcode(URL, IDENTITY, length=1, + encoded="%20"); } elsif (req.url == "/11") { set resp.http.bad - = blob.transcode_n(2, URL, IDENTITY, encoded="%20"); + = blob.transcode(URL, IDENTITY, length=2, + encoded="%20"); } } } diff --git a/bin/varnishtest/tests/m00044.vtc b/bin/varnishtest/tests/m00044.vtc index ba4b757..e68374a 100644 --- a/bin/varnishtest/tests/m00044.vtc +++ b/bin/varnishtest/tests/m00044.vtc @@ -29,7 +29,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # vice versa at runtime. set resp.http.Base64-Encoded = blob.encode(BASE64, - blob=blob.decode(HEX, req.http.Hex-Encoded)); + blob=blob.decode(HEX, encoded=req.http.Hex-Encoded)); } sub vcl_recv { @@ -53,9 +53,10 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # IDENTITY sub vcl_deliver { set resp.http.Trunced-Foo1 - = blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); + = blob.encode(IDENTITY, blob=blob.decode(HEX, + encoded="666f6f00626172")); set resp.http.Trunced-Foo2 - = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); + = blob.encode(blob=blob.decode(HEX, encoded="666f6f00626172")); } ############################################################ @@ -65,14 +66,15 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode( HEX, - blob=blob.decode(HEX, resp.http.First + resp.http.Second)); + blob=blob.decode(HEX, encoded=resp.http.First + resp.http.Second)); } ############################################################ # encode - also contains decode examples sub vcl_deliver { set resp.http.encode1 - = blob.encode(HEX, blob=blob.decode(BASE64, "Zm9vYmFyYmF6")); + = blob.encode(HEX, blob=blob.decode(BASE64, + encoded="Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 @@ -108,7 +110,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { ############################################################ # blob init + .get + .encode sub vcl_init { - new theblob1 = blob.blob(BASE64, "YmxvYg=="); + new theblob1 = blob.blob(BASE64, encoded="YmxvYg=="); # same with named arguments new theblob2 = blob.blob(encoded="YmxvYg==", decoding=BASE64); diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 6c8ea69..3688987 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -257,7 +257,7 @@ varnish v1 -errvcl {Expected 'from path ...'} { varnish v1 -errvcl {INT * BLOB not possible.} { import blob; sub vcl_deliver { - set resp.status = 100 * blob.decode(HEX, "a"); + set resp.status = 100 * blob.decode(HEX, encoded="a"); } } diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index a5553c6..290e716 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -12,12 +12,9 @@ $Module blob 3 utilities for the VCL blob type # binary-to-text encodings STRING blob.encode([ENUM encoding,] [ENUM case,] BLOB blob) - BLOB blob.decode([ENUM decoding,] STRING_LIST encoded) - BLOB blob.decode_n(INT n, [ENUM decoding,] STRING_LIST encoded) + BLOB blob.decode([ENUM decoding,] [INT length,] STRING_LIST encoded) STRING blob.transcode([ENUM decoding,] [ENUM encoding,] [ENUM case,] - STRING_LIST encoded) - STRING blob.transcode_n(INT n, [ENUM decoding,] [ENUM encoding,] - [ENUM case,] STRING_LIST encoded) + [INT length,] STRING_LIST encoded) # other utilities BOOL blob.same(BLOB, BLOB) @@ -55,8 +52,9 @@ Examples:: # decode() and encode() functions convert blobs to text and # vice versa at runtime. set resp.http.Base64-Encoded - = blob.encode(BASE64, - blob=blob.decode(HEX, req.http.Hex-Encoded)); + = blob.encode(BASE64, + blob=blob.decode(HEX, + encoded=req.http.Hex-Encoded)); } sub vcl_recv { @@ -123,7 +121,8 @@ blob. For example:: # Decode from the hex encoding for "foo\0bar". # The header will be seen as "foo". set resp.http.Trunced-Foo1 - = blob.encode(IDENTITY, blob=blob.decode(HEX, "666f6f00626172")); + = blob.encode(IDENTITY, blob=blob.decode(HEX, + encoded="666f6f00626172")); IDENTITY is the default encoding and decoding. So the above can also be written as:: @@ -131,7 +130,7 @@ be written as:: # Decode from the hex encoding for "foo\0bar". # The header will be seen as "foo". set resp.http.Trunced-Foo2 - = blob.encode(blob=blob.decode(HEX, "666f6f00626172")); + = blob.encode(blob=blob.decode(HEX, encoded="666f6f00626172")); The ``case`` ENUM is ignored for ``IDENTITY`` encodings. @@ -176,7 +175,7 @@ byte. For example:: set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode(HEX, blob=blob.decode(HEX, - resp.http.First + resp.http.Second)); + encoded=resp.http.First + resp.http.Second)); URL --- @@ -189,16 +188,22 @@ The ``URL`` encoding implements "percent encoding" as per RFC3986. The affect alphabetic characters that are not percent-encoded. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", INT length=0, + STRING_LIST encoded) Returns the BLOB derived from the string ``encoded`` according to the scheme specified by ``decoding``. +If ``length`` > 0, only decode the first ``length`` characters of the +encoded string. If ``length`` <= 0 or greater than the length of the +string, then decode the entire string. The default value of ``length`` +is 0. + ``decoding`` defaults to IDENTITY. Example:: - blob.decode(BASE64, "Zm9vYmFyYmF6"); + blob.decode(BASE64, encoded="Zm9vYmFyYmF6"); # same with named parameters blob.decode(encoded="Zm9vYmFyYmF6", decoding=BASE64); @@ -206,15 +211,6 @@ Example:: # convert string to blob blob.decode(encoded="foo"); -$Function BLOB decode_n(INT n, - ENUM {IDENTITY, BASE64, BASE64URL, - BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", - STRING_LIST encoded) - -Same as ``decode()``, but only decode the first ``n`` characters of -the encoded string. If ``n`` is greater than the length of the string, -then return the same result as ``decode()``. - $Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", ENUM {LOWER, UPPER} case="LOWER", BLOB blob) @@ -228,7 +224,8 @@ Returns a string representation of the BLOB ``blob`` as specifed by Example:: set resp.http.encode1 - = blob.encode(HEX, blob=blob.decode(BASE64, "Zm9vYmFyYmF6")); + = blob.encode(HEX, + blob=blob.decode(BASE64, encoded="Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 @@ -244,7 +241,7 @@ $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER", + ENUM {LOWER, UPPER} case="LOWER", INT length=0, STRING_LIST encoded) Translates from one encoding to another, by first decoding the string @@ -253,6 +250,10 @@ the encoding of the resulting blob according to the scheme ``encoding``. ``case`` determines the case of hex digits for the ``HEX`` and ``URL`` encodings, and is ignored for other encodings. +As with ``decode()``: If ``length`` > 0, only decode the first +``length`` characters of the encoded string, otherwise decode the +entire string. The default value of ``length`` is 0. + ``decoding`` and ``encoding`` default to IDENTITY, and ``case`` defaults to LOWER. @@ -274,17 +275,6 @@ Example:: set resp.http.urlencoded = blob.transcode(encoded="foo bar", encoding=URL); -$Function STRING transcode_n(INT n, - ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", - ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER", - STRING_LIST encoded) - -Same as ``transcode()``, but only from the first ``n`` characters of -the encoded string. - $Function BOOL same(BLOB, BLOB) Returns true if and only if the two BLOB arguments are the same @@ -326,7 +316,7 @@ Creates an object that contains the BLOB derived from the string Example:: - new theblob1 = blob.blob(BASE64, "YmxvYg=="); + new theblob1 = blob.blob(BASE64, encoded="YmxvYg=="); # same with named arguments new theblob2 = blob.blob(encoded="YmxvYg==", decoding=BASE64); diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 850f975..2da7781 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -336,11 +336,11 @@ find_nonempty_va(const char *restrict *p, va_list ap) return (q); } -static VCL_BLOB -decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *restrict const p, - va_list ap) +VCL_BLOB __match_proto__(td_blob_decode) +vmod_decode(VRT_CTX, VCL_ENUM decs, VCL_INT length, const char *p, ...) { enum encoding dec = parse_encoding(decs); + va_list ap; struct wb_s wb; struct vmod_priv *b; char *buf; @@ -364,8 +364,12 @@ decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *restrict const p, } buf = wb_buf(&wb); + if (length <= 0) + length = -1; + va_start(ap, p); errno = 0; - len = func[dec].decode(dec, buf, wb_space(&wb), n, p, ap); + len = func[dec].decode(dec, buf, wb_space(&wb), length, p, ap); + va_end(ap); if (len == -1) { err_decode(ctx, p); @@ -383,33 +387,7 @@ decode(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *restrict const p, b->priv = buf; b->len = len; b->free = NULL; - return b; -} - -VCL_BLOB __match_proto__(td_blob_decode) -vmod_decode(VRT_CTX, VCL_ENUM decs, const char *p, ...) -{ - va_list ap; - VCL_BLOB r; - - va_start(ap, p); - r = decode(ctx, -1, decs, p, ap); - va_end(ap); - - return (r); -} - -VCL_BLOB __match_proto__(td_blob_decode_n) -vmod_decode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, const char *p, ...) -{ - va_list ap; - VCL_BLOB r; - - va_start(ap, p); - r = decode(ctx, n, decs, p, ap); - va_end(ap); - - return (r); + return (b); } static VCL_STRING @@ -460,14 +438,14 @@ encodes_hex(enum encoding enc) return (enc == HEX || enc == URL); } -static VCL_STRING -transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, - const char *restrict const p, va_list ap) +VCL_STRING __match_proto__(td_blob_transcode) +vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, + VCL_INT length, const char *p, ...) { enum encoding dec = parse_encoding(decs); enum encoding enc = parse_encoding(encs); enum case_e kase = parse_case(case_s); - va_list aq; + va_list ap; struct vmod_priv b; VCL_STRING r; @@ -481,9 +459,9 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, * Allocate space for the decoded blob on the stack * ignoring the limitation imposed by n */ - va_copy(aq, ap); - size_t l = decode_l_va(dec, p, aq); - va_end(aq); + va_start(ap, p); + size_t l = decode_l_va(dec, p, ap); + va_end(ap); if (l == 0) return ""; /* XXX: handle stack overflow? */ @@ -491,10 +469,12 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, b.free = NULL; b.priv = buf; + if (length <= 0) + length = -1; + va_start(ap, p); errno = 0; - va_copy(aq, ap); - b.len = func[dec].decode(dec, buf, l, n, p, aq); - va_end(aq); + b.len = func[dec].decode(dec, buf, l, length, p, ap); + va_end(ap); if (b.len == -1) { err_decode(ctx, p); @@ -509,11 +489,11 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, * since the call may specify upper- or lower-case that differs * from the encoded string. */ - if (n == -1 && enc == dec && !encodes_hex(enc)) { + if (length == -1 && enc == dec && !encodes_hex(enc)) { const char *q, *pp = p; - va_copy(aq, ap); + va_start(ap, p); q = find_nonempty_va(&pp, ap); - va_end(aq); + va_end(ap); if (pp == vrt_magic_string_end) return ""; @@ -529,34 +509,6 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, return (r); } -VCL_STRING __match_proto__(td_blob_transcode) -vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, - const char *p, ...) -{ - va_list ap; - VCL_STRING r; - - va_start(ap, p); - r = transcode(ctx, -1, decs, encs, case_s, p, ap); - va_end(ap); - - return (r); -} - -VCL_STRING __match_proto__(td_blob_transcode_n) -vmod_transcode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs, - VCL_ENUM case_s, const char *p, ...) -{ - va_list ap; - VCL_STRING r; - - va_start(ap, p); - r = transcode(ctx, n, decs, encs, case_s, p, ap); - va_end(ap); - - return (r); -} - VCL_BOOL __match_proto__(td_blob_same) vmod_same(VRT_CTX, VCL_BLOB b1, VCL_BLOB b2) { From hermunn at varnish-software.com Fri Sep 15 11:17:19 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:19 +0000 (UTC) Subject: [5.2] e9ff38c Make $(VMOD_LDFLAGS) available in our build too Message-ID: <20170915111719.395FB982C5@lists.varnish-cache.org> commit e9ff38c425793e4ad08c8eb4bfc3c12627b9785e Author: Dridi Boukelmoune Date: Tue Sep 12 00:39:05 2017 +0200 Make $(VMOD_LDFLAGS) available in our build too Refs da91fec diff --git a/configure.ac b/configure.ac index 751af53..5b9dbac 100644 --- a/configure.ac +++ b/configure.ac @@ -67,6 +67,9 @@ AC_ARG_WITH([dot], fi]) AM_CONDITIONAL(HAVE_DOT,[test "x$DOT" != "xno"]) +# Define VMOD flags +_VARNISH_VMOD_LDFLAGS + # Check for python. _VARNISH_CHECK_PYTHON diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 30a5928..b7f58e5 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -67,7 +67,7 @@ libvmod_XXX_la_CFLAGS = \\ libvmod_XXX_la_LDFLAGS = \\ $(AM_LDFLAGS) \\ - -module -export-dynamic -avoid-version -shared \\ + $(VMOD_LDFLAGS) \\ @SAN_LDFLAGS@ nodist_libvmod_XXX_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 9871b3f..3b4ed7a 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_blob_la_CFLAGS = \ libvmod_blob_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_blob_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index 3fb7d98..dddd350 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -27,7 +27,7 @@ libvmod_debug_la_CFLAGS = \ libvmod_debug_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ -rpath /nowhere @SAN_LDFLAGS@ diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index f30062d..19e10a3 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_directors_la_CFLAGS = \ libvmod_directors_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_directors_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index 9671d53..3a5b4a5 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_purge_la_CFLAGS = \ libvmod_purge_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_purge_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 259476e..66410b0 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_std_la_CFLAGS = \ libvmod_std_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_std_la_SOURCES = vcc_if.c vcc_if.h diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 545bb56..1eb8f6f 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -19,7 +19,7 @@ libvmod_vtc_la_CFLAGS = \ libvmod_vtc_la_LDFLAGS = \ $(AM_LDFLAGS) \ - -module -export-dynamic -avoid-version -shared \ + $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ nodist_libvmod_vtc_la_SOURCES = vcc_if.c vcc_if.h diff --git a/varnish.m4 b/varnish.m4 index 82514ea..9a7f868 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -135,12 +135,22 @@ AC_DEFUN([_VARNISH_CHECK_PYTHON], [ ]) +# _VARNISH_VMOD_LDFLAGS +# --------------------- +AC_DEFUN([_VARNISH_VMOD_LDFLAGS], [ + + AC_SUBST([VMOD_LDFLAGS], + "-module -export-dynamic -avoid-version -shared") + +]) + # _VARNISH_VMOD_CONFIG # -------------------- AC_DEFUN([_VARNISH_VMOD_CONFIG], [ AC_REQUIRE([_VARNISH_PKG_CONFIG]) AC_REQUIRE([_VARNISH_CHECK_DEVEL]) + AC_REQUIRE([_VARNISH_VMOD_LDFLAGS]) dnl Check the VMOD toolchain AC_REQUIRE([AC_LANG_C]) @@ -175,10 +185,6 @@ AC_DEFUN([_VARNISH_VMOD_CONFIG], [ AC_SUBST([am__v_VMODTOOL_]) AC_SUBST([AM_V_VMODTOOL]) - dnl Define VMODs LDFLAGS - AC_SUBST([VMOD_LDFLAGS], - "-module -export-dynamic -avoid-version -shared") - dnl Substitute an alias for compatibility reasons AC_SUBST([VMOD_TEST_PATH], [$VARNISH_TEST_PATH]) ]) From hermunn at varnish-software.com Fri Sep 15 11:17:19 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:19 +0000 (UTC) Subject: [5.2] b9a5ac6 VMOD blob: clarify the docs for same() concerning empty BLOBs. Message-ID: <20170915111719.584EF982D7@lists.varnish-cache.org> commit b9a5ac6dd6179f0870bbda14d2cc5948b0f36b35 Author: Geoff Simmons Date: Tue Sep 12 00:46:02 2017 +0200 VMOD blob: clarify the docs for same() concerning empty BLOBs. References #2421 diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 290e716..0f3dbb4 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -278,7 +278,8 @@ Example:: $Function BOOL same(BLOB, BLOB) Returns true if and only if the two BLOB arguments are the same -object, i.e. they specify exactly the same region of memory. +object, i.e. they specify exactly the same region of memory, or both +are empty. If the BLOBs are both empty (length is 0 and/or the internal pointer is NULL), then ``same()`` returns ``true``. If any non-empty BLOB From hermunn at varnish-software.com Fri Sep 15 11:17:19 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:19 +0000 (UTC) Subject: [5.2] e19efd7 Free decode object on failure Message-ID: <20170915111719.7EB22982F4@lists.varnish-cache.org> commit e19efd7283b4654a00125735695ab0b3c2639469 Author: Federico G. Schwindt Date: Mon Sep 11 23:25:18 2017 +0100 Free decode object on failure To be revisited post release. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index c5d9530..4dc75f1 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -209,8 +209,10 @@ h2_kill_req(struct worker *wrk, const struct h2_sess *h2, AZ(pthread_cond_signal(r2->cond)); r2 = NULL; } else { - if (r2->state == H2_S_OPEN) + if (r2->state == H2_S_OPEN) { (void)h2h_decode_fini(h2, r2->decode); + FREE_OBJ(r2->decode); + } } Lck_Unlock(&h2->sess->mtx); if (r2 != NULL) @@ -596,6 +598,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) VSLb(h2->vsl, SLT_Debug, "HPACK(hdr) %s", h2e->name); Lck_Unlock(&h2->sess->mtx); (void)h2h_decode_fini(h2, r2->decode); + FREE_OBJ(r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); return (h2e); @@ -630,6 +633,7 @@ h2_rx_continuation(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) VSLb(h2->vsl, SLT_Debug, "HPACK(cont) %s", h2e->name); Lck_Unlock(&h2->sess->mtx); (void)h2h_decode_fini(h2, r2->decode); + FREE_OBJ(r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); return (h2e); From hermunn at varnish-software.com Fri Sep 15 11:17:19 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:19 +0000 (UTC) Subject: [5.2] 3c54ecc VMOD blob: rename subblob() as sub(). Message-ID: <20170915111719.9F68D98302@lists.varnish-cache.org> commit 3c54ecc59906fae7c56f77c1d75d362790a92e7b Author: Geoff Simmons Date: Tue Sep 12 00:59:28 2017 +0200 VMOD blob: rename subblob() as sub(). Closes #2421 diff --git a/bin/varnishtest/tests/m00045.vtc b/bin/varnishtest/tests/m00045.vtc index 83697a7..d82e7f5 100644 --- a/bin/varnishtest/tests/m00045.vtc +++ b/bin/varnishtest/tests/m00045.vtc @@ -1,4 +1,4 @@ -varnishtest "VMOD blob same(), equal(), length() and subblob()" +varnishtest "VMOD blob same(), equal(), length() and sub()" varnish v1 -vcl { import blob; @@ -165,7 +165,7 @@ client c1 { expect resp.http.empty2len == "0" } -run -# subblob() +# sub() varnish v1 -vcl { import blob; backend b { .host = "${bad_ip}"; } @@ -183,23 +183,23 @@ varnish v1 -vcl { sub vcl_synth { set resp.http.up03 - = blob.encode(BASE64, blob=blob.subblob(up07.get(), 4B)); + = blob.encode(BASE64, blob=blob.sub(up07.get(), 4B)); set resp.http.down07060504 - = blob.encode(BASE64, blob=blob.subblob(down07.get(), 4B)); + = blob.encode(BASE64, blob=blob.sub(down07.get(), 4B)); set resp.http.up04050607 = blob.encode(BASE64, - blob=blob.subblob(up07.get(), 4B, 4B)); + blob=blob.sub(up07.get(), 4B, 4B)); set resp.http.down03 = blob.encode(BASE64, - blob=blob.subblob(down07.get(), 4B, 4B)); + blob=blob.sub(down07.get(), 4B, 4B)); set resp.http.up07 - = blob.encode(BASE64, blob=blob.subblob(up07.get(), 8B)); + = blob.encode(BASE64, blob=blob.sub(up07.get(), 8B)); set resp.http.down07 - = blob.encode(BASE64, blob=blob.subblob(down07.get(), 8B)); + = blob.encode(BASE64, blob=blob.sub(down07.get(), 8B)); set resp.http.zerobytes - = blob.encode(BASE64, blob=blob.subblob(down07.get(), 0B)); + = blob.encode(BASE64, blob=blob.sub(down07.get(), 0B)); set resp.http.zerolen - = blob.length(blob.subblob(down07.get(), 0B)); + = blob.length(blob.sub(down07.get(), 0B)); } } @@ -217,7 +217,7 @@ client c1 { expect resp.http.zerolen == "0" } -run -# subblob() failures +# sub() failures server s1 -repeat 3 { rxreq txresp @@ -234,23 +234,23 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/empty") { set resp.http.empty = blob.encode(BASE64, blob= - blob.subblob(empty.get(), 1B)); + blob.sub(empty.get(), 1B)); } elsif (req.url == "/toolong") { set resp.http.toolong = blob.encode(BASE64, - blob=blob.subblob(up07.get(), 9B)); + blob=blob.sub(up07.get(), 9B)); } elsif (req.url == "/badoffset") { set resp.http.badoffset = blob.encode(BASE64, - blob=blob.subblob(up07.get(), 4B, 5B)); + blob=blob.sub(up07.get(), 4B, 5B)); } } } logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" { expect 0 * Begin req - expect * = VCL_Error "^vmod blob error: blob is empty in blob.subblob..$" + expect * = VCL_Error "^vmod blob error: blob is empty in blob.sub..$" expect * = End } -start @@ -273,7 +273,7 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error "^vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.subblob..$" + expect * * VCL_Error "^vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.sub..$" } -run client c1 { @@ -285,41 +285,41 @@ client c1 { } -run logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { - expect * * VCL_Error "^vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.subblob..$" + expect * * VCL_Error "^vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.sub..$" } -run -# VCL load failures from subblob() -varnish v1 -errvcl {vmod blob error: blob is empty in blob.subblob()} { +# VCL load failures from sub() +varnish v1 -errvcl {vmod blob error: blob is empty in blob.sub()} { import blob; backend b { .host = "${bad_ip}"; } sub vcl_init { new empty = blob.blob(IDENTITY, ""); - if (blob.same(empty.get(), blob.subblob(empty.get(), 0B))) { + if (blob.same(empty.get(), blob.sub(empty.get(), 0B))) { new B = blob.blob(IDENTITY, "b"); } } } -varnish v1 -errvcl {vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.subblob()} { +varnish v1 -errvcl {vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.sub()} { import blob; backend b { .host = "${bad_ip}"; } sub vcl_init { new up07 = blob.blob(BASE64, "AAECAwQFBgc="); - if (blob.same(up07.get(), blob.subblob(up07.get(), 9B))) { + if (blob.same(up07.get(), blob.sub(up07.get(), 9B))) { new B = blob.blob(IDENTITY, "b"); } } } -varnish v1 -errvcl {vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.subblob()} { +varnish v1 -errvcl {vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.sub()} { import blob; backend b { .host = "${bad_ip}"; } sub vcl_init { new up07 = blob.blob(BASE64, "AAECAwQFBgc="); - if (blob.same(up07.get(), blob.subblob(up07.get(), 4B, 5B))) { + if (blob.same(up07.get(), blob.sub(up07.get(), 4B, 5B))) { new B = blob.blob(IDENTITY, "b"); } } diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 0f3dbb4..2c4df6d 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -20,7 +20,7 @@ $Module blob 3 utilities for the VCL blob type BOOL blob.same(BLOB, BLOB) BOOL blob.equal(BLOB, BLOB) INT blob.length(BLOB) - BLOB blob.subblob(BLOB, BYTES length [, BYTES offset]) + BLOB blob.sub(BLOB, BYTES length [, BYTES offset]) # blob object new OBJ = blob.blob([ENUM decoding,] STRING_LIST encoded) @@ -298,14 +298,14 @@ $Function INT length(BLOB) Returns the length of the BLOB. -$Function BLOB subblob(BLOB, BYTES length, BYTES offset = 0) +$Function BLOB sub(BLOB, BYTES length, BYTES offset = 0) Returns a new BLOB formed from ``length`` bytes of the BLOB argument starting at ``offset`` bytes from the start of its memory region. The default value of ``offset`` is 0B. -``subblob()`` fails and returns NULL if the BLOB argument is empty, or -if ``offset + length`` requires more bytes than are available in the +``sub()`` fails and returns NULL if the BLOB argument is empty, or if +``offset + length`` requires more bytes than are available in the BLOB. $Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, @@ -377,7 +377,7 @@ not known until runtime. ERRORS ====== -The encoders, decoders and ``subblob()`` may fail if there is +The encoders, decoders and ``sub()`` may fail if there is insufficient space to create the new blob or string. Decoders may also fail if the encoded string is an illegal format for the decoding scheme. @@ -408,11 +408,11 @@ strings. The ``blob`` object and its methods allocate memory from the heap, and hence they are only limited by available virtual memory. The ``encode()``, ``decode()`` and ``transcode()`` functions allocate -Varnish workspace, as does ``subblob()`` for the newly created BLOB. -If these functions are failing, as indicated by "out of space" -messages in the Varnish log (with the ``VCL_Error`` tag), then you -will need to increase the varnishd parameters ``workspace_client`` -and/or ``workspace_backend``. +Varnish workspace, as does ``sub()`` for the newly created BLOB. If +these functions are failing, as indicated by "out of space" messages +in the Varnish log (with the ``VCL_Error`` tag), then you will need to +increase the varnishd parameters ``workspace_client`` and/or +``workspace_backend``. The ``transcode()`` function also allocates space on the stack for a temporary BLOB. If this function causes stack overflow, you may need diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 2da7781..7ded3a8 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -549,8 +549,8 @@ vmod_length(VRT_CTX, VCL_BLOB b) return b->len; } -VCL_BLOB __match_proto__(td_blob_subblob) -vmod_subblob(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) +VCL_BLOB __match_proto__(td_blob_sub) +vmod_sub(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) { uintptr_t snap; struct vmod_priv *sub; @@ -560,13 +560,13 @@ vmod_subblob(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) assert(off >= 0); if (b == NULL || b->len == 0 || b->priv == NULL) { - ERR(ctx, "blob is empty in blob.subblob()"); + ERR(ctx, "blob is empty in blob.sub()"); return NULL; } assert(b->len >= 0); if (off + n > b->len) { VERR(ctx, "size %lld from offset %lld requires more bytes than " - "blob length %d in blob.subblob()", n, off, b->len); + "blob length %d in blob.sub()", n, off, b->len); return NULL; } @@ -575,11 +575,11 @@ vmod_subblob(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) snap = WS_Snapshot(ctx->ws); if ((sub = WS_Alloc(ctx->ws, sizeof(*sub))) == NULL) { - ERRNOMEM(ctx, "Allocating BLOB result in blob.subblob()"); + ERRNOMEM(ctx, "Allocating BLOB result in blob.sub()"); return NULL; } if ((sub->priv = WS_Alloc(ctx->ws, n)) == NULL) { - VERRNOMEM(ctx, "Allocating %lld bytes in blob.subblob()", n); + VERRNOMEM(ctx, "Allocating %lld bytes in blob.sub()", n); WS_Reset(ctx->ws, snap); return NULL; } From hermunn at varnish-software.com Fri Sep 15 11:17:19 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:19 +0000 (UTC) Subject: [5.2] dbe1d1f Also flexelint new vmods Message-ID: <20170915111719.BFAD898313@lists.varnish-cache.org> commit dbe1d1f9062ee5780e9f55a785593c330a963a2d Author: Poul-Henning Kamp Date: Tue Sep 12 04:15:26 2017 +0000 Also flexelint new vmods diff --git a/lib/libvmod_blob/flint.lnt b/lib/libvmod_blob/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvmod_blob/flint.sh b/lib/libvmod_blob/flint.sh new file mode 100755 index 0000000..522e30d --- /dev/null +++ b/lib/libvmod_blob/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + -I../../bin/varnishd + *.c +' + +. ../../tools/flint_skel.sh diff --git a/lib/libvmod_vtc/flint.lnt b/lib/libvmod_vtc/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvmod_vtc/flint.sh b/lib/libvmod_vtc/flint.sh new file mode 100755 index 0000000..522e30d --- /dev/null +++ b/lib/libvmod_vtc/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + -I../../bin/varnishd + *.c +' + +. ../../tools/flint_skel.sh From hermunn at varnish-software.com Fri Sep 15 11:17:19 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:19 +0000 (UTC) Subject: [5.2] c63f2f3 Flexelintery Message-ID: <20170915111719.E29319832A@lists.varnish-cache.org> commit c63f2f335d1dc033dcc30b2d761f8cbaae572895 Author: Poul-Henning Kamp Date: Tue Sep 12 04:38:32 2017 +0000 Flexelintery diff --git a/flint.lnt b/flint.lnt index 3fa3bf4..aab7299 100644 --- a/flint.lnt +++ b/flint.lnt @@ -39,6 +39,8 @@ -e785 // Too few initializers for aggregate -e786 // String concatenation within initializer +-e788 // enum constant '___' not used within defaulted switch + -esym(818, argv) // Pointer parameter '...' could be declared as pointing to const /* @@ -75,6 +77,8 @@ -esym(534, sleep) -esym(534, usleep) +-esym(768, vmod_priv) // global struct member '___' (___) not referenced + /////////////////////////////////////////////////////////////////////// // diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c index e1afcf8..9fd3fc4 100644 --- a/lib/libvmod_vtc/vmod_vtc.c +++ b/lib/libvmod_vtc/vmod_vtc.c @@ -187,7 +187,7 @@ vmod_workspace_##name(VRT_CTX, VCL_ENUM which) \ \ op; \ } -VTC_WS_OP(VOID, snapshot, vtc_ws_snapshot = WS_Snapshot(ws)) +VTC_WS_OP(VOID, snapshot, (vtc_ws_snapshot = WS_Snapshot(ws))) VTC_WS_OP(VOID, reset, WS_Reset(ws, vtc_ws_snapshot)) VTC_WS_OP(VOID, overflow, WS_MarkOverflow(ws)) VTC_WS_OP(BOOL, overflowed, return (WS_Overflowed(ws))) @@ -198,7 +198,7 @@ VTC_WS_OP(BOOL, overflowed, return (WS_Overflowed(ws))) VCL_INT __match_proto__(td_vtc_typesize) vmod_typesize(VRT_CTX, VCL_STRING s) { - VCL_INT i = 0; + size_t i = 0; const char *p; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -219,5 +219,5 @@ vmod_typesize(VRT_CTX, VCL_STRING s) default: return (-1); } } - return (i); + return ((VCL_INT)i); } From hermunn at varnish-software.com Fri Sep 15 11:17:20 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:20 +0000 (UTC) Subject: [5.2] 8376094 Umap and free all segments on VSM_Destroy() Message-ID: <20170915111720.0D76998336@lists.varnish-cache.org> commit 83760941c88e85472a28fa5fcfca43ee903fde02 Author: Poul-Henning Kamp Date: Tue Sep 12 06:34:00 2017 +0000 Umap and free all segments on VSM_Destroy() Fixes #2416 diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 9d3ed85..2b8c7e6 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -147,6 +147,44 @@ vsm_diag(struct vsm *vd, const char *fmt, ...) /*--------------------------------------------------------------------*/ +static void +vsm_unmapseg(struct vsm_seg *vg) +{ + size_t sz, ps, len; + + CHECK_OBJ_NOTNULL(vg, VSM_SEG_MAGIC); + + AN(vg->b); + AN(vg->e); + sz = strtoul(vg->av[2], NULL, 10); + assert(sz > 0); + ps = getpagesize(); + len = RUP2(sz, ps); + AZ(munmap(vg->b, len)); + vg->b = vg->e = NULL; +} + +/*--------------------------------------------------------------------*/ + +static void +vsm_delseg(struct vsm_seg *vg) +{ + + CHECK_OBJ_NOTNULL(vg, VSM_SEG_MAGIC); + + if (vg->b != NULL) + vsm_unmapseg(vg); + + if (vg->stale) + VTAILQ_REMOVE(&vg->set->stale, vg, list); + else + VTAILQ_REMOVE(&vg->set->segs, vg, list); + VAV_Free(vg->av); + FREE_OBJ(vg); +} + +/*--------------------------------------------------------------------*/ + static struct vsm_set * vsm_newset(const char *dirname) { @@ -173,7 +211,10 @@ vsm_delset(struct vsm_set **p) closefd(&vs->fd); if (vs->dfd >= 0) closefd(&vs->dfd); - // XXX: delete segments + while (!VTAILQ_EMPTY(&vs->stale)) + vsm_delseg(VTAILQ_FIRST(&vs->stale)); + while (!VTAILQ_EMPTY(&vs->segs)) + vsm_delseg(VTAILQ_FIRST(&vs->segs)); FREE_OBJ(vs); } @@ -243,11 +284,13 @@ VSM_Destroy(struct vsm **vdp) TAKE_OBJ_NOTNULL(vd, vdp, VSM_MAGIC); VSM_ResetError(vd); - free(vd->dname); - vsm_delset(&vd->mgt); - vsm_delset(&vd->child); + REPLACE(vd->dname, NULL); + if (vd->diag != NULL) + VSB_destroy(&vd->diag); if (vd->dfd >= 0) closefd(&vd->dfd); + vsm_delset(&vd->mgt); + vsm_delset(&vd->child); FREE_OBJ(vd); } @@ -699,7 +742,6 @@ int VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf) { struct vsm_seg *vg; - size_t sz, ps, len; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); AN(vd->attached); @@ -714,19 +756,9 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf) vf->e = NULL; if (vg->refs > 0) return(0); - AN(vg->b); - AN(vg->e); - sz = strtoul(vg->av[2], NULL, 10); - assert(sz > 0); - ps = getpagesize(); - len = RUP2(sz, ps); - AZ(munmap(vg->b, len)); - vg->b = vg->e = NULL; - if (vg->stale) { - VTAILQ_REMOVE(&vg->set->stale, vg, list); - VAV_Free(vg->av); - FREE_OBJ(vg); - } + vsm_unmapseg(vg); + if (vg->stale) + vsm_delseg(vg); return (0); } From hermunn at varnish-software.com Fri Sep 15 11:17:20 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:20 +0000 (UTC) Subject: [5.2] 200118b Add skeleton What's New and Upgrading docs for 5.2. Message-ID: <20170915111720.2E4819834D@lists.varnish-cache.org> commit 200118ba724d45d3025c4bf3daa67ee5244a7768 Author: Geoff Simmons Date: Tue Sep 12 10:10:25 2017 +0200 Add skeleton What's New and Upgrading docs for 5.2. At present mostly consisting of XXX's. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst new file mode 100644 index 0000000..e8d46d0 --- /dev/null +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -0,0 +1,51 @@ +.. _whatsnew_changes_5.2: + +Changes in Varnish 5.2 +====================== + +*XXX: preamble* + +Varnish statistics +~~~~~~~~~~~~~~~~~~ + +*XXX: changes and new features of VSC/VSM* + +.. _whatsnew_new_vmods: + +New VMODs in the standard distribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: introductory paragraphs about new VMODs* + +VMOD purge +---------- + +*XXX: about VMOD purge* + +VMOD vtc +-------- + +*XXX: about VMOD vtc* + +VMOD blob +--------- + +*XXX: about VMOD blob* + +XXX: Any other headline changes ... +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: ...* + +News for authors of VMODs and Varnish API client applications +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: such news may include:* + +* *XXX: effects of new VSC/VSM on VMODs* + +* *XXX: effects of new VSC/VSM on API client apps* + +* *XXX: changes in VRT* + +*EOF* diff --git a/doc/sphinx/whats-new/index.rst b/doc/sphinx/whats-new/index.rst index c0b55b3..35d47c3 100644 --- a/doc/sphinx/whats-new/index.rst +++ b/doc/sphinx/whats-new/index.rst @@ -8,6 +8,15 @@ This section describes the changes and improvements between different versions of Varnish, and what upgrading between the different versions entail. +Varnish 5.2 +----------- + +.. toctree:: + :maxdepth: 2 + + changes-5.2 + upgrading-5.2 + Varnish 5.1 ----------- diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst new file mode 100644 index 0000000..8048cb8 --- /dev/null +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -0,0 +1,107 @@ +.. _whatsnew_upgrading_5.2: + +%%%%%%%%%%%%%%%%%%%%%%%% +Upgrading to Varnish 5.2 +%%%%%%%%%%%%%%%%%%%%%%%% + +Varnish statistics and logging +============================== + +*XXX: anything new for users or admins concerning statistics,* +*varnishstat, logging etc* + +varnishd parameters +=================== + +* *XXX: -p params that are new, modified, deprecated or removed* + +* *XXX: use rst refs to keep it short* + +* *XXX: ...* + +Changes to VCL +============== + +*XXX: intro paragraph* + +*XXX: emphasize what most likely needs to be done, if anything,* +*to migrate from 5.1 to 5.2* + +*XXX: ... or reassure that you probably don't have to do anything* +*to migrate from 5.1 to 5.2* + +XXX: headline changes ... +~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: the most important changes or additions first* + +``req.hash`` and ``bereq.hash`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: about {be}req.hash, mention data type BLOB, advise about* +*:ref:`vmod_blob(3)`* + +XXX: vcl_sub_XXX ... +~~~~~~~~~~~~~~~~~~~~ + +*XXX: list changes by VCL sub* + +XXX: more VCL changes ... +~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: any more details and new features that VCL authors have to know* + +vmod_std +~~~~~~~~ + +* *XXX: any changes in VMOD std?* + +New VMODs in the standard distribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +See :ref:`vmod_purge(3)`, :ref:`vmod_vtc(3)`, :ref:`vmod_blob(3)` and +:ref:`whatsnew_new_vmods`. + +Other changes +============= + +* ``varnishstat(1)``: + + * *XXX: changes due to new VSC/VSM* + + * *XXX: ...* + +* ``varnishlog(1)``: + + * *XXX: changes due to new VSC/VSM* + + * *XXX: ...* + +* ``varnishtest(1)`` and ``vtc(7)``: + + * *XXX: changes in test code* + + * *XXX: for example due to VMOD vtc* + + * *XXX: ...* + +* *XXX: any other changes in the standard VUT tools* + + * *XXX: ...* + +* *XXX: changes in VRT that may affect VMOD authors* + + * *XXX: ...* + +* *XXX: changes for developers?* + + * *XXX: such as sanitizer flags?* + + * *XXX: ...* + +* *XXX: other changes in tools and infrastructure in and around + Varnish ...* + + * *XXX: anything new about project tools, VTEST & GCOV, etc?* + + * *XXX: ...* From hermunn at varnish-software.com Fri Sep 15 11:17:20 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:20 +0000 (UTC) Subject: [5.2] 9b9f981 Close the VFPs on error Message-ID: <20170915111720.4EE029835F@lists.varnish-cache.org> commit 9b9f98155814a741505f7886cf6c24c1133c89a0 Author: Federico G. Schwindt Date: Tue Sep 12 00:12:13 2017 +0100 Close the VFPs on error diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index fe3fdae..20b3596 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -544,6 +544,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) if (vfc->failed) { (void)VFP_Error(vfc, "Fetch pipeline failed to process"); bo->htc->doclose = SC_RX_BODY; + VFP_Close(vfc); VDI_Finish(wrk, bo); if (!bo->do_stream) { assert(bo->fetch_objcore->boc->state < BOS_STREAM); From hermunn at varnish-software.com Fri Sep 15 11:17:20 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:20 +0000 (UTC) Subject: [5.2] cd4c073 Remove referenses to repo.varnish-cache.org Message-ID: <20170915111720.79A2898373@lists.varnish-cache.org> commit cd4c0739f4789a2e067b21ad979677bc561e642e Author: Simon Vikstrom Date: Tue Sep 12 08:05:27 2017 +0200 Remove referenses to repo.varnish-cache.org diff --git a/README.Packaging b/README.Packaging index baccc17..71ac964 100644 --- a/README.Packaging +++ b/README.Packaging @@ -13,7 +13,7 @@ Official packages ----------------- The official Debian and Redhat packages are built by the Varnish Cache team -and made available on https://repo.varnish-cache.org/ . +and made available on https://packagecloud.io/varnishcache/ . Packaging files and scripts for Debian and Redhat: diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index d65588d..fba97e1 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -31,7 +31,7 @@ Red Hat / CentOS ---------------- We try to keep the latest version available as prebuilt RPMs (el5 and el6) -on `repo.varnish-cache.org `_. See the online +on `packagecloud.io/varnishcache `_. See the online `Red Hat installation instructions `_ for more information. @@ -62,7 +62,7 @@ want to compile Varnish from source for other reasons, follow these steps: Download the appropriate release tarball, which you can find on -http://repo.varnish-cache.org/source/ . +https://varnish-cache.org/releases/ . Alternatively, if you want to hack on Varnish, you should clone our git repository by doing. diff --git a/doc/sphinx/whats-new/relnote-5.0.rst b/doc/sphinx/whats-new/relnote-5.0.rst index 71b895e..513f46d 100644 --- a/doc/sphinx/whats-new/relnote-5.0.rst +++ b/doc/sphinx/whats-new/relnote-5.0.rst @@ -25,7 +25,7 @@ stuff in two separate documents: How to get Varnish 5.0 ---------------------- -`Source download `_ +`Source download `_ Packages for mainstream operating systems should appear in as soon as they trickle through the machinery. From hermunn at varnish-software.com Fri Sep 15 11:17:20 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:20 +0000 (UTC) Subject: [5.2] 1eb30b0 Add text about VSM/VSC renovation Message-ID: <20170915111720.9646E9838A@lists.varnish-cache.org> commit 1eb30b0a6345e41a31224fa22a0fed5d890a7aae Author: Poul-Henning Kamp Date: Tue Sep 12 08:34:44 2017 +0000 Add text about VSM/VSC renovation diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index e8d46d0..0c0140c 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -8,7 +8,14 @@ Changes in Varnish 5.2 Varnish statistics ~~~~~~~~~~~~~~~~~~ -*XXX: changes and new features of VSC/VSM* +The export of statistics counters via shared memory has been +overhauled to get rid of limitations which made sense 11 years +ago but no so much now. + +Statistics counters are now self-describing in shared memory, +paving the way so that VMODs or maybe even VCL can define +counters in the future, and have them show up in varnishstat +and other VSC-API based programs. .. _whatsnew_new_vmods: @@ -42,9 +49,33 @@ News for authors of VMODs and Varnish API client applications *XXX: such news may include:* -* *XXX: effects of new VSC/VSM on VMODs* +VSM/VSC API changes +------------------- + +The rewrite of the VSM/VSC code has similified the API and +made it much more robust, and code calling into these APIs +will have to be updated to match. + +The necessary changes mostly center around detecting if the +varnishd management/worker process has restarted. + +In the new VSM-api once setup is done, VSM_Attach() latches +on to a running varnishd master process and stays there. + +VSM_Status() returns information about the master and worker +process, if they are running, if they have been restarted +(since the previous call to VSM_Status()) and updates the +in-memory list of VSM segments. + +Each VSM segment is now a separate piece of shared memory +and the name of the segment can be much longer now. + +Before the actual shared memory can be accessed, the +applicaiton must call VSM_Map() and when VSM_StillValid() +indicates that the segment is no longer valid, VSM_Unmap() +should be called to release the segment again. -* *XXX: effects of new VSC/VSM on API client apps* +All in all, this should be simpler and more robust now. * *XXX: changes in VRT* From hermunn at varnish-software.com Fri Sep 15 11:17:20 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:20 +0000 (UTC) Subject: [5.2] 126a456 Add a blurb about VMOD blob to What's New in 5.2. Message-ID: <20170915111720.B1E599839A@lists.varnish-cache.org> commit 126a456ea85af0c9eea089ab23f62f606340e424 Author: Geoff Simmons Date: Tue Sep 12 10:59:38 2017 +0200 Add a blurb about VMOD blob to What's New in 5.2. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 0c0140c..a07b1c3 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -37,7 +37,19 @@ VMOD vtc VMOD blob --------- -*XXX: about VMOD blob* +We have added the variables ``req.hash`` and ``bereq.hash`` to VCL, +which contain the hash value computed by Varnish for the current +request, for use in cache lookup. Their data type is BLOB, which +represents arbitrary data of any length -- the new variables contain +the raw binary hashes. + +This is the first time that an element of standard VCL has the BLOB +type (BLOBs have only been used in third-party VMODs until now). So we +have added VMOD blob to facilitate their use. In particular, the VMOD +implements binary-to-text encodings, for example so that you can +assign the hash to a header as a base64 or hex string. It also +provides some other utilities such as getting the length of a BLOB or +testing BLOBs for equality. See :ref:`vmod_blob(3)`. XXX: Any other headline changes ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From hermunn at varnish-software.com Fri Sep 15 11:17:20 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:20 +0000 (UTC) Subject: [5.2] 58aa154 Typo Message-ID: <20170915111720.D7E3F983AB@lists.varnish-cache.org> commit 58aa15454ab56be0cabedb55728f9d6339d8ff38 Author: Geoff Simmons Date: Tue Sep 12 11:01:13 2017 +0200 Typo diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index a07b1c3..0e3a9b6 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -10,7 +10,7 @@ Varnish statistics The export of statistics counters via shared memory has been overhauled to get rid of limitations which made sense 11 years -ago but no so much now. +ago but not so much now. Statistics counters are now self-describing in shared memory, paving the way so that VMODs or maybe even VCL can define From hermunn at varnish-software.com Fri Sep 15 11:17:20 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:20 +0000 (UTC) Subject: [5.2] 11d6e28 Update copyright notice Message-ID: <20170915111721.01B7E983BA@lists.varnish-cache.org> commit 11d6e28a628afc3a805dec7925df02daff9504b2 Author: Dridi Boukelmoune Date: Tue Sep 12 10:16:49 2017 +0200 Update copyright notice diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index e3e343d..0f3fb80 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011-2015 Varnish Software AS + * Copyright (c) 2011-2017 Varnish Software AS * All rights reserved. * * Author: Tollef Fog Heen @@ -116,6 +116,7 @@ LIBVARNISHAPI_2.0 { VSM__itern; VSM_invalid; VSM_valid; + # vtim.c VTIM_format; VTIM_mono; From hermunn at varnish-software.com Fri Sep 15 11:17:21 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:21 +0000 (UTC) Subject: [5.2] 01555ad Sort new VMODs in alphabetic order Message-ID: <20170915111721.26F92983CB@lists.varnish-cache.org> commit 01555ada79f0c771657bfb4359165f867f361ea2 Author: Dridi Boukelmoune Date: Tue Sep 12 11:03:30 2017 +0200 Sort new VMODs in alphabetic order And some whitespace cleanup. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 0e3a9b6..4804a86 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -24,16 +24,6 @@ New VMODs in the standard distribution *XXX: introductory paragraphs about new VMODs* -VMOD purge ----------- - -*XXX: about VMOD purge* - -VMOD vtc --------- - -*XXX: about VMOD vtc* - VMOD blob --------- @@ -51,6 +41,16 @@ assign the hash to a header as a base64 or hex string. It also provides some other utilities such as getting the length of a BLOB or testing BLOBs for equality. See :ref:`vmod_blob(3)`. +VMOD purge +---------- + +*XXX: about VMOD purge* + +VMOD vtc +-------- + +*XXX: about VMOD vtc* + XXX: Any other headline changes ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8048cb8..cc70923 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -16,7 +16,7 @@ varnishd parameters * *XXX: -p params that are new, modified, deprecated or removed* * *XXX: use rst refs to keep it short* - + * *XXX: ...* Changes to VCL @@ -59,9 +59,9 @@ vmod_std New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See :ref:`vmod_purge(3)`, :ref:`vmod_vtc(3)`, :ref:`vmod_blob(3)` and +See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)`, :ref:`vmod_vtc(3)` and :ref:`whatsnew_new_vmods`. - + Other changes ============= From hermunn at varnish-software.com Fri Sep 15 11:17:21 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:21 +0000 (UTC) Subject: [5.2] 5064880 Expose vcstool to external projects Message-ID: <20170915111721.4939A983DA@lists.varnish-cache.org> commit 506488015ad9e0e04871d85980ebbe9ccfbedf6f Author: Dridi Boukelmoune Date: Tue Sep 12 18:23:00 2017 +0200 Expose vcstool to external projects diff --git a/varnish.m4 b/varnish.m4 index 9a7f868..8d4a486 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -28,8 +28,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. -# varnish.m4 - Macros to define VMOD builds. -*- Autoconf -*- -# serial 7 (varnish-5.1.2) +# varnish.m4 - Macros to build against Varnish. -*- Autoconf -*- +# serial 8 (varnish-5.2.0) # # This collection of macros helps create VMODs or tools interacting with # Varnish Cache using the GNU build system (autotools). In order to work @@ -85,6 +85,7 @@ AC_DEFUN([_VARNISH_PKG_CONFIG], [ PKG_CHECK_VAR([VARNISHAPI_VMODDIR], [varnishapi], [vmoddir]) PKG_CHECK_VAR([VMODTOOL], [varnishapi], [vmodtool]) + PKG_CHECK_VAR([VCSTOOL], [varnishapi], [vcstool]) AC_SUBST([VARNISH_LIBRARY_PATH], [$VARNISHAPI_LIBDIR:$VARNISHAPI_LIBDIR/varnish]) @@ -384,6 +385,9 @@ AC_DEFUN([VARNISH_VMODS], [ # - vcldir added # - pkgvcldir added # +# Since Varnish 5.2.0: +# - VCSTOOL added +# # Verify that the version of Varnish Cache found by pkg-config is at least # MINIMUM-VERSION. If MAXIMUM-VERSION is specified, verify that the version # is strictly below MAXIMUM-VERSION. @@ -408,6 +412,7 @@ AC_DEFUN([VARNISH_VMODS], [ # - VARNISHAPI_VCLDIR # - VARNISHAPI_VMODDIR # - VMODTOOL +# - VCSTOOL # # In addition, two directories are set up for installation in automake: # diff --git a/varnishapi.pc.in b/varnishapi.pc.in index b452f6b..b9c638b 100644 --- a/varnishapi.pc.in +++ b/varnishapi.pc.in @@ -13,6 +13,7 @@ pkgdatadir=${datadir}/@PACKAGE@ vcldir=${pkgdatadir}/vcl vmoddir=${libdir}/@PACKAGE@/vmods vmodtool=${pkgdatadir}/vmodtool.py +vcstool=${pkgdatadir}/vcstool.py Name: VarnishAPI Description: Varnish API From hermunn at varnish-software.com Fri Sep 15 11:17:21 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:21 +0000 (UTC) Subject: [5.2] 8bfe521 Whitespace OCD Message-ID: <20170915111721.9F6209840E@lists.varnish-cache.org> commit 8bfe521cd52e60d6dad2082f2462a096a49acac6 Author: Poul-Henning Kamp Date: Wed Sep 13 09:21:36 2017 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index 81b654d..e4d963c 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -52,15 +52,15 @@ varnish v1 -vcl { set resp.http.truncated = blob.encode(IDENTITY, - blob=blob.decode(HEX, encoded="666f6f00626172")); + blob=blob.decode(HEX, encoded="666f6f00626172")); set resp.http.lc = blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, - encoded="Don't care")); + encoded="Don't care")); set resp.http.uc = blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, - encoded="Don't care")); + encoded="Don't care")); } } -start diff --git a/bin/varnishtest/tests/m00034.vtc b/bin/varnishtest/tests/m00034.vtc index 95ea934..9d7144e 100644 --- a/bin/varnishtest/tests/m00034.vtc +++ b/bin/varnishtest/tests/m00034.vtc @@ -15,7 +15,7 @@ varnish v1 -vcl { set resp.http.hobbes = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, - encoded= + encoded= {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."})); set resp.http.list = @@ -27,7 +27,7 @@ varnish v1 -vcl { set resp.http.empty = blob.encode(IDENTITY, - blob=blob.decode(IDENTITY, length=5, encoded="")); + blob=blob.decode(IDENTITY, length=5, encoded="")); set resp.http.undef = blob.encode(IDENTITY, blob=blob.decode(IDENTITY, length=5, diff --git a/bin/varnishtest/tests/m00035.vtc b/bin/varnishtest/tests/m00035.vtc index 6190914..9f7df33 100644 --- a/bin/varnishtest/tests/m00035.vtc +++ b/bin/varnishtest/tests/m00035.vtc @@ -20,11 +20,11 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.hex = blob.encode(HEX, blob=blob.decode(IDENTITY, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.hexlc = blob.encode(HEX, LOWER, - blob.decode(IDENTITY, encoded=req.http.pangram)); + blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.hexuc = blob.encode(HEX, UPPER, @@ -32,27 +32,27 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.hobbes = blob.encode(HEX, blob=blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.hobbeslc = blob.encode(HEX, LOWER, blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEX, UPPER, blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.all = blob.encode(HEX, blob=blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-lc = blob.encode(HEX, LOWER, blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-uc = blob.encode(HEX, UPPER, blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.empty = blob.encode(HEX, blob=blob.decode(IDENTITY, encoded="")); @@ -99,19 +99,19 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.decalluc = blob.encode(BASE64, blob=blob.decode(HEX, - encoded=req.http.hexalluc)); + encoded=req.http.hexalluc)); set resp.http.decalllc = blob.encode(BASE64, blob=blob.decode(HEX, - encoded=req.http.hexalllc)); + encoded=req.http.hexalllc)); set resp.http.decallucodd = blob.encode(BASE64, - blob=blob.decode(HEX, encoded=req.http.hexallucodd)); + blob=blob.decode(HEX, encoded=req.http.hexallucodd)); set resp.http.decalllcodd = blob.encode(BASE64, - blob=blob.decode(HEX, encoded=req.http.hexalllcodd)); + blob=blob.decode(HEX, encoded=req.http.hexalllcodd)); set resp.http.decempty = blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="")); @@ -125,13 +125,13 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.decemptypieces = blob.encode(IDENTITY, blob=blob.decode(HEX, encoded=req.http.unset + "" - + req.http.unset + "")); + + req.http.unset + "")); set req.http.part1 = "666"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob=blob.decode(HEX, - encoded=req.http.part1 + - "F6F206261722062617A2071757578")); + encoded=req.http.part1 + + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; set resp.http.dec3param = @@ -142,12 +142,12 @@ varnish v1 -arg "-p workspace_client=256k" -vcl { set resp.http.dec3pieces = blob.encode(IDENTITY, blob=blob.decode(HEX, - encoded=req.http.part1 + + encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, blob=blob.decode(HEX, encoded= - "" + req.http.unset + "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 diff --git a/bin/varnishtest/tests/m00036.vtc b/bin/varnishtest/tests/m00036.vtc index 635d726..12e1c24 100644 --- a/bin/varnishtest/tests/m00036.vtc +++ b/bin/varnishtest/tests/m00036.vtc @@ -20,7 +20,7 @@ varnish v1 -vcl { set resp.http.hexlc = blob.encode(HEX, blob=blob.decode(IDENTITY, 5, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.hexuc = blob.encode(HEX, UPPER, @@ -28,20 +28,20 @@ varnish v1 -vcl { set resp.http.hobbeslc = blob.encode(HEX, - blob=blob.decode(IDENTITY, 5, - encoded=req.http.hobbes)); + blob=blob.decode(IDENTITY, 5, + encoded=req.http.hobbes)); set resp.http.hobbesuc = blob.encode(HEX, UPPER, - blob.decode(IDENTITY, 5, encoded=req.http.hobbes)); + blob.decode(IDENTITY, 5, encoded=req.http.hobbes)); set resp.http.all-lc = blob.encode(HEX, blob=blob.decode(BASE64, 8, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-uc = blob.encode(HEX, UPPER, - blob.decode(BASE64, 8, encoded=req.http.b64all)); + blob.decode(BASE64, 8, encoded=req.http.b64all)); set resp.http.empty-lc = blob.encode(HEX, blob=blob.decode(IDENTITY, 5, encoded="")); @@ -51,13 +51,13 @@ varnish v1 -vcl { set resp.http.hexlcparam = blob.encode(blob=blob.decode(IDENTITY, 5, - encoded=req.http.pangram), - encoding=HEX, case=LOWER); + encoded=req.http.pangram), + encoding=HEX, case=LOWER); set resp.http.hexucparam = blob.encode(blob=blob.decode(IDENTITY, 5, - encoded=req.http.pangram), - encoding=HEX, case=UPPER); + encoded=req.http.pangram), + encoding=HEX, case=UPPER); set req.http.hexucfoobar = "666F6F206261722062617A2071757578"; set req.http.hexlcfoobar = std.tolower(req.http.hexucfoobar); @@ -72,30 +72,30 @@ varnish v1 -vcl { set resp.http.decuc = blob.encode(IDENTITY, blob=blob.decode(HEX, 10, - encoded=req.http.hexucfoobar)); + encoded=req.http.hexucfoobar)); set resp.http.declc = blob.encode(IDENTITY, blob=blob.decode(HEX, 10, - encoded=req.http.hexlcfoobar)); + encoded=req.http.hexlcfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, blob=blob.decode(HEX, 12, - encoded=req.http.hexhobbesuc)); + encoded=req.http.hexhobbesuc)); set resp.http.dechobbeslc = blob.encode(IDENTITY, blob=blob.decode(HEX, 12, - encoded=req.http.hexhobbeslc)); + encoded=req.http.hexhobbeslc)); set resp.http.decalluc = blob.encode(BASE64, - blob=blob.decode(HEX, 12, encoded=req.http.hexalluc)); + blob=blob.decode(HEX, 12, encoded=req.http.hexalluc)); set resp.http.decalllc = blob.encode(BASE64, - blob=blob.decode(HEX, 12, encoded=req.http.hexalllc)); + blob=blob.decode(HEX, 12, encoded=req.http.hexalllc)); set resp.http.decallucodd = blob.encode(BASE64, blob=blob.decode(HEX, 11, @@ -122,8 +122,8 @@ varnish v1 -vcl { set req.http.part1 = "666"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob=blob.decode(HEX, 6, - encoded=req.http.part1 + - "F6F206261722062617A2071757578")); + encoded=req.http.part1 + + "F6F206261722062617A2071757578")); set req.http.part2 = "57578"; set resp.http.dec3param = @@ -134,12 +134,12 @@ varnish v1 -vcl { set resp.http.dec3pieces = blob.encode(IDENTITY, blob=blob.decode(HEX, 30, - encoded=req.http.part1 + + encoded=req.http.part1 + "F6F206261722062617A20717" + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, blob=blob.decode(HEX, 20, encoded="" - + req.http.unset + + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "F6F206261722062617A20717" + "" + req.http.unset + req.http.part2 @@ -192,7 +192,7 @@ varnish v1 -vcl+backend { set req.http.foo = "123"; set resp.http.badhex = blob.encode(HEX, UPPER, blob.decode(HEX, 2, - encoded="g" + req.http.foo)); + encoded="g" + req.http.foo)); } } diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index e8ee70a..3209394 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -35,7 +35,7 @@ varnish v1 -vcl { set resp.http.b64all = blob.encode(BASE64, blob=blob.decode(HEX, - encoded=req.http.hexall)); + encoded=req.http.hexall)); set resp.http.b64url = blob.encode(BASE64URL, @@ -55,7 +55,7 @@ varnish v1 -vcl { set resp.http.b64urlall = blob.encode(BASE64URL, blob=blob.decode(HEX, - encoded=req.http.hexall)); + encoded=req.http.hexall)); set resp.http.b64urlnopad = blob.encode(BASE64URLNOPAD, @@ -83,7 +83,7 @@ varnish v1 -vcl { blob.encode(BASE64URL, blob=blob.decode(IDENTITY, encoded="")); set resp.http.nopadempty = blob.encode(BASE64URLNOPAD, - blob=blob.decode(IDENTITY, encoded="")); + blob=blob.decode(IDENTITY, encoded="")); set resp.http.b64param = blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), @@ -99,11 +99,11 @@ varnish v1 -vcl { set resp.http.b64xcode = blob.transcode(IDENTITY, BASE64, - encoded=req.url + "Hello world" + req.url); + encoded=req.url + "Hello world" + req.url); set resp.http.b64urlxcode = blob.transcode(IDENTITY, BASE64URL, - encoded=req.url + "Hello world" + req.url); + encoded=req.url + "Hello world" + req.url); set resp.http.b64urlnopadxcode = blob.transcode(IDENTITY, BASE64URLNOPAD, @@ -161,7 +161,7 @@ varnish v1 -vcl { set resp.http.dec = blob.encode(IDENTITY, blob= blob.decode(BASE64, - encoded=req.http.foobarbazquux)); + encoded=req.http.foobarbazquux)); set resp.http.dec2 = blob.encode(IDENTITY, @@ -184,13 +184,13 @@ varnish v1 -vcl { set resp.http.nopaddechobbes = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, + blob=blob.decode(BASE64URLNOPAD, encoded=req.http.hobbesnopad)); set resp.http.nopaddecall = blob.encode(HEX, blob=blob.decode(BASE64URLNOPAD, - encoded=req.http.allurl)); + encoded=req.http.allurl)); set resp.http.b64empty = blob.encode(IDENTITY, blob=blob.decode(BASE64, encoded="")); @@ -198,7 +198,7 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob=blob.decode(BASE64URL, encoded="")); set resp.http.nopadempty = blob.encode(IDENTITY, - blob=blob.decode(BASE64URLNOPAD, encoded="")); + blob=blob.decode(BASE64URLNOPAD, encoded="")); set resp.http.emptypieces = blob.encode(IDENTITY, blob= blob.decode(BASE64, encoded=req.http.unset + "" + req.http.unset @@ -207,7 +207,7 @@ varnish v1 -vcl { set resp.http.decenc = blob.encode(BASE64, blob=blob.decode(BASE64, - encoded=req.http.foobarbazquux)); + encoded=req.http.foobarbazquux)); set resp.http.l = "L"; set resp.http.dec2pieces @@ -305,7 +305,7 @@ varnish v1 -vcl+backend { elsif (req.url == "/base64urlnopad") { set resp.http.badpad = blob.encode(IDENTITY, blob=blob.decode(BASE64URLNOPAD, - encoded="TWFu" + req.http.foo)); + encoded="TWFu" + req.http.foo)); } } } diff --git a/bin/varnishtest/tests/m00039.vtc b/bin/varnishtest/tests/m00039.vtc index 2149585..bfcd67e 100644 --- a/bin/varnishtest/tests/m00039.vtc +++ b/bin/varnishtest/tests/m00039.vtc @@ -23,75 +23,75 @@ varnish v1 -vcl { set resp.http.url = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.urllc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.urluc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.pangram)); + encoded=req.http.pangram)); set resp.http.hobbes = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.hobbeslc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.hobbesuc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.hobbes)); + encoded=req.http.hobbes)); set resp.http.umlauts = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.umlauts)); + encoded=req.http.umlauts)); set resp.http.umlautslc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.umlauts)); + encoded=req.http.umlauts)); set resp.http.umlautsuc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.umlauts)); + encoded=req.http.umlauts)); set resp.http.phk = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.phkspeak)); + encoded=req.http.phkspeak)); set resp.http.phklc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.phkspeak)); + encoded=req.http.phkspeak)); set resp.http.phkuc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.phkspeak)); + encoded=req.http.phkspeak)); set resp.http.utf8 = blob.encode(URL, blob=blob.decode(IDENTITY, - encoded=req.http.utf8)); + encoded=req.http.utf8)); set resp.http.utf8lc = blob.encode(URL, LOWER, blob.decode(IDENTITY, - encoded=req.http.utf8)); + encoded=req.http.utf8)); set resp.http.utf8uc = blob.encode(URL, UPPER, blob.decode(IDENTITY, - encoded=req.http.utf8)); + encoded=req.http.utf8)); set resp.http.all = blob.encode(URL, blob=blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-lc = blob.encode(URL, LOWER, blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.all-uc = blob.encode(URL, UPPER, blob.decode(BASE64, - encoded=req.http.b64all)); + encoded=req.http.b64all)); set resp.http.empty = blob.encode(URL, blob=blob.decode(IDENTITY, encoded="")); @@ -175,7 +175,7 @@ varnish v1 -vcl { set resp.http.decmixed = blob.encode(IDENTITY, blob=blob.decode(URL, - encoded=req.http.urlmixedfoobar)); + encoded=req.http.urlmixedfoobar)); set resp.http.dechobbesuc = blob.encode(IDENTITY, @@ -211,11 +211,11 @@ varnish v1 -vcl { set resp.http.decalluc = blob.encode(BASE64, blob=blob.decode(URL, - encoded=req.http.urlalluc)); + encoded=req.http.urlalluc)); set resp.http.decalllc = blob.encode(BASE64, blob=blob.decode(URL, - encoded=req.http.urlalllc)); + encoded=req.http.urlalllc)); set resp.http.decempty = blob.encode(IDENTITY, blob=blob.decode(URL, encoded="")); @@ -231,8 +231,8 @@ varnish v1 -vcl { set req.http.part1 = "foo%"; set resp.http.dec2pieces = blob.encode(IDENTITY, blob=blob.decode(URL, - encoded=req.http.part1 + - "20bar%20baz%20quux")); + encoded=req.http.part1 + + "20bar%20baz%20quux")); set req.http.part2 = "0quux"; set resp.http.dec3param = @@ -243,11 +243,11 @@ varnish v1 -vcl { set resp.http.dec3pieces = blob.encode(IDENTITY, blob=blob.decode(URL, encoded= - req.http.part1 + "20bar%20baz%2" + req.http.part2)); + req.http.part1 + "20bar%20baz%2" + req.http.part2)); set resp.http.decmanypieces = blob.encode(IDENTITY, blob=blob.decode(URL, encoded= - "" + req.http.unset + "" + req.http.unset + req.http.part1 + req.http.unset + "" + req.http.unset + "" + "20bar%20baz%2" + "" + req.http.unset + req.http.part2 @@ -294,7 +294,7 @@ varnish v1 -vcl+backend { if (req.url == "/percent") { set resp.http.bad = blob.encode(URL, UPPER, blob.decode(URL, - encoded="%")); + encoded="%")); } elsif (req.url == "/percent-two") { set resp.http.bad = blob.encode(URL, UPPER, diff --git a/bin/varnishtest/tests/m00041.vtc b/bin/varnishtest/tests/m00041.vtc index 4056d9c..4c543d8 100644 --- a/bin/varnishtest/tests/m00041.vtc +++ b/bin/varnishtest/tests/m00041.vtc @@ -302,7 +302,7 @@ varnish v1 -vcl { set resp.http.urlalldownuc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, - encoded=req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownlc2b64 = blob.transcode(URL, BASE64, encoded=req.http.urlalldownlc); @@ -312,7 +312,7 @@ varnish v1 -vcl { set resp.http.urlalldownlc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, - encoded=req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlallupuc2b64 = blob.transcode(URL, BASE64, encoded=req.http.urlallupuc); diff --git a/bin/varnishtest/tests/m00042.vtc b/bin/varnishtest/tests/m00042.vtc index ecd8b44..aaac4b9 100644 --- a/bin/varnishtest/tests/m00042.vtc +++ b/bin/varnishtest/tests/m00042.vtc @@ -23,15 +23,15 @@ varnish v1 -vcl { set resp.http.id2id = blob.transcode(IDENTITY, IDENTITY, length=5, - encoded="Hello world"); + encoded="Hello world"); set resp.http.id2b64 = blob.transcode(IDENTITY, BASE64, length=5, - encoded=req.http.hobbes); + encoded=req.http.hobbes); set resp.http.id2b64nopad = blob.transcode(IDENTITY, BASE64URLNOPAD, length=5, - encoded=req.http.hobbes); + encoded=req.http.hobbes); set resp.http.id2hex = blob.transcode(IDENTITY, HEX, length=5, encoded=req.http.hobbes); @@ -53,34 +53,34 @@ varnish v1 -vcl { set resp.http.b642id = blob.transcode(BASE64, IDENTITY, length=8, - encoded=req.http.hobbesb64); + encoded=req.http.hobbesb64); set resp.http.hex2id = blob.transcode(HEX, IDENTITY, length=12, - encoded=req.http.hexhobbes); + encoded=req.http.hexhobbes); set resp.http.hexalldown2b64 = blob.transcode(HEX, BASE64, length=12, - encoded=req.http.hexalldown); + encoded=req.http.hexalldown); set resp.http.hexalldown2b64url = blob.transcode(HEX, BASE64URL, length=12, - encoded=req.http.hexalldown); + encoded=req.http.hexalldown); set resp.http.hexalldown2b64nopad = blob.transcode(HEX, BASE64URLNOPAD, length=10, - encoded=req.http.hexalldown); + encoded=req.http.hexalldown); set resp.http.hexallup2b64 = blob.transcode(HEX, BASE64, length=12, encoded=req.http.hexallup); set resp.http.hexallup2b64url = blob.transcode(HEX, BASE64URL, length=10, - encoded=req.http.hexallup); + encoded=req.http.hexallup); set resp.http.hexallup2b64nopad = blob.transcode(HEX, BASE64URLNOPAD, length=10, - encoded=req.http.hexallup); + encoded=req.http.hexallup); set resp.http.hexalldown2url = blob.transcode(HEX, URL, length=12, encoded=req.http.hexalldown); @@ -157,7 +157,7 @@ varnish v1 -vcl { set resp.http.b64allurl2hex = blob.transcode(BASE64URL, HEX, length=8, - encoded=req.http.b64allurl); + encoded=req.http.b64allurl); set resp.http.b64allurl2hexuc = blob.transcode(BASE64URL, HEX, UPPER, 8, req.http.b64allurl); @@ -176,7 +176,7 @@ varnish v1 -vcl { set resp.http.b64allurl2url = blob.transcode(BASE64URL, URL, length=8, - encoded=req.http.b64allurl); + encoded=req.http.b64allurl); set resp.http.b64allurl2urluc = blob.transcode(BASE64URL, URL, UPPER, 8, req.http.b64allurl); @@ -286,19 +286,19 @@ varnish v1 -vcl { set resp.http.urluc2id = blob.transcode(URL, IDENTITY, length=27, - encoded=req.http.urlhobbesuc); + encoded=req.http.urlhobbesuc); set resp.http.urllc2id = blob.transcode(URL, IDENTITY, length=63, - encoded=req.http.urlhobbeslc); + encoded=req.http.urlhobbeslc); set resp.http.urlalldownuc2b64 = blob.transcode(URL, BASE64, length=18, - encoded=req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64url = blob.transcode(URL, BASE64URL, length=15, - encoded=req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, length=15, @@ -306,11 +306,11 @@ varnish v1 -vcl { set resp.http.urlalldownlc2b64 = blob.transcode(URL, BASE64, length=18, - encoded=req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64url = blob.transcode(URL, BASE64URL, length=15, - encoded=req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, length=15, @@ -318,11 +318,11 @@ varnish v1 -vcl { set resp.http.urlallupuc2b64 = blob.transcode(URL, BASE64, length=36, - encoded=req.http.urlallupuc); + encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64url = blob.transcode(URL, BASE64URL, length=33, - encoded=req.http.urlallupuc); + encoded=req.http.urlallupuc); set resp.http.urlallupuc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, length=33, @@ -330,11 +330,11 @@ varnish v1 -vcl { set resp.http.urlalluplc2b64 = blob.transcode(URL, BASE64, length=36, - encoded=req.http.urlalluplc); + encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64url = blob.transcode(URL, BASE64URL, length=33, - encoded=req.http.urlalluplc); + encoded=req.http.urlalluplc); set resp.http.urlalluplc2b64nopad = blob.transcode(URL, BASE64URLNOPAD, length=33, @@ -342,7 +342,7 @@ varnish v1 -vcl { set resp.http.urlalldownuc2url = blob.transcode(URL, URL, length=423, - encoded=req.http.urlalldownuc); + encoded=req.http.urlalldownuc); set resp.http.urlalldownuc2urluc = blob.transcode(URL, URL, UPPER, 423, req.http.urlalldownuc); @@ -352,7 +352,7 @@ varnish v1 -vcl { set resp.http.urlalldownlc2url = blob.transcode(URL, URL, length=423, - encoded=req.http.urlalldownlc); + encoded=req.http.urlalldownlc); set resp.http.urlalldownlc2urluc = blob.transcode(URL, URL, UPPER, 423, req.http.urlalldownlc); @@ -427,12 +427,12 @@ varnish v1 -vcl+backend { if (req.url == "/1") { set resp.http.good = blob.transcode(URL, IDENTITY, length=3, - encoded="%2c%q"); + encoded="%2c%q"); } elsif (req.url == "/2") { set resp.http.good = blob.transcode(URL, IDENTITY, length=3, - encoded="%3a%2q"); + encoded="%3a%2q"); } elsif (req.url == "/3") { set resp.http.bad @@ -473,12 +473,12 @@ varnish v1 -vcl+backend { elsif (req.url == "/10") { set resp.http.bad = blob.transcode(URL, IDENTITY, length=1, - encoded="%20"); + encoded="%20"); } elsif (req.url == "/11") { set resp.http.bad = blob.transcode(URL, IDENTITY, length=2, - encoded="%20"); + encoded="%20"); } } } diff --git a/bin/varnishtest/tests/m00044.vtc b/bin/varnishtest/tests/m00044.vtc index e68374a..edad4d4 100644 --- a/bin/varnishtest/tests/m00044.vtc +++ b/bin/varnishtest/tests/m00044.vtc @@ -36,7 +36,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { # transcode() converts from one encoding to another. set req.http.Hex-Encoded = blob.transcode(decoding=BASE64, encoding=HEX, case=UPPER, - encoded="YmF6"); + encoded="YmF6"); # transcode() can replace other specific encoding/deconding # vmods - e.g. vmod_urlcode @@ -54,7 +54,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { sub vcl_deliver { set resp.http.Trunced-Foo1 = blob.encode(IDENTITY, blob=blob.decode(HEX, - encoded="666f6f00626172")); + encoded="666f6f00626172")); set resp.http.Trunced-Foo2 = blob.encode(blob=blob.decode(HEX, encoded="666f6f00626172")); } @@ -74,7 +74,7 @@ varnish v1 -arg "-p http_max_hdr=128" -vcl+backend { sub vcl_deliver { set resp.http.encode1 = blob.encode(HEX, blob=blob.decode(BASE64, - encoded="Zm9vYmFyYmF6")); + encoded="Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 diff --git a/bin/varnishtest/tests/m00045.vtc b/bin/varnishtest/tests/m00045.vtc index d82e7f5..345534c 100644 --- a/bin/varnishtest/tests/m00045.vtc +++ b/bin/varnishtest/tests/m00045.vtc @@ -188,10 +188,10 @@ varnish v1 -vcl { = blob.encode(BASE64, blob=blob.sub(down07.get(), 4B)); set resp.http.up04050607 = blob.encode(BASE64, - blob=blob.sub(up07.get(), 4B, 4B)); + blob=blob.sub(up07.get(), 4B, 4B)); set resp.http.down03 = blob.encode(BASE64, - blob=blob.sub(down07.get(), 4B, 4B)); + blob=blob.sub(down07.get(), 4B, 4B)); set resp.http.up07 = blob.encode(BASE64, blob=blob.sub(up07.get(), 8B)); set resp.http.down07 @@ -239,7 +239,7 @@ varnish v1 -vcl+backend { elsif (req.url == "/toolong") { set resp.http.toolong = blob.encode(BASE64, - blob=blob.sub(up07.get(), 9B)); + blob=blob.sub(up07.get(), 9B)); } elsif (req.url == "/badoffset") { set resp.http.badoffset = blob.encode(BASE64, diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 2c4df6d..48e42c3 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -52,9 +52,9 @@ Examples:: # decode() and encode() functions convert blobs to text and # vice versa at runtime. set resp.http.Base64-Encoded - = blob.encode(BASE64, - blob=blob.decode(HEX, - encoded=req.http.Hex-Encoded)); + = blob.encode(BASE64, + blob=blob.decode(HEX, + encoded=req.http.Hex-Encoded)); } sub vcl_recv { @@ -122,7 +122,7 @@ blob. For example:: # The header will be seen as "foo". set resp.http.Trunced-Foo1 = blob.encode(IDENTITY, blob=blob.decode(HEX, - encoded="666f6f00626172")); + encoded="666f6f00626172")); IDENTITY is the default encoding and decoding. So the above can also be written as:: @@ -175,7 +175,7 @@ byte. For example:: set resp.http.Second = "def0"; set resp.http.Hex-Decoded = blob.encode(HEX, blob=blob.decode(HEX, - encoded=resp.http.First + resp.http.Second)); + encoded=resp.http.First + resp.http.Second)); URL --- @@ -188,8 +188,8 @@ The ``URL`` encoding implements "percent encoding" as per RFC3986. The affect alphabetic characters that are not percent-encoded. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, - HEX, URL} decoding="IDENTITY", INT length=0, - STRING_LIST encoded) + HEX, URL} decoding="IDENTITY", INT length=0, + STRING_LIST encoded) Returns the BLOB derived from the string ``encoded`` according to the scheme specified by ``decoding``. @@ -225,7 +225,7 @@ Example:: set resp.http.encode1 = blob.encode(HEX, - blob=blob.decode(BASE64, encoded="Zm9vYmFyYmF6")); + blob=blob.decode(BASE64, encoded="Zm9vYmFyYmF6")); # same with named parameters set resp.http.encode2 @@ -260,7 +260,7 @@ defaults to LOWER. Example:: set resp.http.Hex2Base64-1 - = blob.transcode(HEX, BASE64, encoded="666f6f"); + = blob.transcode(HEX, BASE64, encoded="666f6f"); # same with named parameters set resp.http.Hex2Base64-2 From hermunn at varnish-software.com Fri Sep 15 11:17:21 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:21 +0000 (UTC) Subject: [5.2] 4452ca8 Document -p param changes in Upgrading to 5.2. Message-ID: <20170915111721.C024998420@lists.varnish-cache.org> commit 4452ca81b69fe25f1c0ca4ada1a0b089a9896ecf Author: Geoff Simmons Date: Wed Sep 13 12:09:35 2017 +0200 Document -p param changes in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 2164e32..bf7da09 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -13,11 +13,13 @@ counters, but these should all be transparent at the user-level. varnishd parameters =================== -* *XXX: -p params that are new, modified, deprecated or removed* +The :ref:`ref_param_cli_buffer` parameter is deprecated and +ignored. Memory for the CLI command buffer is now dynamically +allocated. -* *XXX: use rst refs to keep it short* - -* *XXX: ...* +We have updated the documentation for :ref:`ref_param_send_timeout`, +:ref:`ref_param_idle_send_timeout`, :ref:`ref_param_timeout_idle` and +:ref:`ref_param_ban_cutoff`. Changes to VCL ============== From hermunn at varnish-software.com Fri Sep 15 11:17:21 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:21 +0000 (UTC) Subject: [5.2] 7be4e10 Grammar/phrasing Message-ID: <20170915111721.DD47998439@lists.varnish-cache.org> commit 7be4e106939281b4d7161c82139d38703bd58608 Author: Geoff Simmons Date: Wed Sep 13 12:19:10 2017 +0200 Grammar/phrasing diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index bf7da09..0151c33 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -61,8 +61,8 @@ vmod_std New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)`, :ref:`vmod_vtc(3)` and -:ref:`whatsnew_new_vmods`. +See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and +:ref:`vmod_vtc(3)`. See :ref:`whatsnew_new_vmods`. Other changes ============= From hermunn at varnish-software.com Fri Sep 15 11:17:22 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:22 +0000 (UTC) Subject: [5.2] b54cf7d Documentation Message-ID: <20170915111722.0B7B698447@lists.varnish-cache.org> commit b54cf7d09201ba53d760ae99a15498d6044ab515 Author: Dridi Boukelmoune Date: Wed Sep 13 12:19:29 2017 +0200 Documentation diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 5688246..de73237 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -35,7 +35,11 @@ See :ref:`vmod_blob(3)`. VMOD purge ---------- -*XXX: DRIDI ? about VMOD purge* +Before the introduction of ``vcl 4.0`` there used to be a ``purge`` function +instead of a ``return(purge)`` transition. This module works like old-style +VCL purges (which should be used from both ``vcl_hit`` and ``vcl_miss``) and +provides more capabilities than regular purges, and lets you know how many +objects were affected. See :ref:`vmod_purge(3)`. @@ -53,7 +57,9 @@ pretty evil functionality, for instance ``debug.panic()``. We have split the non-suicidal test-writing stuff from ``vmod_debug`` into a new ``vmod_vtc``, which is included in binary releases from now on, in order to make it easier for people to use ``varnishtest`` -to test local configurations, VMODs etc. +to test local configurations, VMODs etc. The main highlight is that you +can now synchronize barriers with VCL code thanks to ``vmod_vtc``, other +conveniences were added like workspace manipulations. See :ref:`vmod_vtc(3)`. @@ -71,7 +77,21 @@ News for authors of VMODs and Varnish API client applications $ABI [strict|vrt] ----------------- -*XXX: DRIDI ?* +VMOD authors have the option of only integrating with the blessed +interface provided by ``varnishd`` or go deeper in the stack. As +a general rule of thumb you are considered "on your own" if your +VMOD uses more than the VRT (Varnish RunTime) and it is supposed +to be built for the exact Varnish version. + +Varnish was already capable of checking the major/minor VRT version +a VMOD was built against, or require the exact version, but picking +one or the other depended on how Varnish was built. + +VMOD authors can now specify whether a module complies to the VRT +and only needs to be rebuilt when breaking changes are introduced +by adding ``$ABI vrt`` to their VCC descriptor. The default value +is ``$ABI strict`` when omitted, and all VMODs from the standard +Varnish distribution have a strict requirement. VSM/VSC API changes ------------------- @@ -93,7 +113,7 @@ This paves the way for VMODs or maybe even VCL to define custom counters, and have them show up in varnishstat and other VSC-API based programs just like the rest of the counters. -The rewrite of the VSM/VSC code similified both APIs and +The rewrite of the VSM/VSC code simplified both APIs and made them much more robust but code calling into these APIs will have to be updated to match. @@ -112,12 +132,26 @@ Each VSM segment is now a separate piece of shared memory and the name of the segment can be much longer now. Before the actual shared memory can be accessed, the -applicaiton must call VSM_Map() and when VSM_StillValid() +application must call VSM_Map() and when VSM_StillValid() indicates that the segment is no longer valid, VSM_Unmap() should be called to release the segment again. All in all, this should be simpler and more robust now. -*XXX: changes in VRT* +VRT API changes +--------------- + +``VRT_purge`` now fails a transaction instead of panicking when used +outside of ``vcl_hit`` or ``vcl_miss``. It also returns the number +of purged objects. + +New ``http_CollectHdrSep`` function, ``http_*`` symbols and associated +data structures are part of the curated Varnish RunTime. Using them +does not require strict ABI compliance. + +New VUT API +----------- + +XXX: document once merged *EOF* diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 0151c33..4a7bf2f 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -67,6 +67,19 @@ See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and Other changes ============= +* VSL + +The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an additional +field with the remaining TTL of the object at the time of the lookup. +While this should greatly help troubleshooting, this might break tools +relying on those records to get the VXID of the object hit during lookup. + +Instead of using ``Hit``, such tools should now use ``Hit[1]`` instead, +and the same applies to ``HitMiss`` and ``HitPass``. + +The ``Hit`` record also grew two additional fields for the grace and +keep periods. This should again be useful for troubleshooting. + * ``varnishstat(1)``: * *XXX: changes due to new VSC/VSM* @@ -91,10 +104,6 @@ Other changes * *XXX: ...* -* *XXX: changes in VRT that may affect VMOD authors* - - * *XXX: ...* - * *XXX: changes for developers?* * *XXX: such as sanitizer flags?* diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 48e42c3..96dea4e 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -7,6 +7,7 @@ # $Module blob 3 utilities for the VCL blob type +$ABI strict :: diff --git a/lib/libvmod_vtc/vmod.vcc b/lib/libvmod_vtc/vmod.vcc index b57a794..c521f37 100644 --- a/lib/libvmod_vtc/vmod.vcc +++ b/lib/libvmod_vtc/vmod.vcc @@ -26,6 +26,7 @@ # SUCH DAMAGE. $Module vtc 3 Utility module for varnishtest +$ABI strict DESCRIPTION =========== From hermunn at varnish-software.com Fri Sep 15 11:17:22 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:22 +0000 (UTC) Subject: [5.2] 3228575 Document addition of std.file_exists() in Upgrading to 5.2. Message-ID: <20170915111722.3482098458@lists.varnish-cache.org> commit 3228575db18832573942425f571755c94dfafbd1 Author: Geoff Simmons Date: Wed Sep 13 12:23:29 2017 +0200 Document addition of std.file_exists() in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 4a7bf2f..b8c3388 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -56,7 +56,7 @@ XXX: more VCL changes ... vmod_std ~~~~~~~~ -* *XXX: any changes in VMOD std?* +Added :ref:`func_file_exists`. New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From hermunn at varnish-software.com Fri Sep 15 11:17:22 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:22 +0000 (UTC) Subject: [5.2] c565556 Wording Message-ID: <20170915111722.529029846C@lists.varnish-cache.org> commit c565556f5ac28c800cacb9df6d6cd03e66618d47 Author: Dridi Boukelmoune Date: Wed Sep 13 12:47:12 2017 +0200 Wording diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index b8c3388..31d075b 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -74,11 +74,11 @@ field with the remaining TTL of the object at the time of the lookup. While this should greatly help troubleshooting, this might break tools relying on those records to get the VXID of the object hit during lookup. -Instead of using ``Hit``, such tools should now use ``Hit[1]`` instead, -and the same applies to ``HitMiss`` and ``HitPass``. +Instead of using ``Hit``, such tools should now use ``Hit[1]``, and the +same applies to ``HitMiss`` and ``HitPass``. -The ``Hit`` record also grew two additional fields for the grace and -keep periods. This should again be useful for troubleshooting. +The ``Hit`` record also grew two more fields for the grace and keep periods. +This should again be useful for troubleshooting. * ``varnishstat(1)``: From hermunn at varnish-software.com Fri Sep 15 11:17:22 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:22 +0000 (UTC) Subject: [5.2] 5188382 Document addition of {be}req.hash to 5.2. Message-ID: <20170915111722.701F498479@lists.varnish-cache.org> commit 5188382ee591d137a579a349738e657afdd0327f Author: Geoff Simmons Date: Wed Sep 13 12:48:16 2017 +0200 Document addition of {be}req.hash to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 31d075b..8a789d1 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -40,8 +40,24 @@ XXX: headline changes ... ``req.hash`` and ``bereq.hash`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*XXX: about {be}req.hash, mention data type BLOB, advise about* -*:ref:`vmod_blob(3)`* +Added ``req.hash`` and ``bereq.hash``, which contain the hash value +computed by Varnish for cache lookup in the current transaction, to +be used in client or backend context, respectively. Their data type +is BLOB, and they contain the raw binary hash. + +You can use :ref:`vmod_blob(3)` to work with the hashes:: + + import blob; + + sub vcl_backend_fetch { + # Send the transaction hash to the backend as a hex string + set bereq.http.Hash = blob.encode(HEX, blob=bereq.hash); + } + + sub vcl_deliver { + # Send the hash in a response header as a base64 string + set resp.http.Hash = blob.encode(BASE64, blob=req.hash); + } XXX: vcl_sub_XXX ... ~~~~~~~~~~~~~~~~~~~~ From hermunn at varnish-software.com Fri Sep 15 11:17:22 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:22 +0000 (UTC) Subject: [5.2] 6b34e97 Summarize changes for devs in 5.2. Message-ID: <20170915111722.90D569848A@lists.varnish-cache.org> commit 6b34e976279bce41c546d9141c21d121e5e1a75e Author: Geoff Simmons Date: Wed Sep 13 13:35:11 2017 +0200 Summarize changes for devs in 5.2. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index de73237..7dced4d 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -73,6 +73,7 @@ News for authors of VMODs and Varnish API client applications *XXX: such news may include:* +.. _whatsnew_abi: $ABI [strict|vrt] ----------------- @@ -93,6 +94,8 @@ by adding ``$ABI vrt`` to their VCC descriptor. The default value is ``$ABI strict`` when omitted, and all VMODs from the standard Varnish distribution have a strict requirement. +.. _whatsnew_vsm_vsc_5.2: + VSM/VSC API changes ------------------- @@ -138,6 +141,8 @@ should be called to release the segment again. All in all, this should be simpler and more robust now. +.. _whatsnew_vrt_5.2: + VRT API changes --------------- @@ -149,6 +154,8 @@ New ``http_CollectHdrSep`` function, ``http_*`` symbols and associated data structures are part of the curated Varnish RunTime. Using them does not require strict ABI compliance. +.. _whatsnew_vut_5.2: + New VUT API ----------- diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8a789d1..53291e4 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -120,9 +120,23 @@ This should again be useful for troubleshooting. * *XXX: ...* -* *XXX: changes for developers?* +* Changes for developers: - * *XXX: such as sanitizer flags?* + * The VSM and VSC APIs for shared memory and statistics have + changed, and may necessitate changes in client applications, see + :ref:`whatsnew_vsm_vsc_5.2`. + + * Added the ``$ABI`` directive for VMOD vcc declarations, see + :ref:`whatsnew_abi`. + + * There have been some minor changes in the VRT API, which may be + used for VMODs and client apps, see :ref:`whatsnew_vrt_5.2`. + + * The VUT API (for Varnish UTilities), which facilitates the + development of client apps, is now publicly available, see + :ref:`whatsnew_vut_5.2`. + + * *XXX: anything else, such as sanitizer flags?* * *XXX: ...* From hermunn at varnish-software.com Fri Sep 15 11:17:22 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:22 +0000 (UTC) Subject: [5.2] f049a54 Editorial: move docs about changes in VSL Hit* output to the section about varnishlog(1). Message-ID: <20170915111722.B40C09849E@lists.varnish-cache.org> commit f049a54829f44a979b7b8ad9462465d46c9139b7 Author: Geoff Simmons Date: Wed Sep 13 13:44:38 2017 +0200 Editorial: move docs about changes in VSL Hit* output to the section about varnishlog(1). diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 53291e4..3aee8c2 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -83,19 +83,6 @@ See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and Other changes ============= -* VSL - -The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an additional -field with the remaining TTL of the object at the time of the lookup. -While this should greatly help troubleshooting, this might break tools -relying on those records to get the VXID of the object hit during lookup. - -Instead of using ``Hit``, such tools should now use ``Hit[1]``, and the -same applies to ``HitMiss`` and ``HitPass``. - -The ``Hit`` record also grew two more fields for the grace and keep periods. -This should again be useful for troubleshooting. - * ``varnishstat(1)``: * *XXX: changes due to new VSC/VSM* @@ -104,6 +91,20 @@ This should again be useful for troubleshooting. * ``varnishlog(1)``: + * The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an + additional field with the remaining TTL of the object at the time + of the lookup. While this should greatly help troubleshooting, + this might break tools relying on those records to get the VXID of + the object hit during lookup. + + Instead of using ``Hit``, such tools should now use ``Hit[1]``, + and the same applies to ``HitMiss`` and ``HitPass``. + + The ``Hit`` record also grew two more fields for the grace and + keep periods. This should again be useful for troubleshooting. + + See :ref:`vsl(7)`. + * *XXX: changes due to new VSC/VSM* * *XXX: ...* From hermunn at varnish-software.com Fri Sep 15 11:17:22 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:22 +0000 (UTC) Subject: [5.2] e23f2b2 Document the addition of debug:vmod_so_keep to 5.2. Message-ID: <20170915111722.D4C17984C4@lists.varnish-cache.org> commit e23f2b21138d81af367cc5d25a21c8538b85520c Author: Geoff Simmons Date: Wed Sep 13 14:04:26 2017 +0200 Document the addition of debug:vmod_so_keep to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 3aee8c2..6e2a489 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -21,6 +21,9 @@ We have updated the documentation for :ref:`ref_param_send_timeout`, :ref:`ref_param_idle_send_timeout`, :ref:`ref_param_timeout_idle` and :ref:`ref_param_ban_cutoff`. +Added the debug bit ``vmod_so_keep``, see :ref:`ref_param_debug` and +the notes about changes for developers below. + Changes to VCL ============== @@ -137,6 +140,11 @@ Other changes development of client apps, is now publicly available, see :ref:`whatsnew_vut_5.2`. + * The debug bit ``vmod_so_keep`` instructs Varnish not to clean + up its copies of VMOD shared objects when it stops. This makes + it possible for VMOD authors to load their code into a debugger + after a varnishd crash. See :ref:`ref_param_debug`. + * *XXX: anything else, such as sanitizer flags?* * *XXX: ...* From hermunn at varnish-software.com Fri Sep 15 11:17:22 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:22 +0000 (UTC) Subject: [5.2] 104a209 Document the "vmod_so_keep" effect of varnishtest -L/-l in 5.2. Message-ID: <20170915111722.F0B38984DA@lists.varnish-cache.org> commit 104a20914c8880f4342fadc52d117d8beffaf376 Author: Geoff Simmons Date: Wed Sep 13 14:16:48 2017 +0200 Document the "vmod_so_keep" effect of varnishtest -L/-l in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 6e2a489..d9327c5 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -114,9 +114,12 @@ Other changes * ``varnishtest(1)`` and ``vtc(7)``: - * *XXX: changes in test code* + * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* - * *XXX: for example due to VMOD vtc* + * When varnishtest is invoked with ``-L`` or ``-l``, Varnish + instances started by a test do not clean up their copies of VMOD + shared objects when they stop. See the note about ``vmod_so_keep`` + below. * *XXX: ...* From hermunn at varnish-software.com Fri Sep 15 11:17:23 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:23 +0000 (UTC) Subject: [5.2] 127703d Document the "Not Running" output of varnishstat in 5.2. Message-ID: <20170915111723.1B6AD984F4@lists.varnish-cache.org> commit 127703d37833b0162e7d12b1942fa99ef3c2f23d Author: Geoff Simmons Date: Wed Sep 13 14:35:06 2017 +0200 Document the "Not Running" output of varnishstat in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index d9327c5..6bb9e9a 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -88,9 +88,11 @@ Other changes * ``varnishstat(1)``: - * *XXX: changes due to new VSC/VSM* + * In curses mode, the top two lines showing uptimes for the + management and child processes show the text ``Not Running`` if + either or both of the processes are down. - * *XXX: ...* + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: @@ -108,10 +110,6 @@ Other changes See :ref:`vsl(7)`. - * *XXX: changes due to new VSC/VSM* - - * *XXX: ...* - * ``varnishtest(1)`` and ``vtc(7)``: * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* From hermunn at varnish-software.com Fri Sep 15 11:17:23 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:23 +0000 (UTC) Subject: [5.2] 9e3efbe There is a race between the call to VSM_Status() and VSM_Map() where the shared memory segment could have gone away, simply ignore the segment in that case. Message-ID: <20170915111723.3D94C98504@lists.varnish-cache.org> commit 9e3efbed1930d733f9fbbb0890e2920336b2d857 Author: Poul-Henning Kamp Date: Wed Sep 13 12:36:32 2017 +0000 There is a race between the call to VSM_Status() and VSM_Map() where the shared memory segment could have gone away, simply ignore the segment in that case. Fixes #2411 diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 8ca2572..155c675 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -327,7 +327,15 @@ vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp) ALLOC_OBJ(sp, VSC_SEG_MAGIC); AN(sp); *sp->fantom = *fp; - AZ(VSM_Map(vsm, sp->fantom)); + if (VSM_Map(vsm, sp->fantom)) { + /* + * If the seg was removed between our call to VSM_Status() + * and now, we won't be able to map it. + */ + FREE_OBJ(sp); + return (NULL); + } + // AZ(VSM_Map(vsm, sp->fantom)); u = vbe64dec(sp->fantom->b); if (u == 0) { @@ -407,10 +415,12 @@ VSC_Iter(struct vsc *vsc, struct vsm *vsm, VSC_iter_f *fiter, void *priv) sp = VTAILQ_NEXT(sp, list); } else { sp = vsc_add_seg(vsc, vsm, &ifantom); - VTAILQ_INSERT_TAIL(&vsc->segs, sp, list); - if (fiter != NULL) - i = vsc_iter_seg(vsc, sp, fiter, priv); - sp = NULL; + if (sp != NULL) { + VTAILQ_INSERT_TAIL(&vsc->segs, sp, list); + if (fiter != NULL) + i = vsc_iter_seg(vsc, sp, fiter, priv); + sp = NULL; + } } if (i) break; From hermunn at varnish-software.com Fri Sep 15 11:17:23 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:23 +0000 (UTC) Subject: [5.2] 7945e6b Document the demise of the -N option for the VSL tools in 5.2. Message-ID: <20170915111723.59A0698512@lists.varnish-cache.org> commit 7945e6b04534e150b9bc3a7d446184d84493ea26 Author: Geoff Simmons Date: Wed Sep 13 14:45:18 2017 +0200 Document the demise of the -N option for the VSL tools in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 6bb9e9a..53573d7 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -121,6 +121,11 @@ Other changes * *XXX: ...* +* The ``-N`` command-line option, which was previously availabe for + ``varnishlog(1)``, ``varnishstat(1)``, ``varnishncsa(1)`` and + ``varnishhist(1)``, is not comaptible with the changed internal + logging API, and has been retired. + * *XXX: any other changes in the standard VUT tools* * *XXX: ...* From hermunn at varnish-software.com Fri Sep 15 11:17:23 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:23 +0000 (UTC) Subject: [5.2] fe8cea6 Mention the changed interpretation of varnishstat -f in 5.2. Message-ID: <20170915111723.7569698545@lists.varnish-cache.org> commit fe8cea6641d5aa26628e3dafe2375372254cb407 Author: Geoff Simmons Date: Wed Sep 13 14:49:13 2017 +0200 Mention the changed interpretation of varnishstat -f in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 53573d7..05e6790 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -92,6 +92,9 @@ Other changes management and child processes show the text ``Not Running`` if either or both of the processes are down. + * The interpretation of multiple ``-f`` options in the command line + has changed slightly, see :ref:`varnishstat(1)`. + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: From hermunn at varnish-software.com Fri Sep 15 11:17:23 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:23 +0000 (UTC) Subject: [5.2] 3327f8a Document the changed default for server.identity in 5.2. Message-ID: <20170915111723.9432C98550@lists.varnish-cache.org> commit 3327f8a3ab455218a1566b6f7acf2163c86f3af0 Author: Geoff Simmons Date: Wed Sep 13 15:27:10 2017 +0200 Document the changed default for server.identity in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 05e6790..5e3552a 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -62,6 +62,15 @@ You can use :ref:`vmod_blob(3)` to work with the hashes:: set resp.http.Hash = blob.encode(BASE64, blob=req.hash); } +``server.identity`` +~~~~~~~~~~~~~~~~~~~ + +If the ``-i`` option is not set in the invocation of ``varnishd``, +then ``server.identity`` is set to the host name (as returned by +``gethostname(3)``). Previously, ``server.identity`` was set to the +value of the ``-n`` option (or the default instance name if ``-n`` was +not set). See :ref:`varnishd(1)`. + XXX: vcl_sub_XXX ... ~~~~~~~~~~~~~~~~~~~~ From hermunn at varnish-software.com Fri Sep 15 11:17:23 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:23 +0000 (UTC) Subject: [5.2] a872a12 Document changes around the varnishd -i option in 5.2. Message-ID: <20170915111723.AF9389855C@lists.varnish-cache.org> commit a872a12bbaf8fc873cb107f3a94054f33ee88823 Author: Geoff Simmons Date: Wed Sep 13 16:08:26 2017 +0200 Document changes around the varnishd -i option in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 5e3552a..869906c 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -95,6 +95,22 @@ See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and Other changes ============= +* ``varnishd(1)``: + + * The default value of ``server.identity`` when the ``-i`` option is + not set has been changed as noted above. + + * Also, ``-i`` no longer determines the ``ident`` field used by + ``syslog(3)``; now Varnish is always identified by the string + ``varnishd`` in the syslog. + + * On a system that supports ``setproctitle(3)``, the Varnish + management process will appear in the output of ``ps(1)`` as + ``Varnish-Mgr``, and the child process as ``Varnish-Child``. If + the ``-i`` option has been set, then these strings in the ps + output are followed by ``-i`` and the identity string set by the + option. + * ``varnishstat(1)``: * In curses mode, the top two lines showing uptimes for the From hermunn at varnish-software.com Fri Sep 15 11:17:23 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:23 +0000 (UTC) Subject: [5.2] 43f738e Document use of vcl_path if varnishd -f is relative in Upgrading to 5.2. Message-ID: <20170915111723.CEEE498586@lists.varnish-cache.org> commit 43f738e35201964cee7c12ec436b7558c35e5aa5 Author: Geoff Simmons Date: Wed Sep 13 16:27:13 2017 +0200 Document use of vcl_path if varnishd -f is relative in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 869906c..6c977bd 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -111,6 +111,10 @@ Other changes output are followed by ``-i`` and the identity string set by the option. + * The ``-f`` option for a VCL source file now honors the + ``vcl_path`` parameter if a relative file name is used, see + :ref:`varnishd(1)` and :ref:`ref_param_vcl_path`. + * ``varnishstat(1)``: * In curses mode, the top two lines showing uptimes for the From hermunn at varnish-software.com Fri Sep 15 11:17:23 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:23 +0000 (UTC) Subject: [5.2] 3c6319e Note the clarification of bans with unset fields in Upgrading to 5.2. Message-ID: <20170915111723.EA463985B7@lists.varnish-cache.org> commit 3c6319e2535325396b760eaac12cf0643bf0e252 Author: Geoff Simmons Date: Wed Sep 13 16:34:09 2017 +0200 Note the clarification of bans with unset fields in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 6c977bd..3a16ce0 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -92,6 +92,13 @@ New VMODs in the standard distribution See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and :ref:`vmod_vtc(3)`. See :ref:`whatsnew_new_vmods`. +Bans +~~~~ + +We have clarified the interpretation of a ban when a comparison in the +ban expression is attempted against an unset field, see +:ref:`vcl(7)_ban` in :ref:`vcl(7)`. + Other changes ============= From hermunn at varnish-software.com Fri Sep 15 11:17:24 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:24 +0000 (UTC) Subject: [5.2] cef5808 Consistently use "mgt" Message-ID: <20170915111724.19821985DC@lists.varnish-cache.org> commit cef5808cac33800fabf2989af9d677ae501496b6 Author: Poul-Henning Kamp Date: Wed Sep 13 14:39:32 2017 +0000 Consistently use "mgt" Spottes by: dridi diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index ebcaba5..b3b8856 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -308,13 +308,13 @@ mgt_launch_child(struct cli *cli) child_state = CH_STARTING; - /* Open pipe for mgr->child CLI */ + /* Open pipe for mgt->child CLI */ AZ(pipe(cp)); heritage.cli_in = cp[0]; MCH_Fd_Inherit(heritage.cli_in, "cli_in"); child_cli_out = cp[1]; - /* Open pipe for child->mgr CLI */ + /* Open pipe for child->mgt CLI */ AZ(pipe(cp)); heritage.cli_out = cp[1]; MCH_Fd_Inherit(heritage.cli_out, "cli_out"); diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index 4d4c56d..f9c0157 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -46,7 +46,7 @@ #include #endif -static gid_t vju_mgr_gid; +static gid_t vju_mgt_gid; static uid_t vju_uid; static gid_t vju_gid; static const char *vju_user; @@ -166,7 +166,7 @@ vju_init(char **args) AN(vju_user); - vju_mgr_gid = getgid(); + vju_mgt_gid = getgid(); if (vju_wrkuser == NULL && vju_getwrkuid(VCACHE_USER)) { vju_wrkuid = vju_uid; @@ -191,7 +191,7 @@ vju_master(enum jail_master_e jme) AZ(seteuid(vju_uid)); } else { AZ(seteuid(0)); - AZ(setegid(vju_mgr_gid)); + AZ(setegid(vju_mgt_gid)); } } diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 8a5f918..2b341f4 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -758,7 +758,7 @@ main(int argc, char * const *argv) i_arg = mgt_HostName(); heritage.identity = i_arg; - mgt_ProcTitle("Mgr"); + mgt_ProcTitle("Mgt"); openlog("varnishd", LOG_PID, LOG_LOCAL0); From hermunn at varnish-software.com Fri Sep 15 11:17:24 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:24 +0000 (UTC) Subject: [5.2] 0ad3278 s/mgr/mgt/ for consistency Message-ID: <20170915111724.470C6985FF@lists.varnish-cache.org> commit 0ad32783040c7f0ebcdc3bb686cdd7cb8ec71fab Author: Poul-Henning Kamp Date: Wed Sep 13 14:43:33 2017 +0000 s/mgr/mgt/ for consistency diff --git a/doc/sphinx/phk/barriers.rst b/doc/sphinx/phk/barriers.rst index e85e81a..f9ba31b 100644 --- a/doc/sphinx/phk/barriers.rst +++ b/doc/sphinx/phk/barriers.rst @@ -22,7 +22,7 @@ barriers between the various components:: | | | | |runs | | | | .-<- create -<-. | .->- fork ->-. v | - v |->- check -->-|-- MGR --| |-- VCC <- loads -| + v |->- check -->-|-- MGT --| |-- VCC <- loads -| VSM |-<- write --<-' | '-<- wait -<-' | | TOOLS | | | | ^ | .-------------' | | @@ -48,7 +48,7 @@ barriers between the various components:: The really Important Barrier ============================ -The central actor in Varnish is the Manager process, "MGR", which is the +The central actor in Varnish is the Manager process, "MGT", which is the process the administrator "(ADMIN)" starts to get web-cache service. Having been there myself, I do not subscribe to the "I feel cool and important diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 3a16ce0..8d837f9 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -113,7 +113,7 @@ Other changes * On a system that supports ``setproctitle(3)``, the Varnish management process will appear in the output of ``ps(1)`` as - ``Varnish-Mgr``, and the child process as ``Varnish-Child``. If + ``Varnish-Mgt``, and the child process as ``Varnish-Child``. If the ``-i`` option has been set, then these strings in the ps output are followed by ``-i`` and the identity string set by the option. diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 79f9a02..5a5ffbb 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -184,7 +184,7 @@ struct vcc { int hindent; unsigned cnt; - struct vsb *fi; /* VCC info to MGR */ + struct vsb *fi; /* VCC info to MGT */ struct vsb *fc; /* C-code */ struct vsb *fh; /* H-code (before C-code) */ struct vsb *fb; /* Body of current sub From hermunn at varnish-software.com Fri Sep 15 11:17:24 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:24 +0000 (UTC) Subject: [5.2] 3ef113f Add a section about VCL token parsing in Upgrading to 5.2, currently TBD. Message-ID: <20170915111724.65B479860A@lists.varnish-cache.org> commit 3ef113f5eafd3d0094ad1b9c4b08a6f8de50bfa3 Author: Geoff Simmons Date: Wed Sep 13 16:48:32 2017 +0200 Add a section about VCL token parsing in Upgrading to 5.2, currently TBD. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8d837f9..ad0b3d7 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -40,6 +40,11 @@ XXX: headline changes ... *XXX: the most important changes or additions first* +Stricter checking of VCL symbol names +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*XXX: TBD by DB* + ``req.hash`` and ``bereq.hash`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From hermunn at varnish-software.com Fri Sep 15 11:17:24 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:24 +0000 (UTC) Subject: [5.2] 1c96cf4 Document addition of vtc feature ignore_unknown_macro to 5.2. Message-ID: <20170915111724.84E8998622@lists.varnish-cache.org> commit 1c96cf4fba9cb8773e755822353a231fb9a4dfd3 Author: Geoff Simmons Date: Wed Sep 13 16:56:14 2017 +0200 Document addition of vtc feature ignore_unknown_macro to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index ad0b3d7..73d1a3c 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -163,6 +163,9 @@ Other changes shared objects when they stop. See the note about ``vmod_so_keep`` below. + * Added the feature switch ``ignore_unknown_macro`` for test cases, + see :ref:`vtc(7)`. + * *XXX: ...* * The ``-N`` command-line option, which was previously availabe for From hermunn at varnish-software.com Fri Sep 15 11:17:24 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:24 +0000 (UTC) Subject: [5.2] 590dc08 Mention the field specifier limit in varnishncsa in Upgrading to 5.2. Message-ID: <20170915111724.A676798636@lists.varnish-cache.org> commit 590dc08f8b483959e6b382e79fff2675709a0080 Author: Geoff Simmons Date: Wed Sep 13 17:29:56 2017 +0200 Mention the field specifier limit in varnishncsa in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 73d1a3c..850573c 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -168,6 +168,11 @@ Other changes * *XXX: ...* +* ``varnishncsa(1)`` + + * Field specifiers (such as the 1 in ``Hit[1]``) are now limited to + to 255, see :ref:`varnishncsa(1)`. + * The ``-N`` command-line option, which was previously availabe for ``varnishlog(1)``, ``varnishstat(1)``, ``varnishncsa(1)`` and ``varnishhist(1)``, is not comaptible with the changed internal From hermunn at varnish-software.com Fri Sep 15 11:17:24 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:24 +0000 (UTC) Subject: [5.2] c5e2d85 Mention removal of type and ident from varnishstat output in Upgrading to 5.2. Message-ID: <20170915111724.C9E1C9864E@lists.varnish-cache.org> commit c5e2d85901ed6bb59bcf9e1c8693af2804a45860 Author: Geoff Simmons Date: Wed Sep 13 17:33:55 2017 +0200 Mention removal of type and ident from varnishstat output in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 850573c..03f4f2e 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -136,6 +136,9 @@ Other changes * The interpretation of multiple ``-f`` options in the command line has changed slightly, see :ref:`varnishstat(1)`. + * The ``type`` and ``ident`` fields have been removed from the XML + and JSON output formats, see :ref:`varnishstat(1)`. + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: From hermunn at varnish-software.com Fri Sep 15 11:17:24 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:24 +0000 (UTC) Subject: [5.2] c1c5069 Document removal of the s_req counter in 5.2. Message-ID: <20170915111724.E9D779866C@lists.varnish-cache.org> commit c1c5069d4bd4ad02acd8e00abf0de086683d4411 Author: Geoff Simmons Date: Wed Sep 13 17:37:59 2017 +0200 Document removal of the s_req counter in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 03f4f2e..56c925b 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -139,6 +139,9 @@ Other changes * The ``type`` and ``ident`` fields have been removed from the XML and JSON output formats, see :ref:`varnishstat(1)`. + * The ``MAIN.s_req`` statistic has been removed, as it was identical + to ``MAIN.client_req``. + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: From hermunn at varnish-software.com Fri Sep 15 11:17:25 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:25 +0000 (UTC) Subject: [5.2] 80435af Documentation Message-ID: <20170915111725.1285498680@lists.varnish-cache.org> commit 80435af9bcab570f5163ec32f1bddae1cba9b93f Author: Dridi Boukelmoune Date: Wed Sep 13 17:40:27 2017 +0200 Documentation diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 56c925b..00abba5 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -40,10 +40,37 @@ XXX: headline changes ... *XXX: the most important changes or additions first* -Stricter checking of VCL symbol names -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consistent symbol names +~~~~~~~~~~~~~~~~~~~~~~~ + +VCL symbols originate from various parts of Varnish: there are built-in +variables, subroutines, functions, and the free-form headers. Symbols +may live in a namespace denoted by the ``'.'`` (dot) character as in +``req.http.Cache-Control``. When you create a VCL label, a new symbol +becomes available, named after the label. Storage backends always have +a name, even if you don't specify one, and they can also be accessed in +VCL: for example ``storage.Transient``. + +Because headers and VCL names could contain dashes, while subroutines or +VMOD objects couldn't, this created an inconsistency. All symbols follow +the same rules now and must follow the same (case-insensitive) pattern: +``[a-z][a-z0-9_-]*``. + +You can now write code like:: + + sub my-sub { + new my-obj = my_vmod.my_constuctor(storage.my-store); + } + + sub vcl_init { + call my-sub; + } + +As you may notice in the example above, it is not possible yet to have +dashes in a vmod symbol. -*XXX: TBD by DB* +Long storage backend names used to be truncated due to a limitation in +the VSC subsystem, this is no longer the case. ``req.hash`` and ``bereq.hash`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -127,6 +154,10 @@ Other changes ``vcl_path`` parameter if a relative file name is used, see :ref:`varnishd(1)` and :ref:`ref_param_vcl_path`. + * The ``-a`` option can now take a name, otherwise a default one + is selected to name the listen address. It may become accessible + in VCL in the future. + * ``varnishstat(1)``: * In curses mode, the top two lines showing uptimes for the @@ -160,6 +191,11 @@ Other changes See :ref:`vsl(7)`. + * The ``SessOpen`` log record displays the name of the listen address + instead of the endpoint in its 3rd field. + + See :ref:`vsl(7)`. + * ``varnishtest(1)`` and ``vtc(7)``: * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* From hermunn at varnish-software.com Fri Sep 15 11:17:25 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:25 +0000 (UTC) Subject: [5.2] 1c55d49 Mention the addition of bereq.is_bgfetch in Upgrading to 5.2. Message-ID: <20170915111725.348CF98692@lists.varnish-cache.org> commit 1c55d4991ff3e4d2ab7980d77c05ac49f5f4d27c Author: Geoff Simmons Date: Wed Sep 13 17:49:19 2017 +0200 Mention the addition of bereq.is_bgfetch in Upgrading to 5.2. Since we seem to have a number of new VCL variables, there is now a section heading for that in Upgrading. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 00abba5..ee281eb 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -72,8 +72,11 @@ dashes in a vmod symbol. Long storage backend names used to be truncated due to a limitation in the VSC subsystem, this is no longer the case. +New VCL variables +~~~~~~~~~~~~~~~~~ + ``req.hash`` and ``bereq.hash`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------- Added ``req.hash`` and ``bereq.hash``, which contain the hash value computed by Varnish for cache lookup in the current transaction, to @@ -95,7 +98,7 @@ You can use :ref:`vmod_blob(3)` to work with the hashes:: } ``server.identity`` -~~~~~~~~~~~~~~~~~~~ +------------------- If the ``-i`` option is not set in the invocation of ``varnishd``, then ``server.identity`` is set to the host name (as returned by @@ -103,6 +106,16 @@ then ``server.identity`` is set to the host name (as returned by value of the ``-n`` option (or the default instance name if ``-n`` was not set). See :ref:`varnishd(1)`. +``bereq.is_bgfetch`` +-------------------- + +``bereq.is_bgfetch`` is readable in backend contexts, and is true if +the fetch takes place in the background. That is, it is true if +Varnish found a response in the cache whose TTL was expired, but was +still in grace time. Varnish returns the stale cached response to the +client, and initiates the background fetch to refresh the cache +object. + XXX: vcl_sub_XXX ... ~~~~~~~~~~~~~~~~~~~~ From hermunn at varnish-software.com Fri Sep 15 11:17:25 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:25 +0000 (UTC) Subject: [5.2] 264155b Document the addition of named listen addresses to 5.2. Message-ID: <20170915111725.5233C986AF@lists.varnish-cache.org> commit 264155bf4630c039616f3c893bf7ec29732a4644 Author: Geoff Simmons Date: Wed Sep 13 18:01:16 2017 +0200 Document the addition of named listen addresses to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index ee281eb..2166340 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -149,6 +149,14 @@ Other changes * ``varnishd(1)``: + * Listen addresses specified with ``-a`` may now be given a name on + the command line, for example ``-a admin=127.0.0.1:88`` to + identify an address used for administrative requests but not + regular client traffic. If you don't specify a name, then ``a0``, + ``a1`` and so forth are used. The endpoint names are used in the + log output, for example with the ``SessOpen`` tag. See + :ref:`varnishd(1)`. + * The default value of ``server.identity`` when the ``-i`` option is not set has been changed as noted above. From hermunn at varnish-software.com Fri Sep 15 11:17:21 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:21 +0000 (UTC) Subject: [5.2] 1156b8e Some work on the release docs Message-ID: <20170915111721.6FB18983F8@lists.varnish-cache.org> commit 1156b8ea6b4cf7c142e40a6a61050223f90215fd Author: Poul-Henning Kamp Date: Wed Sep 13 08:46:46 2017 +0000 Some work on the release docs diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 4804a86..5688246 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -3,26 +3,15 @@ Changes in Varnish 5.2 ====================== -*XXX: preamble* - -Varnish statistics -~~~~~~~~~~~~~~~~~~ - -The export of statistics counters via shared memory has been -overhauled to get rid of limitations which made sense 11 years -ago but not so much now. - -Statistics counters are now self-describing in shared memory, -paving the way so that VMODs or maybe even VCL can define -counters in the future, and have them show up in varnishstat -and other VSC-API based programs. +Varnish 5.2 is mostly changes under the hood so most varnish +installations will be able to upgrade with no modifications. .. _whatsnew_new_vmods: New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*XXX: introductory paragraphs about new VMODs* +We have added three new VMODs to the varnish project. VMOD blob --------- @@ -30,7 +19,7 @@ VMOD blob We have added the variables ``req.hash`` and ``bereq.hash`` to VCL, which contain the hash value computed by Varnish for the current request, for use in cache lookup. Their data type is BLOB, which -represents arbitrary data of any length -- the new variables contain +represents opaque data of any length -- the new variables contain the raw binary hashes. This is the first time that an element of standard VCL has the BLOB @@ -39,17 +28,34 @@ have added VMOD blob to facilitate their use. In particular, the VMOD implements binary-to-text encodings, for example so that you can assign the hash to a header as a base64 or hex string. It also provides some other utilities such as getting the length of a BLOB or -testing BLOBs for equality. See :ref:`vmod_blob(3)`. +testing BLOBs for equality. + +See :ref:`vmod_blob(3)`. VMOD purge ---------- -*XXX: about VMOD purge* +*XXX: DRIDI ? about VMOD purge* + +See :ref:`vmod_purge(3)`. VMOD vtc -------- -*XXX: about VMOD vtc* +As long as we have had VMODs, we had an internal vmod called ``vmod_debug`` +which were used with ``varnishtest`` to exercise the VMOD related parts of +``varnishd``. Over time this vmod grew other useful functions for writing +test-cases. + +We only distribute ``vmod_debug`` in source releases, because it has some +pretty evil functionality, for instance ``debug.panic()``. + +We have split the non-suicidal test-writing stuff from ``vmod_debug`` +into a new ``vmod_vtc``, which is included in binary releases from +now on, in order to make it easier for people to use ``varnishtest`` +to test local configurations, VMODs etc. + +See :ref:`vmod_vtc(3)`. XXX: Any other headline changes ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -61,11 +67,34 @@ News for authors of VMODs and Varnish API client applications *XXX: such news may include:* + +$ABI [strict|vrt] +----------------- + +*XXX: DRIDI ?* + VSM/VSC API changes ------------------- -The rewrite of the VSM/VSC code has similified the API and -made it much more robust, and code calling into these APIs +The export of statistics counters via shared memory has been +overhauled to get rid of limitations which made sense 11 years +ago but not so much now. + +A set of statistics counters are now fully defined in a ``.vsc`` +file which is processed by the ``vsctool.py`` script into a .c and +.h file, which is compiled into the relevant body of code. + +This means that statistics counters are now self-describing in +shared memory, and ``varnishstat`` or other VSC-API using programs +have no compiled in knowledge about which counters exist or how +to treat them. + +This paves the way for VMODs or maybe even VCL to define +custom counters, and have them show up in varnishstat and +other VSC-API based programs just like the rest of the counters. + +The rewrite of the VSM/VSC code similified both APIs and +made them much more robust but code calling into these APIs will have to be updated to match. The necessary changes mostly center around detecting if the @@ -74,10 +103,10 @@ varnishd management/worker process has restarted. In the new VSM-api once setup is done, VSM_Attach() latches on to a running varnishd master process and stays there. -VSM_Status() returns information about the master and worker -process, if they are running, if they have been restarted -(since the previous call to VSM_Status()) and updates the -in-memory list of VSM segments. +VSM_Status() updates the in-memory list of VSM segments, and +returns information about the master and worker proces: +Are they running? Have they been restarted? Have VSM segments +been added/deleted? Each VSM segment is now a separate piece of shared memory and the name of the segment can be much longer now. @@ -89,6 +118,6 @@ should be called to release the segment again. All in all, this should be simpler and more robust now. -* *XXX: changes in VRT* +*XXX: changes in VRT* *EOF* diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index cc70923..2164e32 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -7,8 +7,8 @@ Upgrading to Varnish 5.2 Varnish statistics and logging ============================== -*XXX: anything new for users or admins concerning statistics,* -*varnishstat, logging etc* +There are extensive changes under the hood with respect to statistics +counters, but these should all be transparent at the user-level. varnishd parameters =================== From hermunn at varnish-software.com Fri Sep 15 11:17:25 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:25 +0000 (UTC) Subject: [5.2] 91753f0 s/vcs/vsc/ Message-ID: <20170915111725.72D67986B9@lists.varnish-cache.org> commit 91753f0bde4e2892da09aa6767c6a5275ed17279 Author: Dridi Boukelmoune Date: Wed Sep 13 18:01:58 2017 +0200 s/vcs/vsc/ Too many acronyms... diff --git a/varnish.m4 b/varnish.m4 index 8d4a486..b56d2fc 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -85,7 +85,7 @@ AC_DEFUN([_VARNISH_PKG_CONFIG], [ PKG_CHECK_VAR([VARNISHAPI_VMODDIR], [varnishapi], [vmoddir]) PKG_CHECK_VAR([VMODTOOL], [varnishapi], [vmodtool]) - PKG_CHECK_VAR([VCSTOOL], [varnishapi], [vcstool]) + PKG_CHECK_VAR([VSCTOOL], [varnishapi], [vsctool]) AC_SUBST([VARNISH_LIBRARY_PATH], [$VARNISHAPI_LIBDIR:$VARNISHAPI_LIBDIR/varnish]) @@ -386,7 +386,7 @@ AC_DEFUN([VARNISH_VMODS], [ # - pkgvcldir added # # Since Varnish 5.2.0: -# - VCSTOOL added +# - VSCTOOL added # # Verify that the version of Varnish Cache found by pkg-config is at least # MINIMUM-VERSION. If MAXIMUM-VERSION is specified, verify that the version @@ -412,7 +412,7 @@ AC_DEFUN([VARNISH_VMODS], [ # - VARNISHAPI_VCLDIR # - VARNISHAPI_VMODDIR # - VMODTOOL -# - VCSTOOL +# - VSCTOOL # # In addition, two directories are set up for installation in automake: # diff --git a/varnishapi.pc.in b/varnishapi.pc.in index b9c638b..6441952 100644 --- a/varnishapi.pc.in +++ b/varnishapi.pc.in @@ -13,7 +13,7 @@ pkgdatadir=${datadir}/@PACKAGE@ vcldir=${pkgdatadir}/vcl vmoddir=${libdir}/@PACKAGE@/vmods vmodtool=${pkgdatadir}/vmodtool.py -vcstool=${pkgdatadir}/vcstool.py +vsctool=${pkgdatadir}/vsctool.py Name: VarnishAPI Description: Varnish API From hermunn at varnish-software.com Fri Sep 15 11:17:25 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:25 +0000 (UTC) Subject: [5.2] 7d407e7 Revert "Document the addition of named listen addresses to 5.2." Message-ID: <20170915111725.91DA9986C5@lists.varnish-cache.org> commit 7d407e7b590876c139549f84c95929e1461a3bdc Author: Geoff Simmons Date: Wed Sep 13 18:06:32 2017 +0200 Revert "Document the addition of named listen addresses to 5.2." This reverts commit a1ac5e7e4e014b12b11cde584a55abee0d5f8ec1. Redundant diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 2166340..ee281eb 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -149,14 +149,6 @@ Other changes * ``varnishd(1)``: - * Listen addresses specified with ``-a`` may now be given a name on - the command line, for example ``-a admin=127.0.0.1:88`` to - identify an address used for administrative requests but not - regular client traffic. If you don't specify a name, then ``a0``, - ``a1`` and so forth are used. The endpoint names are used in the - log output, for example with the ``SessOpen`` tag. See - :ref:`varnishd(1)`. - * The default value of ``server.identity`` when the ``-i`` option is not set has been changed as noted above. From hermunn at varnish-software.com Fri Sep 15 11:17:25 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:25 +0000 (UTC) Subject: [5.2] b74e5c5 Elaborate a bit on the addition of named -a addresses in 5.2. Message-ID: <20170915111725.B8704986E9@lists.varnish-cache.org> commit b74e5c511e8141e73f7f1d90a72c9e245f0a0b09 Author: Geoff Simmons Date: Wed Sep 13 18:11:20 2017 +0200 Elaborate a bit on the addition of named -a addresses in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index ee281eb..c932fca 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -167,9 +167,12 @@ Other changes ``vcl_path`` parameter if a relative file name is used, see :ref:`varnishd(1)` and :ref:`ref_param_vcl_path`. - * The ``-a`` option can now take a name, otherwise a default one - is selected to name the listen address. It may become accessible - in VCL in the future. + * The ``-a`` option can now take a name, for example ``-a + admin=127.0.0.1:88`` to identify an address used for + administrative requests but not regular client traffic. Otherwise, + a default name is selected for the listen address (``a0``, ``a1`` + and so forth). Endpoint names appear in the log output, as noted + below, and may become accessible in VCL in the future. * ``varnishstat(1)``: From hermunn at varnish-software.com Fri Sep 15 11:17:25 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:25 +0000 (UTC) Subject: [5.2] 72cab1c Use the corect directory Message-ID: <20170915111725.D1907986F9@lists.varnish-cache.org> commit 72cab1c0b5436620340bd4c0a39a93d72eb3ea3a Author: Dridi Boukelmoune Date: Wed Sep 13 18:24:17 2017 +0200 Use the corect directory diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 55409d7..19217df 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -217,7 +217,7 @@ BUILT_SOURCES = vhp_hufdec.h DISTCLEANFILES += vhp_hufdec.h ####################################################################### -VSC_main.c VSC_main.h: $(srcdir)/main.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_main.c VSC_main.h: $(srcdir)/main.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/main.vsc $(varnishd_OBJECTS): VSC_main.h @@ -229,7 +229,7 @@ nodist_varnishd_SOURCES += VSC_main.c ####################################################################### -VSC_lck.c VSC_lck.h: $(srcdir)/lck.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_lck.c VSC_lck.h: $(srcdir)/lck.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/lck.vsc $(varnishd_OBJECTS): VSC_lck.h @@ -241,7 +241,7 @@ nodist_varnishd_SOURCES += VSC_lck.c ####################################################################### -VSC_vbe.c VSC_vbe.h: $(srcdir)/vbe.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_vbe.c VSC_vbe.h: $(srcdir)/vbe.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/vbe.vsc $(varnishd_OBJECTS): VSC_vbe.h @@ -253,7 +253,7 @@ nodist_varnishd_SOURCES += VSC_vbe.c ####################################################################### -VSC_sma.c VSC_sma.h: $(srcdir)/sma.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_sma.c VSC_sma.h: $(srcdir)/sma.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/sma.vsc $(varnishd_OBJECTS): VSC_sma.h @@ -265,7 +265,7 @@ nodist_varnishd_SOURCES += VSC_sma.c ####################################################################### -VSC_smf.c VSC_smf.h: $(srcdir)/smf.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_smf.c VSC_smf.h: $(srcdir)/smf.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/smf.vsc $(varnishd_OBJECTS): VSC_smf.h @@ -277,7 +277,7 @@ nodist_varnishd_SOURCES += VSC_smf.c ####################################################################### -VSC_mempool.c VSC_mempool.h: $(srcdir)/mempool.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_mempool.c VSC_mempool.h: $(srcdir)/mempool.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/mempool.vsc $(varnishd_OBJECTS): VSC_mempool.h @@ -289,7 +289,7 @@ nodist_varnishd_SOURCES += VSC_mempool.c ####################################################################### -VSC_mgt.c VSC_mgt.h: $(srcdir)/mgt.vsc $(top_builddir)/lib/libvcc/vsctool.py +VSC_mgt.c VSC_mgt.h: $(srcdir)/mgt.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/mgt.vsc $(varnishd_OBJECTS): VSC_mgt.h From hermunn at varnish-software.com Fri Sep 15 11:17:25 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:25 +0000 (UTC) Subject: [5.2] cc5fa2d Install common/common_vsm.h Message-ID: <20170915111725.F3C3F98711@lists.varnish-cache.org> commit cc5fa2d70c6b57941260ca848e30d341a22417b9 Author: Dridi Boukelmoune Date: Wed Sep 13 18:40:36 2017 +0200 Install common/common_vsm.h We need it to build out-of-tree VSCs. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 19217df..0abe151 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -120,7 +120,6 @@ noinst_HEADERS = \ cache/cache_priv.h \ cache/cache_transport.h \ common/heritage.h \ - common/common_vsm.h \ hash/hash_slinger.h \ hpack/vhp.h \ http1/cache_http1.h \ @@ -140,6 +139,7 @@ nobase_pkginclude_HEADERS = \ cache/cache_backend.h \ cache/cache_director.h \ common/common.h \ + common/common_vsm.h \ common/com_params.h \ waiter/waiter.h From hermunn at varnish-software.com Fri Sep 15 11:17:26 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:26 +0000 (UTC) Subject: [5.2] 799cb38 Deprecate the second sub-argument to varnishd -l now that VSM autosizes everything. Message-ID: <20170915111726.24B609872A@lists.varnish-cache.org> commit 799cb38843796454c41ade348219c48c4bf2702f Author: Poul-Henning Kamp Date: Wed Sep 13 21:45:21 2017 +0000 Deprecate the second sub-argument to varnishd -l now that VSM autosizes everything. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 2b341f4..6da09e5 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -129,9 +129,8 @@ usage(void) printf(FMT, "", " -s malloc"); printf(FMT, "", " -s file"); - printf(FMT, "-l vsl[,vsm]", "Size of shared memory file"); + printf(FMT, "-l vsl", "Size of shared memory log"); printf(FMT, "", " vsl: space for VSL records [80m]"); - printf(FMT, "", " vsm: space for stats counters [1m]"); printf("\nSecurity options:\n"); @@ -269,7 +268,6 @@ init_params(struct cli *cli) MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G"); - MCF_ParamConf(MCF_MAXIMUM, "vsm_space", "1G"); } #if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux) @@ -661,14 +659,17 @@ main(int argc, char * const *argv) av = VAV_Parse(optarg, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) - ARGV_ERR("\t-l ...: %s\n", av[0]); + ARGV_ERR("-l ...: %s\n", av[0]); + if (av[1] != NULL && av[2] != NULL && av[3] != NULL) + ARGV_ERR("Too many sub arguments to -l\n"); if (av[1] != NULL) { MCF_ParamSet(cli, "vsl_space", av[1]); cli_check(cli); } if (av[1] != NULL && av[2] != NULL) { - MCF_ParamSet(cli, "vsm_space", av[2]); - cli_check(cli); + fprintf(stderr, + "Warning: Ignoring deprecated second" + " subargument to -l\n"); } VAV_Free(av); break; diff --git a/bin/varnishtest/tests/a00016.vtc b/bin/varnishtest/tests/a00016.vtc index 354b01f..4055b7a 100644 --- a/bin/varnishtest/tests/a00016.vtc +++ b/bin/varnishtest/tests/a00016.vtc @@ -1,4 +1,4 @@ -varnishtest "Test -I argument" +varnishtest "Test -I and -l arguments" shell -err -expect {Only one -I allowed} { touch foo bar @@ -9,5 +9,17 @@ shell -err -expect {Error: -I file CLI command failed (104)} { echo "vcl.list" > foo echo "-foobar" >> foo echo "vcl.load" >> foo - varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,1m + varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m +} + +shell -err -expect {Error: -l ...: Missing '"'} { + varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l '2m,"' +} + +shell -err -expect {Error: Too many sub arguments} { + varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m,2m +} + +shell -err -expect {Warning: Ignoring deprecated second subargument} { + varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 33cfcb9..9f97f46 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -422,7 +422,7 @@ varnish_launch(struct varnish *v) VSB_cat(vsb, " -p debug=+vsm_keep"); VSB_cat(vsb, " -p debug=+vmod_so_keep"); } - VSB_printf(vsb, " -l 2m,1m,-"); + VSB_printf(vsb, " -l 2m"); VSB_printf(vsb, " -p auto_restart=off"); VSB_printf(vsb, " -p syslog_cli_traffic=off"); VSB_printf(vsb, " -p sigsegv_handler=on"); diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index b8455c6..195a33b 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -180,12 +180,11 @@ Tuning options files. Name is referenced in logs, VCL, statistics, etc. If name is not specified, "s0", "s1" and so forth is used. --l +-l - Specifies size of shmlog file. vsl is the space for the VSL records - [80M] and vsm is the space for stats counters [1M]. Scaling suffixes - like 'K' and 'M' can be used up to (G)igabytes. - Default is 81 Megabytes. + Specifies size of the space for the VSL records. + Scaling suffixes like 'K' and 'M' can be used up to (G)igabytes. + Default is 80 Megabytes. Security options ---------------- diff --git a/include/tbl/params.h b/include/tbl/params.h index 837c62f..b1c1f33 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1605,11 +1605,10 @@ PARAM( /* max */ "4G", /* default */ "1M", /* units */ "bytes", - /* flags */ MUST_RESTART, + /* flags */ 0, /* s-text */ - "The amount of space to allocate for stats counters in the VSM " - "memory segment. If you make this too small, some counters will " - "be invisible. Making it too large just costs memory resources.", + "DEPRECATED: This parameter is ignored.\n" + "There is no global limit on amount of shared memory now.", /* l-text */ "", /* func */ NULL ) From hermunn at varnish-software.com Fri Sep 15 11:17:26 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:26 +0000 (UTC) Subject: [5.2] 12c6707 Change the max for vsm_space to 1G on all archs, now that we no longer use this parameter any more. Message-ID: <20170915111726.453F798738@lists.varnish-cache.org> commit 12c67075ce307e0ee6d51ed8d9b27cc66ef41cda Author: Poul-Henning Kamp Date: Wed Sep 13 21:53:03 2017 +0000 Change the max for vsm_space to 1G on all archs, now that we no longer use this parameter any more. diff --git a/include/tbl/params.h b/include/tbl/params.h index b1c1f33..2a2bbf3 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1602,7 +1602,7 @@ PARAM( /* name */ vsm_space, /* typ */ bytes, /* min */ "1M", - /* max */ "4G", + /* max */ "1G", /* default */ "1M", /* units */ "bytes", /* flags */ 0, From hermunn at varnish-software.com Fri Sep 15 11:17:26 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:26 +0000 (UTC) Subject: [5.2] 217e190 Remove stale comments Message-ID: <20170915111726.65C9798743@lists.varnish-cache.org> commit 217e19071b4087861e0642d1c876f9e2efa4110e Author: Dridi Boukelmoune Date: Thu Sep 14 00:02:36 2017 +0200 Remove stale comments diff --git a/bin/varnishd/lck.vsc b/bin/varnishd/lck.vsc index 99a7824..75b69be 100644 --- a/bin/varnishd/lck.vsc +++ b/bin/varnishd/lck.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: lck :oneliner: Lock Counters :order: 70 diff --git a/bin/varnishd/main.vsc b/bin/varnishd/main.vsc index b513ac4..ca999f7 100644 --- a/bin/varnishd/main.vsc +++ b/bin/varnishd/main.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_f_main.h - .. varnish_vsc_begin:: main :oneliner: Main counters :order: 10 diff --git a/bin/varnishd/mempool.vsc b/bin/varnishd/mempool.vsc index 0f333cc..8c47245 100644 --- a/bin/varnishd/mempool.vsc +++ b/bin/varnishd/mempool.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: mempool :oneliner: Memory Pool Counters :order: 30 diff --git a/bin/varnishd/mgt.vsc b/bin/varnishd/mgt.vsc index d766e99..c3ca867 100644 --- a/bin/varnishd/mgt.vsc +++ b/bin/varnishd/mgt.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: mgt :oneliner: Management Process Counters :order: 20 diff --git a/bin/varnishd/sma.vsc b/bin/varnishd/sma.vsc index 5756bec..d2ecc52 100644 --- a/bin/varnishd/sma.vsc +++ b/bin/varnishd/sma.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: sma :oneliner: Malloc Stevedore Counters :order: 40 diff --git a/bin/varnishd/smf.vsc b/bin/varnishd/smf.vsc index 3ba2f3f..4ec0dcc 100644 --- a/bin/varnishd/smf.vsc +++ b/bin/varnishd/smf.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: smf :oneliner: File Stevedore Counters :order: 50 diff --git a/bin/varnishd/vbe.vsc b/bin/varnishd/vbe.vsc index fee72bf..c5ca37f 100644 --- a/bin/varnishd/vbe.vsc +++ b/bin/varnishd/vbe.vsc @@ -2,9 +2,6 @@ This is *NOT* a RST file but the syntax has been chosen so that it may become an RST file at some later date. - XXX: For now this file must be kept in 100% agreement with - XXX: include/tbl/vsc_fields.h - .. varnish_vsc_begin:: vbe :oneliner: Backend Counters :order: 60 From hermunn at varnish-software.com Fri Sep 15 11:17:26 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:26 +0000 (UTC) Subject: [5.2] 60b9c9e Use argv[0] as the VUT.progname Message-ID: <20170915111726.8445398774@lists.varnish-cache.org> commit 60b9c9edebec01bf84745761c8da451763aa694e Author: Dridi Boukelmoune Date: Tue Apr 18 09:24:52 2017 +0200 Use argv[0] as the VUT.progname This gives users a consistent usage/help message depending on whether they run VUTs from the PATH or from a specific location. In order to kill some of the redundancy, a VUT_InitProg macro does the $0 magic. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 417c97e..fbf1f39 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -57,8 +57,6 @@ #define HIST_N 2000 /* how far back we remember */ #define HIST_RES 100 /* bucket resolution */ -static const char progname[] = "varnishhist"; - static int hist_low; static int hist_high; static int hist_range; @@ -471,7 +469,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -497,7 +495,7 @@ main(int argc, char **argv) struct profile cli_p = {0}; cli_p.name = 0; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); AZ(pthread_cond_init(&timebend_cv, NULL)); while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 8018f7b..3050a6e 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -50,8 +50,6 @@ #include "vut.h" #include "miniobj.h" -static const char progname[] = "varnishlog"; - static struct log { /* Options */ int a_opt; @@ -66,7 +64,7 @@ static void __attribute__((__noreturn__)) usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -121,7 +119,7 @@ main(int argc, char * const *argv) { int opt; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); memset(&LOG, 0, sizeof LOG); while ((opt = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 0fa722f..58f5234 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -69,8 +69,6 @@ #define TIME_FMT "[%d/%b/%Y:%T %z]" #define FORMAT "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" -static const char progname[] = "varnishncsa"; - struct format; enum e_frag { @@ -165,7 +163,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -1144,7 +1142,7 @@ main(int argc, char * const *argv) signed char opt; char *format = NULL; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); memset(&CTX, 0, sizeof CTX); VTAILQ_INIT(&CTX.format); VTAILQ_INIT(&CTX.watch_vcl_log); diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index aa268c9..af20e65 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -49,8 +49,6 @@ #include "varnishstat.h" -static const char progname[] = "varnishstat"; - /*--------------------------------------------------------------------*/ static int __match_proto__(VSC_iter_f) @@ -243,7 +241,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt +=2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -259,7 +257,7 @@ main(int argc, char * const *argv) int i; struct vsc *vsc; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); vd = VSM_New(); AN(vd); vsc = VSC_New(); diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index e824961..f73530d 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -61,7 +61,7 @@ shell -match {^\d+.\d+.\d+.\d+ - user \[../.../20[1-9][0-9]:..:..:.. (?# shell "grep -q /2 ${tmpdir}/ncsa.log" # command line -shell -expect "Usage: varnishncsa " \ +shell -match "Usage: .*varnishncsa " \ "varnishncsa -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishncsa -V" @@ -107,7 +107,7 @@ shell -err -expect "Invalid grouping mode: session" \ {varnishncsa -g session} shell -err -expect "Can't open output file (No such file or directory)" \ {varnishncsa -w /nonexistent/file} -shell -err -expect "Usage: varnishncsa " \ +shell -err -match "Usage: .*varnishncsa " \ {varnishncsa extra} # -b diff --git a/bin/varnishtest/tests/u00004.vtc b/bin/varnishtest/tests/u00004.vtc index 811b370..4bdc41f 100644 --- a/bin/varnishtest/tests/u00004.vtc +++ b/bin/varnishtest/tests/u00004.vtc @@ -14,9 +14,9 @@ client c1 { shell -expect "fetch" "varnishtop -n ${v1_name} -1 -d" -shell -expect "Usage: varnishtop " \ +shell -match "Usage: .*varnishtop " \ "varnishtop -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishtop -V" -shell -err -expect "Usage: varnishtop " \ +shell -err -match "Usage: .*varnishtop " \ "varnishtop extra" diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc index 52242be..415307c 100644 --- a/bin/varnishtest/tests/u00005.vtc +++ b/bin/varnishtest/tests/u00005.vtc @@ -29,13 +29,13 @@ shell -expect "MGT.uptime" \ shell -match "^MGT" \ "varnishstat -1 -n ${v1_name} -f ^foo" -shell -expect "Usage: varnishstat " \ +shell -match "Usage: .*varnishstat " \ "varnishstat -h" shell -expect "Varnishstat -f option fields:" \ "varnishstat -n ${v1_name} -l" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishstat -V" -shell -err -expect "Usage: varnishstat " \ +shell -err -match "Usage: .*varnishstat " \ "varnishstat extra" shell -err -expect "-t: Invalid argument: -1" \ "varnishstat -t -1" diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index e87e4da..2d16bca 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -15,11 +15,11 @@ shell { -w ${tmpdir}/vlog.bin } -shell -expect "Usage: varnishlog " \ +shell -match "Usage: .*varnishlog " \ "varnishlog -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishlog -V" -shell -err -expect "Usage: varnishlog " \ +shell -err -match "Usage: .*varnishlog " \ "varnishlog extra" shell -err -expect "Missing -w option" \ "varnishlog -D" diff --git a/bin/varnishtest/tests/u00007.vtc b/bin/varnishtest/tests/u00007.vtc index 80d956c..8a095d5 100644 --- a/bin/varnishtest/tests/u00007.vtc +++ b/bin/varnishtest/tests/u00007.vtc @@ -7,11 +7,11 @@ server s1 { varnish v1 -vcl+backend {} -start -shell -expect "Usage: varnishhist " \ +shell -match "Usage: .*varnishhist " \ "varnishhist -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ "varnishhist -V" -shell -err -expect "Usage: varnishhist " \ +shell -err -match "Usage: .*varnishhist " \ "varnishhist extra" shell -err -expect "-p: invalid '0'" \ "varnishhist -p 0" diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 39600ce..5639b22 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -71,7 +71,6 @@ struct top { double count; }; -static const char progname[] = "varnishtop"; static float period = 60; /* seconds */ static int end_of_file = 0; static unsigned ntop; @@ -318,7 +317,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Usage: %s \n\n", VUT.progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt +=2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -331,7 +330,7 @@ main(int argc, char **argv) int o, once = 0; pthread_t thr; - VUT_Init(progname, argc, argv, &vopt_spec); + VUT_InitProg(argc, argv, &vopt_spec); while ((o = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { switch (o) { diff --git a/include/vut.h b/include/vut.h index aab3608..703faa4 100644 --- a/include/vut.h +++ b/include/vut.h @@ -71,6 +71,8 @@ void VUT_Error(int status, const char *fmt, ...) int VUT_Arg(int opt, const char *arg); +#define VUT_InitProg(argc, argv, spec) VUT_Init(argv[0], argc, argv, spec) + void VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *); From hermunn at varnish-software.com Fri Sep 15 11:17:26 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:26 +0000 (UTC) Subject: [5.2] f155b00 Name VUT global options accordingly Message-ID: <20170915111726.A6E51987A8@lists.varnish-cache.org> commit f155b007503161f224cb131556d19059c09910a9 Author: Dridi Boukelmoune Date: Tue Sep 5 12:31:51 2017 +0200 Name VUT global options accordingly The API is responsible for checking that global options aren't used more than once, despite it being handled (soon) in individual VUT setups. diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index a4f70cd..7ad374b 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -93,4 +93,4 @@ VUT_OPT_q VUT_OPT_r VUT_OPT_t VSL_OPT_T -VUT_OPT_V +VUT_GLOBAL_OPT_V diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h index 4847268..417b764 100644 --- a/bin/varnishlog/varnishlog_options.h +++ b/bin/varnishlog/varnishlog_options.h @@ -59,7 +59,7 @@ VSL_OPT_b VSL_OPT_c VSL_OPT_C VUT_OPT_d -VUT_OPT_D +VUT_GLOBAL_OPT_D VUT_OPT_g VUT_OPT_h VSL_OPT_i @@ -67,13 +67,13 @@ VSL_OPT_I VUT_OPT_k VSL_OPT_L VUT_OPT_n -VUT_OPT_P +VUT_GLOBAL_OPT_P VUT_OPT_q VUT_OPT_r VUT_OPT_t VSL_OPT_T VSL_OPT_v -VUT_OPT_V +VUT_GLOBAL_OPT_V LOG_OPT_w VSL_OPT_x VSL_OPT_X diff --git a/bin/varnishncsa/varnishncsa_options.h b/bin/varnishncsa/varnishncsa_options.h index 6fe13de..16bcdb1 100644 --- a/bin/varnishncsa/varnishncsa_options.h +++ b/bin/varnishncsa/varnishncsa_options.h @@ -78,16 +78,16 @@ NCSA_OPT_b NCSA_OPT_c VSL_OPT_C VUT_OPT_d -VUT_OPT_D +VUT_GLOBAL_OPT_D NCSA_OPT_F NCSA_OPT_f NCSA_OPT_g VUT_OPT_h VSL_OPT_L VUT_OPT_n -VUT_OPT_P +VUT_GLOBAL_OPT_P VUT_OPT_q VUT_OPT_r VUT_OPT_t -VUT_OPT_V +VUT_GLOBAL_OPT_V NCSA_OPT_w diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index af20e65..a1e70fa 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -274,9 +274,6 @@ main(int argc, char * const *argv) case 'l': f_list = 1; break; - case 'V': - VCS_Message("varnishstat"); - exit(0); case 'x': xml = 1; break; @@ -286,6 +283,9 @@ main(int argc, char * const *argv) case 'f': AN(VSC_Arg(vsc, opt, optarg)); break; + case 'V': + AN(VUT_Arg(opt, optarg)); + break; default: i = VSM_Arg(vd, opt, optarg); if (i < 0) diff --git a/bin/varnishstat/varnishstat_options.h b/bin/varnishstat/varnishstat_options.h index 5307a1d..a1ea33b 100644 --- a/bin/varnishstat/varnishstat_options.h +++ b/bin/varnishstat/varnishstat_options.h @@ -65,5 +65,5 @@ STAT_OPT_j STAT_OPT_l VUT_OPT_n VUT_OPT_t -VUT_OPT_V +VUT_GLOBAL_OPT_V STAT_OPT_x diff --git a/bin/varnishtop/varnishtop_options.h b/bin/varnishtop/varnishtop_options.h index 1cf0e20..dcad737 100644 --- a/bin/varnishtop/varnishtop_options.h +++ b/bin/varnishtop/varnishtop_options.h @@ -72,4 +72,4 @@ VUT_OPT_t VSL_OPT_T VSL_OPT_x VSL_OPT_X -VUT_OPT_V +VUT_GLOBAL_OPT_V diff --git a/include/vut.h b/include/vut.h index 703faa4..b214cdb 100644 --- a/include/vut.h +++ b/include/vut.h @@ -51,7 +51,6 @@ struct VUT { struct VSL_data *vsl; struct vsm *vsm; struct VSLQ *vslq; - struct vpf_fh *pfh; int sighup; int sigint; int sigusr1; diff --git a/include/vut_options.h b/include/vut_options.h index 9f0ad78..d6941e1 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -29,16 +29,26 @@ /* VUT options */ +#define VUT_GLOBAL_OPT_D \ + VOPT("D", "[-D]", "Daemonize", \ + "Daemonize." \ + ) + +#define VUT_GLOBAL_OPT_P \ + VOPT("P:", "[-P ]", "PID file", \ + "Write the process' PID to the specified file." \ + ) + +#define VUT_GLOBAL_OPT_V \ + VOPT("V", "[-V]", "Version", \ + "Print version information and exit." \ + ) + #define VUT_OPT_d \ VOPT("d", "[-d]", "Process old log entries and exit", \ "Process log records at the head of the log and exit." \ ) -#define VUT_OPT_D \ - VOPT("D", "[-D]", "Daemonize", \ - "Daemonize." \ - ) - #define VUT_OPT_g \ VOPT("g:", "[-g ]", "Grouping mode (default: vxid)", \ "The grouping of the log records. The default is to group" \ @@ -63,11 +73,6 @@ " the host name is used." \ ) -#define VUT_OPT_P \ - VOPT("P:", "[-P ]", "PID file", \ - "Write the process' PID to the specified file." \ - ) - #define VUT_OPT_q \ VOPT("q:", "[-q ]", "VSL query", \ "Specifies the VSL query to use." \ @@ -90,8 +95,3 @@ " indefinetely for the Varnish instance to appear. " \ " Defaults to 5 seconds." \ ) - -#define VUT_OPT_V \ - VOPT("V", "[-V]", "Version", \ - "Print version information and exit." \ - ) diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 4057c3f..1797dab 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -61,12 +61,24 @@ struct VUT VUT; static int vut_synopsis(const struct vopt_spec *); static int vut_options(const struct vopt_spec *); +static struct vpf_fh *pfh; +static unsigned daemonized; + +static int +vut_daemon(void) +{ + if (daemonized) + VUT_Error(1, "Already running as a daemon"); + daemonized = 1; + return (varnish_daemon(0, 0)); +} + static void vut_vpf_remove(void) { - if (VUT.pfh) { - AZ(VPF_Remove(VUT.pfh)); - VUT.pfh = NULL; + if (pfh != NULL) { + AZ(VPF_Remove(pfh)); + pfh = NULL; } } @@ -250,19 +262,21 @@ VUT_Setup(void) /* Open PID file */ if (VUT.P_arg) { - AZ(VUT.pfh); - VUT.pfh = VPF_Open(VUT.P_arg, 0644, NULL); - if (VUT.pfh == NULL) + if (pfh != NULL) + VUT_Error(1, "PID file already created"); + pfh = VPF_Open(VUT.P_arg, 0644, NULL); + if (pfh == NULL) VUT_Error(1, "%s: %s", VUT.P_arg, strerror(errno)); } /* Daemon mode */ - if (VUT.D_opt && varnish_daemon(0, 0) == -1) + if (VUT.D_opt && vut_daemon() == -1) VUT_Error(1, "Daemon mode: %s", strerror(errno)); /* Write PID and setup exit handler */ - if (VUT.pfh != NULL) { - AZ(VPF_Write(VUT.pfh)); + if (VUT.P_arg) { + AN(pfh); + AZ(VPF_Write(pfh)); AZ(atexit(vut_vpf_remove)); } } @@ -279,7 +293,7 @@ VUT_Fini(void) free(VUT.t_arg); vut_vpf_remove(); - AZ(VUT.pfh); + AZ(pfh); if (VUT.vslq) VSLQ_Delete(&VUT.vslq); From hermunn at varnish-software.com Fri Sep 15 11:17:26 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:26 +0000 (UTC) Subject: [5.2] 6ce27bf Signals must be forwarded to VUTs by programs Message-ID: <20170915111726.C8A9A987BD@lists.varnish-cache.org> commit 6ce27bf89e7500062f31a600c4835a7602258508 Author: Dridi Boukelmoune Date: Tue Sep 5 15:12:14 2017 +0200 Signals must be forwarded to VUTs by programs This is a first step away from the global VUT symbol, handled outside of VUT_Setup in preparation for the "unglobalization". diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index fbf1f39..bb7dc70 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -484,6 +484,12 @@ profile_error(const char *s) exit(1); } +static void +vut_sighandler(int sig) +{ + VUT_Signaled(&VUT, sig); +} + int main(int argc, char **argv) { @@ -608,6 +614,7 @@ main(int argc, char **argv) log_ten = log(10.0); + VUT_Signal(vut_sighandler); VUT_Setup(); ident = VSM_Dup(VUT.vsm, "Arg", "-i"); if (pthread_create(&thr, NULL, do_curses, NULL) != 0) diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 3050a6e..ffd1450 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -114,6 +114,12 @@ sighup(void) return (1); } +static void +vut_sighandler(int sig) +{ + VUT_Signaled(&VUT, sig); +} + int main(int argc, char * const *argv) { @@ -166,6 +172,7 @@ main(int argc, char * const *argv) LOG.fo = stdout; VUT.idle_f = flushout; + VUT_Signal(vut_sighandler); VUT_Setup(); VUT_Main(); VUT_Fini(); diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 58f5234..bd20848 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -1108,6 +1109,12 @@ sighup(void) return (1); } +static void +vut_sighandler(int sig) +{ + VUT_Signaled(&VUT, sig); +} + static char * read_format(const char *formatfile) { @@ -1228,6 +1235,7 @@ main(int argc, char * const *argv) CTX.fo = stdout; VUT.idle_f = flushout; + VUT_Signal(vut_sighandler); VUT_Setup(); VUT_Main(); VUT_Fini(); diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index a1e70fa..a13ce61 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 5639b22..eb0dd6f 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -185,6 +185,12 @@ sighup(void) } static void +vut_sighandler(int sig) +{ + VUT_Signaled(&VUT, sig); +} + +static void update(int p) { struct top *tp, *tp2; @@ -362,6 +368,7 @@ main(int argc, char **argv) if (optind != argc) usage(1); + VUT_Signal(vut_sighandler); VUT_Setup(); ident = VSM_Dup(VUT.vsm, "Arg", "-i"); if (!once) { diff --git a/include/vut.h b/include/vut.h index b214cdb..d084ec3 100644 --- a/include/vut.h +++ b/include/vut.h @@ -31,6 +31,7 @@ struct vopt_spec; +typedef void VUT_sighandler_f(int); typedef int VUT_cb_f(void); struct VUT { @@ -75,6 +76,9 @@ int VUT_Arg(int opt, const char *arg); void VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *); +void VUT_Signal(VUT_sighandler_f); +void VUT_Signaled(struct VUT *, int); + void VUT_Setup(void); int VUT_Main(void); void VUT_Fini(void); diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 0f3fb80..4f23dc5 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -134,6 +134,8 @@ LIBVARNISHAPI_2.0 { VUT_Init; VUT_Main; VUT_Setup; + VUT_Signal; + VUT_Signaled; local: *; diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 1797dab..d6dbbb9 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -82,15 +82,6 @@ vut_vpf_remove(void) } } -static void -vut_signal(int sig) -{ - - VUT.sighup |= (sig == SIGHUP); - VUT.sigint |= (sig == SIGINT || sig == SIGTERM); - VUT.sigusr1 |= (sig == SIGUSR1); -} - static int __match_proto__(VSLQ_dispatch_f) vut_dispatch(struct VSL_data *vsl, struct VSL_transaction * const trans[], void *priv) @@ -216,6 +207,27 @@ VUT_Init(const char *progname, int argc, char * const *argv, } void +VUT_Signal(VUT_sighandler_f sig_cb) +{ + + AN(sig_cb); + (void)signal(SIGHUP, sig_cb); + (void)signal(SIGINT, sig_cb); + (void)signal(SIGTERM, sig_cb); + (void)signal(SIGUSR1, sig_cb); +} + +void +VUT_Signaled(struct VUT *vut, int sig) +{ + + AN(vut); + vut->sighup |= (sig == SIGHUP); + vut->sigint |= (sig == SIGINT || sig == SIGTERM); + vut->sigusr1 |= (sig == SIGUSR1); +} + +void VUT_Setup(void) { struct VSL_cursor *c; @@ -254,12 +266,6 @@ VUT_Setup(void) // Cursor is handled in VUT_Main() } - /* Signal handlers */ - (void)signal(SIGHUP, vut_signal); - (void)signal(SIGINT, vut_signal); - (void)signal(SIGTERM, vut_signal); - (void)signal(SIGUSR1, vut_signal); - /* Open PID file */ if (VUT.P_arg) { if (pfh != NULL) From hermunn at varnish-software.com Fri Sep 15 11:17:26 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:26 +0000 (UTC) Subject: [5.2] e821a0b Pass VUTs to callbacks Message-ID: <20170915111726.E9E38987D3@lists.varnish-cache.org> commit e821a0b0de71e2e911870b7a0f4cd44bfc133bbd Author: Dridi Boukelmoune Date: Tue Sep 5 15:28:32 2017 +0200 Pass VUTs to callbacks With the exception of dispatch_f that already has a dispatch_priv. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index bb7dc70..fe2df7a 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -366,8 +366,9 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], } static int __match_proto__(VUT_cb_f) -sighup(void) +sighup(struct VUT *v) { + assert(v == &VUT); quit = 1; return (1); } diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index ffd1450..edabf63 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -87,9 +87,10 @@ openout(int append) } static int __match_proto__(VUT_cb_f) -rotateout(void) +rotateout(struct VUT *v) { + assert(v == &VUT); AN(LOG.w_arg); AN(LOG.fo); fclose(LOG.fo); @@ -99,9 +100,11 @@ rotateout(void) } static int __match_proto__(VUT_cb_f) -flushout(void) +flushout(struct VUT *v) { + if (v != NULL) + assert(v == &VUT); AN(LOG.fo); if (fflush(LOG.fo)) return (-5); @@ -109,8 +112,9 @@ flushout(void) } static int __match_proto__(VUT_cb_f) -sighup(void) +sighup(struct VUT *v) { + assert(v == &VUT); return (1); } @@ -177,7 +181,7 @@ main(int argc, char * const *argv) VUT_Main(); VUT_Fini(); - (void)flushout(); + (void)flushout(NULL); exit(0); } diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index bd20848..415691e 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -183,9 +183,10 @@ openout(int append) } static int __match_proto__(VUT_cb_f) -rotateout(void) +rotateout(struct VUT *v) { + assert(v == &VUT); AN(CTX.w_arg); AN(CTX.fo); fclose(CTX.fo); @@ -195,9 +196,10 @@ rotateout(void) } static int __match_proto__(VUT_cb_f) -flushout(void) +flushout(struct VUT *v) { + assert(v == &VUT); AN(CTX.fo); if (fflush(CTX.fo)) return (-5); @@ -1104,8 +1106,9 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], } static int __match_proto__(VUT_cb_f) -sighup(void) +sighup(struct VUT *v) { + assert(v == &VUT); return (1); } diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index eb0dd6f..85d8dab 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -178,8 +178,9 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], } static int __match_proto__(VUT_cb_f) -sighup(void) +sighup(struct VUT *v) { + assert(v == &VUT); quit = 1; return (1); } diff --git a/include/vut.h b/include/vut.h index d084ec3..1fbe755 100644 --- a/include/vut.h +++ b/include/vut.h @@ -29,10 +29,11 @@ * Common functions for the utilities */ +struct VUT; struct vopt_spec; typedef void VUT_sighandler_f(int); -typedef int VUT_cb_f(void); +typedef int VUT_cb_f(struct VUT *); struct VUT { const char *progname; diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index d6dbbb9..5bd24d4 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -324,7 +324,7 @@ VUT_Main(void) if (VUT.sighup && VUT.sighup_f) { /* sighup callback */ VUT.sighup = 0; - i = VUT.sighup_f(); + i = VUT.sighup_f(&VUT); if (i) break; } @@ -370,7 +370,7 @@ VUT_Main(void) else if (i == 0) { /* Nothing to do but wait */ if (VUT.idle_f) { - i = VUT.idle_f(); + i = VUT.idle_f(&VUT); if (i) break; } From hermunn at varnish-software.com Fri Sep 15 11:17:27 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:27 +0000 (UTC) Subject: [5.2] 8cedf8d Remove the global VUT symbol Message-ID: <20170915111727.1A54C987E1@lists.varnish-cache.org> commit 8cedf8d0686da3bbe4aa7ac188d8fd8091e659c4 Author: Dridi Boukelmoune Date: Tue Sep 5 11:26:09 2017 +0200 Remove the global VUT symbol diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index fe2df7a..7054b6d 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -57,6 +57,8 @@ #define HIST_N 2000 /* how far back we remember */ #define HIST_RES 100 /* bucket resolution */ +static struct VUT *vut; + static int hist_low; static int hist_high; static int hist_range; @@ -368,7 +370,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], static int __match_proto__(VUT_cb_f) sighup(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); quit = 1; return (1); } @@ -470,7 +472,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -488,7 +490,7 @@ profile_error(const char *s) static void vut_sighandler(int sig) { - VUT_Signaled(&VUT, sig); + VUT_Signaled(vut, sig); } int @@ -502,7 +504,8 @@ main(int argc, char **argv) struct profile cli_p = {0}; cli_p.name = 0; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); AZ(pthread_cond_init(&timebend_cv, NULL)); while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { @@ -565,7 +568,7 @@ main(int argc, char **argv) " (invalid factor '%s')", optarg); break; default: - if (!VUT_Arg(i, optarg)) + if (!VUT_Arg(vut, i, optarg)) usage(1); } } @@ -574,11 +577,11 @@ main(int argc, char **argv) usage(1); /* Check for valid grouping mode */ - assert(VUT.g_arg < VSL_g__MAX); - if (VUT.g_arg != VSL_g_vxid && VUT.g_arg != VSL_g_request) + assert(vut->g_arg < VSL_g__MAX); + if (vut->g_arg != VSL_g_vxid && vut->g_arg != VSL_g_request) VUT_Error(1, "Invalid grouping mode: %s" " (only vxid and request are supported)", - VSLQ_grouping[VUT.g_arg]); + VSLQ_grouping[vut->g_arg]); if (profile) { for (active_profile = profiles; active_profile->name; @@ -593,7 +596,7 @@ main(int argc, char **argv) assert(active_profile->VSL_arg == 'b' || active_profile->VSL_arg == 'c'); - assert(VUT_Arg(active_profile->VSL_arg, NULL)); + assert(VUT_Arg(vut, active_profile->VSL_arg, NULL)); match_tag = active_profile->tag; fnum = active_profile->field; hist_low = active_profile->hist_low; @@ -616,16 +619,16 @@ main(int argc, char **argv) log_ten = log(10.0); VUT_Signal(vut_sighandler); - VUT_Setup(); - ident = VSM_Dup(VUT.vsm, "Arg", "-i"); + VUT_Setup(vut); + ident = VSM_Dup(vut->vsm, "Arg", "-i"); if (pthread_create(&thr, NULL, do_curses, NULL) != 0) VUT_Error(1, "pthread_create(): %s", strerror(errno)); - VUT.dispatch_f = accumulate; - VUT.dispatch_priv = NULL; - VUT.sighup_f = sighup; - VUT_Main(); + vut->dispatch_f = accumulate; + vut->dispatch_priv = NULL; + vut->sighup_f = sighup; + VUT_Main(vut); end_of_file = 1; AZ(pthread_join(thr, NULL)); - VUT_Fini(); + VUT_Fini(&vut); exit(0); } diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index edabf63..6f6772b 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -50,6 +50,8 @@ #include "vut.h" #include "miniobj.h" +static struct VUT *vut; + static struct log { /* Options */ int a_opt; @@ -64,7 +66,7 @@ static void __attribute__((__noreturn__)) usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -79,18 +81,18 @@ openout(int append) if (LOG.A_opt) LOG.fo = fopen(LOG.w_arg, append ? "a" : "w"); else - LOG.fo = VSL_WriteOpen(VUT.vsl, LOG.w_arg, append, 0); + LOG.fo = VSL_WriteOpen(vut->vsl, LOG.w_arg, append, 0); if (LOG.fo == NULL) VUT_Error(2, "Cannot open output file (%s)", - LOG.A_opt ? strerror(errno) : VSL_Error(VUT.vsl)); - VUT.dispatch_priv = LOG.fo; + LOG.A_opt ? strerror(errno) : VSL_Error(vut->vsl)); + vut->dispatch_priv = LOG.fo; } static int __match_proto__(VUT_cb_f) rotateout(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); AN(LOG.w_arg); AN(LOG.fo); fclose(LOG.fo); @@ -103,8 +105,7 @@ static int __match_proto__(VUT_cb_f) flushout(struct VUT *v) { - if (v != NULL) - assert(v == &VUT); + assert(v == vut); AN(LOG.fo); if (fflush(LOG.fo)) return (-5); @@ -114,14 +115,15 @@ flushout(struct VUT *v) static int __match_proto__(VUT_cb_f) sighup(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); return (1); } static void vut_sighandler(int sig) { - VUT_Signaled(&VUT, sig); + AN(vut); + VUT_Signaled(vut, sig); } int @@ -129,7 +131,8 @@ main(int argc, char * const *argv) { int opt; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); memset(&LOG, 0, sizeof LOG); while ((opt = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { @@ -150,7 +153,7 @@ main(int argc, char * const *argv) REPLACE(LOG.w_arg, optarg); break; default: - if (!VUT_Arg(opt, optarg)) + if (!VUT_Arg(vut, opt, optarg)) usage(1); } } @@ -158,28 +161,28 @@ main(int argc, char * const *argv) if (optind != argc) usage(1); - if (VUT.D_opt && !LOG.w_arg) + if (vut->D_opt && !LOG.w_arg) VUT_Error(1, "Missing -w option"); /* Setup output */ if (LOG.A_opt || !LOG.w_arg) - VUT.dispatch_f = VSL_PrintTransactions; + vut->dispatch_f = VSL_PrintTransactions; else - VUT.dispatch_f = VSL_WriteTransactions; - VUT.sighup_f = sighup; + vut->dispatch_f = VSL_WriteTransactions; + vut->sighup_f = sighup; if (LOG.w_arg) { openout(LOG.a_opt); AN(LOG.fo); - if (VUT.D_opt) - VUT.sighup_f = rotateout; + if (vut->D_opt) + vut->sighup_f = rotateout; } else LOG.fo = stdout; - VUT.idle_f = flushout; + vut->idle_f = flushout; VUT_Signal(vut_sighandler); - VUT_Setup(); - VUT_Main(); - VUT_Fini(); + VUT_Setup(vut); + VUT_Main(vut); + VUT_Fini(&vut); (void)flushout(NULL); diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 415691e..22391d1 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -70,6 +70,8 @@ #define TIME_FMT "[%d/%b/%Y:%T %z]" #define FORMAT "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" +static struct VUT *vut; + struct format; enum e_frag { @@ -164,7 +166,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt += 2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -186,7 +188,7 @@ static int __match_proto__(VUT_cb_f) rotateout(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); AN(CTX.w_arg); AN(CTX.fo); fclose(CTX.fo); @@ -199,7 +201,7 @@ static int __match_proto__(VUT_cb_f) flushout(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); AN(CTX.fo); if (fflush(CTX.fo)) return (-5); @@ -1108,14 +1110,15 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], static int __match_proto__(VUT_cb_f) sighup(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); return (1); } static void vut_sighandler(int sig) { - VUT_Signaled(&VUT, sig); + AN(vut); + VUT_Signaled(vut, sig); } static char * @@ -1152,7 +1155,8 @@ main(int argc, char * const *argv) signed char opt; char *format = NULL; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); memset(&CTX, 0, sizeof CTX); VTAILQ_INIT(&CTX.format); VTAILQ_INIT(&CTX.watch_vcl_log); @@ -1200,7 +1204,7 @@ main(int argc, char * const *argv) REPLACE(CTX.w_arg, optarg); break; default: - if (!VUT_Arg(opt, optarg)) + if (!VUT_Arg(vut, opt, optarg)) usage(1); } } @@ -1211,14 +1215,14 @@ main(int argc, char * const *argv) if (optind != argc) usage(1); - if (VUT.D_opt && !CTX.w_arg) + if (vut->D_opt && !CTX.w_arg) VUT_Error(1, "Missing -w option"); /* Check for valid grouping mode */ - assert(VUT.g_arg < VSL_g__MAX); - if (VUT.g_arg != VSL_g_vxid && VUT.g_arg != VSL_g_request) + assert(vut->g_arg < VSL_g__MAX); + if (vut->g_arg != VSL_g_vxid && vut->g_arg != VSL_g_request) VUT_Error(1, "Invalid grouping mode: %s", - VSLQ_grouping[VUT.g_arg]); + VSLQ_grouping[vut->g_arg]); /* Prepare output format */ parse_format(format); @@ -1226,22 +1230,22 @@ main(int argc, char * const *argv) format = NULL; /* Setup output */ - VUT.dispatch_f = dispatch_f; - VUT.dispatch_priv = NULL; - VUT.sighup_f = sighup; + vut->dispatch_f = dispatch_f; + vut->dispatch_priv = NULL; + vut->sighup_f = sighup; if (CTX.w_arg) { openout(CTX.a_opt); AN(CTX.fo); - if (VUT.D_opt) - VUT.sighup_f = rotateout; + if (vut->D_opt) + vut->sighup_f = rotateout; } else CTX.fo = stdout; - VUT.idle_f = flushout; + vut->idle_f = flushout; VUT_Signal(vut_sighandler); - VUT_Setup(); - VUT_Main(); - VUT_Fini(); + VUT_Setup(vut); + VUT_Main(vut); + VUT_Fini(&vut); exit(0); } diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index a13ce61..7d02906 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -50,6 +50,8 @@ #include "varnishstat.h" +static struct VUT *vut; + /*--------------------------------------------------------------------*/ static int __match_proto__(VSC_iter_f) @@ -242,7 +244,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt +=2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -258,7 +260,8 @@ main(int argc, char * const *argv) int i; struct vsc *vsc; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); vd = VSM_New(); AN(vd); vsc = VSC_New(); @@ -285,7 +288,7 @@ main(int argc, char * const *argv) AN(VSC_Arg(vsc, opt, optarg)); break; case 'V': - AN(VUT_Arg(opt, optarg)); + AN(VUT_Arg(vut, opt, optarg)); break; default: i = VSM_Arg(vd, opt, optarg); diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 85d8dab..09d939f 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -60,6 +60,8 @@ #define AC(x) x #endif +static struct VUT *vut; + struct top { uint8_t tag; const char *rec_data; @@ -180,7 +182,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], static int __match_proto__(VUT_cb_f) sighup(struct VUT *v) { - assert(v == &VUT); + assert(v == vut); quit = 1; return (1); } @@ -188,7 +190,8 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - VUT_Signaled(&VUT, sig); + AN(vut); + VUT_Signaled(vut, sig); } static void @@ -324,7 +327,7 @@ usage(int status) { const char **opt; - fprintf(stderr, "Usage: %s \n\n", VUT.progname); + fprintf(stderr, "Usage: %s \n\n", vut->progname); fprintf(stderr, "Options:\n"); for (opt = vopt_spec.vopt_usage; *opt != NULL; opt +=2) fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); @@ -337,12 +340,13 @@ main(int argc, char **argv) int o, once = 0; pthread_t thr; - VUT_InitProg(argc, argv, &vopt_spec); + vut = VUT_InitProg(argc, argv, &vopt_spec); + AN(vut); while ((o = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { switch (o) { case '1': - AN(VUT_Arg('d', NULL)); + AN(VUT_Arg(vut, 'd', NULL)); once = 1; break; case 'f': @@ -361,7 +365,7 @@ main(int argc, char **argv) } break; default: - if (!VUT_Arg(o, optarg)) + if (!VUT_Arg(vut, o, optarg)) usage(1); } } @@ -370,8 +374,8 @@ main(int argc, char **argv) usage(1); VUT_Signal(vut_sighandler); - VUT_Setup(); - ident = VSM_Dup(VUT.vsm, "Arg", "-i"); + VUT_Setup(vut); + ident = VSM_Dup(vut->vsm, "Arg", "-i"); if (!once) { if (pthread_create(&thr, NULL, do_curses, NULL) != 0) { fprintf(stderr, "pthread_create(): %s\n", @@ -379,15 +383,15 @@ main(int argc, char **argv) exit(1); } } - VUT.dispatch_f = accumulate; - VUT.dispatch_priv = NULL; - VUT.sighup_f = sighup; - VUT_Main(); + vut->dispatch_f = accumulate; + vut->dispatch_priv = NULL; + vut->sighup_f = sighup; + VUT_Main(vut); end_of_file = 1; if (once) dump(); else pthread_join(thr, NULL); - VUT_Fini(); + VUT_Fini(&vut); exit(0); } diff --git a/include/vut.h b/include/vut.h index 1fbe755..2e3a3c7 100644 --- a/include/vut.h +++ b/include/vut.h @@ -64,22 +64,20 @@ struct VUT { void *dispatch_priv; }; -extern struct VUT VUT; - //lint -sem(VUT_Error, r_no) void VUT_Error(int status, const char *fmt, ...) __v_printflike(2, 3) __attribute__((__noreturn__)); -int VUT_Arg(int opt, const char *arg); +int VUT_Arg(struct VUT *, int opt, const char *arg); #define VUT_InitProg(argc, argv, spec) VUT_Init(argv[0], argc, argv, spec) -void VUT_Init(const char *progname, int argc, char * const *argv, +struct VUT * VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *); void VUT_Signal(VUT_sighandler_f); void VUT_Signaled(struct VUT *, int); -void VUT_Setup(void); -int VUT_Main(void); -void VUT_Fini(void); +void VUT_Setup(struct VUT *); +int VUT_Main(struct VUT *); +void VUT_Fini(struct VUT **); diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 4f23dc5..7454f4f 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -127,7 +127,6 @@ LIBVARNISHAPI_2.0 { VTIM_timeval; # vut.c - VUT; VUT_Arg; VUT_Error; VUT_Fini; diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 5bd24d4..6103e9c 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -56,8 +56,6 @@ #include "vapi/voptget.h" -struct VUT VUT; - static int vut_synopsis(const struct vopt_spec *); static int vut_options(const struct vopt_spec *); @@ -86,16 +84,18 @@ static int __match_proto__(VSLQ_dispatch_f) vut_dispatch(struct VSL_data *vsl, struct VSL_transaction * const trans[], void *priv) { + struct VUT *vut; int i; - (void)priv; - if (VUT.k_arg == 0) + vut = priv; + AN(vut); + if (vut->k_arg == 0) return (-1); /* End of file */ - AN(VUT.dispatch_f); - i = VUT.dispatch_f(vsl, trans, VUT.dispatch_priv); - if (VUT.k_arg > 0) - VUT.k_arg--; - if (i >= 0 && VUT.k_arg == 0) + AN(vut->dispatch_f); + i = vut->dispatch_f(vsl, trans, vut->dispatch_priv); + if (vut->k_arg > 0) + vut->k_arg--; + if (i >= 0 && vut->k_arg == 0) return (-1); /* End of file */ return (i); } @@ -116,7 +116,7 @@ VUT_Error(int status, const char *fmt, ...) } int -VUT_Arg(int opt, const char *arg) +VUT_Arg(struct VUT *vut, int opt, const char *arg) { int i; char *p; @@ -124,86 +124,90 @@ VUT_Arg(int opt, const char *arg) switch (opt) { case 'd': /* Head */ - VUT.d_opt = 1; + vut->d_opt = 1; return (1); case 'D': /* Daemon mode */ - VUT.D_opt = 1; + vut->D_opt = 1; return (1); case 'g': /* Grouping */ AN(arg); - VUT.g_arg = VSLQ_Name2Grouping(arg, -1); - if (VUT.g_arg == -2) + vut->g_arg = VSLQ_Name2Grouping(arg, -1); + if (vut->g_arg == -2) VUT_Error(1, "Ambiguous grouping type: %s", arg); - else if (VUT.g_arg < 0) + else if (vut->g_arg < 0) VUT_Error(1, "Unknown grouping type: %s", arg); return (1); case 'k': /* Log transaction limit */ AN(arg); - VUT.k_arg = (int)strtol(arg, &p, 10); - if (*p != '\0' || VUT.k_arg <= 0) + vut->k_arg = (int)strtol(arg, &p, 10); + if (*p != '\0' || vut->k_arg <= 0) VUT_Error(1, "-k: Invalid number '%s'", arg); return (1); case 'n': /* Varnish instance name */ AN(arg); - REPLACE(VUT.n_arg, arg); + REPLACE(vut->n_arg, arg); return (1); case 'P': /* PID file */ AN(arg); - REPLACE(VUT.P_arg, arg); + REPLACE(vut->P_arg, arg); return (1); case 'q': /* Query to use */ AN(arg); - REPLACE(VUT.q_arg, arg); + REPLACE(vut->q_arg, arg); return (1); case 'r': /* Binary file input */ AN(arg); - REPLACE(VUT.r_arg, arg); + REPLACE(vut->r_arg, arg); return (1); case 't': /* VSM connect timeout */ - REPLACE(VUT.t_arg, arg); + REPLACE(vut->t_arg, arg); return (1); case 'V': /* Print version number and exit */ - VCS_Message(VUT.progname); + VCS_Message(vut->progname); exit(0); default: - AN(VUT.vsl); - i = VSL_Arg(VUT.vsl, opt, arg); + AN(vut->vsl); + i = VSL_Arg(vut->vsl, opt, arg); if (i < 0) - VUT_Error(1, "%s", VSL_Error(VUT.vsl)); + VUT_Error(1, "%s", VSL_Error(vut->vsl)); return (i); } } -void +struct VUT * VUT_Init(const char *progname, int argc, char * const *argv, const struct vopt_spec *voc) { + struct VUT *vut; AN(progname); AN(argv); AN(voc); - AZ(VUT.progname); + + vut = calloc(1, sizeof *vut); + AN(vut); if (argc == 2 && !strcmp(argv[1], "--synopsis")) exit(vut_synopsis(voc)); if (argc == 2 && !strcmp(argv[1], "--options")) exit(vut_options(voc)); - VUT.progname = progname; - VUT.g_arg = VSL_g_vxid; - AZ(VUT.vsl); - VUT.vsl = VSL_New(); - AN(VUT.vsl); - VUT.k_arg = -1; + vut->progname = progname; + vut->g_arg = VSL_g_vxid; + AZ(vut->vsl); + vut->vsl = VSL_New(); + AN(vut->vsl); + vut->k_arg = -1; + return (vut); } void @@ -228,59 +232,60 @@ VUT_Signaled(struct VUT *vut, int sig) } void -VUT_Setup(void) +VUT_Setup(struct VUT *vut) { struct VSL_cursor *c; - AN(VUT.vsl); - AZ(VUT.vsm); - AZ(VUT.vslq); + AN(vut); + AN(vut->vsl); + AZ(vut->vsm); + AZ(vut->vslq); /* Check input arguments (2 used for bug in FlexeLint) */ - if ((VUT.n_arg == NULL ? 0 : 2) + - (VUT.r_arg == NULL ? 0 : 2) > 2) + if ((vut->n_arg == NULL ? 0 : 2) + + (vut->r_arg == NULL ? 0 : 2) > 2) VUT_Error(1, "Only one of -n and -r options may be used"); /* Create and validate the query expression */ - VUT.vslq = VSLQ_New(VUT.vsl, NULL, VUT.g_arg, VUT.q_arg); - if (VUT.vslq == NULL) + vut->vslq = VSLQ_New(vut->vsl, NULL, vut->g_arg, vut->q_arg); + if (vut->vslq == NULL) VUT_Error(1, "Query expression error:\n%s", - VSL_Error(VUT.vsl)); + VSL_Error(vut->vsl)); /* Setup input */ - if (VUT.r_arg) { - c = VSL_CursorFile(VUT.vsl, VUT.r_arg, 0); + if (vut->r_arg) { + c = VSL_CursorFile(vut->vsl, vut->r_arg, 0); if (c == NULL) - VUT_Error(1, "%s", VSL_Error(VUT.vsl)); - VSLQ_SetCursor(VUT.vslq, &c); + VUT_Error(1, "%s", VSL_Error(vut->vsl)); + VSLQ_SetCursor(vut->vslq, &c); AZ(c); } else { - VUT.vsm = VSM_New(); - AN(VUT.vsm); - if (VUT.n_arg && VSM_Arg(VUT.vsm, 'n', VUT.n_arg) <= 0) - VUT_Error(1, "%s", VSM_Error(VUT.vsm)); - if (VUT.t_arg && VSM_Arg(VUT.vsm, 't', VUT.t_arg) <= 0) - VUT_Error(1, "%s", VSM_Error(VUT.vsm)); - if (VSM_Attach(VUT.vsm, STDERR_FILENO)) - VUT_Error(1, "VSM: %s", VSM_Error(VUT.vsm)); + vut->vsm = VSM_New(); + AN(vut->vsm); + if (vut->n_arg && VSM_Arg(vut->vsm, 'n', vut->n_arg) <= 0) + VUT_Error(1, "%s", VSM_Error(vut->vsm)); + if (vut->t_arg && VSM_Arg(vut->vsm, 't', vut->t_arg) <= 0) + VUT_Error(1, "%s", VSM_Error(vut->vsm)); + if (VSM_Attach(vut->vsm, STDERR_FILENO)) + VUT_Error(1, "VSM: %s", VSM_Error(vut->vsm)); // Cursor is handled in VUT_Main() } /* Open PID file */ - if (VUT.P_arg) { + if (vut->P_arg) { if (pfh != NULL) VUT_Error(1, "PID file already created"); - pfh = VPF_Open(VUT.P_arg, 0644, NULL); + pfh = VPF_Open(vut->P_arg, 0644, NULL); if (pfh == NULL) - VUT_Error(1, "%s: %s", VUT.P_arg, strerror(errno)); + VUT_Error(1, "%s: %s", vut->P_arg, strerror(errno)); } /* Daemon mode */ - if (VUT.D_opt && vut_daemon() == -1) + if (vut->D_opt && vut_daemon() == -1) VUT_Error(1, "Daemon mode: %s", strerror(errno)); /* Write PID and setup exit handler */ - if (VUT.P_arg) { + if (vut->P_arg) { AN(pfh); AZ(VPF_Write(pfh)); AZ(atexit(vut_vpf_remove)); @@ -288,89 +293,98 @@ VUT_Setup(void) } void -VUT_Fini(void) +VUT_Fini(struct VUT **vutp) { - AN(VUT.progname); + struct VUT *vut; + + AN(vutp); + vut = *vutp; + *vutp = NULL; - free(VUT.n_arg); - free(VUT.P_arg); - free(VUT.q_arg); - free(VUT.r_arg); - free(VUT.t_arg); + AN(vut); + AN(vut->progname); + + free(vut->n_arg); + free(vut->P_arg); + free(vut->q_arg); + free(vut->r_arg); + free(vut->t_arg); vut_vpf_remove(); AZ(pfh); - if (VUT.vslq) - VSLQ_Delete(&VUT.vslq); - if (VUT.vsl) - VSL_Delete(VUT.vsl); - if (VUT.vsm) - VSM_Destroy(&VUT.vsm); + if (vut->vslq) + VSLQ_Delete(&vut->vslq); + if (vut->vsl) + VSL_Delete(vut->vsl); + if (vut->vsm) + VSM_Destroy(&vut->vsm); - memset(&VUT, 0, sizeof VUT); + memset(vut, 0, sizeof *vut); + free(vut); } int -VUT_Main(void) +VUT_Main(struct VUT *vut) { struct VSL_cursor *c; int i = -1; int hascursor = -1; - AN(VUT.vslq); + AN(vut); + AN(vut->vslq); - while (!VUT.sigint) { - if (VUT.sighup && VUT.sighup_f) { + while (!vut->sigint) { + if (vut->sighup && vut->sighup_f) { /* sighup callback */ - VUT.sighup = 0; - i = VUT.sighup_f(&VUT); + vut->sighup = 0; + i = vut->sighup_f(vut); if (i) break; } - if (VUT.sigusr1) { + if (vut->sigusr1) { /* Flush and report any incomplete records */ - VUT.sigusr1 = 0; - (void)VSLQ_Flush(VUT.vslq, vut_dispatch, NULL); + vut->sigusr1 = 0; + (void)VSLQ_Flush(vut->vslq, vut_dispatch, vut); } // We must repeatedly call VSM_Status() when !hascursor // to make VSM discover our segment. - if (VUT.vsm != NULL && - (VSM_Status(VUT.vsm) & VSM_WRK_RESTARTED)) { + if (vut->vsm != NULL && + (VSM_Status(vut->vsm) & VSM_WRK_RESTARTED)) { if (hascursor < 1) { fprintf(stderr, "Log abandonned\n"); - VSLQ_SetCursor(VUT.vslq, NULL); + VSLQ_SetCursor(vut->vslq, NULL); hascursor = 0; } } - if (VUT.vsm != NULL && hascursor < 1) { + if (vut->vsm != NULL && hascursor < 1) { /* Reconnect VSM */ - AZ(VUT.r_arg); + AZ(vut->r_arg); VTIM_sleep(0.1); - c = VSL_CursorVSM(VUT.vsl, VUT.vsm, - (VUT.d_opt ? VSL_COPT_TAILSTOP : VSL_COPT_TAIL) + c = VSL_CursorVSM(vut->vsl, vut->vsm, + (vut->d_opt ? VSL_COPT_TAILSTOP : VSL_COPT_TAIL) | VSL_COPT_BATCH); if (c == NULL) { - VSL_ResetError(VUT.vsl); + VSL_ResetError(vut->vsl); continue; } if (hascursor >= 0) fprintf(stderr, "Log reacquired\n"); hascursor = 1; - VSLQ_SetCursor(VUT.vslq, &c); + VSLQ_SetCursor(vut->vslq, &c); AZ(c); } - i = VSLQ_Dispatch(VUT.vslq, vut_dispatch, NULL); + i = VSLQ_Dispatch(vut->vslq, vut_dispatch, vut); if (i == 1) /* Call again */ continue; else if (i == 0) { /* Nothing to do but wait */ - if (VUT.idle_f) { - i = VUT.idle_f(&VUT); + if (vut->idle_f) { + i = vut->idle_f(vut); if (i) break; } @@ -381,17 +395,17 @@ VUT_Main(void) break; } - if (VUT.vsm == NULL) + if (vut->vsm == NULL) break; /* XXX: Make continuation optional */ - (void)VSLQ_Flush(VUT.vslq, vut_dispatch, NULL); + (void)VSLQ_Flush(vut->vslq, vut_dispatch, vut); if (i == -2) { /* Abandoned */ fprintf(stderr, "Log abandoned\n"); - VSLQ_SetCursor(VUT.vslq, NULL); + VSLQ_SetCursor(vut->vslq, NULL); hascursor = 0; } else if (i < -2) /* Overrun */ From hermunn at varnish-software.com Fri Sep 15 11:17:27 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:27 +0000 (UTC) Subject: [5.2] fc5c259 Handle VUT errors in a callback Message-ID: <20170915111727.39565987ED@lists.varnish-cache.org> commit fc5c2593554a878b1de812b6293d5cd88a2a7477 Author: Dridi Boukelmoune Date: Tue Sep 5 15:58:16 2017 +0200 Handle VUT errors in a callback When omitted, the callback defaults to printing to stderr and exiting with the provided status. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 7054b6d..b8ebc19 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -516,7 +516,7 @@ main(int argc, char **argv) case 'p': delay = strtod(optarg, NULL); if (delay <= 0) - VUT_Error(1, "-p: invalid '%s'", optarg); + VUT_Error(vut, 1, "-p: invalid '%s'", optarg); break; case 'P': colon = strchr(optarg, ':'); @@ -545,7 +545,7 @@ main(int argc, char **argv) match_tag = VSL_Name2Tag(ptag, colon - ptag); if (match_tag < 0) - VUT_Error(1, + VUT_Error(vut, 1, "-P: '%s' is not a valid tag name", optarg); cli_p.name = "custom"; @@ -557,12 +557,12 @@ main(int argc, char **argv) case 'B': timebend = strtod(optarg, NULL); if (timebend == 0) - VUT_Error(1, + VUT_Error(vut, 1, "-B: being able to bend time does not" " mean we can stop it" " (invalid factor '%s')", optarg); if (timebend < 0) - VUT_Error(1, + VUT_Error(vut, 1, "-B: being able to bend time does not" " mean we can make it go backwards" " (invalid factor '%s')", optarg); @@ -579,7 +579,7 @@ main(int argc, char **argv) /* Check for valid grouping mode */ assert(vut->g_arg < VSL_g__MAX); if (vut->g_arg != VSL_g_vxid && vut->g_arg != VSL_g_request) - VUT_Error(1, "Invalid grouping mode: %s" + VUT_Error(vut, 1, "Invalid grouping mode: %s" " (only vxid and request are supported)", VSLQ_grouping[vut->g_arg]); @@ -592,7 +592,7 @@ main(int argc, char **argv) } AN(active_profile); if (!active_profile->name) - VUT_Error(1, "-P: No such profile '%s'", profile); + VUT_Error(vut, 1, "-P: No such profile '%s'", profile); assert(active_profile->VSL_arg == 'b' || active_profile->VSL_arg == 'c'); @@ -622,7 +622,7 @@ main(int argc, char **argv) VUT_Setup(vut); ident = VSM_Dup(vut->vsm, "Arg", "-i"); if (pthread_create(&thr, NULL, do_curses, NULL) != 0) - VUT_Error(1, "pthread_create(): %s", strerror(errno)); + VUT_Error(vut, 1, "pthread_create(): %s", strerror(errno)); vut->dispatch_f = accumulate; vut->dispatch_priv = NULL; vut->sighup_f = sighup; diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 6f6772b..60f46f9 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -83,7 +83,7 @@ openout(int append) else LOG.fo = VSL_WriteOpen(vut->vsl, LOG.w_arg, append, 0); if (LOG.fo == NULL) - VUT_Error(2, "Cannot open output file (%s)", + VUT_Error(vut, 2, "Cannot open output file (%s)", LOG.A_opt ? strerror(errno) : VSL_Error(vut->vsl)); vut->dispatch_priv = LOG.fo; } @@ -162,7 +162,7 @@ main(int argc, char * const *argv) usage(1); if (vut->D_opt && !LOG.w_arg) - VUT_Error(1, "Missing -w option"); + VUT_Error(vut, 1, "Missing -w option"); /* Setup output */ if (LOG.A_opt || !LOG.w_arg) diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 22391d1..979e598 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -180,7 +180,7 @@ openout(int append) AN(CTX.w_arg); CTX.fo = fopen(CTX.w_arg, append ? "a" : "w"); if (CTX.fo == NULL) - VUT_Error(1, "Can't open output file (%s)", + VUT_Error(vut, 1, "Can't open output file (%s)", strerror(errno)); } @@ -630,19 +630,19 @@ parse_x_format(char *buf) while (*e != '\0') e++; if (e == buf) - VUT_Error(1, "Missing tag in VSL:"); + VUT_Error(vut, 1, "Missing tag in VSL:"); if (e[-1] == ']') { r = e - 1; while (r > buf && *r != '[') r--; if (r == buf || r[1] == ']') - VUT_Error(1, "Syntax error: VSL:%s", buf); + VUT_Error(vut, 1, "Syntax error: VSL:%s", buf); e[-1] = '\0'; lval = strtol(r + 1, &s, 10); if (s != e - 1) - VUT_Error(1, "Syntax error: VSL:%s]", buf); + VUT_Error(vut, 1, "Syntax error: VSL:%s]", buf); if (lval <= 0 || lval > 255) { - VUT_Error(1, + VUT_Error(vut, 1, "Syntax error. Field specifier must be" " between 1 and 255: %s]", buf); @@ -661,15 +661,15 @@ parse_x_format(char *buf) r = NULL; } if (slt == -2) - VUT_Error(1, "Tag not unique: %s", buf); + VUT_Error(vut, 1, "Tag not unique: %s", buf); if (slt == -1) - VUT_Error(1, "Unknown log tag: %s", buf); + VUT_Error(vut, 1, "Unknown log tag: %s", buf); assert(slt >= 0); addf_vsl(slt, lval, r); return; } - VUT_Error(1, "Unknown formatting extension: %s", buf); + VUT_Error(vut, 1, "Unknown formatting extension: %s", buf); } static void @@ -763,7 +763,7 @@ parse_format(const char *format) while (*q && *q != '}') q++; if (!*q) - VUT_Error(1, "Unmatched bracket at: %s", + VUT_Error(vut, 1, "Unmatched bracket at: %s", p - 2); assert(q - p < sizeof buf - 1); strncpy(buf, p, q - p); @@ -783,14 +783,14 @@ parse_format(const char *format) parse_x_format(buf); break; default: - VUT_Error(1, + VUT_Error(vut, 1, "Unknown format specifier at: %s", p - 2); } p = q; break; default: - VUT_Error(1, "Unknown format specifier at: %s", + VUT_Error(vut, 1, "Unknown format specifier at: %s", p - 1); } } @@ -1131,16 +1131,16 @@ read_format(const char *formatfile) fmtfile = fopen(formatfile, "r"); if (fmtfile == NULL) - VUT_Error(1, "Can't open format file (%s)", + VUT_Error(vut, 1, "Can't open format file (%s)", strerror(errno)); AN(fmtfile); fmtlen = getline(&fmt, &len, fmtfile); if (fmtlen == -1) { free(fmt); if (feof(fmtfile)) - VUT_Error(1, "Empty format file"); + VUT_Error(vut, 1, "Empty format file"); else - VUT_Error(1, "Can't read format from file (%s)", + VUT_Error(vut, 1, "Can't read format from file (%s)", strerror(errno)); } fclose(fmtfile); @@ -1216,12 +1216,12 @@ main(int argc, char * const *argv) usage(1); if (vut->D_opt && !CTX.w_arg) - VUT_Error(1, "Missing -w option"); + VUT_Error(vut, 1, "Missing -w option"); /* Check for valid grouping mode */ assert(vut->g_arg < VSL_g__MAX); if (vut->g_arg != VSL_g_vxid && vut->g_arg != VSL_g_request) - VUT_Error(1, "Invalid grouping mode: %s", + VUT_Error(vut, 1, "Invalid grouping mode: %s", VSLQ_grouping[vut->g_arg]); /* Prepare output format */ diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 7d02906..29fae97 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -293,7 +293,7 @@ main(int argc, char * const *argv) default: i = VSM_Arg(vd, opt, optarg); if (i < 0) - VUT_Error(1, "%s", VSM_Error(vd)); + VUT_Error(vut, 1, "%s", VSM_Error(vd)); if (!i) usage(1); } @@ -306,7 +306,7 @@ main(int argc, char * const *argv) curses = 1; if (VSM_Attach(vd, STDERR_FILENO)) - VUT_Error(1, "%s", VSM_Error(vd)); + VUT_Error(vut, 1, "%s", VSM_Error(vd)); if (curses) do_curses(vd, vsc, 1.0); diff --git a/include/vut.h b/include/vut.h index 2e3a3c7..1097700 100644 --- a/include/vut.h +++ b/include/vut.h @@ -34,6 +34,7 @@ struct vopt_spec; typedef void VUT_sighandler_f(int); typedef int VUT_cb_f(struct VUT *); +typedef void VUT_error_f(struct VUT *, int, const char *, va_list); struct VUT { const char *progname; @@ -60,13 +61,13 @@ struct VUT { /* Callback functions */ VUT_cb_f *idle_f; VUT_cb_f *sighup_f; + VUT_error_f *error_f; VSLQ_dispatch_f *dispatch_f; void *dispatch_priv; }; -//lint -sem(VUT_Error, r_no) -void VUT_Error(int status, const char *fmt, ...) - __v_printflike(2, 3) __attribute__((__noreturn__)); +void VUT_Error(struct VUT *, int status, const char *fmt, ...) + __v_printflike(3, 4); int VUT_Arg(struct VUT *, int opt, const char *arg); diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 6103e9c..fe8e815 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -63,10 +63,10 @@ static struct vpf_fh *pfh; static unsigned daemonized; static int -vut_daemon(void) +vut_daemon(struct VUT *vut) { if (daemonized) - VUT_Error(1, "Already running as a daemon"); + VUT_Error(vut, 1, "Already running as a daemon"); daemonized = 1; return (varnish_daemon(0, 0)); } @@ -100,21 +100,30 @@ vut_dispatch(struct VSL_data *vsl, struct VSL_transaction * const trans[], return (i); } -void -VUT_Error(int status, const char *fmt, ...) +//lint -sem(vut_error, r_no) +static void __attribute__((__noreturn__)) __match_proto__(VUT_error_f) +vut_error(struct VUT *vut, int status, const char *fmt, va_list ap) { - va_list ap; - assert(status != 0); + AN(vut); AN(fmt); - va_start(ap, fmt); vfprintf(stderr, fmt, ap); - va_end(ap); fprintf(stderr, "\n"); exit(status); } +void +VUT_Error(struct VUT *vut, int status, const char *fmt, ...) +{ + va_list ap; + + assert(status != 0); + va_start(ap, fmt); + vut_error(vut, status, fmt, ap); + va_end(ap); +} + int VUT_Arg(struct VUT *vut, int opt, const char *arg) { @@ -135,16 +144,16 @@ VUT_Arg(struct VUT *vut, int opt, const char *arg) AN(arg); vut->g_arg = VSLQ_Name2Grouping(arg, -1); if (vut->g_arg == -2) - VUT_Error(1, "Ambiguous grouping type: %s", arg); + VUT_Error(vut, 1, "Ambiguous grouping type: %s", arg); else if (vut->g_arg < 0) - VUT_Error(1, "Unknown grouping type: %s", arg); + VUT_Error(vut, 1, "Unknown grouping type: %s", arg); return (1); case 'k': /* Log transaction limit */ AN(arg); vut->k_arg = (int)strtol(arg, &p, 10); if (*p != '\0' || vut->k_arg <= 0) - VUT_Error(1, "-k: Invalid number '%s'", arg); + VUT_Error(vut, 1, "-k: Invalid number '%s'", arg); return (1); case 'n': /* Varnish instance name */ @@ -178,7 +187,7 @@ VUT_Arg(struct VUT *vut, int opt, const char *arg) AN(vut->vsl); i = VSL_Arg(vut->vsl, opt, arg); if (i < 0) - VUT_Error(1, "%s", VSL_Error(vut->vsl)); + VUT_Error(vut, 1, "%s", VSL_Error(vut->vsl)); return (i); } } @@ -203,10 +212,11 @@ VUT_Init(const char *progname, int argc, char * const *argv, vut->progname = progname; vut->g_arg = VSL_g_vxid; + vut->k_arg = -1; + vut->error_f = vut_error; AZ(vut->vsl); vut->vsl = VSL_New(); AN(vut->vsl); - vut->k_arg = -1; return (vut); } @@ -244,45 +254,45 @@ VUT_Setup(struct VUT *vut) /* Check input arguments (2 used for bug in FlexeLint) */ if ((vut->n_arg == NULL ? 0 : 2) + (vut->r_arg == NULL ? 0 : 2) > 2) - VUT_Error(1, "Only one of -n and -r options may be used"); + VUT_Error(vut, 1, "Only one of -n and -r options may be used"); /* Create and validate the query expression */ vut->vslq = VSLQ_New(vut->vsl, NULL, vut->g_arg, vut->q_arg); if (vut->vslq == NULL) - VUT_Error(1, "Query expression error:\n%s", + VUT_Error(vut, 1, "Query expression error:\n%s", VSL_Error(vut->vsl)); /* Setup input */ if (vut->r_arg) { c = VSL_CursorFile(vut->vsl, vut->r_arg, 0); if (c == NULL) - VUT_Error(1, "%s", VSL_Error(vut->vsl)); + VUT_Error(vut, 1, "%s", VSL_Error(vut->vsl)); VSLQ_SetCursor(vut->vslq, &c); AZ(c); } else { vut->vsm = VSM_New(); AN(vut->vsm); if (vut->n_arg && VSM_Arg(vut->vsm, 'n', vut->n_arg) <= 0) - VUT_Error(1, "%s", VSM_Error(vut->vsm)); + VUT_Error(vut, 1, "%s", VSM_Error(vut->vsm)); if (vut->t_arg && VSM_Arg(vut->vsm, 't', vut->t_arg) <= 0) - VUT_Error(1, "%s", VSM_Error(vut->vsm)); + VUT_Error(vut, 1, "%s", VSM_Error(vut->vsm)); if (VSM_Attach(vut->vsm, STDERR_FILENO)) - VUT_Error(1, "VSM: %s", VSM_Error(vut->vsm)); + VUT_Error(vut, 1, "VSM: %s", VSM_Error(vut->vsm)); // Cursor is handled in VUT_Main() } /* Open PID file */ if (vut->P_arg) { if (pfh != NULL) - VUT_Error(1, "PID file already created"); + VUT_Error(vut, 1, "PID file already created"); pfh = VPF_Open(vut->P_arg, 0644, NULL); if (pfh == NULL) - VUT_Error(1, "%s: %s", vut->P_arg, strerror(errno)); + VUT_Error(vut, 1, "%s: %s", vut->P_arg, strerror(errno)); } /* Daemon mode */ - if (vut->D_opt && vut_daemon() == -1) - VUT_Error(1, "Daemon mode: %s", strerror(errno)); + if (vut->D_opt && vut_daemon(vut) == -1) + VUT_Error(vut, 1, "Daemon mode: %s", strerror(errno)); /* Write PID and setup exit handler */ if (vut->P_arg) { From hermunn at varnish-software.com Fri Sep 15 11:17:27 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:27 +0000 (UTC) Subject: [5.2] c1e6397 Slap a magic number in struct VUT Message-ID: <20170915111727.66B119880B@lists.varnish-cache.org> commit c1e639709306e8c1b2210924913712b781faa3cb Author: Dridi Boukelmoune Date: Tue Sep 12 00:04:27 2017 +0200 Slap a magic number in struct VUT diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 60f46f9..bc0c352 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -122,7 +122,7 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); VUT_Signaled(vut, sig); } diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 979e598..18eec35 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -1117,7 +1117,7 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); VUT_Signaled(vut, sig); } diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 09d939f..1282806 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -45,6 +45,7 @@ #define VOPT_DEFINITION #define VOPT_INC "varnishtop_options.h" +#include "miniobj.h" #include "vcurses.h" #include "vapi/vsl.h" #include "vapi/vsm.h" @@ -190,7 +191,7 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); VUT_Signaled(vut, sig); } diff --git a/include/vut.h b/include/vut.h index 1097700..0d731cf 100644 --- a/include/vut.h +++ b/include/vut.h @@ -37,6 +37,8 @@ typedef int VUT_cb_f(struct VUT *); typedef void VUT_error_f(struct VUT *, int, const char *, va_list); struct VUT { + unsigned magic; +#define VUT_MAGIC 0xdf3b3de8 const char *progname; /* Options */ diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index fe8e815..9845470 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -87,8 +87,8 @@ vut_dispatch(struct VSL_data *vsl, struct VSL_transaction * const trans[], struct VUT *vut; int i; - vut = priv; - AN(vut); + CAST_OBJ_NOTNULL(vut, priv, VUT_MAGIC); + if (vut->k_arg == 0) return (-1); /* End of file */ AN(vut->dispatch_f); @@ -105,7 +105,7 @@ static void __attribute__((__noreturn__)) __match_proto__(VUT_error_f) vut_error(struct VUT *vut, int status, const char *fmt, va_list ap) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); AN(fmt); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); @@ -202,7 +202,7 @@ VUT_Init(const char *progname, int argc, char * const *argv, AN(argv); AN(voc); - vut = calloc(1, sizeof *vut); + ALLOC_OBJ(vut, VUT_MAGIC); AN(vut); if (argc == 2 && !strcmp(argv[1], "--synopsis")) @@ -235,7 +235,7 @@ void VUT_Signaled(struct VUT *vut, int sig) { - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); vut->sighup |= (sig == SIGHUP); vut->sigint |= (sig == SIGINT || sig == SIGTERM); vut->sigusr1 |= (sig == SIGUSR1); @@ -246,7 +246,7 @@ VUT_Setup(struct VUT *vut) { struct VSL_cursor *c; - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); AN(vut->vsl); AZ(vut->vsm); AZ(vut->vslq); @@ -307,11 +307,7 @@ VUT_Fini(struct VUT **vutp) { struct VUT *vut; - AN(vutp); - vut = *vutp; - *vutp = NULL; - - AN(vut); + TAKE_OBJ_NOTNULL(vut, vutp, VUT_MAGIC); AN(vut->progname); free(vut->n_arg); @@ -331,7 +327,7 @@ VUT_Fini(struct VUT **vutp) VSM_Destroy(&vut->vsm); memset(vut, 0, sizeof *vut); - free(vut); + FREE_OBJ(vut); } int @@ -341,7 +337,7 @@ VUT_Main(struct VUT *vut) int i = -1; int hascursor = -1; - AN(vut); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); AN(vut->vslq); while (!vut->sigint) { From hermunn at varnish-software.com Fri Sep 15 11:17:27 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:27 +0000 (UTC) Subject: [5.2] c8f1bb1 Promote VUT headers Message-ID: <20170915111727.88E6998824@lists.varnish-cache.org> commit c8f1bb19b72f580f0c2bcf6dc1f3cf85cbfdfee8 Author: Dridi Boukelmoune Date: Tue Apr 18 09:35:22 2017 +0200 Promote VUT headers The corresponding symbols were already in libvarnishapi since 1.5! diff --git a/include/Makefile.am b/include/Makefile.am index 2feb37f..a77cae9 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -48,7 +48,9 @@ nobase_pkginclude_HEADERS = \ vapi/vsl_int.h \ vapi/voptget.h \ vapi/vapi_options.h \ - vcli.h + vcli.h \ + vut.h \ + vut_options.h # Headers for use with vmods nobase_pkginclude_HEADERS += \ @@ -95,9 +97,7 @@ nobase_noinst_HEADERS = \ vsub.h \ vss.h \ vtcp.h \ - vtree.h \ - vut.h \ - vut_options.h + vtree.h GENERATED_H = \ tbl/vrt_stv_var.h \ From hermunn at varnish-software.com Fri Sep 15 11:17:27 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:27 +0000 (UTC) Subject: [5.2] 36bdf7f New autoconf macro for VUT manual boilerplate Message-ID: <20170915111727.AAFD298841@lists.varnish-cache.org> commit 36bdf7f27e1a9a6c5f027db494bdd67fef5fc71e Author: Dridi Boukelmoune Date: Tue Sep 12 20:28:51 2017 +0200 New autoconf macro for VUT manual boilerplate For out-of-tree utilities. diff --git a/varnish.m4 b/varnish.m4 index b56d2fc..c58392c 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -373,6 +373,123 @@ AC_DEFUN([VARNISH_VMODS], [ [_VARNISH_VMOD(_vmod_name)]) ]) +# _VARNISH_UTILITY(NAME) +# ---------------------- +AC_DEFUN([_VARNISH_UTILITY], [ + + VUT_RULES=" + +$1_synopsis.rst: $1 + \$(A""M_V_GEN) ./$1 --synopsis >$1_synopsis.rst + +$1_options.rst: $1 + \$(A""M_V_GEN) ./$1 --options >$1_options.rst + +$1.rst: $1_synopsis.rst $1_options.rst + +" + + AC_SUBST(m4_toupper(GENERATE_$1_DOCS), [$VUT_RULES]) + m4_ifdef([_AM_SUBST_NOTMAKE], + [_AM_SUBST_NOTMAKE(m4_toupper(GENERATE_$1_DOCS))]) + + AC_SUBST(m4_toupper(GENERATED_$1_DOCS), + ["$1_synopsis.rst $1_options.rst"]) +]) + +# VARNISH_UTILITIES(NAMES) +# ------------------------ +# Since: Varnish 5.2.0 +# +# To write programs that consume the VSM, and in particular the VSL, it is +# possible since Varnish 5.2.0 to use the VUT (Varnish UTility) API already +# used by varnishlog, varnishstat and the other utilities from the standard +# Varnish distribution. +# +# This API can optionally be used to generate part of the manual: the synopsis +# and the list of options. The generated RST files can then be included from +# the main RST file that is written manually. +# +# For example, if you define the following in configure.ac: +# +# VARNISH_UTILITIES([foo bar]) +# +# Two build rules will be available for use in Makefile.am for the programs +# foo and bar: +# +# bin_PROGRAMS = foo bar +# +# [...] +# +# @GENERATE_FOO_DOCS@ +# @GENERATE_BAR_DOCS@ +# +# If the API is used in a way that enables the generation of the synopsis and +# the list of options, they will automatically be regenerated whenever the foo +# and bar programs are rebuilt, and marked as dependencies for RST manuals +# named foo.rst and bar.rst. +# +# In the manual you can then include the generated documentation in the +# relevant sections: +# +# SYNOPSIS +# ======== +# +# .. include:: foo_synopsis.rst +# foo |synopsis| +# +# DESCRIPTION +# =========== +# +# [...] +# +# The following options are available: +# +# .. include:: foo_options.rst +# +# This however won't work in a VPATH build, so instead of authoring foo.rst +# and bar.rst, a better solution is to create foo.rst.in and bar.rst.in files +# and add them to the AC_CONFIG_FILES macro in configure.ac. For example, if +# foo.rst.in and bar.rst.in are located in the src/ directory: +# +# AC_CONFIG_FILES([ +# [...] +# src/foo.rst +# src/bar.rst +# ]) +# +# Then you can include the build directory, either relative or absolute, to +# the include directives: +# +# SYNOPSIS +# ======== +# +# .. include:: @builddir@/foo_synopsis.rst +# foo |synopsis| +# +# DESCRIPTION +# =========== +# +# [...] +# +# The following options are available: +# +# .. include:: @builddir@/foo_options.rst +# +# This will ensure that foo.rst and bar.rst always find the generated files +# when the source directory is different from the build directory. Finally, +# the generated files are exposed in a variable to help clean them: +# +# CLEANFILES += $(GENERATED_FOO_DOCS) $(GENERATED_BAR_DOCS) +# +# It is the maintainer's responsibility to build the actual manuals. +# +AC_DEFUN([VARNISH_UTILITIES], [ + m4_foreach([_vut_name], + m4_split(m4_normalize([$1])), + [_VARNISH_UTILITY(_vut_name)]) +]) + # VARNISH_PREREQ(MINIMUM-VERSION, [MAXIMUM-VERSION]) # -------------------------------------------------- # Since: Varnish 4.1.4 From hermunn at varnish-software.com Fri Sep 15 11:17:27 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:27 +0000 (UTC) Subject: [5.2] 7ca8c0c What's new? VUT Message-ID: <20170915111727.C78DF98867@lists.varnish-cache.org> commit 7ca8c0c4a5888200128ddcb1cfaff915f71b6070 Author: Dridi Boukelmoune Date: Wed Sep 13 16:48:39 2017 +0200 What's new? VUT diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 7dced4d..b9585ce 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -156,9 +156,26 @@ does not require strict ABI compliance. .. _whatsnew_vut_5.2: -New VUT API ------------ - -XXX: document once merged +Added VUT API +------------- + +One way to extend Varnish is to write VSM clients, programs that tap +into the Varnish Shared Memory (VSM) usually via ``libvarnishapi`` or +community bindings for other languages than C. Varnish already ships +with VUTs (Varnish UTilities) that either process the Varnish Shared +Log (VSL) like ``varnishlog`` or ``varnishncsa`` or the Varnish Shared +Counters (VSC) like ``varnishstat``. + +Most of the setup for these programs is similar, and so they shared an +API that is now available outside of the Varnish source tree. The VUT +API has been cleaned up to remove assumptions made for our utilities. +It hides most of the complexity and redundancy of setting up a log +processor and helps you focus on your functionality. If you use +autotools for building, a new macro in ``varnish.m4`` removes some of +the boilerplate to generate part of the documentation. + +We hope that much like VMODs we will see new tools that take advantage +of this API to extend Varnish in new ways much like VMODs made it easy +to add new functionality to VCL. *EOF* From hermunn at varnish-software.com Fri Sep 15 11:17:27 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:27 +0000 (UTC) Subject: [5.2] d70fe1f Missing header Message-ID: <20170915111727.ED23698878@lists.varnish-cache.org> commit d70fe1fc10bf7173f364a85261bf19d16f5d82ea Author: Dridi Boukelmoune Date: Thu Sep 14 01:07:51 2017 +0200 Missing header diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index bc0c352..e0a4846 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -32,6 +32,7 @@ #include "config.h" +#include #include #include #include From hermunn at varnish-software.com Fri Sep 15 11:17:28 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:28 +0000 (UTC) Subject: [5.2] 7304e20 Actually use the configured VUT error callback Message-ID: <20170915111728.166A09888B@lists.varnish-cache.org> commit 7304e20cde2870898f3cc4493828203e2ab7299c Author: Dridi Boukelmoune Date: Thu Sep 14 01:23:03 2017 +0200 Actually use the configured VUT error callback diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 9845470..1438195 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -118,9 +118,12 @@ VUT_Error(struct VUT *vut, int status, const char *fmt, ...) { va_list ap; - assert(status != 0); + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); + AN(vut->error_f); + AN(status); + va_start(ap, fmt); - vut_error(vut, status, fmt, ap); + vut->error_f(vut, status, fmt, ap); va_end(ap); } From hermunn at varnish-software.com Fri Sep 15 11:17:28 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:28 +0000 (UTC) Subject: [5.2] 0ceee85 Documentation placeholder for varnishd -l Message-ID: <20170915111728.371E39889D@lists.varnish-cache.org> commit 0ceee85a36c47531a3bd4fb01d19074138a3e322 Author: Dridi Boukelmoune Date: Thu Sep 14 01:24:21 2017 +0200 Documentation placeholder for varnishd -l diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index c932fca..f901330 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -149,6 +149,10 @@ Other changes * ``varnishd(1)``: + .. XXX phk, a word on -l changes and the implications on how the + working directory may grow in size? This may be a problem + when /var/lib/varnish is mounted in RAM. + * The default value of ``server.identity`` when the ``-i`` option is not set has been changed as noted above. From hermunn at varnish-software.com Fri Sep 15 11:17:28 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:28 +0000 (UTC) Subject: [5.2] b0d7d11 Missing header Message-ID: <20170915111728.579D5988B7@lists.varnish-cache.org> commit b0d7d1181a55400cc62d05cf11de163bd8dfc24b Author: Dridi Boukelmoune Date: Thu Sep 14 01:50:49 2017 +0200 Missing header diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index b8ebc19..4770249 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 29fae97..5b31ee9 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -32,6 +32,7 @@ #include "config.h" +#include #include #include #include diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 1282806..8dfa516 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include From hermunn at varnish-software.com Fri Sep 15 11:17:28 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:28 +0000 (UTC) Subject: [5.2] 1ef8241 Typos Message-ID: <20170915111728.78883988D2@lists.varnish-cache.org> commit 1ef82413c68cb920ef82d01c722ceaff99e8911f Author: Geoff Simmons Date: Thu Sep 14 08:31:30 2017 +0200 Typos diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index f901330..8b23e6c 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -235,9 +235,9 @@ Other changes * Field specifiers (such as the 1 in ``Hit[1]``) are now limited to to 255, see :ref:`varnishncsa(1)`. -* The ``-N`` command-line option, which was previously availabe for +* The ``-N`` command-line option, which was previously available for ``varnishlog(1)``, ``varnishstat(1)``, ``varnishncsa(1)`` and - ``varnishhist(1)``, is not comaptible with the changed internal + ``varnishhist(1)``, is not compatible with the changed internal logging API, and has been retired. * *XXX: any other changes in the standard VUT tools* From hermunn at varnish-software.com Fri Sep 15 11:17:28 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:28 +0000 (UTC) Subject: [5.2] 5f9e1af VMOD blob: move the $ABI declaration to the bottom of the VCC file. Message-ID: <20170915111728.95CC9988E0@lists.varnish-cache.org> commit 5f9e1af4b7d356e64dfd24a9d1ef9ec291bf81e3 Author: Geoff Simmons Date: Thu Sep 14 08:35:40 2017 +0200 VMOD blob: move the $ABI declaration to the bottom of the VCC file. Like $Event, $ABI has the effect of making generated docs until the next $-directive disappear. diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 96dea4e..e1db306 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -7,7 +7,6 @@ # $Module blob 3 utilities for the VCL blob type -$ABI strict :: @@ -425,3 +424,5 @@ SEE ALSO * :ref:`varnishd(1)` * :ref:`vcl(7)` * :ref:`vmod_std(3)` + +$ABI strict From hermunn at varnish-software.com Fri Sep 15 11:17:28 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:28 +0000 (UTC) Subject: [5.2] 6b45072 Editorial: change a section heading in Upgrading to 5.2. Message-ID: <20170915111728.B2BA6988EC@lists.varnish-cache.org> commit 6b45072885c61c46dc94541294f7d7a41e806864 Author: Geoff Simmons Date: Thu Sep 14 08:45:49 2017 +0200 Editorial: change a section heading in Upgrading to 5.2. server.identity is not a new VCL variable. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8b23e6c..364cc01 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -72,8 +72,8 @@ dashes in a vmod symbol. Long storage backend names used to be truncated due to a limitation in the VSC subsystem, this is no longer the case. -New VCL variables -~~~~~~~~~~~~~~~~~ +VCL variables +~~~~~~~~~~~~~ ``req.hash`` and ``bereq.hash`` ------------------------------- @@ -109,11 +109,11 @@ not set). See :ref:`varnishd(1)`. ``bereq.is_bgfetch`` -------------------- -``bereq.is_bgfetch`` is readable in backend contexts, and is true if -the fetch takes place in the background. That is, it is true if -Varnish found a response in the cache whose TTL was expired, but was -still in grace time. Varnish returns the stale cached response to the -client, and initiates the background fetch to refresh the cache +Added ``bereq.is_bgfetch``, which is readable in backend contexts, and +is true if the fetch takes place in the background. That is, it is +true if Varnish found a response in the cache whose TTL was expired, +but was still in grace time. Varnish returns the stale cached response +to the client, and initiates the background fetch to refresh the cache object. XXX: vcl_sub_XXX ... From hermunn at varnish-software.com Fri Sep 15 11:17:28 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:28 +0000 (UTC) Subject: [5.2] 9b5c832 Make failure to submit results non-fatal. Message-ID: <20170915111728.D8BB79890C@lists.varnish-cache.org> commit 9b5c832c4b491f2f47c42d61fe6cbbae7f06c309 Author: Poul-Henning Kamp Date: Thu Sep 14 07:14:21 2017 +0000 Make failure to submit results non-fatal. diff --git a/tools/vtest.sh b/tools/vtest.sh index 4bb8ffe..e990d10 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -283,5 +283,9 @@ do fi echo "VTEST END" >> ${VTEST_REPORT} pack > ${TMPDIR}/_report.tgz - submit ${TMPDIR}/_report.tgz + + submit ${TMPDIR}/_report.tgz || \ + sleep 300 || \ + submit ${TMPDIR}/_report.tgz || \ + true done From hermunn at varnish-software.com Fri Sep 15 11:17:28 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:28 +0000 (UTC) Subject: [5.2] 677317f Mention support for sanitizers in Upgrading to 5.2. Message-ID: <20170915111728.F40AA98916@lists.varnish-cache.org> commit 677317fc0ff825ba186142a741572e936b6d3ed9 Author: Geoff Simmons Date: Thu Sep 14 09:24:39 2017 +0200 Mention support for sanitizers in Upgrading to 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 364cc01..b28c328 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -265,7 +265,12 @@ Other changes it possible for VMOD authors to load their code into a debugger after a varnishd crash. See :ref:`ref_param_debug`. - * *XXX: anything else, such as sanitizer flags?* + * The project build tools now facilitate the use of sanitizer flags + (``-fsanitize`` for the compiler and ``ld``), for undefined + behavior, threads, addresses and memory. See the options + ``--enable-ubsan``, ``--enable-tsan``, ``--enable-asan`` and + ``--enable-msan`` for the ``configure`` script generated by + autoconf. * *XXX: ...* From hermunn at varnish-software.com Fri Sep 15 11:17:29 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:29 +0000 (UTC) Subject: [5.2] 948f3c1 Mention clarification of req.backend_hint and restarts as of 5.2. Message-ID: <20170915111729.1ED0A98929@lists.varnish-cache.org> commit 948f3c14fdb14d6bd0977cdb72a771a671379906 Author: Geoff Simmons Date: Thu Sep 14 10:00:20 2017 +0200 Mention clarification of req.backend_hint and restarts as of 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index b28c328..196fcf0 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -116,6 +116,14 @@ but was still in grace time. Varnish returns the stale cached response to the client, and initiates the background fetch to refresh the cache object. +``req.backend_hint`` +-------------------- + +We have clarified what happens to ``req.backend_hint`` on a client +restart -- it gets reset to the default backend. So you might want to +make sure that the backend hint gets set the way you want in that +situation. + XXX: vcl_sub_XXX ... ~~~~~~~~~~~~~~~~~~~~ From hermunn at varnish-software.com Fri Sep 15 11:17:29 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:29 +0000 (UTC) Subject: [5.2] 0b67439 Document addition of counter req_dropped in 5.2. Message-ID: <20170915111729.3ECA09894C@lists.varnish-cache.org> commit 0b674390a73a5a39fac952e404f15989786aae11 Author: Geoff Simmons Date: Thu Sep 14 10:07:15 2017 +0200 Document addition of counter req_dropped in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 196fcf0..77a063d 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -201,6 +201,11 @@ Other changes * The ``MAIN.s_req`` statistic has been removed, as it was identical to ``MAIN.client_req``. + * Added the counter ``req_dropped``. Similar to ``sess_dropped``, + this is the number of times an HTTP/2 stream was refused because + the internal queue is full. See :ref:`varnish-counters(7)` and + :ref:`ref_param_thread_queue_limit`. + * *XXX: anything else? stats added, removed or changed?* * ``varnishlog(1)``: From hermunn at varnish-software.com Fri Sep 15 11:17:29 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:29 +0000 (UTC) Subject: [5.2] edfcf80 Sanitizer support is not new in 5.2 after all. Message-ID: <20170915111729.6266E9895D@lists.varnish-cache.org> commit edfcf804df187ba281cb3c27832bf9bb240c911c Author: Geoff Simmons Date: Thu Sep 14 10:15:09 2017 +0200 Sanitizer support is not new in 5.2 after all. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 77a063d..c66b488 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -278,13 +278,6 @@ Other changes it possible for VMOD authors to load their code into a debugger after a varnishd crash. See :ref:`ref_param_debug`. - * The project build tools now facilitate the use of sanitizer flags - (``-fsanitize`` for the compiler and ``ld``), for undefined - behavior, threads, addresses and memory. See the options - ``--enable-ubsan``, ``--enable-tsan``, ``--enable-asan`` and - ``--enable-msan`` for the ``configure`` script generated by - autoconf. - * *XXX: ...* * *XXX: other changes in tools and infrastructure in and around From hermunn at varnish-software.com Fri Sep 15 11:17:29 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:29 +0000 (UTC) Subject: [5.2] 0c88fbf Document changed format for VCL_trace logs in 5.2. Message-ID: <20170915111729.8104A9896D@lists.varnish-cache.org> commit 0c88fbf2529a14aa7118623890a6aab08c12a72d Author: Geoff Simmons Date: Thu Sep 14 10:23:37 2017 +0200 Document changed format for VCL_trace logs in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index c66b488..1ecfe00 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -229,6 +229,11 @@ Other changes See :ref:`vsl(7)`. + * The output format of ``VCL_trace`` log records, which appear if + you have switched on the ``VCL_trace`` flag in the VSL mask, has + changed to include the VCL configuration name. See :ref:`vsl(7)` + and :ref:`ref_param_vsl_mask`. + * ``varnishtest(1)`` and ``vtc(7)``: * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* From hermunn at varnish-software.com Fri Sep 15 11:17:29 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:29 +0000 (UTC) Subject: [5.2] 2c533be Don't swallow RST with the $ABI stanza Message-ID: <20170915111729.A0C0998984@lists.varnish-cache.org> commit 2c533be6a5624a7a678334cffa5953375ac8a63e Author: Dridi Boukelmoune Date: Thu Sep 14 10:45:10 2017 +0200 Don't swallow RST with the $ABI stanza diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index b7f58e5..d2e7a30 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -484,6 +484,7 @@ class s_abi(stanza): err("Valid ABI types are 'strict' or 'vrt', got '%s'\n" % self.line[1]) strict_abi = self.line[1] == 'strict' + self.vcc.contents.append(self) class s_event(stanza): def parse(self): diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index e1db306..96dea4e 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -7,6 +7,7 @@ # $Module blob 3 utilities for the VCL blob type +$ABI strict :: @@ -424,5 +425,3 @@ SEE ALSO * :ref:`varnishd(1)` * :ref:`vcl(7)` * :ref:`vmod_std(3)` - -$ABI strict From hermunn at varnish-software.com Fri Sep 15 11:17:29 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:29 +0000 (UTC) Subject: [5.2] db6c793 Document deprecation of -p vsm_space in 5.2. Message-ID: <20170915111729.BACB198990@lists.varnish-cache.org> commit db6c793c7f513984a108266e7200a65262252d67 Author: Geoff Simmons Date: Thu Sep 14 10:54:24 2017 +0200 Document deprecation of -p vsm_space in 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 1ecfe00..936764b 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -13,9 +13,11 @@ counters, but these should all be transparent at the user-level. varnishd parameters =================== -The :ref:`ref_param_cli_buffer` parameter is deprecated and -ignored. Memory for the CLI command buffer is now dynamically -allocated. +The :ref:`ref_param_vsm_space` and :ref:`ref_param_cli_buffer` +parameters are now deprecated and ignored. The updated logging +implementation manages space automatically, so it no longer needs +:ref:`ref_param_vsm_space`. Memory for the CLI command buffer is now +dynamically allocated. We have updated the documentation for :ref:`ref_param_send_timeout`, :ref:`ref_param_idle_send_timeout`, :ref:`ref_param_timeout_idle` and From hermunn at varnish-software.com Fri Sep 15 11:17:29 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:29 +0000 (UTC) Subject: [5.2] 7efb593 Remove some of the XXX's in the release notes for 5.2. Message-ID: <20170915111729.D5B389899D@lists.varnish-cache.org> commit 7efb593fd5d245f16c9f4b2e3740b52bb755a7f3 Author: Geoff Simmons Date: Thu Sep 14 11:30:25 2017 +0200 Remove some of the XXX's in the release notes for 5.2. We seem to have most of it. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index b9585ce..8a125e9 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -63,16 +63,9 @@ conveniences were added like workspace manipulations. See :ref:`vmod_vtc(3)`. -XXX: Any other headline changes ... -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -*XXX: ...* - News for authors of VMODs and Varnish API client applications ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -*XXX: such news may include:* - .. _whatsnew_abi: $ABI [strict|vrt] diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 936764b..e6fc93f 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -37,11 +37,6 @@ Changes to VCL *XXX: ... or reassure that you probably don't have to do anything* *to migrate from 5.1 to 5.2* -XXX: headline changes ... -~~~~~~~~~~~~~~~~~~~~~~~~~ - -*XXX: the most important changes or additions first* - Consistent symbol names ~~~~~~~~~~~~~~~~~~~~~~~ @@ -126,16 +121,6 @@ restart -- it gets reset to the default backend. So you might want to make sure that the backend hint gets set the way you want in that situation. -XXX: vcl_sub_XXX ... -~~~~~~~~~~~~~~~~~~~~ - -*XXX: list changes by VCL sub* - -XXX: more VCL changes ... -~~~~~~~~~~~~~~~~~~~~~~~~~ - -*XXX: any more details and new features that VCL authors have to know* - vmod_std ~~~~~~~~ @@ -208,8 +193,6 @@ Other changes the internal queue is full. See :ref:`varnish-counters(7)` and :ref:`ref_param_thread_queue_limit`. - * *XXX: anything else? stats added, removed or changed?* - * ``varnishlog(1)``: * The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an @@ -248,8 +231,6 @@ Other changes * Added the feature switch ``ignore_unknown_macro`` for test cases, see :ref:`vtc(7)`. - * *XXX: ...* - * ``varnishncsa(1)`` * Field specifiers (such as the 1 in ``Hit[1]``) are now limited to @@ -260,10 +241,6 @@ Other changes ``varnishhist(1)``, is not compatible with the changed internal logging API, and has been retired. -* *XXX: any other changes in the standard VUT tools* - - * *XXX: ...* - * Changes for developers: * The VSM and VSC APIs for shared memory and statistics have @@ -284,12 +261,3 @@ Other changes up its copies of VMOD shared objects when it stops. This makes it possible for VMOD authors to load their code into a debugger after a varnishd crash. See :ref:`ref_param_debug`. - - * *XXX: ...* - -* *XXX: other changes in tools and infrastructure in and around - Varnish ...* - - * *XXX: anything new about project tools, VTEST & GCOV, etc?* - - * *XXX: ...* From hermunn at varnish-software.com Fri Sep 15 11:17:29 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:29 +0000 (UTC) Subject: [5.2] 2c6cf9b Fleshe out the -l XXX Message-ID: <20170915111729.F14C8989B8@lists.varnish-cache.org> commit 2c6cf9b4b88911e7cbb9e15cd2a7af089640f28c Author: Poul-Henning Kamp Date: Thu Sep 14 09:31:21 2017 +0000 Fleshe out the -l XXX diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index e6fc93f..477efe4 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -144,9 +144,9 @@ Other changes * ``varnishd(1)``: - .. XXX phk, a word on -l changes and the implications on how the - working directory may grow in size? This may be a problem - when /var/lib/varnish is mounted in RAM. + * The total size of the shared memory space for logs and counters + no longer needs to be configured explicitly and therefore the + second subargument to ``-l`` is now ignored. * The default value of ``server.identity`` when the ``-i`` option is not set has been changed as noted above. From hermunn at varnish-software.com Fri Sep 15 11:17:30 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:30 +0000 (UTC) Subject: [5.2] 80d4a27 Amazing that neither Coverity or FlexeLint complained about the syslog-ism "%m" being used in vsnprintf() via VSB. Message-ID: <20170915111730.1FCC4989D3@lists.varnish-cache.org> commit 80d4a276a20158b16a28d7e0d138f3bd98f74d72 Author: Poul-Henning Kamp Date: Thu Sep 14 09:37:57 2017 +0000 Amazing that neither Coverity or FlexeLint complained about the syslog-ism "%m" being used in vsnprintf() via VSB. That said, it would have been damn convenient of %m was also usable in *printf(3)... diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 4d23bba..f00e19a 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -622,7 +622,8 @@ Marg_connect(const struct vev *e, int what) M_fd = VTCP_connected(M_fd); if (M_fd < 0) { - MGT_Complain(C_INFO, "Could not connect to CLI-master: %m"); + MGT_Complain(C_INFO, "Could not connect to CLI-master: %s", + strerror(errno)); ma = VTAILQ_FIRST(&m_addr_list); AN(ma); VTAILQ_REMOVE(&m_addr_list, ma, list); From hermunn at varnish-software.com Fri Sep 15 11:17:30 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:30 +0000 (UTC) Subject: [5.2] f07449b Intro sentences to "Changes to VCL" for 5.2. Message-ID: <20170915111730.42C1E989E1@lists.varnish-cache.org> commit f07449bc0c67997329641a79de282c4c94469215 Author: Geoff Simmons Date: Thu Sep 14 11:44:24 2017 +0200 Intro sentences to "Changes to VCL" for 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 477efe4..8c335e6 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -29,13 +29,8 @@ the notes about changes for developers below. Changes to VCL ============== -*XXX: intro paragraph* - -*XXX: emphasize what most likely needs to be done, if anything,* -*to migrate from 5.1 to 5.2* - -*XXX: ... or reassure that you probably don't have to do anything* -*to migrate from 5.1 to 5.2* +We have added a few new variables and clarified some matters. VCL +written for Varnish 5.1 should run without changes on 5.2. Consistent symbol names ~~~~~~~~~~~~~~~~~~~~~~~ From hermunn at varnish-software.com Fri Sep 15 11:17:30 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:30 +0000 (UTC) Subject: [5.2] a0da354 Minor polish in the release docs for 5.2. Message-ID: <20170915111730.6383C989FE@lists.varnish-cache.org> commit a0da3543936fdc5b4dc8840c4fb7ad3b9f9e3496 Author: Geoff Simmons Date: Thu Sep 14 11:59:53 2017 +0200 Minor polish in the release docs for 5.2. diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index 8a125e9..ebd421e 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -47,7 +47,7 @@ VMOD vtc -------- As long as we have had VMODs, we had an internal vmod called ``vmod_debug`` -which were used with ``varnishtest`` to exercise the VMOD related parts of +which was used with ``varnishtest`` to exercise the VMOD related parts of ``varnishd``. Over time this vmod grew other useful functions for writing test-cases. @@ -167,8 +167,6 @@ processor and helps you focus on your functionality. If you use autotools for building, a new macro in ``varnish.m4`` removes some of the boilerplate to generate part of the documentation. -We hope that much like VMODs we will see new tools that take advantage -of this API to extend Varnish in new ways much like VMODs made it easy -to add new functionality to VCL. - -*EOF* +We hope that we will see new tools that take advantage of this API to +extend Varnish in new ways, much like VMODs made it easy to add new +functionality to VCL. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 8c335e6..686dde3 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -94,7 +94,7 @@ You can use :ref:`vmod_blob(3)` to work with the hashes:: If the ``-i`` option is not set in the invocation of ``varnishd``, then ``server.identity`` is set to the host name (as returned by -``gethostname(3)``). Previously, ``server.identity`` was set to the +``gethostname(3)``). Previously, ``server.identity`` defaulted to the value of the ``-n`` option (or the default instance name if ``-n`` was not set). See :ref:`varnishd(1)`. @@ -125,7 +125,7 @@ New VMODs in the standard distribution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See :ref:`vmod_blob(3)`, :ref:`vmod_purge(3)` and -:ref:`vmod_vtc(3)`. See :ref:`whatsnew_new_vmods`. +:ref:`vmod_vtc(3)`. Read about them in :ref:`whatsnew_new_vmods`. Bans ~~~~ @@ -172,7 +172,7 @@ Other changes * In curses mode, the top two lines showing uptimes for the management and child processes show the text ``Not Running`` if - either or both of the processes are down. + one or both of the processes are down. * The interpretation of multiple ``-f`` options in the command line has changed slightly, see :ref:`varnishstat(1)`. @@ -193,7 +193,7 @@ Other changes * The ``Hit``, ``HitMiss`` and ``HitPass`` log records grew an additional field with the remaining TTL of the object at the time of the lookup. While this should greatly help troubleshooting, - this might break tools relying on those records to get the VXID of + it might break tools relying on those records to get the VXID of the object hit during lookup. Instead of using ``Hit``, such tools should now use ``Hit[1]``, From hermunn at varnish-software.com Fri Sep 15 11:17:30 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:30 +0000 (UTC) Subject: [5.2] 73b2430 Minor constification Message-ID: <20170915111730.85B1398A0B@lists.varnish-cache.org> commit 73b2430e8608771ad5866571db2115d4d53c51e6 Author: Poul-Henning Kamp Date: Thu Sep 14 16:13:32 2017 +0000 Minor constification diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index baafa66..000d505 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -150,7 +150,7 @@ VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id) } struct vmod_priv * -VRT_priv_task(VRT_CTX, void *vmod_id) +VRT_priv_task(VRT_CTX, const void *vmod_id) { uintptr_t id; @@ -169,7 +169,7 @@ VRT_priv_task(VRT_CTX, void *vmod_id) } struct vmod_priv * -VRT_priv_top(VRT_CTX, void *vmod_id) +VRT_priv_top(VRT_CTX, const void *vmod_id) { uintptr_t id; diff --git a/include/vrt.h b/include/vrt.h index 9f1ad5e..3d59bfe 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -358,8 +358,8 @@ struct vclref * VRT_ref_vcl(VRT_CTX, const char *); void VRT_rel_vcl(VRT_CTX, struct vclref **); void VRT_priv_fini(const struct vmod_priv *p); -struct vmod_priv *VRT_priv_task(VRT_CTX, void *vmod_id); -struct vmod_priv *VRT_priv_top(VRT_CTX, void *vmod_id); +struct vmod_priv *VRT_priv_task(VRT_CTX, const void *vmod_id); +struct vmod_priv *VRT_priv_top(VRT_CTX, const void *vmod_id); /* Stevedore related functions */ int VRT_Stv(const char *nm); From hermunn at varnish-software.com Fri Sep 15 11:17:30 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:30 +0000 (UTC) Subject: [5.2] 55dab8e Make the (v)bprintf() macros also check for negative return values. Message-ID: <20170915111730.A360698A19@lists.varnish-cache.org> commit 55dab8e8ae39f0ac85cb3c48ddefc8f948087dfe Author: Poul-Henning Kamp Date: Thu Sep 14 16:22:35 2017 +0000 Make the (v)bprintf() macros also check for negative return values. diff --git a/include/vdef.h b/include/vdef.h index af51c47..b7fee8b 100644 --- a/include/vdef.h +++ b/include/vdef.h @@ -38,15 +38,17 @@ /* Safe printf into a fixed-size buffer */ #define bprintf(buf, fmt, ...) \ do { \ - assert(snprintf(buf, sizeof buf, fmt, __VA_ARGS__) \ - < sizeof buf); \ + int ibprintf; \ + ibprintf = snprintf(buf, sizeof buf, fmt, __VA_ARGS__); \ + assert(ibprintf >= 0 && ibprintf < sizeof buf); \ } while (0) /* Safe printf into a fixed-size buffer */ #define vbprintf(buf, fmt, ap) \ do { \ - assert(vsnprintf(buf, sizeof buf, fmt, ap) \ - < sizeof buf); \ + int ivbprintf; \ + ivbprintf = vsnprintf(buf, sizeof buf, fmt, ap); \ + assert(ivbprintf >= 0 && ivbprintf < sizeof buf); \ } while (0) /* Close and discard filedescriptor */ From hermunn at varnish-software.com Fri Sep 15 11:17:30 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:30 +0000 (UTC) Subject: [5.2] 382584e Slightly change VAS so that we always call a function on panic, and let that check if another function is desired. Message-ID: <20170915111730.C701A98A32@lists.varnish-cache.org> commit 382584eb3e3bf1ae74ec82ead0ed4489453ad733 Author: Poul-Henning Kamp Date: Thu Sep 14 16:42:13 2017 +0000 Slightly change VAS so that we always call a function on panic, and let that check if another function is desired. diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 0d329e1..6601b29 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -691,7 +691,7 @@ PAN_Init(void) { AZ(pthread_mutex_init(&panicstr_mtx, NULL)); - VAS_Fail = pan_ic; + VAS_Fail_Func = pan_ic; pan_vsb = &pan_vsb_storage; AN(heritage.panic_str); AN(heritage.panic_str_len); diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index df786e8..a764d1f 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -292,7 +292,7 @@ void vtc_loginit(char *buf, unsigned buflen) { - VAS_Fail = vtc_log_VAS_Fail; + VAS_Fail_Func = vtc_log_VAS_Fail; t0 = VTIM_mono(); vtclog_buf = buf; vtclog_left = buflen; diff --git a/include/vas.h b/include/vas.h index 591d99e..ec4adc5 100644 --- a/include/vas.h +++ b/include/vas.h @@ -46,9 +46,11 @@ enum vas_e { VAS_VCL, }; -typedef void vas_f(const char *, const char *, int, const char *, enum vas_e); +typedef void vas_f(const char *, const char *, int, const char *, enum vas_e) + __attribute__((__noreturn__)); -extern vas_f *VAS_Fail __attribute__((__noreturn__)); +extern vas_f *VAS_Fail_Func __attribute__((__noreturn__)); +extern vas_f VAS_Fail __attribute__((__noreturn__)); #ifdef WITHOUT_ASSERTS #define assert(e) ((void)(e)) diff --git a/lib/libvarnish/binary_heap.c b/lib/libvarnish/binary_heap.c index 9799276..beb9a64 100644 --- a/lib/libvarnish/binary_heap.c +++ b/lib/libvarnish/binary_heap.c @@ -470,7 +470,7 @@ vasfail(const char *func, const char *file, int line, abort(); } -vas_f *VAS_Fail = vasfail; +vas_f *VAS_Fail_Func = vasfail; struct foo { unsigned magic; diff --git a/lib/libvarnish/vas.c b/lib/libvarnish/vas.c index 0c857a0..3d7f631 100644 --- a/lib/libvarnish/vas.c +++ b/lib/libvarnish/vas.c @@ -38,35 +38,39 @@ #include "vas.h" -static void __attribute__((__noreturn__)) -VAS_Fail_default(const char *func, const char *file, int line, +vas_f *VAS_Fail_Func __attribute__((__noreturn__)); + +void __attribute__((__noreturn__)) +VAS_Fail(const char *func, const char *file, int line, const char *cond, enum vas_e kind) { int err = errno; - if (kind == VAS_MISSING) { - fprintf(stderr, - "Missing error handling code in %s(), %s line %d:\n" - " Condition(%s) not true.\n", - func, file, line, cond); - } else if (kind == VAS_INCOMPLETE) { - fprintf(stderr, - "Incomplete code in %s(), %s line %d:\n", - func, file, line); - } else if (kind == VAS_WRONG) { - fprintf(stderr, - "Wrong turn in %s(), %s line %d: %s\n", - func, file, line, cond); + if (VAS_Fail_Func != NULL) { + VAS_Fail_Func(func, file, line, cond, kind); } else { - fprintf(stderr, - "Assert error in %s(), %s line %d:\n" - " Condition(%s) not true.\n", - func, file, line, cond); + if (kind == VAS_MISSING) { + fprintf(stderr, + "Missing error handling code in %s(), %s line %d:\n" + " Condition(%s) not true.\n", + func, file, line, cond); + } else if (kind == VAS_INCOMPLETE) { + fprintf(stderr, + "Incomplete code in %s(), %s line %d:\n", + func, file, line); + } else if (kind == VAS_WRONG) { + fprintf(stderr, + "Wrong turn in %s(), %s line %d: %s\n", + func, file, line, cond); + } else { + fprintf(stderr, + "Assert error in %s(), %s line %d:\n" + " Condition(%s) not true.\n", + func, file, line, cond); + } + if (err) + fprintf(stderr, + " errno = %d (%s)\n", err, strerror(err)); } - if (err) - fprintf(stderr, - " errno = %d (%s)\n", err, strerror(err)); abort(); } - -vas_f *VAS_Fail __attribute__((__noreturn__)) = VAS_Fail_default; diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 7454f4f..4cc3b50 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -30,6 +30,7 @@ LIBVARNISHAPI_2.0 { global: # vas.c VAS_Fail; + VAS_Fail_Func; # vcli.c VCLI_AuthResponse; From hermunn at varnish-software.com Fri Sep 15 11:17:30 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:30 +0000 (UTC) Subject: [5.2] 9f31ea0 OCD for PC-Lint-Plus Message-ID: <20170915111730.E892198A40@lists.varnish-cache.org> commit 9f31ea018c175f74c4dc5a7ea2f59fc8bed86ed8 Author: Poul-Henning Kamp Date: Thu Sep 14 16:43:20 2017 +0000 OCD for PC-Lint-Plus diff --git a/include/vdef.h b/include/vdef.h index b7fee8b..70f8178 100644 --- a/include/vdef.h +++ b/include/vdef.h @@ -40,7 +40,7 @@ do { \ int ibprintf; \ ibprintf = snprintf(buf, sizeof buf, fmt, __VA_ARGS__); \ - assert(ibprintf >= 0 && ibprintf < sizeof buf); \ + assert(ibprintf >= 0 && ibprintf < (int)sizeof buf); \ } while (0) /* Safe printf into a fixed-size buffer */ @@ -48,7 +48,7 @@ do { \ int ivbprintf; \ ivbprintf = vsnprintf(buf, sizeof buf, fmt, ap); \ - assert(ivbprintf >= 0 && ivbprintf < sizeof buf); \ + assert(ivbprintf >= 0 && ivbprintf < (int)sizeof buf); \ } while (0) /* Close and discard filedescriptor */ From hermunn at varnish-software.com Fri Sep 15 11:17:31 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:31 +0000 (UTC) Subject: [5.2] ff3ab53 VMOD blob: use a DEFAULT value for the case ENUM. Message-ID: <20170915111731.1C5EE98A65@lists.varnish-cache.org> commit ff3ab5340c62d354c518592601a26dc2f250d0c7 Author: Geoff Simmons Date: Thu Sep 14 17:42:23 2017 +0200 VMOD blob: use a DEFAULT value for the case ENUM. DEFAULT is interpreted as LOWER for the HEX and URL encodings, and is the only legal value for all other encodings. diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index e4d963c..02d896d 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -54,13 +54,9 @@ varnish v1 -vcl { blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="666f6f00626172")); - set resp.http.lc = - blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, - encoded="Don't care")); - - set resp.http.uc = - blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, - encoded="Don't care")); + set resp.http.pos = + blob.encode(IDENTITY, DEFAULT, blob.decode(IDENTITY, + encoded="foobar")); } } -start @@ -76,6 +72,52 @@ client c1 { expect resp.http.param == "The quick brown fox jumps over the lazy dog" expect resp.http.paramlist == "/The quick brown fox jumps over the lazy dog/" expect resp.http.truncated == "foo" - expect resp.http.lc == "Don't care" - expect resp.http.uc == "Don't care" + expect resp.http.pos == "foobar" } -run + +# Require case=DEFAULT + +server s1 -repeat 2 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + if (req.url == "/lc") { + set resp.http.lc = + blob.encode(IDENTITY, LOWER, blob.decode(IDENTITY, + encoded="foobar")); + } + elsif (req.url == "/uc") { + set resp.http.uc = + blob.encode(IDENTITY, UPPER, blob.decode(IDENTITY, + encoded="foobar")); + } + } +} + +client c1 { + txreq -url "/lc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.lc == +} -run + +client c1 { + txreq -url "/uc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.uc == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding IDENTITY$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding IDENTITY$" +} -start + +logexpect l1 -wait diff --git a/bin/varnishtest/tests/m00037.vtc b/bin/varnishtest/tests/m00037.vtc index 3209394..e545f1c 100644 --- a/bin/varnishtest/tests/m00037.vtc +++ b/bin/varnishtest/tests/m00037.vtc @@ -21,13 +21,9 @@ varnish v1 -vcl { blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded= req.http.pangram)); - set resp.http.b64lc = - blob.encode(BASE64, LOWER, blob.decode(IDENTITY, encoded= - req.http.pangram)); - - set resp.http.b64uc = - blob.encode(BASE64, UPPER, blob.decode(IDENTITY, encoded= - req.http.pangram)); + set resp.http.b64pos = + blob.encode(BASE64, DEFAULT, blob.decode(IDENTITY, encoded= + req.http.pangram)); set resp.http.b64hobbes = blob.encode(BASE64, blob=blob.decode(IDENTITY, encoded= @@ -41,12 +37,8 @@ varnish v1 -vcl { blob.encode(BASE64URL, blob=blob.decode(IDENTITY, encoded=req.http.pangram)); - set resp.http.b64urllc = - blob.encode(BASE64URL, LOWER, - blob.decode(IDENTITY, encoded=req.http.pangram)); - - set resp.http.b64urluc = - blob.encode(BASE64URL, UPPER, + set resp.http.b64urlpos = + blob.encode(BASE64URL, DEFAULT, blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64urlhobbes = @@ -61,12 +53,8 @@ varnish v1 -vcl { blob.encode(BASE64URLNOPAD, blob=blob.decode(IDENTITY, encoded=req.http.pangram)); - set resp.http.b64urlnopadlc = - blob.encode(BASE64URLNOPAD, LOWER, - blob.decode(IDENTITY, encoded=req.http.pangram)); - - set resp.http.b64urlnopaduc = - blob.encode(BASE64URLNOPAD, UPPER, + set resp.http.b64urlnopadpos = + blob.encode(BASE64URLNOPAD, DEFAULT, blob.decode(IDENTITY, encoded=req.http.pangram)); set resp.http.b64nopadhobbes = @@ -87,15 +75,15 @@ varnish v1 -vcl { set resp.http.b64param = blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), - encoding=BASE64, case=LOWER); + encoding=BASE64, case=DEFAULT); set resp.http.b64urlparam = blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), - encoding=BASE64URL, case=UPPER); + encoding=BASE64URL, case=DEFAULT); set resp.http.b64urlnopadparam = blob.encode(blob=blob.decode(IDENTITY, encoded=req.http.pangram), - encoding=BASE64URLNOPAD, case=LOWER); + encoding=BASE64URLNOPAD, case=DEFAULT); set resp.http.b64xcode = blob.transcode(IDENTITY, BASE64, @@ -115,18 +103,15 @@ client c1 { txreq -url "/" rxresp expect resp.http.b64 == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" - expect resp.http.b64lc == resp.http.b64 - expect resp.http.b64uc == resp.http.b64 + expect resp.http.b64pos == resp.http.b64 expect resp.http.b64hobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" expect resp.http.b64all == "//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" expect resp.http.b64url == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==" - expect resp.http.b64urllc == resp.http.b64url - expect resp.http.b64urluc == resp.http.b64url + expect resp.http.b64urlpos == resp.http.b64url expect resp.http.b64urlhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=" expect resp.http.b64urlall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA==" expect resp.http.b64urlnopad == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw" - expect resp.http.b64urlnopadlc == resp.http.b64urlnopad - expect resp.http.b64urlnopaduc == resp.http.b64urlnopad + expect resp.http.b64urlnopadpos == resp.http.b64urlnopad expect resp.http.b64nopadhobbes == "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4" expect resp.http.b64nopadall == "__79_Pv6-fj39vX08_Lx8O_u7ezr6uno5-bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL--vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI-OjYyLiomIh4aFhIOCgYB_fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAA" expect resp.http.b64empty == "" @@ -339,3 +324,102 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "././"$} expect * * VCL_Error {^vmod blob error: cannot decode, illegal encoding beginning with "TWFu"$} } -run + +# Require case=DEFAULT + +server s1 -repeat 6 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_deliver { + if (req.url == "/b64lc") { + set resp.http.b64lc = + blob.encode(BASE64, LOWER, blob.decode(IDENTITY, encoded="")); + } + elsif (req.url == "/b64uc") { + set resp.http.b64uc = + blob.encode(BASE64, UPPER, blob.decode(IDENTITY, encoded="")); + } + elsif (req.url == "/b64urllc") { + set resp.http.b64urllc = + blob.encode(BASE64URL, LOWER, blob.decode(IDENTITY, encoded="")); + } + elsif (req.url == "/b64urluc") { + set resp.http.b64urluc = + blob.encode(BASE64URL, UPPER, blob.decode(IDENTITY, encoded="")); + } + elsif (req.url == "/b64urlnopadlc") { + set resp.http.b64urlnopadlc = + blob.encode(BASE64URLNOPAD, LOWER, blob.decode(IDENTITY, + encoded="")); + } + elsif (req.url == "/b64urlnopaduc") { + set resp.http.b64urlnopaduc = + blob.encode(BASE64URLNOPAD, UPPER, blob.decode(IDENTITY, + encoded="")); + } + } +} + +client c1 { + txreq -url "/b64lc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64lc == +} -run + +client c1 { + txreq -url "/b64uc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64uc == +} -run + +client c1 { + txreq -url "/b64urllc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urllc == +} -run + +client c1 { + txreq -url "/b64urluc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urluc == +} -run + +client c1 { + txreq -url "/b64urlnopadlc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urlnopadlc == +} -run + +client c1 { + txreq -url "/b64urlnopaduc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urlnopaduc == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64URL" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64URL" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64URLNOPAD" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64URLNOPAD" +} -start + +logexpect l1 -wait diff --git a/bin/varnishtest/tests/m00043.vtc b/bin/varnishtest/tests/m00043.vtc index 7521255..9062314 100644 --- a/bin/varnishtest/tests/m00043.vtc +++ b/bin/varnishtest/tests/m00043.vtc @@ -1,9 +1,8 @@ varnishtest "VMOD blob blob object interface" -server s1 {} -start - -varnish v1 -arg "-i serverid" -vcl+backend { +varnish v1 -arg "-i serverid" -vcl { import blob; + backend b { .host = "${bad_ip}"; } sub vcl_init { new id = blob.blob(IDENTITY, @@ -93,8 +92,9 @@ client c1 { # run twice to test retrieving cached encodings client c1 -run -varnish v1 -vcl+backend { +varnish v1 -vcl { import blob; + backend b { .host = "${bad_ip}"; } sub vcl_init { new idempty = blob.blob(IDENTITY, ""); @@ -165,8 +165,9 @@ client c1 { # run twice to test retrieving cached encodings client c1 -run -varnish v1 -vcl+backend { +varnish v1 -vcl { import blob; + backend b { .host = "${bad_ip}"; } sub vcl_init { new b64 = blob.blob(BASE64, "L0hlbGxvIHdvcmxkLw=="); @@ -254,8 +255,9 @@ client c2 { # run twice client c2 -run -varnish v1 -vcl+backend { +varnish v1 -vcl { import blob; + backend b { .host = "${bad_ip}"; } sub vcl_init { new id = blob.blob(IDENTITY, @@ -332,6 +334,125 @@ client c3 -run varnish v1 -cliok "vcl.discard vcl1" varnish v1 -cliok "vcl.discard vcl2" +# Require case=DEFAULT in the .encode() method where necessary + +server s1 -repeat 8 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import blob; + + sub vcl_init { + new b = blob.blob(IDENTITY, ""); + } + + sub vcl_deliver { + if (req.url == "/idlc") { + set resp.http.idlc = b.encode(IDENTITY, LOWER); + } + elsif (req.url == "/iduc") { + set resp.http.iduc = b.encode(IDENTITY, UPPER); + } + if (req.url == "/b64lc") { + set resp.http.b64lc = b.encode(BASE64, LOWER); + } + elsif (req.url == "/b64uc") { + set resp.http.b64uc = b.encode(BASE64, UPPER); + } + elsif (req.url == "/b64urllc") { + set resp.http.b64urllc = b.encode(BASE64URL, LOWER); + } + elsif (req.url == "/b64urluc") { + set resp.http.b64urluc = b.encode(BASE64URL, UPPER); + } + elsif (req.url == "/b64urlnopadlc") { + set resp.http.b64urlnopadlc = b.encode(BASE64URLNOPAD, LOWER); + } + elsif (req.url == "/b64urlnopaduc") { + set resp.http.b64urlnopaduc = b.encode(BASE64URLNOPAD, UPPER); + } + } +} + +client c1 { + txreq -url "/idlc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.idlc == +} -run + +client c1 { + txreq -url "/iduc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.iduc == +} -run + +client c1 { + txreq -url "/b64lc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64lc == +} -run + +client c1 { + txreq -url "/b64uc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64uc == +} -run + +client c1 { + txreq -url "/b64urllc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urllc == +} -run + +client c1 { + txreq -url "/b64urluc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urluc == +} -run + +client c1 { + txreq -url "/b64urlnopadlc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urlnopadlc == +} -run + +client c1 { + txreq -url "/b64urlnopaduc" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + expect resp.http.b64urlnopaduc == +} -run + +logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" { + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding IDENTITY$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding IDENTITY$" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64$" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64URL$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64URL$" + expect * * VCL_Error "^vmod blob error: case LOWER is illegal with encoding BASE64URLNOPAD$" + expect * * VCL_Error "^vmod blob error: case UPPER is illegal with encoding BASE64URLNOPAD$" +} -start + +logexpect l1 -wait + varnish v1 -errvcl {vmod blob error: cannot create blob err, illegal encoding beginning with "g"} { import blob; backend b { .host="${bad_ip}"; } diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 96dea4e..3b90d3a 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -94,16 +94,19 @@ Empty strings are decoded into a "null blob" (of length 0), and conversely a null blob is encoded as the empty string. For encodings with ``HEX`` or ``URL``, you may also specify a ``case`` -ENUM with one of the values ``LOWER`` or ``UPPER`` to produce a string -with lower- or uppercase hex digits (in ``[a-f]`` or ``[A-F]``), -respectively. The default value for ``case`` is ``LOWER``. +ENUM with one of the values ``LOWER``, ``UPPER`` or ``DEFAULT`` to +produce a string with lower- or uppercase hex digits (in ``[a-f]`` or +``[A-F]``). The default value for ``case`` is ``DEFAULT``, which for +``HEX`` and ``URL`` means the same as ``LOWER``. The ``case`` ENUM is not relevant for decodings; ``HEX`` or ``URL`` strings to be decoded as BLOBs may have hex digits in either case, or -in mixed case. The ``case`` ENUM is also ignored for all other -encodings. You cannot, for example, produce an uppercase string by -using the IDENTITY scheme with ``case=UPPER``. To change the case of a -string, use the ``toupper`` or ``tolower`` functions from +in mixed case. + +The ``case`` ENUM MUST be set to ``DEFAULT`` for the other encodings +(BASE64* and IDENTITY). You cannot, for example, produce an uppercase +string by using the IDENTITY scheme with ``case=UPPER``. To change the +case of a string, use the ``toupper`` or ``tolower`` functions from :ref:`vmod_std(3)`. IDENTITY @@ -133,7 +136,7 @@ be written as:: set resp.http.Trunced-Foo2 = blob.encode(blob=blob.decode(HEX, encoded="666f6f00626172")); -The ``case`` ENUM is ignored for ``IDENTITY`` encodings. +The ``case`` ENUM MUST be set to ``DEFAULT`` for ``IDENTITY`` encodings. BASE64* ------- @@ -155,16 +158,17 @@ The ``BASE64URLNOPAD`` encoding uses the same alphabet as ``BASE6URL``, but leaves out the padding. Thus the length of an encoding with this scheme is not necessarily a mutltiple of four. -The ``case`` ENUM is ignored for for all of the ``BASE64*`` encodings. +The ``case`` ENUM MUST be set to ``DEFAULT`` for for all of the +``BASE64*`` encodings. HEX --- The ``HEX`` encoding scheme converts hex strings into blobs and vice versa. For encodings, you may use the ``case`` ENUM to specify upper- -or lowercase hex digits ``A`` through ``f`` (default ``LOWER``). A -prefix such as ``0x`` is not used for an encoding and is illegal for a -decoding. +or lowercase hex digits ``A`` through ``f`` (default ``DEFAULT``, +which means the same as ``LOWER``). A prefix such as ``0x`` is not +used for an encoding and is illegal for a decoding. If a hex string to be decoded has an odd number of digits, it is decoded as if a ``0`` is prepended to it; that is, the first digit is @@ -214,13 +218,15 @@ Example:: $Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER", BLOB blob) + ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT", BLOB blob) Returns a string representation of the BLOB ``blob`` as specifed by ``encoding``. ``case`` determines the case of hex digits for the ``HEX`` and ``URL`` encodings, and is ignored for the other encodings. -``encoding`` defaults to IDENTITY, and ``case`` defaults to LOWER. +``encoding`` defaults to IDENTITY, and ``case`` defaults to DEFAULT. +DEFAULT is interpreted as LOWER for the HEX and URL encodings, and is +the required value for the other encodings. Example:: @@ -242,8 +248,8 @@ $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER", INT length=0, - STRING_LIST encoded) + ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT", + INT length=0, STRING_LIST encoded) Translates from one encoding to another, by first decoding the string ``encoded`` according to the scheme ``decoding``, and then returning @@ -256,7 +262,8 @@ As with ``decode()``: If ``length`` > 0, only decode the first entire string. The default value of ``length`` is 0. ``decoding`` and ``encoding`` default to IDENTITY, and ``case`` -defaults to LOWER. +defaults to DEFAULT. DEFAULT is interpreted as LOWER for the HEX and +URL encodings, and is the required value for the other encodings. Example:: @@ -343,12 +350,12 @@ Example:: $Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", - ENUM {LOWER, UPPER} case="LOWER") + ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT") Returns an encoding of BLOB created by the constructor, according to the scheme ``encoding``. ``case`` determines the case of hex digits -for the ``HEX`` and ``URL`` encodings, and is ignored for other -encodings. +for the ``HEX`` and ``URL`` encodings, and MUST be set to ``DEFAULT`` +for the other encodings. Example:: @@ -378,10 +385,11 @@ not known until runtime. ERRORS ====== -The encoders, decoders and ``sub()`` may fail if there is -insufficient space to create the new blob or string. Decoders may also -fail if the encoded string is an illegal format for the decoding -scheme. +The encoders, decoders and ``sub()`` may fail if there is insufficient +space to create the new blob or string. Decoders may also fail if the +encoded string is an illegal format for the decoding scheme. Encoders +will fail for the ``IDENTITY`` and ``BASE64*`` encoding schemes if the +``case`` ENUM is not set to ``DEFAULT``. If any of the VMOD's methods, functions or constructor fail, then VCL failure is invoked, just as if ``return(fail)`` had been called in the diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 7ded3a8..7e58db1 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -159,6 +159,9 @@ static inline enum case_e parse_case(VCL_ENUM case_s) { switch(*case_s) { + case 'D': + AZ(strcmp(case_s + 1, "EFAULT")); + return DEFAULT; case 'L': AZ(strcmp(case_s + 1, "OWER")); return LOWER; @@ -170,6 +173,25 @@ parse_case(VCL_ENUM case_s) } } +static inline int +encodes_hex(enum encoding enc) +{ + return (enc == HEX || enc == URL); +} + +/* Require case DEFAULT for all encodings besides HEX and URL. */ + +static inline int +check_enc_case(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, enum encoding enc, + enum case_e kase) +{ + if (!encodes_hex(enc) && kase != DEFAULT) { + VERR(ctx, "case %s is illegal with encoding %s", case_s, encs); + return 0; + } + return 1; +} + /* Objects */ VCL_VOID __match_proto__(td_blob_blob__init) @@ -250,8 +272,12 @@ vmod_blob_encode(VRT_CTX, struct vmod_blob_blob *b, VCL_ENUM encs, CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(b, VMOD_BLOB_MAGIC); + if (!check_enc_case(ctx, encs, case_s, enc, kase)) + return NULL; if (b->blob.len == 0) return ""; + if (kase == DEFAULT) + kase = LOWER; if (b->encoding[enc][kase] == NULL) { AZ(pthread_mutex_lock(&b->lock)); @@ -396,7 +422,6 @@ encode(VRT_CTX, enum encoding enc, enum case_e kase, VCL_BLOB b) struct wb_s wb; ssize_t len; - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AENC(enc); if (b == NULL) @@ -429,13 +454,11 @@ vmod_encode(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, VCL_BLOB b) { enum encoding enc = parse_encoding(encs); enum case_e kase = parse_case(case_s); - return encode(ctx, enc, kase, b); -} -static inline int -encodes_hex(enum encoding enc) -{ - return (enc == HEX || enc == URL); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (!check_enc_case(ctx, encs, case_s, enc, kase)) + return NULL; + return encode(ctx, enc, kase, b); } VCL_STRING __match_proto__(td_blob_transcode) @@ -455,6 +478,9 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, AENC(dec); AENC(enc); + if (!check_enc_case(ctx, encs, case_s, enc, kase)) + return NULL; + /* * Allocate space for the decoded blob on the stack * ignoring the limitation imposed by n diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h index 9cc1d45..04663e5 100644 --- a/lib/libvmod_blob/vmod_blob.h +++ b/lib/libvmod_blob/vmod_blob.h @@ -34,9 +34,14 @@ #define AENC(enc) assert((enc) > _INVALID && (enc) < __MAX_ENCODING) +/* + * The enums MUST appear in this order, since LOWER and UPPER are used to + * index the array of cached encodings for the blob object. + */ enum case_e { LOWER, UPPER, + DEFAULT, }; /* From hermunn at varnish-software.com Fri Sep 15 11:17:31 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:31 +0000 (UTC) Subject: [5.2] c6a8af4 VMOD blob: move $ABI directive again. Message-ID: <20170915111731.3A9A398A76@lists.varnish-cache.org> commit c6a8af4e659083f6cc19346c7c24052923ddae78 Author: Geoff Simmons Date: Thu Sep 14 18:56:31 2017 +0200 VMOD blob: move $ABI directive again. So that part of the docs appear in the SYNOPSIS section. diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 3b90d3a..a462f3a 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -7,7 +7,6 @@ # $Module blob 3 utilities for the VCL blob type -$ABI strict :: @@ -28,6 +27,8 @@ $ABI strict BLOB .get() STRING .encode([ENUM encoding,] [ENUM case]) +$ABI strict + DESCRIPTION =========== From hermunn at varnish-software.com Fri Sep 15 11:17:31 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:31 +0000 (UTC) Subject: [5.2] 7f0226c GCC doesn't like attributes on typedefs Message-ID: <20170915111731.59C3198A84@lists.varnish-cache.org> commit 7f0226cb842e6b2feab6d56b96e1de5fec3c8a7b Author: Poul-Henning Kamp Date: Thu Sep 14 17:46:39 2017 +0000 GCC doesn't like attributes on typedefs diff --git a/include/vas.h b/include/vas.h index ec4adc5..76bcb75 100644 --- a/include/vas.h +++ b/include/vas.h @@ -46,8 +46,7 @@ enum vas_e { VAS_VCL, }; -typedef void vas_f(const char *, const char *, int, const char *, enum vas_e) - __attribute__((__noreturn__)); +typedef void vas_f(const char *, const char *, int, const char *, enum vas_e); extern vas_f *VAS_Fail_Func __attribute__((__noreturn__)); extern vas_f VAS_Fail __attribute__((__noreturn__)); From hermunn at varnish-software.com Fri Sep 15 11:17:31 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:31 +0000 (UTC) Subject: [5.2] 042de50 Missing assert Message-ID: <20170915111731.8C46E98A9B@lists.varnish-cache.org> commit 042de503a7b3fad3efab691f36e8a4e97c159981 Author: Poul-Henning Kamp Date: Thu Sep 14 20:37:11 2017 +0000 Missing assert diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index bba58b3..dc25ea4 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -624,6 +624,7 @@ MCF_DumpRstParam(void) t1 = strchr(p, '\t'); if (t1 != NULL && t1 < q) { t2 = strchr(t1 + 1, '\t'); + AN(t2); printf("\n\t*"); (void)fwrite(t1 + 1, (t2 - 1) - t1, 1, stdout); printf("*\n\t\t"); From hermunn at varnish-software.com Fri Sep 15 11:17:31 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:31 +0000 (UTC) Subject: [5.2] ecee294 Add a couple of clarifying asserts Message-ID: <20170915111731.AC90898AAB@lists.varnish-cache.org> commit ecee294ce6bdd14bb8e4b3b775442f632468a527 Author: Poul-Henning Kamp Date: Thu Sep 14 21:04:11 2017 +0000 Add a couple of clarifying asserts diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 39cb394..43f89b2 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -566,6 +566,8 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) if (b0 == bn) return (0); + AN(b0); + AN(bn); /* * This loop is safe without locks, because we know we hold From hermunn at varnish-software.com Fri Sep 15 11:17:31 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:31 +0000 (UTC) Subject: [5.2] f2ea93b Remove the last XXX from the release docs for 5.2. Message-ID: <20170915111731.CA83798ABA@lists.varnish-cache.org> commit f2ea93b880bb35d7877187eff8760f008e376ae9 Author: Geoff Simmons Date: Fri Sep 15 08:43:42 2017 +0200 Remove the last XXX from the release docs for 5.2. diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 686dde3..0b32705 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -216,8 +216,6 @@ Other changes * ``varnishtest(1)`` and ``vtc(7)``: - * *XXX: changes in test scripting or test code, for example due to VMOD vtc?* - * When varnishtest is invoked with ``-L`` or ``-l``, Varnish instances started by a test do not clean up their copies of VMOD shared objects when they stop. See the note about ``vmod_so_keep`` From hermunn at varnish-software.com Fri Sep 15 11:17:31 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:31 +0000 (UTC) Subject: [5.2] 0388ecb Polish. Message-ID: <20170915111731.ED8B098AC9@lists.varnish-cache.org> commit 0388ecb08e37e040b83f0fd3ffcccdd1adb2cb99 Author: Poul-Henning Kamp Date: Fri Sep 15 07:22:30 2017 +0000 Polish. Remove mention of http_CollectHdrSep(). diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index ebd421e..fb1d194 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -54,12 +54,14 @@ test-cases. We only distribute ``vmod_debug`` in source releases, because it has some pretty evil functionality, for instance ``debug.panic()``. -We have split the non-suicidal test-writing stuff from ``vmod_debug`` -into a new ``vmod_vtc``, which is included in binary releases from -now on, in order to make it easier for people to use ``varnishtest`` -to test local configurations, VMODs etc. The main highlight is that you -can now synchronize barriers with VCL code thanks to ``vmod_vtc``, other -conveniences were added like workspace manipulations. +We have taken the non-suicidal test-writing goodies out of +``vmod_debug`` and put them into a new ``vmod_vtc``, to make them +available to people using ``varnishtest`` to test local configurations, +VMODs etc. + +The hottest trick in ``vmod_vtc`` is that VTC-barriers can be +accessed from the VCL code, but there are other conveniences like +workspace manipulations etc. See :ref:`vmod_vtc(3)`. @@ -84,8 +86,7 @@ one or the other depended on how Varnish was built. VMOD authors can now specify whether a module complies to the VRT and only needs to be rebuilt when breaking changes are introduced by adding ``$ABI vrt`` to their VCC descriptor. The default value -is ``$ABI strict`` when omitted, and all VMODs from the standard -Varnish distribution have a strict requirement. +is ``$ABI strict`` when omitted. .. _whatsnew_vsm_vsc_5.2: @@ -102,8 +103,8 @@ file which is processed by the ``vsctool.py`` script into a .c and This means that statistics counters are now self-describing in shared memory, and ``varnishstat`` or other VSC-API using programs -have no compiled in knowledge about which counters exist or how -to treat them. +no longer have a compiled in list of which counters exist or how +to handle them. This paves the way for VMODs or maybe even VCL to define custom counters, and have them show up in varnishstat and @@ -120,7 +121,7 @@ In the new VSM-api once setup is done, VSM_Attach() latches on to a running varnishd master process and stays there. VSM_Status() updates the in-memory list of VSM segments, and -returns information about the master and worker proces: +returns status information about the master and worker proces: Are they running? Have they been restarted? Have VSM segments been added/deleted? @@ -143,10 +144,6 @@ VRT API changes outside of ``vcl_hit`` or ``vcl_miss``. It also returns the number of purged objects. -New ``http_CollectHdrSep`` function, ``http_*`` symbols and associated -data structures are part of the curated Varnish RunTime. Using them -does not require strict ABI compliance. - .. _whatsnew_vut_5.2: Added VUT API @@ -170,3 +167,5 @@ the boilerplate to generate part of the documentation. We hope that we will see new tools that take advantage of this API to extend Varnish in new ways, much like VMODs made it easy to add new functionality to VCL. + +*eof* diff --git a/doc/sphinx/whats-new/upgrading-5.2.rst b/doc/sphinx/whats-new/upgrading-5.2.rst index 0b32705..9d02522 100644 --- a/doc/sphinx/whats-new/upgrading-5.2.rst +++ b/doc/sphinx/whats-new/upgrading-5.2.rst @@ -14,10 +14,12 @@ varnishd parameters =================== The :ref:`ref_param_vsm_space` and :ref:`ref_param_cli_buffer` -parameters are now deprecated and ignored. The updated logging -implementation manages space automatically, so it no longer needs -:ref:`ref_param_vsm_space`. Memory for the CLI command buffer is now -dynamically allocated. +parameters are now deprecated and ignored. They will be removed +in a future major release. + +The updated shared memory implementation manages space automatically, so +it no longer needs :ref:`ref_param_vsm_space`. Memory for the CLI +command buffer is now dynamically allocated. We have updated the documentation for :ref:`ref_param_send_timeout`, :ref:`ref_param_idle_send_timeout`, :ref:`ref_param_timeout_idle` and @@ -254,3 +256,5 @@ Other changes up its copies of VMOD shared objects when it stops. This makes it possible for VMOD authors to load their code into a debugger after a varnishd crash. See :ref:`ref_param_debug`. + +*eof* From hermunn at varnish-software.com Fri Sep 15 11:17:32 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:32 +0000 (UTC) Subject: [5.2] 5a68f67 Add changelog entry for pull 2382 and heading for 5.2.0 Message-ID: <20170915111732.19E2A98AD9@lists.varnish-cache.org> commit 5a68f6758f95aa5042961a97c01ab8e276d4b0a3 Author: P?l Hermunn Johansen Date: Fri Sep 15 12:02:55 2017 +0200 Add changelog entry for pull 2382 and heading for 5.2.0 diff --git a/doc/changes.rst b/doc/changes.rst index 9003c32..9b546b1 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -2,6 +2,14 @@ Varnish Cache Trunk (ongoing) ============================= +================================ +Varnish Cache 5.2.0 (2017-09-15) +================================ + +* The cli_buffer parameter has been deprecated (2382_) + +.. _2382: https://github.com/varnishcache/varnish-cache/pull/2382 + ================================== Varnish Cache 5.2-RC1 (2017-09-04) ================================== From hermunn at varnish-software.com Fri Sep 15 11:17:32 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:17:32 +0000 (UTC) Subject: [5.2] 393f1be Spelling and cosmetic Message-ID: <20170915111732.39EA498AFF@lists.varnish-cache.org> commit 393f1bed3ca9503a3d092c8b4340e01f8b510c23 Author: Federico G. Schwindt Date: Fri Sep 15 11:55:49 2017 +0100 Spelling and cosmetic diff --git a/doc/sphinx/whats-new/changes-5.2.rst b/doc/sphinx/whats-new/changes-5.2.rst index fb1d194..43764b3 100644 --- a/doc/sphinx/whats-new/changes-5.2.rst +++ b/doc/sphinx/whats-new/changes-5.2.rst @@ -117,23 +117,23 @@ will have to be updated to match. The necessary changes mostly center around detecting if the varnishd management/worker process has restarted. -In the new VSM-api once setup is done, VSM_Attach() latches +In the new VSM-API once setup is done, VSM_Attach() latches on to a running varnishd master process and stays there. VSM_Status() updates the in-memory list of VSM segments, and -returns status information about the master and worker proces: +returns status information about the master and worker processes: Are they running? Have they been restarted? Have VSM segments been added/deleted? Each VSM segment is now a separate piece of shared memory -and the name of the segment can be much longer now. +and the name of the segment can be much longer. Before the actual shared memory can be accessed, the application must call VSM_Map() and when VSM_StillValid() indicates that the segment is no longer valid, VSM_Unmap() should be called to release the segment again. -All in all, this should be simpler and more robust now. +All in all, this should be simpler and more robust. .. _whatsnew_vrt_5.2: From hermunn at varnish-software.com Fri Sep 15 11:34:04 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 15 Sep 2017 11:34:04 +0000 (UTC) Subject: [5.2] 4c4875c Prepare for 5.2.0 release Message-ID: <20170915113404.B8C109FC62@lists.varnish-cache.org> commit 4c4875cbf17668f5ae3badb074e9b6f5167a52e1 Author: P?l Hermunn Johansen Date: Fri Sep 15 13:18:23 2017 +0200 Prepare for 5.2.0 release This should be compared to 8e0b7b20446f in master, which shows that this is essensially trunk, but with a different history. diff --git a/configure.ac b/configure.ac index 5b9dbac..ab629c9 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2017 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [5.2.0-rc2], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [5.2.0], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index 9b546b1..e2fbcd8 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,7 +1,3 @@ -============================= -Varnish Cache Trunk (ongoing) -============================= - ================================ Varnish Cache 5.2.0 (2017-09-15) ================================ From nils.goroll at uplex.de Mon Sep 18 16:02:07 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 18 Sep 2017 16:02:07 +0000 (UTC) Subject: [master] 105784f remove duplicate word Message-ID: <20170918160207.9487A9A1A4@lists.varnish-cache.org> commit 105784f7b05101d1f37821c772e5ef4d9568dc1a Author: Nils Goroll Date: Mon Sep 18 18:00:52 2017 +0200 remove duplicate word diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index 9282ba3..869f62e 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -157,9 +157,9 @@ $Method VOID .add_backend(BACKEND, REAL) Description Add a backend to the director with a given weight. - Each backend backend will receive approximately - 100 * (weight / (sum(all_added_weights))) per cent of the traffic sent - to this director. + Each backend will receive approximately 100 * (weight / + (sum(all_added_weights))) per cent of the traffic sent to this + director. Example # 2/3 to backend1, 1/3 to backend2. From copier at varnish-cache.org Tue Sep 19 06:42:09 2017 From: copier at varnish-cache.org (copier at varnish-cache.org) Date: Tue, 19 Sep 2017 09:42:09 +0300 Subject: ***Spam*** Message from KM_C224e Message-ID: A non-text attachment was scrubbed... Name: 20171809_50457004961.7z Type: application/zip Size: 3004 bytes Desc: not available URL: From phk at FreeBSD.org Tue Sep 19 07:29:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Sep 2017 07:29:07 +0000 (UTC) Subject: [master] 6d54579 Whitespace OCD Message-ID: <20170919072907.C7476A031D@lists.varnish-cache.org> commit 6d54579f4f401699c2f162ad9d0a721da7304861 Author: Poul-Henning Kamp Date: Tue Sep 19 07:26:04 2017 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/m00033.vtc b/bin/varnishtest/tests/m00033.vtc index 02d896d..64ab208 100644 --- a/bin/varnishtest/tests/m00033.vtc +++ b/bin/varnishtest/tests/m00033.vtc @@ -56,7 +56,7 @@ varnish v1 -vcl { set resp.http.pos = blob.encode(IDENTITY, DEFAULT, blob.decode(IDENTITY, - encoded="foobar")); + encoded="foobar")); } } -start From phk at FreeBSD.org Tue Sep 19 07:29:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Sep 2017 07:29:07 +0000 (UTC) Subject: [master] b5593e2 Fix #2389 Message-ID: <20170919072907.E71F6A0320@lists.varnish-cache.org> commit b5593e22805351a0121924626624eb33641847f6 Author: Poul-Henning Kamp Date: Tue Sep 19 07:26:19 2017 +0000 Fix #2389 Make the subargument to -a select the overall protocol (PROXY/HTTP) but, at least for now, not distinguish versions of these protocols. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 79d5e41..a5131a0 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -674,7 +674,8 @@ XPORT_Find(const char *name) ASSERT_MGT(); VTAILQ_FOREACH(xp, &transports, list) - if (!strcasecmp(xp->name, name)) + if (xp->proto_ident != NULL && + !strcasecmp(xp->proto_ident, name)) return (xp); return (NULL); } diff --git a/bin/varnishd/cache/cache_transport.h b/bin/varnishd/cache/cache_transport.h index 3433959..5de0920 100644 --- a/bin/varnishd/cache/cache_transport.h +++ b/bin/varnishd/cache/cache_transport.h @@ -50,6 +50,7 @@ struct transport { uint16_t number; + const char *proto_ident; // for -a args const char *name; task_func_t *new_session; diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index ceaf4c8..5657e6f 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -240,6 +240,7 @@ http1_minimal_response(struct req *req, uint16_t status) struct transport HTTP1_transport = { .name = "HTTP/1", + .proto_ident = "HTTP", .magic = TRANSPORT_MAGIC, .deliver = V1D_Deliver, .minimal_response = http1_minimal_response, diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index f5ba1e3..b5b46a4 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -54,7 +54,7 @@ extern const char * const builtin_vcl; /* mgt_acceptor.c */ void MAC_Arg(const char *); -void MAC_reopen_sockets(struct cli *); +void MAC_reopen_sockets(void); /* mgt_child.c */ void MCH_Init(void); diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index fa40577..695e882 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -76,7 +76,7 @@ mac_opensocket(struct listen_sock *ls) */ void -MAC_reopen_sockets(struct cli *cli) +MAC_reopen_sockets(void) { struct listen_sock *ls; int fail; @@ -87,14 +87,9 @@ MAC_reopen_sockets(struct cli *cli) VJ_master(JAIL_MASTER_LOW); if (fail == 0) continue; - if (cli == NULL) - MGT_Complain(C_ERR, - "Could not reopen listen socket %s: %s", - ls->endpoint, strerror(fail)); - else - VCLI_Out(cli, - "Could not reopen listen socket %s: %s\n", - ls->endpoint, strerror(fail)); + MGT_Complain(C_ERR, + "Could not reopen listen socket %s: %s", + ls->endpoint, strerror(fail)); } } @@ -184,7 +179,7 @@ MAC_Arg(const char *spec) la->name = name; if (av[2] == NULL) { - xp = XPORT_Find("http/1"); + xp = XPORT_Find("http"); } else { xp = XPORT_Find(av[2]); if (xp == NULL) diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index b3b8856..38d0674 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -525,7 +525,7 @@ mgt_reap_child(void) fprintf(stderr, "WAIT 0x%jx\n", (uintmax_t)r); assert(r == child_pid); - MAC_reopen_sockets(NULL); + MAC_reopen_sockets(); VSB_printf(vsb, "Child (%jd) %s", (intmax_t)r, status ? "died" : "ended"); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 6da09e5..d4eec41 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -91,7 +91,8 @@ usage(void) printf(FMT, "-a address[:port][,proto]", "HTTP listen address and port"); printf(FMT, "", "Can be specified multiple times."); - printf(FMT, "", " default: \":80,HTTP/1\""); + printf(FMT, "", " default: \":80,HTTP\""); + printf(FMT, "", "Proto can be \"PROXY\" or \"HTTP\" (default)"); printf(FMT, "-b address[:port]", "Backend address and port"); printf(FMT, "", " default: \":80\""); printf(FMT, "-f vclfile", "VCL program"); diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index b9f1626..8444f39 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -379,6 +379,7 @@ vpx_new_session(struct worker *wrk, void *arg) struct transport PROXY_transport = { .name = "PROXY", + .proto_ident = "PROXY", .magic = TRANSPORT_MAGIC, .new_session = vpx_new_session, }; diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index 01adffd..d8d74b1 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -11,7 +11,10 @@ shell -err -expect "Too many sub-arguments" { varnishd -a 127.0.0.1:80000,PROXY,FOO -d } shell -err -expect "Too many sub-arguments" { - varnishd -a 127.0.0.1:80000,HTTP/1,FOO -d + varnishd -a 127.0.0.1:80000,HTTP,FOO -d +} +shell -err -expect "Got no socket" { + varnishd -a 239.255.255.255:0,HTTP -d } # This requires non-local binds to be disabled. If you see this fail From martin at varnish-software.com Tue Sep 19 09:00:08 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 19 Sep 2017 09:00:08 +0000 (UTC) Subject: [master] 176f8a0 Avoid buffer read overflow on vcl_error and -sfile Message-ID: <20170919090008.559F1A00AC@lists.varnish-cache.org> commit 176f8a075a963ffbfa56f1c460c15f6a1a6af5a7 Author: Martin Blix Grydeland Date: Mon Sep 18 16:04:53 2017 +0200 Avoid buffer read overflow on vcl_error and -sfile The file stevedore may return a buffer larger than asked for when requesting storage. Due to lack of check for this condition, the code to copy the synthetic error memory buffer from vcl_error would overrun the buffer. Patch by @shamger Fixes: #2429 diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 20b3596..8839642 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -899,6 +899,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) l = ll; if (VFP_GetStorage(bo->vfc, &l, &ptr) != VFP_OK) break; + if (l > ll) + l = ll; memcpy(ptr, VSB_data(synth_body) + o, l); VFP_Extend(bo->vfc, l); ll -= l; From hermunn at varnish-software.com Tue Sep 19 09:29:04 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Tue, 19 Sep 2017 09:29:04 +0000 (UTC) Subject: [4.1] 19a7318 Avoid buffer read overflow on vcl_error and -sfile Message-ID: <20170919092904.685A7A09C2@lists.varnish-cache.org> commit 19a73184c6470a54f843c7c226c641a0b4ac2e8e Author: Martin Blix Grydeland Date: Mon Sep 18 16:04:53 2017 +0200 Avoid buffer read overflow on vcl_error and -sfile The file stevedore may return a buffer larger than asked for when requesting storage. Due to lack of check for this condition, the code to copy the synthetic error memory buffer from vcl_error would overrun the buffer. Patch by @shamger Fixes: #2429 diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index d36377c..70f953f 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -873,6 +873,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) l = ll; if (VFP_GetStorage(bo->vfc, &l, &ptr) != VFP_OK) break; + if (l > ll) + l = ll; memcpy(ptr, VSB_data(synth_body) + o, l); VBO_extend(bo, l); ll -= l; From phk at FreeBSD.org Tue Sep 19 11:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Sep 2017 11:46:05 +0000 (UTC) Subject: [master] e192605 Drop this test, it's not portable. Message-ID: <20170919114605.2103BA05AE@lists.varnish-cache.org> commit e192605e3d8e2275924efc7fc3b0cef24ef6eccf Author: Poul-Henning Kamp Date: Tue Sep 19 11:45:26 2017 +0000 Drop this test, it's not portable. diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index d8d74b1..eca86dc 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -13,9 +13,6 @@ shell -err -expect "Too many sub-arguments" { shell -err -expect "Too many sub-arguments" { varnishd -a 127.0.0.1:80000,HTTP,FOO -d } -shell -err -expect "Got no socket" { - varnishd -a 239.255.255.255:0,HTTP -d -} # This requires non-local binds to be disabled. If you see this fail # and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0. From hermunn at varnish-software.com Tue Sep 19 13:33:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Tue, 19 Sep 2017 13:33:05 +0000 (UTC) Subject: [4.1] 1ec38ef Close a race in the round robin director - for real now Message-ID: <20170919133305.2E158A0787@lists.varnish-cache.org> commit 1ec38efb6fc2c156b50869fd548f2dbdcee709dc Author: Nils Goroll Date: Fri Jul 28 22:01:26 2017 +0200 Close a race in the round robin director - for real now The previous code allowed the compiler to re-read nxt from rr->nxt which could have been incremented cocurrently. Fixes #2378 diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index c6c9c9b..6ebf7a3 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -70,9 +70,9 @@ vmod_rr_resolve(const struct director *dir, struct worker *wrk, CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC); vdir_rdlock(rr->vd); for (u = 0; u < rr->vd->n_backend; u++) { - nxt = rr->nxt %= rr->vd->n_backend; + nxt = rr->nxt % rr->vd->n_backend; + rr->nxt = nxt + 1; be = rr->vd->backend[nxt]; - rr->nxt++; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); if (be->healthy(be, bo, NULL)) break; From hermunn at varnish-software.com Tue Sep 19 14:18:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Tue, 19 Sep 2017 14:18:05 +0000 (UTC) Subject: [4.1] e44e54d start generalizing the signal handler Message-ID: <20170919141805.638749A6DD@lists.varnish-cache.org> commit e44e54dcce14d5d8114b22aef574d37b830359e8 Author: Nils Goroll Date: Wed Aug 23 08:37:21 2017 +0200 start generalizing the signal handler it was already used for more than SIGSEGV, so we should output the actual signal description. Conflicts: bin/varnishd/mgt/mgt_child.c diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 1154de5..80bb861 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -273,18 +273,19 @@ child_poker(const struct vev *e, int what) } /*===================================================================== - * SIGSEGV handler for child process + * signal handler for child process */ static void __match_proto__() -child_sigsegv_handler(int s, siginfo_t *si, void *c) +child_signal_handler(int s, siginfo_t *si, void *c) { char buf[1024]; - (void)s; (void)c; - sprintf(buf, "Segmentation fault by instruction at %p", si->si_addr); + bprintf(buf, "Signal %d (%s) received at %p si_code %d", + s, strsignal(s), si->si_addr, si->si_code); + VAS_Fail(__func__, __FILE__, __LINE__, @@ -389,7 +390,7 @@ mgt_launch_child(struct cli *cli) if (mgt_param.sigsegv_handler) { memset(&sa, 0, sizeof sa); - sa.sa_sigaction = child_sigsegv_handler; + sa.sa_sigaction = child_signal_handler; sa.sa_flags = SA_SIGINFO; (void)sigaction(SIGSEGV, &sa, NULL); (void)sigaction(SIGBUS, &sa, NULL); From hermunn at varnish-software.com Tue Sep 19 14:18:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Tue, 19 Sep 2017 14:18:05 +0000 (UTC) Subject: [4.1] 5efbf4c use an alternative stack for SIGSEGV and test for stack overflow Message-ID: <20170919141805.8BB119A6E0@lists.varnish-cache.org> commit 5efbf4c4145ac17d5ba692c2db88f6b29535b6f5 Author: Nils Goroll Date: Wed Aug 23 08:08:59 2017 +0200 use an alternative stack for SIGSEGV and test for stack overflow Previously, we could run out of stack handling stack overflows, leaving users with unspecific SIGSEGV crashes and no panic message. By providing a single alternative stack exclusively for SIGSEGV handling where sigaltstack() is available, we increase chances for our signal handler to finish successfully. In particular, this will make it easier to diagnose stack overflows by comparing the failing address with the stack info from the panic output. This could be further improved by giving advise to increase thread_pool_stack if si_addr is near the stack boundaries. c00057.vtc now triggers a stack overflow instead of raising a SIGSEGV. Merges #2396 diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 80bb861..64c73fe 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -392,9 +392,23 @@ mgt_launch_child(struct cli *cli) memset(&sa, 0, sizeof sa); sa.sa_sigaction = child_signal_handler; sa.sa_flags = SA_SIGINFO; - (void)sigaction(SIGSEGV, &sa, NULL); (void)sigaction(SIGBUS, &sa, NULL); (void)sigaction(SIGABRT, &sa, NULL); + +#ifdef HAVE_SIGALTSTACK + stack_t ss; + size_t sz = SIGSTKSZ + 4096; + if (sz < mgt_param.wthread_stacksize) + sz = mgt_param.wthread_stacksize; + ss.ss_sp = malloc(sz); + AN(ss.ss_sp); + ss.ss_size = sz; + ss.ss_flags = 0; + AZ(sigaltstack(&ss, NULL)); + sa.sa_flags |= SA_ONSTACK; +#endif + (void)sigaction(SIGSEGV, &sa, NULL); + } (void)signal(SIGINT, SIG_DFL); (void)signal(SIGTERM, SIG_DFL); diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index ba0ec1e..d8008af 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -5,13 +5,32 @@ server s1 { txresp } -start -varnish v1 -cliok "param.set vcc_allow_inline_c true" -varnish v1 -vcl+backend { +varnish v1 \ + -arg "-p vcc_allow_inline_c=true" \ + -arg "-p thread_pool_stack=48k" \ + -vcl+backend { C{ #include #include +#include + +static void _accessor(volatile char *p) { + p[0] = 'V'; p[1] = '\0'; + fprintf(stderr, "%p %s\n", p, p); +} +void (*accessor)(volatile char *p) = _accessor; + }C - sub vcl_recv { C{ raise(SIGSEGV); sleep(2); }C } + sub vcl_recv { C{ + int i; + volatile char overflow[48*1024]; + + /* for downwards stack, take care to hit a single guard page */ + for (i = 47*1024; i >= 0; i -= 1024) + accessor(overflow + i); + /* NOTREACHED */ + sleep(2); + }C } } -start client c1 { diff --git a/configure.ac b/configure.ac index f15d1b5..64c28d7 100644 --- a/configure.ac +++ b/configure.ac @@ -258,6 +258,7 @@ AC_CHECK_FUNCS([setppriv]) AC_CHECK_FUNCS([fallocate]) AC_CHECK_FUNCS([closefrom]) AC_CHECK_FUNCS([vsyslog]) +AC_CHECK_FUNCS([sigaltstack]) save_LIBS="${LIBS}" LIBS="${PTHREAD_LIBS}" From hermunn at varnish-software.com Tue Sep 19 14:48:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Tue, 19 Sep 2017 14:48:05 +0000 (UTC) Subject: [4.1] 5e84d03 Fix sourcing of varnish.m4 when building on FreeBSD Message-ID: <20170919144805.676C0A047C@lists.varnish-cache.org> commit 5e84d0301ad50221269f26777fda88c52ab729c1 Author: Mark Felder Date: Mon Aug 7 19:16:42 2017 -0500 Fix sourcing of varnish.m4 when building on FreeBSD diff --git a/Makefile.am b/Makefile.am index 321b458..e86049c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I m4 -I . SUBDIRS = include lib bin etc doc man From hermunn at varnish-software.com Tue Sep 19 15:00:05 2017 From: hermunn at varnish-software.com (hermunn) Date: Tue, 19 Sep 2017 15:00:05 +0000 (UTC) Subject: [4.1] 69e5f47 Straighten locking wrt vcl_active Message-ID: <20170919150005.158FEA091F@lists.varnish-cache.org> commit 69e5f47157efe4ba6894173f6966b733fac71830 Author: Martin Blix Grydeland Date: Mon Aug 21 14:59:59 2017 +0200 Straighten locking wrt vcl_active The locking around the use of vcl_active does not include the checking of its magic value or the temperature asserts, leading to a race when changing vcl_active. Fixes: #2390 diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index b40e990..ff5b13f 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -161,26 +161,25 @@ VCL_Method_Name(unsigned m) static void VCL_Get(struct vcl **vcc) { + AN(vcc); + while (vcl_active == NULL) (void)usleep(100000); - CHECK_OBJ_NOTNULL(vcl_active, VCL_MAGIC); - AZ(pthread_rwlock_rdlock(&vcl_active->temp_rwl)); - assert(VCL_WARM(vcl_active)); - AZ(pthread_rwlock_unlock(&vcl_active->temp_rwl)); Lck_Lock(&vcl_mtx); - AN(vcl_active); + CHECK_OBJ_NOTNULL(vcl_active, VCL_MAGIC); *vcc = vcl_active; - AN(*vcc); AZ((*vcc)->discard); (*vcc)->busy++; Lck_Unlock(&vcl_mtx); + AZ(pthread_rwlock_rdlock(&(*vcc)->temp_rwl)); + assert(VCL_WARM(*vcc)); + AZ(pthread_rwlock_unlock(&(*vcc)->temp_rwl)); } void VCL_Refresh(struct vcl **vcc) { - CHECK_OBJ_NOTNULL(vcl_active, VCL_MAGIC); if (*vcc == vcl_active) return; if (*vcc != NULL) From dridi.boukelmoune at gmail.com Tue Sep 19 20:37:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Sep 2017 20:37:07 +0000 (UTC) Subject: [master] e441de7 Minor improvements to varnish.m4 Message-ID: <20170919203707.2EC1DA0027@lists.varnish-cache.org> commit e441de71bf59121e4ae07736ede78079bbd2b10e Author: Dridi Boukelmoune Date: Tue Sep 19 15:48:27 2017 +0200 Minor improvements to varnish.m4 Instead of instructing VUT authors to clean the generated files, make sure they are automatically picked up. It is safe to upgrade while still having the CLEAN_FILES rule in Makefile.am, despite "removing" functionality (removing burden in reality). Other improvements include a single Python detection even when building several modules (but the underlying check is cached anyway) and a new dependency to "nodist" sources for VMOD authors that follow the recommendations. The "hardcoded" dependency is still present to avoid breaking existing builds. diff --git a/varnish.m4 b/varnish.m4 index c58392c..07dbcc8 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -29,7 +29,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # varnish.m4 - Macros to build against Varnish. -*- Autoconf -*- -# serial 8 (varnish-5.2.0) +# serial 9 (varnish-5.2.1) # # This collection of macros helps create VMODs or tools interacting with # Varnish Cache using the GNU build system (autotools). In order to work @@ -151,6 +151,7 @@ AC_DEFUN([_VARNISH_VMOD_CONFIG], [ AC_REQUIRE([_VARNISH_PKG_CONFIG]) AC_REQUIRE([_VARNISH_CHECK_DEVEL]) + AC_REQUIRE([_VARNISH_CHECK_PYTHON]) AC_REQUIRE([_VARNISH_VMOD_LDFLAGS]) dnl Check the VMOD toolchain @@ -159,8 +160,6 @@ AC_DEFUN([_VARNISH_VMOD_CONFIG], [ AC_REQUIRE([AC_PROG_CPP]) AC_REQUIRE([AC_PROG_CPP_WERROR]) - _VARNISH_CHECK_PYTHON - AS_IF([test -z "$RST2MAN"], [ AC_MSG_ERROR([rst2man is needed to build VMOD manuals.]) ]) @@ -209,10 +208,12 @@ AC_DEFUN([_VARNISH_VMOD], [ vmod_$1.lo: vcc_$1_if.c vcc_$1_if.h +vmod_$1.lo: \$(nodist_libvmod_$1_la_SOURCES) + vcc_$1_if.h vmod_$1.rst vmod_$1.man.rst: vcc_$1_if.c vcc_$1_if.c: vmod_$1.vcc - \$(AM_V_VMODTOOL) \$(PYTHON) \$(VMODTOOL) -o vcc_$1_if \$(srcdir)/vmod_$1.vcc + \$(A""M_V_VMODTOOL) \$(PYTHON) \$(VMODTOOL) -o vcc_$1_if \$(srcdir)/vmod_$1.vcc vmod_$1.3: vmod_$1.man.rst \$(A""M_V_GEN) \$(RST2MAN) vmod_$1.man.rst vmod_$1.3 @@ -278,7 +279,8 @@ clean-vmod-$1: # # These two set of make rules are independent and may be used in separate # sub-directories. You still need to declare the generated VCC interfaces -# in your library's sources. The generated files can be declared this way: +# in your library's sources. The generated files should be declared this +# way: # # nodist_libvmod_foo_la_SOURCES = vcc_foo_if.c vcc_foo_if.h # nodist_libvmod_bar_la_SOURCES = vcc_bar_if.c vcc_bar_if.h @@ -387,14 +389,19 @@ $1_options.rst: $1 $1.rst: $1_synopsis.rst $1_options.rst +clean: clean-vut-$1 + +distclean: clean-vut-$1 + +clean-vut-$1: + rm -f $1_synopsis.rst $1_options.rst + " AC_SUBST(m4_toupper(GENERATE_$1_DOCS), [$VUT_RULES]) m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE(m4_toupper(GENERATE_$1_DOCS))]) - AC_SUBST(m4_toupper(GENERATED_$1_DOCS), - ["$1_synopsis.rst $1_options.rst"]) ]) # VARNISH_UTILITIES(NAMES) @@ -477,12 +484,8 @@ $1.rst: $1_synopsis.rst $1_options.rst # .. include:: @builddir@/foo_options.rst # # This will ensure that foo.rst and bar.rst always find the generated files -# when the source directory is different from the build directory. Finally, -# the generated files are exposed in a variable to help clean them: -# -# CLEANFILES += $(GENERATED_FOO_DOCS) $(GENERATED_BAR_DOCS) -# -# It is the maintainer's responsibility to build the actual manuals. +# when the source directory is different from the build directory. It is the +# maintainer's responsibility to build the actual manuals. # AC_DEFUN([VARNISH_UTILITIES], [ m4_foreach([_vut_name], From dridi.boukelmoune at gmail.com Tue Sep 19 20:37:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Sep 2017 20:37:07 +0000 (UTC) Subject: [master] f1add71 "LABEL" is not a VCL state Message-ID: <20170919203707.493AEA002A@lists.varnish-cache.org> commit f1add71c2e0b21506a0ee0db3770b6bc3a96d066 Author: Dridi Boukelmoune Date: Tue Sep 19 17:28:46 2017 +0200 "LABEL" is not a VCL state Refs #2432 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index f8579c0..e43967f 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -376,6 +376,8 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) char *p; int i; + assert(vs != VCL_STATE_LABEL); + if (vp == active_vcl || mcf_is_label(vp)) { AN(vp->warm); return (0); From dridi.boukelmoune at gmail.com Tue Sep 19 20:37:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Sep 2017 20:37:07 +0000 (UTC) Subject: [master] 4a7033a Make sure we don't get spurious VCL events Message-ID: <20170919203707.664E6A002E@lists.varnish-cache.org> commit 4a7033a69759f300d9f9112c45db8f3c8f147684 Author: Dridi Boukelmoune Date: Tue Sep 19 18:13:23 2017 +0200 Make sure we don't get spurious VCL events Refs #2432 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index e43967f..24fe078 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -380,8 +380,10 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) if (vp == active_vcl || mcf_is_label(vp)) { AN(vp->warm); + assert(vs != VCL_STATE_COLD); return (0); } + if (vs == VCL_STATE_AUTO) { now = VTIM_mono(); vs = (vp->warm ? VCL_STATE_WARM : VCL_STATE_COLD); From dridi.boukelmoune at gmail.com Tue Sep 19 20:37:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Sep 2017 20:37:07 +0000 (UTC) Subject: [master] 32a7604 Contain the VCL cooldown logic in a single location Message-ID: <20170919203707.80494A0032@lists.varnish-cache.org> commit 32a7604c58175c7a5c358375bebc147c1815ef8c Author: Dridi Boukelmoune Date: Tue Sep 19 19:40:25 2017 +0200 Contain the VCL cooldown logic in a single location It leaks a bit outside the mgt_vcl_cooldown function but it's a trade off to also avoid being too intrusive where go_cold is directly set. The VCL poker now sets the state to COLD instead of indiscriminately sending AUTO to all VCLs, only when the cooldown period has elapsed. Refs #2432 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 24fe078..39cbc64 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -368,11 +368,28 @@ mgt_has_vcl(void) return (!VTAILQ_EMPTY(&vclhead)); } +static unsigned +mgt_vcl_cooldown(struct vclprog *vp) +{ + double now; + + if (vp->state != VCL_STATE_AUTO) + return (0); + + now = VTIM_mono(); + if (vp->go_cold > 0 && vp->go_cold + mgt_param.vcl_cooldown < now) + return (1); + + if (vp->go_cold == 0 && vp != active_vcl) + vp->go_cold = now; + + return (0); +} + static int mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) { unsigned status, warm; - double now; char *p; int i; @@ -380,19 +397,17 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) if (vp == active_vcl || mcf_is_label(vp)) { AN(vp->warm); - assert(vs != VCL_STATE_COLD); + /* Only the poker sends COLD indiscriminately, ignore it */ + if (vs == VCL_STATE_COLD) + AZ(cli); return (0); } - if (vs == VCL_STATE_AUTO) { - now = VTIM_mono(); - vs = (vp->warm ? VCL_STATE_WARM : VCL_STATE_COLD); - if (vp->go_cold > 0 && vp->state == VCL_STATE_AUTO && - vp->go_cold + mgt_param.vcl_cooldown < now) - vs = VCL_STATE_COLD; - } + if (vs == VCL_STATE_AUTO) + vs = (mgt_vcl_cooldown(vp) ? VCL_STATE_COLD : VCL_STATE_WARM); + else + vp->go_cold = 0; - assert(vs != VCL_STATE_AUTO); warm = (vs == VCL_STATE_WARM ? 1 : 0); if (vp->warm == warm) @@ -400,8 +415,6 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) if (!MCH_Running()) { vp->warm = warm; - if (vp->warm == 0) - vp->go_cold = 0; return (0); } @@ -419,8 +432,6 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) /* Success, update mgt's VCL state to reflect child's state */ vp->warm = warm; - if (vp->warm == 0) - vp->go_cold = 0; } free(p); @@ -634,10 +645,7 @@ mcf_vcl_state(struct cli *cli, const char * const *av, void *priv) if (!strcmp(av[3], VCL_STATE_AUTO)) { vp->state = VCL_STATE_AUTO; - if (vp != active_vcl) { - vp->go_cold = VTIM_mono(); - (void)mgt_vcl_setstate(cli, vp, VCL_STATE_AUTO); - } + (void)mgt_vcl_setstate(cli, vp, VCL_STATE_AUTO); } else if (!strcmp(av[3], VCL_STATE_COLD)) { if (vp == active_vcl) { VCLI_Out(cli, "Cannot set the active VCL cold."); @@ -674,14 +682,14 @@ mcf_vcl_use(struct cli *cli, const char * const *av, void *priv) mgt_cli_askchild(&status, &p, "vcl.use %s\n", av[2])) { VCLI_SetResult(cli, status); VCLI_Out(cli, "%s", p); - vp->go_cold = VTIM_mono(); + AZ(vp->go_cold); (void)mgt_vcl_setstate(cli, vp, VCL_STATE_AUTO); } else { VCLI_Out(cli, "VCL '%s' now active", av[2]); vp2 = active_vcl; active_vcl = vp; if (vp2 != NULL) { - vp2->go_cold = VTIM_mono(); + AZ(vp2->go_cold); (void)mgt_vcl_setstate(cli, vp2, VCL_STATE_AUTO); } } @@ -853,7 +861,8 @@ mgt_vcl_poker(const struct vev *e, int what) (void)what; e_poker->timeout = mgt_param.vcl_cooldown * .45; VTAILQ_FOREACH(vp, &vclhead, list) - (void)mgt_vcl_setstate(NULL, vp, VCL_STATE_AUTO); + if (mgt_vcl_cooldown(vp)) + (void)mgt_vcl_setstate(NULL, vp, VCL_STATE_COLD); return (0); } From dridi.boukelmoune at gmail.com Tue Sep 19 20:37:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Sep 2017 20:37:07 +0000 (UTC) Subject: [master] 245b743 Both a label and its VCL must be WARM Message-ID: <20170919203707.9EB3FA003C@lists.varnish-cache.org> commit 245b74334f6d7b3d107c262cdeaf43ce94c7253c Author: Dridi Boukelmoune Date: Tue Sep 19 20:11:38 2017 +0200 Both a label and its VCL must be WARM Otherwise the VCL poker will eventually cool down the underlying VCL. Fixes #2432 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 39cbc64..27fd56a 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -101,6 +101,8 @@ static VTAILQ_HEAD(, vmodfile) vmodhead = VTAILQ_HEAD_INITIALIZER(vmodhead); static struct vclprog *active_vcl; static struct vev *e_poker; +static int mgt_vcl_setstate(struct cli *, struct vclprog *, const char *); + /*--------------------------------------------------------------------*/ static struct vclprog * @@ -187,6 +189,8 @@ mgt_vcl_dep_add(struct vclprog *vp_from, struct vclprog *vp_to) vd->to = vp_to; VTAILQ_INSERT_TAIL(&vp_to->dto, vd, lto); vp_to->nto++; + assert(vp_to->state == VCL_STATE_WARM || /* vcl.label ... */ + vp_to->state == VCL_STATE_LABEL); /* return(vcl(...)) */ } static void @@ -197,6 +201,12 @@ mgt_vcl_dep_del(struct vcldep *vd) VTAILQ_REMOVE(&vd->from->dfrom, vd, lfrom); VTAILQ_REMOVE(&vd->to->dto, vd, lto); vd->to->nto--; + if (vd->to->nto == 0 && vd->to->state == VCL_STATE_WARM) { + vd->to->state = VCL_STATE_AUTO; + AZ(vd->to->go_cold); + (void)mgt_vcl_setstate(NULL, vd->to, VCL_STATE_AUTO); + AN(vd->to->go_cold); + } FREE_OBJ(vd); } @@ -834,10 +844,9 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv) vpl = mgt_vcl_add(av[2], VCL_STATE_LABEL); } AN(vpl); - mgt_vcl_dep_add(vpl, vpt); vpl->warm = 1; - if (vpt->state == VCL_STATE_COLD) - vpt->state = VCL_STATE_AUTO; + vpt->state = VCL_STATE_WARM; + mgt_vcl_dep_add(vpl, vpt); (void)mgt_vcl_setstate(cli, vpt, VCL_STATE_WARM); if (!MCH_Running()) return; diff --git a/bin/varnishtest/tests/r02432.vtc b/bin/varnishtest/tests/r02432.vtc new file mode 100644 index 0000000..97b5d30 --- /dev/null +++ b/bin/varnishtest/tests/r02432.vtc @@ -0,0 +1,29 @@ +varnishtest "label going cold" + +server s1 { } -start + +varnish v1 -cliok "param.set vcl_cooldown 1" + +varnish v1 -vcl+backend { + sub vcl_recv { + return (synth(200)); + } +} -start + +varnish v1 -cliok "vcl.label label1 vcl1" + +varnish v1 -vcl+backend { + sub vcl_recv { + return (vcl(label1)); + } +} + +# let the VCL poker trigger enough times to get +# an occasion to update vcl1's state +delay 3 + +client c1 { + txreq + rxresp + expect resp.status == 200 +} -run From dridi.boukelmoune at gmail.com Tue Sep 19 20:37:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Sep 2017 20:37:07 +0000 (UTC) Subject: [master] e7efee0 Ensure the VCL warmup before touching the label Message-ID: <20170919203707.BE9BEA0059@lists.varnish-cache.org> commit e7efee0f282b3dc6c02ab95d69f4ecdd1c57cb37 Author: Dridi Boukelmoune Date: Tue Sep 19 21:31:39 2017 +0200 Ensure the VCL warmup before touching the label Fixes #2433 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 27fd56a..61aae33 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -838,16 +838,23 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv) vpt->name); return; } + } + + if (mgt_vcl_setstate(cli, vpt, VCL_STATE_WARM)) + return; + vpt->state = VCL_STATE_WARM; /* XXX: race with the poker? */ + + if (vpl != NULL) { mgt_vcl_dep_del(VTAILQ_FIRST(&vpl->dfrom)); AN(VTAILQ_EMPTY(&vpl->dfrom)); } else { vpl = mgt_vcl_add(av[2], VCL_STATE_LABEL); } + AN(vpl); vpl->warm = 1; - vpt->state = VCL_STATE_WARM; mgt_vcl_dep_add(vpl, vpt); - (void)mgt_vcl_setstate(cli, vpt, VCL_STATE_WARM); + if (!MCH_Running()) return; diff --git a/bin/varnishtest/tests/r02433.vtc b/bin/varnishtest/tests/r02433.vtc new file mode 100644 index 0000000..6815687 --- /dev/null +++ b/bin/varnishtest/tests/r02433.vtc @@ -0,0 +1,23 @@ +varnishtest "label a cold vcl" + +server s1 { } -start + +varnish v1 -vcl+backend { + import debug; # can fail a VCL warmup + + sub vcl_recv { + return (synth(200)); + } +} -start + +# a dummy vcl to freely use vcl1 +varnish v1 -vcl+backend { } + +# the magic parameter that fails a VCL warmup +varnish v1 -cliok "param.set max_esi_depth 42" + +varnish v1 -cliok "vcl.state vcl1 cold" +varnish v1 -clierr 300 "vcl.label label1 vcl1" + +# check that creating the label actually failed +varnish v1 -clierr 106 "vcl.discard label1" From dridi.boukelmoune at gmail.com Tue Sep 19 20:37:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Sep 2017 20:37:07 +0000 (UTC) Subject: [master] 66db6c8 Don't contradict the manager Message-ID: <20170919203707.DE3A4A0089@lists.varnish-cache.org> commit 66db6c89a179b619795e101821baeb0ef50835b9 Author: Dridi Boukelmoune Date: Tue Sep 19 22:14:14 2017 +0200 Don't contradict the manager Refs 606d485 diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 4faa0c8..bf8831d 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -53,7 +53,7 @@ static const char * const VCL_TEMP_LABEL = "label"; /* * NB: The COOLING temperature is neither COLD nor WARM. - * And LABEL is not a temperature, it's a state. + * And LABEL is not a temperature, it's a different kind of VCL. */ #define VCL_WARM(v) ((v)->temp == VCL_TEMP_WARM || (v)->temp == VCL_TEMP_BUSY) #define VCL_COLD(v) ((v)->temp == VCL_TEMP_INIT || (v)->temp == VCL_TEMP_COLD) From phk at FreeBSD.org Wed Sep 20 08:37:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Sep 2017 08:37:08 +0000 (UTC) Subject: [master] 097c562 Whitespace ocd Message-ID: <20170920083708.310A3A0AAF@lists.varnish-cache.org> commit 097c56292708642ee4de8f0f6165434a8a2f7a2d Author: Poul-Henning Kamp Date: Wed Sep 20 07:02:30 2017 +0000 Whitespace ocd diff --git a/bin/varnishtest/tests/r02433.vtc b/bin/varnishtest/tests/r02433.vtc index 6815687..b78777e 100644 --- a/bin/varnishtest/tests/r02433.vtc +++ b/bin/varnishtest/tests/r02433.vtc @@ -3,11 +3,11 @@ varnishtest "label a cold vcl" server s1 { } -start varnish v1 -vcl+backend { - import debug; # can fail a VCL warmup + import debug; # can fail a VCL warmup - sub vcl_recv { - return (synth(200)); - } + sub vcl_recv { + return (synth(200)); + } } -start # a dummy vcl to freely use vcl1 From phk at FreeBSD.org Wed Sep 20 08:37:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Sep 2017 08:37:08 +0000 (UTC) Subject: [master] c70284d Minor polish Message-ID: <20170920083708.47149A0AB2@lists.varnish-cache.org> commit c70284dfea1a0b3a7a08c19b58f846745fb1525b Author: Poul-Henning Kamp Date: Wed Sep 20 07:13:12 2017 +0000 Minor polish diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 9a2af88..8a30f59 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -43,7 +43,7 @@ static unsigned fetchfrag; * * Other code is allowed to look at busyobj->fetch_failed to bail out * - * For convenience, always return -1 + * For convenience, always return VFP_ERROR */ enum vfp_status @@ -176,14 +176,13 @@ VFP_Suck(struct vfp_ctx *vc, void *p, ssize_t *lp) vp = VFP_Suck(vc, p, lp); } else if (vfe->closed == VFP_OK) { vp = vfe->vfp->pull(vc, vfe, p, lp); - if (vp != VFP_OK && vp != VFP_END && vp != VFP_ERROR) { - (void)VFP_Error(vc, "Fetch filter %s returned %d", + if (vp != VFP_OK && vp != VFP_END && vp != VFP_ERROR) + vp = VFP_Error(vc, "Fetch filter %s returned %d", vfe->vfp->name, vp); - vp = VFP_ERROR; - } + else + vfe->bytes_out += *lp; vfe->closed = vp; vfe->calls++; - vfe->bytes_out += *lp; } else { /* Already closed filter */ *lp = 0; From phk at FreeBSD.org Wed Sep 20 08:37:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Sep 2017 08:37:08 +0000 (UTC) Subject: [master] bab3d94 Lower-case elective VFP filter names Message-ID: <20170920083708.686EDA0AB8@lists.varnish-cache.org> commit bab3d94afe6fd9357891ff5f1067dc77319c4e12 Author: Poul-Henning Kamp Date: Wed Sep 20 08:25:51 2017 +0000 Lower-case elective VFP filter names diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 734ac2a..ac95a1e 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -273,14 +273,14 @@ vfp_esi_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) } const struct vfp vfp_esi = { - .name = "ESI", + .name = "esi", .init = vfp_esi_init, .pull = vfp_esi_pull, .fini = vfp_esi_fini, }; const struct vfp vfp_esi_gzip = { - .name = "ESI_GZIP", + .name = "esi_gzip", .init = vfp_esi_gzip_init, .pull = vfp_esi_gzip_pull, .fini = vfp_esi_fini, diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 313ed52..ae58708 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -659,7 +659,7 @@ vfp_gzip_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) /*--------------------------------------------------------------------*/ const struct vfp vfp_gunzip = { - .name = "GUNZIP", + .name = "gunzip", .init = vfp_gzip_init, .pull = vfp_gunzip_pull, .fini = vfp_gzip_fini, @@ -668,7 +668,7 @@ const struct vfp vfp_gunzip = { }; const struct vfp vfp_gzip = { - .name = "GZIP", + .name = "gzip", .init = vfp_gzip_init, .pull = vfp_gzip_pull, .fini = vfp_gzip_fini, @@ -677,7 +677,7 @@ const struct vfp vfp_gzip = { }; const struct vfp vfp_testgunzip = { - .name = "TESTGUNZIP", + .name = "testgunzip", .init = vfp_gzip_init, .pull = vfp_testgunzip_pull, .fini = vfp_gzip_fini, From phk at FreeBSD.org Wed Sep 20 08:45:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Sep 2017 08:45:06 +0000 (UTC) Subject: [master] 8efe9c1 Call VFP_Error() in VFP_Push() if we run out of workspace. Message-ID: <20170920084506.E5C21A0182@lists.varnish-cache.org> commit 8efe9c1f84ea697f39c6edafcd34543286c70d70 Author: Poul-Henning Kamp Date: Wed Sep 20 08:44:09 2017 +0000 Call VFP_Error() in VFP_Push() if we run out of workspace. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 8839642..21661c8 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -566,9 +566,6 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) #define vbf_vfp_push(bo, vfp, top) \ do { \ if (VFP_Push((bo)->vfc, (vfp), (top)) == NULL) { \ - assert (WS_Overflowed((bo)->vfc->http->ws)); \ - (void)VFP_Error((bo)->vfc, \ - "workspace_backend overflow"); \ (bo)->htc->doclose = SC_OVERLOAD; \ VDI_Finish((bo)->wrk, bo); \ return (F_STP_ERROR); \ diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 8a30f59..1bb7df3 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -203,8 +203,10 @@ VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp, int top) CHECK_OBJ_NOTNULL(vc->http, HTTP_MAGIC); vfe = WS_Alloc(vc->http->ws, sizeof *vfe); - if (vfe == NULL) + if (vfe == NULL) { + (void)VFP_Error(vc, "Workspace overflow"); return (NULL); + } INIT_OBJ(vfe, VFP_ENTRY_MAGIC); vfe->vfp = vfp; diff --git a/bin/varnishtest/tests/r01739.vtc b/bin/varnishtest/tests/r01739.vtc index c839542..7b8d656 100644 --- a/bin/varnishtest/tests/r01739.vtc +++ b/bin/varnishtest/tests/r01739.vtc @@ -16,7 +16,7 @@ varnish v1 -vcl+backend { } -start logexpect l1 -v v1 -g raw { - expect * 1002 FetchError {^workspace_backend overflow} + expect * 1002 FetchError {^Workspace overflow} expect * = Error {^out of workspace [(]Bo[)]} } -start From hermunn at varnish-software.com Wed Sep 20 12:34:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Wed, 20 Sep 2017 12:34:05 +0000 (UTC) Subject: [4.1] 0ef00ea set the sigaltstack for each thread - SunOS needs it Message-ID: <20170920123405.C30FDA119B@lists.varnish-cache.org> commit 0ef00ea1d6e948b4778b10f968e0b41fbb21b6d7 Author: Nils Goroll Date: Mon Sep 4 19:48:26 2017 +0200 set the sigaltstack for each thread - SunOS needs it Ref: #2396 diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index ede1329..9ede273 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -41,6 +41,11 @@ #include "hash/hash_slinger.h" +#ifdef HAVE_SIGALTSTACK +#include +extern stack_t altstack; +#endif + static void Pool_Work_Thread(struct pool *pp, struct worker *wrk); /*-------------------------------------------------------------------- @@ -398,6 +403,9 @@ pool_thread(void *priv) struct pool_info *pi; CAST_OBJ_NOTNULL(pi, priv, POOL_INFO_MAGIC); +#ifdef HAVE_SIGALTSTACK + AZ(sigaltstack(&altstack, NULL)); +#endif WRK_Thread(pi->qp, pi->stacksize, cache_param->workspace_thread); FREE_OBJ(pi); return (NULL); diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 64c73fe..2477a5a 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -87,6 +87,10 @@ static struct vlu *child_std_vlu; static struct vsb *child_panic = NULL; static double mgt_uptime_t0 = 0.; +#ifdef HAVE_SIGALTSTACK +stack_t altstack; +#endif + static void mgt_reap_child(void); /*--------------------------------------------------------------------- @@ -396,15 +400,14 @@ mgt_launch_child(struct cli *cli) (void)sigaction(SIGABRT, &sa, NULL); #ifdef HAVE_SIGALTSTACK - stack_t ss; size_t sz = SIGSTKSZ + 4096; if (sz < mgt_param.wthread_stacksize) sz = mgt_param.wthread_stacksize; - ss.ss_sp = malloc(sz); - AN(ss.ss_sp); - ss.ss_size = sz; - ss.ss_flags = 0; - AZ(sigaltstack(&ss, NULL)); + altstack.ss_sp = malloc(sz); + AN(altstack.ss_sp); + altstack.ss_size = sz; + altstack.ss_flags = 0; + AZ(sigaltstack(&altstack, NULL)); sa.sa_flags |= SA_ONSTACK; #endif (void)sigaction(SIGSEGV, &sa, NULL); From hermunn at varnish-software.com Wed Sep 20 12:34:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Wed, 20 Sep 2017 12:34:05 +0000 (UTC) Subject: [4.1] e05e9f8 Use a separate segment for the sigaltstack Message-ID: <20170920123405.D9D7EA119E@lists.varnish-cache.org> commit e05e9f85d209ed9573ef4629991249b474523440 Author: Nils Goroll Date: Mon Sep 4 19:55:10 2017 +0200 Use a separate segment for the sigaltstack Having a stack on the heap just feels unclean, also this way we have a chance to get a red zone adjacent to the mapping just in case we manage to overflow the alt stack also. Ref: #2396 diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 2477a5a..130790d 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -88,6 +88,7 @@ static struct vsb *child_panic = NULL; static double mgt_uptime_t0 = 0.; #ifdef HAVE_SIGALTSTACK +#include stack_t altstack; #endif @@ -403,7 +404,10 @@ mgt_launch_child(struct cli *cli) size_t sz = SIGSTKSZ + 4096; if (sz < mgt_param.wthread_stacksize) sz = mgt_param.wthread_stacksize; - altstack.ss_sp = malloc(sz); + altstack.ss_sp = mmap(NULL, sz, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0); + AN(altstack.ss_sp != MAP_FAILED); AN(altstack.ss_sp); altstack.ss_size = sz; altstack.ss_flags = 0; From hermunn at varnish-software.com Wed Sep 20 12:34:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Wed, 20 Sep 2017 12:34:06 +0000 (UTC) Subject: [4.1] 772e716 Move the sigaltstack init to a generic THR_Init() and use it for all threads Message-ID: <20170920123406.1118AA11A3@lists.varnish-cache.org> commit 772e716dc639466b22b6b93410fa1a0f860fdc47 Author: Nils Goroll Date: Mon Sep 11 12:34:32 2017 +0200 Move the sigaltstack init to a generic THR_Init() and use it for all threads This is a back port to 4.1, and the conflicts are partly a result of the non inclusion of 656982a5cf7042a8576c2e9d48defcd25d749fbd in 4.1. (Back port by P?l Hermunn Johansen, hermunn at varnish-software.com) Conflicts: bin/varnishd/cache/cache_pool.c bin/varnishd/cache/cache_wrk.c diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 5b2827a..d204ff9 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -490,6 +490,7 @@ vca_acct(void *arg) double t0, now; THR_SetName("cache-acceptor"); + THR_Init(); (void)arg; (void)vca_tcp_opt_init(); diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index f0ebf83..d8b1684 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -105,6 +105,22 @@ THR_GetName(void) } /*-------------------------------------------------------------------- + * Generic setup all our threads should call + */ +#ifdef HAVE_SIGALTSTACK +#include +extern stack_t altstack; +#endif + +void +THR_Init(void) +{ +#ifdef HAVE_SIGALTSTACK + AZ(sigaltstack(&altstack, NULL)); +#endif +} + +/*-------------------------------------------------------------------- * VXID's are unique transaction numbers allocated with a minimum of * locking overhead via pools in the worker threads. * diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 472441c..88662d3 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -101,6 +101,7 @@ mpl_guard(void *priv) CAST_OBJ_NOTNULL(mpl, priv, MEMPOOL_MAGIC); THR_SetName(mpl->name); + THR_Init(); mpl_slp = 0.15; // random while (1) { VTIM_sleep(mpl_slp); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 409d2c3..874e0cb 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -190,7 +190,8 @@ pool_poolherder(void *priv) struct pool *pp; uint64_t u; - THR_SetName("pool_herder"); + THR_SetName("pool_poolherder"); + THR_Init(); (void)priv; nwq = 0; diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index 521f569..ef0ea26 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -96,6 +96,7 @@ void THR_SetBusyobj(const struct busyobj *); struct busyobj * THR_GetBusyobj(void); void THR_SetRequest(const struct req *); struct req * THR_GetRequest(void); +void THR_Init(void); /* cache_lck.c */ void LCK_Init(void); diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 9ede273..2355752 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -41,11 +41,6 @@ #include "hash/hash_slinger.h" -#ifdef HAVE_SIGALTSTACK -#include -extern stack_t altstack; -#endif - static void Pool_Work_Thread(struct pool *pp, struct worker *wrk); /*-------------------------------------------------------------------- @@ -69,6 +64,7 @@ wrk_bgthread(void *arg) CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC); THR_SetName(bt->name); + THR_Init(); INIT_OBJ(&wrk, WORKER_MAGIC); (void)bt->func(&wrk, bt->priv); @@ -403,9 +399,7 @@ pool_thread(void *priv) struct pool_info *pi; CAST_OBJ_NOTNULL(pi, priv, POOL_INFO_MAGIC); -#ifdef HAVE_SIGALTSTACK - AZ(sigaltstack(&altstack, NULL)); -#endif + THR_Init(); WRK_Thread(pi->qp, pi->stacksize, cache_param->workspace_thread); FREE_OBJ(pi); return (NULL); @@ -477,6 +471,9 @@ pool_herder(void *priv) CAST_OBJ_NOTNULL(pp, priv, POOL_MAGIC); + THR_SetName("pool_herder"); + THR_Init(); + while (1) { wthread_min = cache_param->wthread_min; diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 68afcb2..71c426a 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -86,6 +86,7 @@ vwe_thread(void *priv) w = vwe->waiter; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-epoll"); + THR_Init(); now = VTIM_real(); while (1) { diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 5518875..ec191a7 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -77,6 +77,7 @@ vwk_thread(void *priv) w = vwk->waiter; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-kqueue"); + THR_Init(); now = VTIM_real(); while (1) { diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index ed3a39c..6c72cb1 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -162,6 +162,7 @@ vwp_main(void *priv) int i; THR_SetName("cache-poll"); + THR_Init(); CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC); w = vwp->waiter; diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 705e442..499249f 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -150,6 +150,7 @@ vws_thread(void *priv) w = vws->waiter; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); THR_SetName("cache-ports"); + THR_Init(); now = VTIM_real(); From phk at FreeBSD.org Wed Sep 20 19:01:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Sep 2017 19:01:04 +0000 (UTC) Subject: [master] 5fbe576 Move the beresp body determination to rfc2616 territory. Message-ID: <20170920190104.277C6A486F@lists.varnish-cache.org> commit 5fbe576f9907d603435ec7afd6dfd893350b396f Author: Poul-Henning Kamp Date: Wed Sep 20 13:43:52 2017 +0000 Move the beresp body determination to rfc2616 territory. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e3bc4d4..a1e8b36 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1076,6 +1076,7 @@ unsigned RFC2616_Req_Gzip(const struct http *); int RFC2616_Do_Cond(const struct req *sp); void RFC2616_Weaken_Etag(struct http *hp); void RFC2616_Vary_AE(struct http *hp); +void RFC2616_Response_Body(const struct worker *, const struct busyobj *); /* stevedore.c */ int STV_NewObject(struct worker *, struct objcore *, diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 21661c8..0dc81de 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -304,6 +304,15 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) http_VSL_log(bo->beresp); + RFC2616_Response_Body(wrk, bo); + if (bo->htc->body_status == BS_ERROR) { + bo->htc->doclose = SC_RX_BODY; + VDI_Finish(bo->wrk, bo); + VSLb(bo->vsl, SLT_Error, "Body cannot be fetched"); + assert(bo->director_state == DIR_S_NULL); + return (F_STP_ERROR); + } + if (!http_GetHdr(bo->beresp, H_Date, NULL)) { /* * RFC 2616 14.18 Date: The Date general-header field @@ -327,68 +336,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) http_CollectHdr(bo->beresp, H_Cache_Control); http_CollectHdr(bo->beresp, H_Vary); - /* - * Figure out how the fetch is supposed to happen, before the - * headers are adultered by VCL - */ - if (!strcasecmp(http_GetMethod(bo->bereq), "head")) { - /* - * A HEAD request can never have a body in the reply, - * no matter what the headers might say. - * [RFC7231 4.3.2 p25] - */ - wrk->stats->fetch_head++; - bo->htc->body_status = BS_NONE; - } else if (http_GetStatus(bo->beresp) <= 199) { - /* - * 1xx responses never have a body. - * [RFC7230 3.3.2 p31] - * ... but we should never see them. - */ - wrk->stats->fetch_1xx++; - bo->htc->body_status = BS_ERROR; - } else if (http_IsStatus(bo->beresp, 204)) { - /* - * 204 is "No Content", obviously don't expect a body. - * [RFC7230 3.3.1 p29 and 3.3.2 p31] - */ - wrk->stats->fetch_204++; - if ((http_GetHdr(bo->beresp, H_Content_Length, NULL) && - bo->htc->content_length != 0) || - http_GetHdr(bo->beresp, H_Transfer_Encoding, NULL)) - bo->htc->body_status = BS_ERROR; - else - bo->htc->body_status = BS_NONE; - } else if (http_IsStatus(bo->beresp, 304)) { - /* - * 304 is "Not Modified" it has no body. - * [RFC7230 3.3 p28] - */ - wrk->stats->fetch_304++; - bo->htc->body_status = BS_NONE; - } else if (bo->htc->body_status == BS_CHUNKED) { - wrk->stats->fetch_chunked++; - } else if (bo->htc->body_status == BS_LENGTH) { - assert(bo->htc->content_length > 0); - wrk->stats->fetch_length++; - } else if (bo->htc->body_status == BS_EOF) { - wrk->stats->fetch_eof++; - } else if (bo->htc->body_status == BS_ERROR) { - wrk->stats->fetch_bad++; - } else if (bo->htc->body_status == BS_NONE) { - wrk->stats->fetch_none++; - } else { - WRONG("wrong bodystatus"); - } - - if (bo->htc->body_status == BS_ERROR) { - bo->htc->doclose = SC_RX_BODY; - VDI_Finish(bo->wrk, bo); - VSLb(bo->vsl, SLT_Error, "Body cannot be fetched"); - assert(bo->director_state == DIR_S_NULL); - return (F_STP_ERROR); - } - if (bo->fetch_objcore->flags & OC_F_PRIVATE) { /* private objects have negative TTL */ bo->fetch_objcore->t_origin = now; diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index c649897..67679e1 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -325,3 +325,68 @@ RFC2616_Vary_AE(struct http *hp) http_SetHeader(hp, "Vary: Accept-Encoding"); } } + +/*--------------------------------------------------------------------*/ + +void +RFC2616_Response_Body(const struct worker *wrk, const struct busyobj *bo) +{ + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + + /* + * Figure out how the fetch is supposed to happen, before the + * headers are adultered by VCL + */ + if (!strcasecmp(http_GetMethod(bo->bereq), "head")) { + /* + * A HEAD request can never have a body in the reply, + * no matter what the headers might say. + * [RFC7231 4.3.2 p25] + */ + wrk->stats->fetch_head++; + bo->htc->body_status = BS_NONE; + } else if (http_GetStatus(bo->beresp) <= 199) { + /* + * 1xx responses never have a body. + * [RFC7230 3.3.2 p31] + * ... but we should never see them. + */ + wrk->stats->fetch_1xx++; + bo->htc->body_status = BS_ERROR; + } else if (http_IsStatus(bo->beresp, 204)) { + /* + * 204 is "No Content", obviously don't expect a body. + * [RFC7230 3.3.1 p29 and 3.3.2 p31] + */ + wrk->stats->fetch_204++; + if ((http_GetHdr(bo->beresp, H_Content_Length, NULL) && + bo->htc->content_length != 0) || + http_GetHdr(bo->beresp, H_Transfer_Encoding, NULL)) + bo->htc->body_status = BS_ERROR; + else + bo->htc->body_status = BS_NONE; + } else if (http_IsStatus(bo->beresp, 304)) { + /* + * 304 is "Not Modified" it has no body. + * [RFC7230 3.3 p28] + */ + wrk->stats->fetch_304++; + bo->htc->body_status = BS_NONE; + } else if (bo->htc->body_status == BS_CHUNKED) { + wrk->stats->fetch_chunked++; + } else if (bo->htc->body_status == BS_LENGTH) { + assert(bo->htc->content_length > 0); + wrk->stats->fetch_length++; + } else if (bo->htc->body_status == BS_EOF) { + wrk->stats->fetch_eof++; + } else if (bo->htc->body_status == BS_ERROR) { + wrk->stats->fetch_bad++; + } else if (bo->htc->body_status == BS_NONE) { + wrk->stats->fetch_none++; + } else { + WRONG("wrong bodystatus"); + } +} + From phk at FreeBSD.org Wed Sep 20 19:01:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Sep 2017 19:01:04 +0000 (UTC) Subject: [master] 503a643 Move the responsibility for conclusively deciding beresp->body_status to the VDIR. Message-ID: <20170920190104.454F7A4873@lists.varnish-cache.org> commit 503a64302d7a4160cbf9f15bfedd265a352f14d7 Author: Poul-Henning Kamp Date: Wed Sep 20 13:51:32 2017 +0000 Move the responsibility for conclusively deciding beresp->body_status to the VDIR. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 0dc81de..2715c91 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -304,7 +304,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) http_VSL_log(bo->beresp); - RFC2616_Response_Body(wrk, bo); if (bo->htc->body_status == BS_ERROR) { bo->htc->doclose = SC_RX_BODY; VDI_Finish(bo->wrk, bo); diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index e5032eb..87a3194 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -201,6 +201,7 @@ V1F_FetchRespHdr(struct busyobj *bo) } htc->doclose = http_DoConnection(hp); + RFC2616_Response_Body(bo->wrk, bo); return (0); } From phk at FreeBSD.org Wed Sep 20 19:01:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Sep 2017 19:01:04 +0000 (UTC) Subject: [master] 4fc2d87 Make vdir->getbody() optional. Message-ID: <20170920190104.5ECA1A4878@lists.varnish-cache.org> commit 4fc2d87fed53839ea9c87cb12140fd90da93241e Author: Poul-Henning Kamp Date: Wed Sep 20 13:53:09 2017 +0000 Make vdir->getbody() optional. diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 2fc5b5a..0f65369 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -99,10 +99,11 @@ VDI_GetBody(struct worker *wrk, struct busyobj *bo) d = bo->director_resp; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); AZ(d->resolve); - AN(d->getbody); assert(bo->director_state == DIR_S_HDRS); bo->director_state = DIR_S_BODY; + if (d->getbody == NULL) + return (0); return (d->getbody(d, wrk, bo)); } From phk at FreeBSD.org Wed Sep 20 19:01:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Sep 2017 19:01:04 +0000 (UTC) Subject: [master] cbc7cec Setup the VFP already when we have fetched the headers. Message-ID: <20170920190104.7AA22A487C@lists.varnish-cache.org> commit cbc7cec63fd0d609f1040b49f2f1f704606bb773 Author: Poul-Henning Kamp Date: Wed Sep 20 14:00:42 2017 +0000 Setup the VFP already when we have fetched the headers. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 4e75b2f..b9d6829 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -242,20 +242,6 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, return (-1); } -static int __match_proto__(vdi_getbody_f) -vbe_dir_getbody(const struct director *d, struct worker *wrk, - struct busyobj *bo) -{ - - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->vfc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC); - - return (V1F_Setup_Fetch(bo->vfc, bo->htc)); -} - static const struct suckaddr * __match_proto__(vdi_getip_f) vbe_dir_getip(const struct director *d, struct worker *wrk, struct busyobj *bo) @@ -355,7 +341,6 @@ VBE_fill_director(struct backend *be) d->http1pipe = vbe_dir_http1pipe; d->healthy = vbe_dir_healthy; d->gethdrs = vbe_dir_gethdrs; - d->getbody = vbe_dir_getbody; d->getip = vbe_dir_getip; d->finish = vbe_dir_finish; d->panic = vbe_panic; diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index 87a3194..3e230cb 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -203,5 +203,10 @@ V1F_FetchRespHdr(struct busyobj *bo) htc->doclose = http_DoConnection(hp); RFC2616_Response_Body(bo->wrk, bo); + bo->vfc->http = bo->beresp; + if (bo->htc->body_status != BS_NONE && + bo->htc->body_status != BS_ERROR) + (void)V1F_Setup_Fetch(bo->vfc, bo->htc); + return (0); } From phk at FreeBSD.org Wed Sep 20 19:01:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Sep 2017 19:01:04 +0000 (UTC) Subject: [master] 8e5fd19 Remove last, now unused argument of VFP_Push() Message-ID: <20170920190104.94005A4880@lists.varnish-cache.org> commit 8e5fd19df2529b1706759e47e7e05bd145101f63 Author: Poul-Henning Kamp Date: Wed Sep 20 19:00:08 2017 +0000 Remove last, now unused argument of VFP_Push() diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2715c91..2eb23bf 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -509,9 +509,9 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) /*-------------------------------------------------------------------- */ -#define vbf_vfp_push(bo, vfp, top) \ +#define vbf_vfp_push(bo, vfp) \ do { \ - if (VFP_Push((bo)->vfc, (vfp), (top)) == NULL) { \ + if (VFP_Push((bo)->vfc, (vfp)) == NULL) { \ (bo)->htc->doclose = SC_OVERLOAD; \ VDI_Finish((bo)->wrk, bo); \ return (F_STP_ERROR); \ @@ -573,19 +573,19 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->do_gzip == 0 || bo->do_gunzip == 0); if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) - vbf_vfp_push(bo, &vfp_gunzip, 1); + vbf_vfp_push(bo, &vfp_gunzip); if (bo->htc->content_length != 0) { if (bo->do_esi && bo->do_gzip) { - vbf_vfp_push(bo, &vfp_esi_gzip, 1); + vbf_vfp_push(bo, &vfp_esi_gzip); } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { - vbf_vfp_push(bo, &vfp_esi_gzip, 1); + vbf_vfp_push(bo, &vfp_esi_gzip); } else if (bo->do_esi) { - vbf_vfp_push(bo, &vfp_esi, 1); + vbf_vfp_push(bo, &vfp_esi); } else if (bo->do_gzip) { - vbf_vfp_push(bo, &vfp_gzip, 1); + vbf_vfp_push(bo, &vfp_gzip); } else if (bo->is_gzip && !bo->do_gunzip) { - vbf_vfp_push(bo, &vfp_testgunzip, 1); + vbf_vfp_push(bo, &vfp_testgunzip); } } diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 1bb7df3..fcc4924 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -195,7 +195,7 @@ VFP_Suck(struct vfp_ctx *vc, void *p, ssize_t *lp) /*-------------------------------------------------------------------- */ struct vfp_entry * -VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp, int top) +VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp) { struct vfp_entry *vfe; @@ -211,12 +211,8 @@ VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp, int top) INIT_OBJ(vfe, VFP_ENTRY_MAGIC); vfe->vfp = vfp; vfe->closed = VFP_OK; - if (top) - VTAILQ_INSERT_HEAD(&vc->vfp, vfe, list); - else - VTAILQ_INSERT_TAIL(&vc->vfp, vfe, list); - if (VTAILQ_FIRST(&vc->vfp) == vfe) - vc->vfp_nxt = vfe; + VTAILQ_INSERT_HEAD(&vc->vfp, vfe, list); + vc->vfp_nxt = vfe; return (vfe); } diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 064c94f..6d642aa 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -74,7 +74,7 @@ extern const struct vfp vfp_testgunzip; extern const struct vfp vfp_esi; extern const struct vfp vfp_esi_gzip; -struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *, int top); +struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *); void VFP_Setup(struct vfp_ctx *vc); int VFP_Open(struct vfp_ctx *bo); void VFP_Close(struct vfp_ctx *bo); diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c index e57262c..35c13a6 100644 --- a/bin/varnishd/http1/cache_http1_vfp.c +++ b/bin/varnishd/http1/cache_http1_vfp.c @@ -267,21 +267,21 @@ V1F_Setup_Fetch(struct vfp_ctx *vfc, struct http_conn *htc) switch (htc->body_status) { case BS_EOF: assert(htc->content_length == -1); - vfe = VFP_Push(vfc, &v1f_eof, 0); + vfe = VFP_Push(vfc, &v1f_eof); if (vfe == NULL) return (ENOSPC); vfe->priv2 = 0; break; case BS_LENGTH: assert(htc->content_length > 0); - vfe = VFP_Push(vfc, &v1f_straight, 0); + vfe = VFP_Push(vfc, &v1f_straight); if (vfe == NULL) return (ENOSPC); vfe->priv2 = htc->content_length; break; case BS_CHUNKED: assert(htc->content_length == -1); - vfe = VFP_Push(vfc, &v1f_chunked, 0); + vfe = VFP_Push(vfc, &v1f_chunked); if (vfe == NULL) return (ENOSPC); vfe->priv2 = -1; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 4dc75f1..4eff4e0 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -750,7 +750,7 @@ h2_req_body(struct req *req) CHECK_OBJ(req, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); - vfe = VFP_Push(req->vfc, &h2_body, 0); + vfe = VFP_Push(req->vfc, &h2_body); AN(vfe); vfe->priv1 = r2; } From nils.goroll at uplex.de Thu Sep 21 15:16:08 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 21 Sep 2017 15:16:08 +0000 (UTC) Subject: [master] 1daa9be Error checking for vsb allocation failure in VRT_synth_page() / VCL synthetic() Message-ID: <20170921151608.BFB95A4449@lists.varnish-cache.org> commit 1daa9be95e283e9e73376c45ae7cf28c67cfb054 Author: Nils Goroll Date: Thu Sep 21 17:05:45 2017 +0200 Error checking for vsb allocation failure in VRT_synth_page() / VCL synthetic() diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index ecd2374..cf57413 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -438,7 +438,11 @@ VRT_synth_page(VRT_CTX, const char *str, ...) while (p != vrt_magic_string_end) { if (p == NULL) p = "(null)"; - VSB_cat(vsb, p); + if (VSB_cat(vsb, p)) { + VRT_fail(ctx, "synthetic(): %s", + strerror(VSB_error(vsb))); + break; + } p = va_arg(ap, const char *); } va_end(ap); From phk at FreeBSD.org Sat Sep 23 10:16:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 10:16:09 +0000 (UTC) Subject: [master] 82ac538 Make vrt.h explicitly depend on vdef.h Message-ID: <20170923101609.9D9F8A42B9@lists.varnish-cache.org> commit 82ac538723e8c1625a357a9535f5575cc759319c Author: Poul-Henning Kamp Date: Sat Sep 23 09:03:35 2017 +0000 Make vrt.h explicitly depend on vdef.h diff --git a/include/vrt.h b/include/vrt.h index 3d59bfe..b8e1323 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -31,6 +31,11 @@ * NB: When this file is changed, lib/libvcc/generate.py *MUST* be rerun. */ +#ifdef VRT_H_INCLUDED +# error "vrt.h included multiple times" +#endif +#define VRT_H_INCLUDED + /*********************************************************************** * Major and minor VRT API versions. * @@ -73,12 +78,12 @@ /***********************************************************************/ -#ifdef __v_printflike -# define __vrt_printflike(a,b) __v_printflike(a,b) -#else -# define __vrt_printflike(a,b) +#ifndef VDEF_H_INCLUDED +# error "include vdef.h before vrt.h" #endif +/***********************************************************************/ + struct VCL_conf; struct vrt_acl; struct busyobj; @@ -310,7 +315,7 @@ struct http *VRT_selecthttp(VRT_CTX, enum gethdr_e); const char *VRT_GetHdr(VRT_CTX, const struct gethdr_s *); void VRT_SetHdr(VRT_CTX, const struct gethdr_s *, const char *, ...); void VRT_handling(VRT_CTX, unsigned hand); -void VRT_fail(VRT_CTX, const char *fmt, ...) __vrt_printflike(2,3); +void VRT_fail(VRT_CTX, const char *fmt, ...) __v_printflike(2,3); void VRT_hashdata(VRT_CTX, const char *str, ...); From phk at FreeBSD.org Sat Sep 23 10:16:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 10:16:09 +0000 (UTC) Subject: [master] c90c1d6 Nitpicking Message-ID: <20170923101609.E1779A42BC@lists.varnish-cache.org> commit c90c1d6a768ac2531ea846fbde8795992c139f4e Author: Poul-Henning Kamp Date: Sat Sep 23 09:17:15 2017 +0000 Nitpicking diff --git a/include/vrt.h b/include/vrt.h index b8e1323..8bba11d 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -94,6 +94,7 @@ struct stevedore; struct suckaddr; struct vcl; struct vmod; +struct vmod_priv; struct vsb; struct vsl_log; struct ws; @@ -346,7 +347,6 @@ VCL_VCL VRT_vcl_get(VRT_CTX, const char *); void VRT_vcl_rel(VRT_CTX, VCL_VCL); void VRT_vcl_select(VRT_CTX, VCL_VCL); -struct vmod_priv; typedef void vmod_priv_free_f(void *); struct vmod_priv { void *priv; diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index d2e7a30..6636f61 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -757,10 +757,9 @@ class vcc(object): self.commit_files.append(fn) fo = open(fn + ".tmp", "w") write_c_file_warning(fo) - fo.write("struct vmod_priv;\n") - fo.write("\n") - fo.write("extern const struct vmod_data Vmod_%s_Data;\n" % - (self.modname)) + fo.write("#ifndef VRT_H_INCLUDED\n") + fo.write('# error "Include vrt.h first"\n') + fo.write("#endif\n") fo.write("\n") for j in self.contents: @@ -793,7 +792,9 @@ class vcc(object): def api(self, fo): for i in (714, 759, 765): fo.write("\n/*lint -esym(%d, Vmod_%s_Data) */\n" % (i, self.modname)) - fo.write("const struct vmod_data Vmod_%s_Data = {\n" % + fo.write("\nextern const struct vmod_data Vmod_%s_Data;\n" % + (self.modname)) + fo.write("\nconst struct vmod_data Vmod_%s_Data = {\n" % self.modname) if strict_abi: fo.write("\t.vrt_major =\t0,\n") From phk at FreeBSD.org Sat Sep 23 10:16:10 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 10:16:10 +0000 (UTC) Subject: [master] 59db320 Sort vrt.h and vcl.h out. Message-ID: <20170923101610.4A8ACA42C8@lists.varnish-cache.org> commit 59db32098f8d0c0f658d7a05994837abddca7b6f Author: Poul-Henning Kamp Date: Sat Sep 23 09:56:28 2017 +0000 Sort vrt.h and vcl.h out. vrt.h is required before vcl.h, which only contains the table generated parts of the VRT api. diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 64154f4..04d65ba 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -38,9 +38,9 @@ #include #include -#include "vcl.h" #include "vcli_serve.h" #include "vrt.h" +#include "vcl.h" #include "vtim.h" #include "cache_director.h" diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2eb23bf..01d1eac 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -34,6 +34,7 @@ #include "cache_filter.h" #include "hash/hash_slinger.h" #include "storage/storage.h" +#include "vrt.h" #include "vcl.h" #include "vtim.h" diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 0b56b80..9e1fbe5 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -45,6 +45,7 @@ #include "hash/hash_slinger.h" #include "storage/storage.h" +#include "vrt.h" #include "vcl.h" #include "vsha256.h" #include "vtim.h" diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index bf8831d..ac7c4d8 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -37,8 +37,8 @@ #include #include -#include "vcl.h" #include "vrt.h" +#include "vcl.h" #include "cache_director.h" #include "cache_backend.h" diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index cf57413..4f4c64b 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -36,8 +36,8 @@ #include "cache_director.h" #include "hash/hash_slinger.h" #include "vav.h" -#include "vcl.h" #include "vrt.h" +#include "vcl.h" #include "vrt_obj.h" #include "vsa.h" #include "vtcp.h" diff --git a/include/vrt.h b/include/vrt.h index 8bba11d..db34e79 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -85,7 +85,6 @@ /***********************************************************************/ struct VCL_conf; -struct vrt_acl; struct busyobj; struct director; struct http; @@ -95,6 +94,7 @@ struct suckaddr; struct vcl; struct vmod; struct vmod_priv; +struct vrt_acl; struct vsb; struct vsl_log; struct ws; @@ -166,7 +166,9 @@ struct vrt_ctx { #define VRT_CTX const struct vrt_ctx *ctx -/***********************************************************************/ +/*********************************************************************** + * This is the interface structure to a compiled VMOD + */ struct vmod_data { /* The version/id fields must be first, they protect the rest */ @@ -182,16 +184,39 @@ struct vmod_data { const char *abi; }; -/***********************************************************************/ +/*********************************************************************** + * Enum for which HTTP header-sets we can access + */ + +enum gethdr_e { + HDR_REQ, + HDR_REQ_TOP, + HDR_RESP, + HDR_OBJ, + HDR_BEREQ, + HDR_BERESP +}; -enum gethdr_e { HDR_REQ, HDR_REQ_TOP, HDR_RESP, HDR_OBJ, HDR_BEREQ, - HDR_BERESP }; +/*********************************************************************** + * Enum for events sent to compiled VCL and from there to Vmods + */ + +enum vcl_event_e { + VCL_EVENT_LOAD, + VCL_EVENT_WARM, + VCL_EVENT_COLD, + VCL_EVENT_DISCARD, +}; + +/***********************************************************************/ struct gethdr_s { enum gethdr_e where; const char *what; }; +/***********************************************************************/ + extern const void * const vrt_magic_string_end; extern const void * const vrt_magic_string_unset; @@ -354,10 +379,6 @@ struct vmod_priv { vmod_priv_free_f *free; }; -#ifdef VCL_RET_MAX -typedef int vmod_event_f(VRT_CTX, struct vmod_priv *, enum vcl_event_e); -#endif - struct vclref; struct vclref * VRT_ref_vcl(VRT_CTX, const char *); void VRT_rel_vcl(VRT_CTX, struct vclref **); @@ -380,3 +401,9 @@ const char *VRT_BOOL_string(VCL_BOOL); const char *VRT_BACKEND_string(VCL_BACKEND); const char *VRT_STEVEDORE_string(VCL_STEVEDORE); const char *VRT_CollectString(VRT_CTX, const char *p, ...); + +typedef int vcl_event_f(VRT_CTX, enum vcl_event_e); +typedef int vcl_init_f(VRT_CTX); +typedef void vcl_fini_f(VRT_CTX); +typedef void vcl_func_f(VRT_CTX); +typedef int vmod_event_f(VRT_CTX, struct vmod_priv *, enum vcl_event_e); diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 64e2167..e65f215 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -1108,25 +1108,14 @@ fo = open(join(buildroot, "include/vcl.h"), "w") file_header(fo) fo.write(""" -struct vrt_ctx; -#define VRT_CTX const struct vrt_ctx *ctx -struct req; -struct busyobj; -struct ws; -struct cli; -struct worker; - -enum vcl_event_e { - VCL_EVENT_LOAD, - VCL_EVENT_WARM, - VCL_EVENT_COLD, - VCL_EVENT_DISCARD, -}; - -typedef int vcl_event_f(VRT_CTX, enum vcl_event_e); -typedef int vcl_init_f(VRT_CTX); -typedef void vcl_fini_f(VRT_CTX); -typedef void vcl_func_f(VRT_CTX); +#ifdef VCL_H_INCLUDED +# error "vcl.h included multiple times" +#endif +#define VCL_H_INCLUDED + +#ifndef VRT_H_INCLUDED +# error "include vrt.h before vcl.h" +#endif """) diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 3fcc333..9dd361e 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -39,8 +39,6 @@ #include "vcc_compile.h" -#include "vrt.h" - struct acl_e { VTAILQ_ENTRY(acl_e) list; unsigned char data[VRT_ACL_MAXADDR + 1]; diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 5a5ffbb..600bcb5 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -32,9 +32,10 @@ #include #include "miniobj.h" +#include "vdef.h" #include "vas.h" +#include "vrt.h" #include "vcl.h" -#include "vdef.h" #include "vqueue.h" #include "vsb.h" diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 543ed1e..12d21fd 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -37,7 +37,6 @@ #include "libvcc.h" #include "vfil.h" #include "vmod_abi.h" -#include "vrt.h" static int vcc_path_dlopen(void *priv, const char *fn) diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 6636f61..6e40650 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -497,9 +497,7 @@ class s_event(stanza): self.event_func) def hfile(self, fo): - fo.write("#ifdef VCL_MET_MAX\n") fo.write("vmod_event_f %s;\n" % self.event_func) - fo.write("#endif\n") def cstruct(self, fo): fo.write("\tvmod_event_f\t\t\t*_event;\n") @@ -828,7 +826,7 @@ class vcc(object): fo.write('#include "config.h"\n') fo.write('#include \n') - for i in ["vdef", "vcl", "vrt", self.pfx, "vmod_abi"]: + for i in ["vdef", "vrt", self.pfx, "vmod_abi"]: fo.write('#include "%s.h"\n' % i) fo.write("\n") diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 7e58db1..40702d1 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -30,7 +30,6 @@ #include #include -#include "vcl.h" #include "vdef.h" #include "vrt.h" diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 09312cf..8a1fe41 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -34,7 +34,6 @@ #include "cache/cache.h" -#include "vcl.h" #include "vrt.h" #include "vsa.h" #include "vsb.h" diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c index eecfb7f..caed6bc 100644 --- a/lib/libvmod_debug/vmod_debug_dyn.c +++ b/lib/libvmod_debug/vmod_debug_dyn.c @@ -33,7 +33,6 @@ #include "cache/cache.h" -#include "vcl.h" #include "vrt.h" #include "cache/cache_director.h" @@ -121,8 +120,7 @@ vmod_dyn__init(VRT_CTX, struct vmod_debug_dyn **dynp, if (*addr == '\0' || *port == '\0') { AN(ctx->handling); AZ(*ctx->handling); - VSB_printf(ctx->msg, "Missing dynamic backend address or port"); - VRT_handling(ctx, VCL_RET_FAIL); + VRT_fail(ctx, "Missing dynamic backend address or port"); return; } From phk at FreeBSD.org Sat Sep 23 10:16:10 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 10:16:10 +0000 (UTC) Subject: [master] 9c31eb7 Reflect required vdef->vrt->vcl order Message-ID: <20170923101610.878FEA42D0@lists.varnish-cache.org> commit 9c31eb702852c5c214644e06f439e93e5cb5549c Author: Poul-Henning Kamp Date: Sat Sep 23 10:10:36 2017 +0000 Reflect required vdef->vrt->vcl order diff --git a/include/Makefile.am b/include/Makefile.am index a77cae9..b3401c2 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -127,8 +127,8 @@ noinst_PROGRAMS = vbm_test vbm_test_SOURCES = vbm_test.c vbm.h -vrt.c: vrt.h - cp $(srcdir)/vrt.h $@ +vrt.c: Makefile.am vdef.h vrt.h + cat $(srcdir)/vdef.h $(srcdir)/vrt.h > $@ vrt_test: vrt.c echo "exec ${CC} -c -o _vrt_test vrt.c" > $@ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index e65f215..2f24b78 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -1300,8 +1300,8 @@ vcl_output_lang_h(struct vsb *sb) """) emit_file(fo, srcroot, "include/vdef.h") -emit_file(fo, buildroot, "include/vcl.h") emit_file(fo, srcroot, "include/vrt.h") +emit_file(fo, buildroot, "include/vcl.h") emit_file(fo, buildroot, "include/vrt_obj.h") fo.write("\n}\n") From phk at FreeBSD.org Sat Sep 23 11:41:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 11:41:08 +0000 (UTC) Subject: [master] 0199bde Make symbol names in VCL case insensitive. Message-ID: <20170923114108.8E0B2A46D8@lists.varnish-cache.org> commit 0199bdeb09a9a1e3d1c2271456f39798a6b2f06c Author: Poul-Henning Kamp Date: Sat Sep 23 11:39:36 2017 +0000 Make symbol names in VCL case insensitive. diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 31d3492..2ee26b4 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -134,7 +134,7 @@ VCC_Symbol(struct vcc *tl, struct symbol *parent, assert(l > 0); VTAILQ_FOREACH(sym, &parent->children, list) { - i = strncmp(sym->name, b, l); + i = strncasecmp(sym->name, b, l); if (i < 0) continue; if (i > 0 || l < sym->nlen) { From phk at FreeBSD.org Sat Sep 23 11:56:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 11:56:06 +0000 (UTC) Subject: [master] 784af0b VCL symbols are case insenstive now Message-ID: <20170923115606.5FEB5A4D85@lists.varnish-cache.org> commit 784af0b7f5c7d143ea60d838af75aade8f41e929 Author: Poul-Henning Kamp Date: Sat Sep 23 11:44:22 2017 +0000 VCL symbols are case insenstive now diff --git a/bin/varnishtest/tests/m00045.vtc b/bin/varnishtest/tests/m00045.vtc index 345534c..0106711 100644 --- a/bin/varnishtest/tests/m00045.vtc +++ b/bin/varnishtest/tests/m00045.vtc @@ -296,7 +296,7 @@ varnish v1 -errvcl {vmod blob error: blob is empty in blob.sub()} { sub vcl_init { new empty = blob.blob(IDENTITY, ""); if (blob.same(empty.get(), blob.sub(empty.get(), 0B))) { - new B = blob.blob(IDENTITY, "b"); + new bl = blob.blob(IDENTITY, "b"); } } } @@ -308,7 +308,7 @@ varnish v1 -errvcl {vmod blob error: size 9 from offset 0 requires more bytes th sub vcl_init { new up07 = blob.blob(BASE64, "AAECAwQFBgc="); if (blob.same(up07.get(), blob.sub(up07.get(), 9B))) { - new B = blob.blob(IDENTITY, "b"); + new bl = blob.blob(IDENTITY, "b"); } } } @@ -320,7 +320,7 @@ varnish v1 -errvcl {vmod blob error: size 4 from offset 5 requires more bytes th sub vcl_init { new up07 = blob.blob(BASE64, "AAECAwQFBgc="); if (blob.same(up07.get(), blob.sub(up07.get(), 4B, 5B))) { - new B = blob.blob(IDENTITY, "b"); + new bl = blob.blob(IDENTITY, "b"); } } } From phk at FreeBSD.org Sat Sep 23 11:56:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 11:56:06 +0000 (UTC) Subject: [master] 6aead7b Polish Message-ID: <20170923115606.A1ED3A4D88@lists.varnish-cache.org> commit 6aead7b385e25f93f6754ced28d4b44e9bbf5731 Author: Poul-Henning Kamp Date: Sat Sep 23 11:50:54 2017 +0000 Polish diff --git a/include/Makefile.am b/include/Makefile.am index b3401c2..dde6a89 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -119,7 +119,7 @@ CLEANFILES = \ $(GENERATED_H) \ vrt_test \ _vrt_test \ - vrt.c + _vrt.c TESTS = vbm_test vrt_test @@ -127,11 +127,11 @@ noinst_PROGRAMS = vbm_test vbm_test_SOURCES = vbm_test.c vbm.h -vrt.c: Makefile.am vdef.h vrt.h +_vrt.c: Makefile.am vdef.h vrt.h cat $(srcdir)/vdef.h $(srcdir)/vrt.h > $@ -vrt_test: vrt.c - echo "exec ${CC} -c -o _vrt_test vrt.c" > $@ +vrt_test: _vrt.c + echo "exec ${CC} -c -o _vrt_test _vrt.c" > $@ chmod +x $@ test: ${TESTS} diff --git a/include/vrt.h b/include/vrt.h index db34e79..fc08b68 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -36,6 +36,10 @@ #endif #define VRT_H_INCLUDED +#ifndef VDEF_H_INCLUDED +# error "include vdef.h before vrt.h" +#endif + /*********************************************************************** * Major and minor VRT API versions. * @@ -75,13 +79,6 @@ #define VRT_MINOR_VERSION 1U - -/***********************************************************************/ - -#ifndef VDEF_H_INCLUDED -# error "include vdef.h before vrt.h" -#endif - /***********************************************************************/ struct VCL_conf; From phk at FreeBSD.org Sat Sep 23 21:06:10 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 21:06:10 +0000 (UTC) Subject: [master] c27c7bb Give the VGZ functions their own include file Message-ID: <20170923210610.7C8A9A40C5@lists.varnish-cache.org> commit c27c7bb5cdafdd24fb4f2879a7cce33eeddbd02a Author: Poul-Henning Kamp Date: Sat Sep 23 21:05:07 2017 +0000 Give the VGZ functions their own include file diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 0abe151..7fe38a5 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -119,6 +119,7 @@ noinst_HEADERS = \ cache/cache_pool.h \ cache/cache_priv.h \ cache/cache_transport.h \ + cache/cache_vgz.h \ common/heritage.h \ hash/hash_slinger.h \ hpack/vhp.h \ diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a1e8b36..f970f53 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -712,36 +712,6 @@ enum vbf_fetch_mode_e { void VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, struct objcore *oldoc, enum vbf_fetch_mode_e); -/* cache_gzip.c */ -struct vgz; - -enum vgzret_e { - VGZ_ERROR = -1, - VGZ_OK = 0, - VGZ_END = 1, - VGZ_STUCK = 2, -}; - -enum vgz_flag { VGZ_NORMAL, VGZ_ALIGN, VGZ_RESET, VGZ_FINISH }; -// struct vgz *VGZ_NewUngzip(struct vsl_log *vsl, const char *id); -struct vgz *VGZ_NewGzip(struct vsl_log *vsl, const char *id); -void VGZ_Ibuf(struct vgz *, const void *, ssize_t len); -int VGZ_IbufEmpty(const struct vgz *vg); -void VGZ_Obuf(struct vgz *, void *, ssize_t len); -int VGZ_ObufFull(const struct vgz *vg); -enum vgzret_e VGZ_Gzip(struct vgz *, const void **, ssize_t *len, - enum vgz_flag); -// enum vgzret_e VGZ_Gunzip(struct vgz *, const void **, ssize_t *len); -enum vgzret_e VGZ_Destroy(struct vgz **); - -enum vgz_ua_e { - VUA_UPDATE, // Update start/stop/last bits if changed - VUA_END_GZIP, // Record uncompressed size - VUA_END_GUNZIP, // Record uncompressed size -}; - -void VGZ_UpdateObj(const struct vfp_ctx *, struct vgz*, enum vgz_ua_e); - /* cache_http.c */ unsigned HTTP_estimate(unsigned nhttp); void HTTP_Copy(struct http *to, const struct http * const fm); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 46a5d7d..d5fd97a 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -36,6 +36,7 @@ #include "cache_transport.h" #include "cache_filter.h" +#include "cache_vgz.h" #include "vtim.h" #include "cache_esi.h" diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index ac95a1e..a548d60 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -35,6 +35,7 @@ #include "cache.h" #include "cache_filter.h" +#include "cache_vgz.h" #include "cache_esi.h" diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 38ec348..6866767 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -32,6 +32,7 @@ #include "cache.h" +#include "cache_vgz.h" #include "cache_esi.h" #include "vct.h" #include "vend.h" diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index ae58708..4370866 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -42,6 +42,7 @@ #include "cache.h" #include "cache_filter.h" +#include "cache_vgz.h" #include "vend.h" #include "vgz.h" diff --git a/bin/varnishd/cache/cache_vgz.h b/bin/varnishd/cache/cache_vgz.h new file mode 100644 index 0000000..6f977c1 --- /dev/null +++ b/bin/varnishd/cache/cache_vgz.h @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2011-2015 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. + * + */ + +#ifdef CACHE_VGZ_H_INCLUDED +# error "Multiple includes of cache/cache_vgz.h" +#endif +#define CACHE_VGZ_H_INCLUDED + +struct vgz; + +enum vgzret_e { + VGZ_ERROR = -1, + VGZ_OK = 0, + VGZ_END = 1, + VGZ_STUCK = 2, +}; + +enum vgz_flag { VGZ_NORMAL, VGZ_ALIGN, VGZ_RESET, VGZ_FINISH }; +// struct vgz *VGZ_NewUngzip(struct vsl_log *vsl, const char *id); +struct vgz *VGZ_NewGzip(struct vsl_log *vsl, const char *id); +void VGZ_Ibuf(struct vgz *, const void *, ssize_t len); +int VGZ_IbufEmpty(const struct vgz *vg); +void VGZ_Obuf(struct vgz *, void *, ssize_t len); +int VGZ_ObufFull(const struct vgz *vg); +enum vgzret_e VGZ_Gzip(struct vgz *, const void **, ssize_t *len, + enum vgz_flag); +// enum vgzret_e VGZ_Gunzip(struct vgz *, const void **, ssize_t *len); +enum vgzret_e VGZ_Destroy(struct vgz **); + +enum vgz_ua_e { + VUA_UPDATE, // Update start/stop/last bits if changed + VUA_END_GZIP, // Record uncompressed size + VUA_END_GUNZIP, // Record uncompressed size +}; + +void VGZ_UpdateObj(const struct vfp_ctx *, struct vgz*, enum vgz_ua_e); From phk at FreeBSD.org Sat Sep 23 21:58:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 21:58:07 +0000 (UTC) Subject: [master] 22fdf68 Don't include cache_backend.h, it's off-limits to VMODS Message-ID: <20170923215807.7B85A905C1@lists.varnish-cache.org> commit 22fdf6885847bd750468acfa86757696aec53ce8 Author: Poul-Henning Kamp Date: Sat Sep 23 21:56:43 2017 +0000 Don't include cache_backend.h, it's off-limits to VMODS diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c index caed6bc..10f97aa 100644 --- a/lib/libvmod_debug/vmod_debug_dyn.c +++ b/lib/libvmod_debug/vmod_debug_dyn.c @@ -36,7 +36,6 @@ #include "vrt.h" #include "cache/cache_director.h" -#include "cache/cache_backend.h" #include "vsa.h" #include "vcc_if.h" From phk at FreeBSD.org Sat Sep 23 21:58:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 21:58:07 +0000 (UTC) Subject: [master] 47649ea Reduce visibility of waiters Message-ID: <20170923215807.B8B7B905C4@lists.varnish-cache.org> commit 47649ea0c642855eed4b450189b5b18c071452e6 Author: Poul-Henning Kamp Date: Sat Sep 23 21:57:08 2017 +0000 Reduce visibility of waiters diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f970f53..cd3b2a0 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -40,8 +40,6 @@ #include "vapi/vsl_int.h" -#include "waiter/waiter.h" - #include #include diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index b9d6829..35f1cdb 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -39,6 +39,7 @@ #include "vrt.h" #include "vtcp.h" #include "vtim.h" +#include "waiter/waiter.h" #include "cache_director.h" #include "cache_backend.h" diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 04d65ba..22d10c4 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -32,16 +32,17 @@ #include "config.h" -#include "cache.h" - #include #include #include +#include "cache.h" + #include "vcli_serve.h" #include "vrt.h" #include "vcl.h" #include "vtim.h" +#include "waiter/waiter.h" #include "cache_director.h" #include "cache_backend.h" diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 75a49a5..c1935dd 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -37,18 +37,19 @@ #include "config.h" -#include "cache.h" - #include #include #include +#include "cache.h" + #include "binary_heap.h" #include "vcli_serve.h" #include "vrt.h" #include "vsa.h" #include "vtcp.h" #include "vtim.h" +#include "waiter/waiter.h" #include "cache_director.h" #include "cache_backend.h" diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index 8f8a772..b13a4aa 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -42,6 +42,7 @@ #include "vsa.h" #include "vtcp.h" #include "vtim.h" +#include "waiter/waiter.h" #include "cache_director.h" #include "cache_backend.h" diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 6601b29..6e5a660 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -42,6 +42,8 @@ #include "cache_filter.h" #include "common/heritage.h" +#include "waiter/waiter.h" + #include "vrt.h" #include "cache_director.h" diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 02e1059..ea18156 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -48,6 +48,7 @@ #include "vsa.h" #include "vtcp.h" #include "vtim.h" +#include "waiter/waiter.h" /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index ac7c4d8..004e217 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -30,15 +30,16 @@ #include "config.h" -#include "cache.h" - #include #include #include #include +#include "cache.h" + #include "vrt.h" #include "vcl.h" +#include "waiter/waiter.h" #include "cache_director.h" #include "cache_backend.h" diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 3d4b17d..80a2f1f 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -36,6 +36,7 @@ #include "binary_heap.h" +#include "waiter/waiter.h" #include "waiter/waiter_priv.h" #include "waiter/mgt_waiter.h" diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 358d2be..129bb87 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -41,6 +41,7 @@ #include "cache/cache.h" +#include "waiter/waiter.h" #include "waiter/waiter_priv.h" #include "vtim.h" diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index ff870e7..50bdad3 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -39,6 +39,7 @@ #include +#include "waiter/waiter.h" #include "waiter/waiter_priv.h" #include "vtim.h" diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 52e4de3..fefe22f 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -36,6 +36,7 @@ #include "cache/cache.h" +#include "waiter/waiter.h" #include "waiter/waiter_priv.h" #include "vtim.h" diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 3a1dc49..a7f76c9 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -75,6 +75,7 @@ #include "cache/cache.h" +#include "waiter/waiter.h" #include "waiter/waiter_priv.h" #include "waiter/mgt_waiter.h" #include "vtim.h" From phk at FreeBSD.org Sat Sep 23 22:37:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 23 Sep 2017 22:37:06 +0000 (UTC) Subject: [master] b587956 Struct dstat is called VSC_main now Message-ID: <20170923223706.43F90A4415@lists.varnish-cache.org> commit b58795692449800d0f0d89681f393358cd688c70 Author: Poul-Henning Kamp Date: Sat Sep 23 22:27:58 2017 +0000 Struct dstat is called VSC_main now diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index cd3b2a0..303e038 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -116,11 +116,8 @@ struct vrt_priv; struct vsb; struct worker; struct v1l; - struct VSC_main; -#define dstat VSC_main - #define DIGEST_LEN 32 /*--------------------------------------------------------------------*/ @@ -309,7 +306,7 @@ struct worker { struct objhead *nobjhead; struct objcore *nobjcore; void *nhashpriv; - struct dstat *stats; + struct VSC_main *stats; struct vsl_log *vsl; // borrowed from req/bo struct pool_task task; @@ -898,7 +895,7 @@ struct req *Req_New(const struct worker *, struct sess *); void Req_Release(struct req *); void Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req); void Req_Fail(struct req *req, enum sess_close reason); -void Req_AcctLogCharge(struct dstat *, struct req *); +void Req_AcctLogCharge(struct VSC_main *, struct req *); /* cache_req_body.c */ int VRB_Ignore(struct req *); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 595e836..e25b3a0 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -51,7 +51,7 @@ static VTAILQ_HEAD(,pool) pools = VTAILQ_HEAD_INITIALIZER(pools); */ static void -pool_sumstat(const struct dstat *src) +pool_sumstat(const struct VSC_main *src) { Lck_AssertHeld(&wstat_mtx); @@ -121,7 +121,7 @@ Pool_PurgeStat(unsigned nobj) void __match_proto__(task_func_t) pool_stat_summ(struct worker *wrk, void *priv) { - struct dstat *src; + struct VSC_main *src; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk->pool, POOL_MAGIC); diff --git a/bin/varnishd/cache/cache_pool.h b/bin/varnishd/cache/cache_pool.h index 4814c50..c954aee 100644 --- a/bin/varnishd/cache/cache_pool.h +++ b/bin/varnishd/cache/cache_pool.h @@ -53,8 +53,8 @@ struct pool { uintmax_t sdropped; uintmax_t rdropped; uintmax_t nqueued; - struct dstat *a_stat; - struct dstat *b_stat; + struct VSC_main *a_stat; + struct VSC_main *b_stat; struct mempool *mpl_req; struct mempool *mpl_sess; diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 601574a..2d06616 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -43,7 +43,7 @@ #include "vtim.h" void -Req_AcctLogCharge(struct dstat *ds, struct req *req) +Req_AcctLogCharge(struct VSC_main *ds, struct req *req) { struct acct_req *a; diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 8735929..b7729b1 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -61,7 +61,7 @@ wrk_bgthread(void *arg) { struct bgthread *bt; struct worker wrk; - struct dstat ds; + struct VSC_main ds; CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC); THR_SetName(bt->name); @@ -97,7 +97,7 @@ static void WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace) { struct worker *w, ww; - struct dstat ds; + struct VSC_main ds; unsigned char ws[thread_workspace]; uintptr_t u; @@ -141,7 +141,7 @@ WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace) */ static void -pool_addstat(struct dstat *dst, struct dstat *src) +pool_addstat(struct VSC_main *dst, struct VSC_main *src) { dst->summs++; From fgsch at lodoss.net Sun Sep 24 21:24:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 24 Sep 2017 21:24:06 +0000 (UTC) Subject: [master] 872de71 Update error and define Message-ID: <20170924212406.CA9FCA4ACF@lists.varnish-cache.org> commit 872de71766a9def9ad35102817e8f1d436948819 Author: Federico G. Schwindt Date: Sun Sep 24 18:00:35 2017 +0100 Update error and define diff --git a/bin/varnishd/common/com_params.h b/bin/varnishd/common/com_params.h index a1ddd69..07080d3 100644 --- a/bin/varnishd/common/com_params.h +++ b/bin/varnishd/common/com_params.h @@ -29,10 +29,10 @@ * This file contains the heritage passed when mgt forks cache */ -#ifdef COMMON_PARAMS_H -#error "Multiple includes of common/params.h" +#ifdef COMMON_COM_PARAMS_H +#error "Multiple includes of common/com_params.h" #endif -#define COMMON_PARAMS_H +#define COMMON_COM_PARAMS_H #include "vre.h" From fgsch at lodoss.net Sun Sep 24 21:24:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 24 Sep 2017 21:24:06 +0000 (UTC) Subject: [master] 0a360b4 Sync with recent changes Message-ID: <20170924212406.E5D8BA4AD1@lists.varnish-cache.org> commit 0a360b4cd3e40c69db883bcbeaa5055e73418b39 Author: Federico G. Schwindt Date: Sun Sep 24 18:05:20 2017 +0100 Sync with recent changes diff --git a/.gitignore b/.gitignore index 1c55b88..ba1a4d2 100644 --- a/.gitignore +++ b/.gitignore @@ -109,7 +109,7 @@ cscope.*out /bin/varnishtest/tests/*.log /bin/varnishtest/tests/*.log-t /include/*.log -/include/vrt.c +/include/_vrt.c /include/_vrt_test /include/vrt_test /include/vbm_test From fgsch at lodoss.net Sun Sep 24 21:24:07 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 24 Sep 2017 21:24:07 +0000 (UTC) Subject: [master] cfaf64b Ignore the alternate stack if the handler is off Message-ID: <20170924212407.1402FA4AD4@lists.varnish-cache.org> commit cfaf64b98b5acc8288b3753ed71faf134d6c64ac Author: Federico G. Schwindt Date: Sun Sep 24 21:56:38 2017 +0100 Ignore the alternate stack if the handler is off diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 684d456..4d82fb6 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -124,7 +124,8 @@ void THR_Init(void) { #ifdef HAVE_SIGALTSTACK - AZ(sigaltstack(&altstack, NULL)); + if (altstack.ss_sp != NULL) + AZ(sigaltstack(&altstack, NULL)); #endif } diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index 5853b70..e9791d3 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -39,3 +39,12 @@ client c1 { } -run varnish v1 -cliok "panic.clear" + +# Also check without the handler +varnish v1 -cliok "param.set sigsegv_handler off" +varnish v1 -vcl+backend {} -start + +client c1 { + txreq + rxresp +} -run From phk at FreeBSD.org Mon Sep 25 07:34:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Sep 2017 07:34:05 +0000 (UTC) Subject: [master] c197f40 Move dirty laundy out of view from VMODs Message-ID: <20170925073405.2B833A5D15@lists.varnish-cache.org> commit c197f402b62cb728db030bb950e91d987f9dcdbe Author: Poul-Henning Kamp Date: Mon Sep 25 07:33:08 2017 +0000 Move dirty laundy out of view from VMODs diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 303e038..b6e6825 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -774,9 +774,6 @@ extern const char H__Status[]; extern const char H__Proto[]; extern const char H__Reason[]; -/* cache_http2_deliver.c */ -void V2D_Init(void); - /* cache_main.c */ #define VXID(u) ((u) & VSL_IDENTMASK) uint32_t VXID_Get(struct worker *, uint32_t marker); @@ -878,18 +875,6 @@ void ObjSendEvent(struct worker *, struct objcore *oc, unsigned event); const char *body_status_2str(enum body_status e); const char *sess_close_2str(enum sess_close sc, int want_desc); -/* cache_pool.c */ -int Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio); -int Pool_Task_Arg(struct worker *, enum task_prio, task_func_t *, - const void *arg, size_t arg_len); -void Pool_Sumstat(const struct worker *w); -int Pool_TrySumstat(const struct worker *wrk); -void Pool_PurgeStat(unsigned nobj); -int Pool_Task_Any(struct pool_task *task, enum task_prio prio); - -/* cache_range.c [VRG] */ -void VRG_dorange(struct req *req, const char *r); - /* cache_req.c */ struct req *Req_New(const struct worker *, struct sess *); void Req_Release(struct req *); @@ -939,7 +924,6 @@ void SES_Set_String_Attr(struct sess *sp, enum sess_attr a, const char *src); const char *SES_Get_String_Attr(const struct sess *sp, enum sess_attr a); /* cache_shmlog.c */ -#ifdef VSL_ENDMARKER void VSLv(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, va_list va); void VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...) __v_printflike(3, 4); @@ -972,24 +956,9 @@ VSLb_ts_busyobj(struct busyobj *bo, const char *event, double now) void VSL_Flush(struct vsl_log *, int overflow); -#endif - -/* cache_vary.c */ -int VRY_Create(struct busyobj *bo, struct vsb **psb); -int VRY_Match(struct req *, const uint8_t *vary); -void VRY_Prep(struct req *); -void VRY_Clear(struct req *); -enum vry_finish_flag { KEEP, DISCARD }; -void VRY_Finish(struct req *req, enum vry_finish_flag); - /* cache_vcl.c */ -const char *VCL_Method_Name(unsigned); const char *VCL_Name(const struct vcl *); -void VCL_Ref(struct vcl *); -void VCL_Refresh(struct vcl **); -void VCL_Rel(struct vcl **); -const char *VCL_Return_Name(unsigned); - +const char *VCL_Method_Name(unsigned); #define VCL_MET_MAC(l,u,t,b) \ void VCL_##l##_method(struct vcl *, struct worker *, struct req *, \ struct busyobj *bo, void *specific); @@ -1116,4 +1085,3 @@ DO_DEBUG(enum debug_bits x) #ifdef VARNISHD_IS_NOT_A_VMOD # include "cache/cache_priv.h" #endif - diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index 18bb141..b6cec52 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -102,10 +102,20 @@ int PAN_already(struct vsb *, const void *); /* cache_pool.c */ void Pool_Init(void); +int Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio); +int Pool_Task_Arg(struct worker *, enum task_prio, task_func_t *, + const void *arg, size_t arg_len); +void Pool_Sumstat(const struct worker *w); +int Pool_TrySumstat(const struct worker *wrk); +void Pool_PurgeStat(unsigned nobj); +int Pool_Task_Any(struct pool_task *task, enum task_prio prio); /* cache_proxy.c [VPX] */ task_func_t VPX_Proto_Sess; +/* cache_range.c [VRG] */ +void VRG_dorange(struct req *req, const char *r); + /* cache_session.c */ void SES_NewPool(struct pool *, unsigned pool_no); void SES_DestroyPool(struct pool *); @@ -118,12 +128,25 @@ void VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, uint32_t vxid); void VSL_End(struct vsl_log *vsl); +/* cache_vary.c */ +int VRY_Create(struct busyobj *bo, struct vsb **psb); +int VRY_Match(struct req *, const uint8_t *vary); +void VRY_Prep(struct req *); +void VRY_Clear(struct req *); +enum vry_finish_flag { KEEP, DISCARD }; +void VRY_Finish(struct req *req, enum vry_finish_flag); + /* cache_vcl.c */ struct director *VCL_DefaultDirector(const struct vcl *); const struct vrt_backend_probe *VCL_DefaultProbe(const struct vcl *); void VCL_Init(void); void VCL_Panic(struct vsb *, const struct vcl *); void VCL_Poll(void); +void VCL_Ref(struct vcl *); +void VCL_Refresh(struct vcl **); +void VCL_Rel(struct vcl **); +const char *VCL_Return_Name(unsigned); + /* cache_vrt.c */ void VRTPRIV_init(struct vrt_privs *privs); @@ -137,6 +160,9 @@ void VMOD_Panic(struct vsb *); /* http1/cache_http1_pipe.c */ void V1P_Init(void); +/* cache_http2_deliver.c */ +void V2D_Init(void); + /* stevedore.c */ void STV_open(void); void STV_close(void); From hermunn at varnish-software.com Mon Sep 25 14:52:07 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Mon, 25 Sep 2017 14:52:07 +0000 (UTC) Subject: [4.1] 3f62309 Move the cli buffer to VSB (from stack) Message-ID: <20170925145207.B7932611FF@lists.varnish-cache.org> commit 3f6230961612599f117537c1f5184cef2e9c1ca7 Author: P?l Hermunn Johansen Date: Mon Sep 11 16:21:19 2017 +0200 Move the cli buffer to VSB (from stack) If the cli buffer is allocated on the stack, the mgt process will crash hard for big values of this parameter. Instead we allocate on the heap. The new cli buffer an "auto" VSB. This means that the varnish parameter cli_buffer is ignored from now on, and the manual marks it as deprecated. Closes: #2382 Conflicts: bin/varnishd/mgt/mgt_cli.c diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index fa021d6..bcab2af 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -64,6 +64,8 @@ static const char *secret_file; #define MCF_NOAUTH 0 /* NB: zero disables here-documents */ #define MCF_AUTH 16 +struct vsb *cli_buf = NULL; + /*--------------------------------------------------------------------*/ static void @@ -191,24 +193,30 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) { int i, j; va_list ap; unsigned u; - char buf[mgt_param.cli_buffer], *p; + + if (cli_buf == NULL) { + cli_buf = VSB_new_auto(); + AN(cli_buf); + } else { + VSB_clear(cli_buf); + } if (resp != NULL) *resp = NULL; if (status != NULL) *status = 0; - if (cli_i < 0|| cli_o < 0) { + if (cli_i < 0 || cli_o < 0) { if (status != NULL) *status = CLIS_CANT; return (CLIS_CANT); } va_start(ap, fmt); - vbprintf(buf, fmt, ap); + AZ(VSB_vprintf(cli_buf, fmt, ap)); va_end(ap); - p = strchr(buf, '\0'); - assert(p != NULL && p > buf && p[-1] == '\n'); - i = p - buf; - j = write(cli_o, buf, i); + AZ(VSB_finish(cli_buf)); + i = VSB_len(cli_buf); + assert(i > 0 && VSB_data(cli_buf)[i - 1] == '\n'); + j = write(cli_o, VSB_data(cli_buf), i); if (j != i) { if (status != NULL) *status = CLIS_COMMS; diff --git a/bin/varnishtest/tests/r02382.vtc b/bin/varnishtest/tests/r02382.vtc new file mode 100644 index 0000000..7a398b3 --- /dev/null +++ b/bin/varnishtest/tests/r02382.vtc @@ -0,0 +1,21 @@ +varnishtest "Very very big cli_buffer" + +# If the cli_buffer is on the stack, setting it very big can crash varnish + +server s1 { + rxreq + expect req.url == "/1" + txresp +} -start + +varnish v1 -arg "-p cli_buffer=32M" -vcl+backend { +} -start + +varnish v1 -cliok "ping" + +delay .5 + +client c1 { + txreq -url /1 + rxresp +} -run diff --git a/include/tbl/params.h b/include/tbl/params.h index 9a272a3..3546b67 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -235,10 +235,8 @@ PARAM( /* units */ "bytes", /* flags */ 0, /* s-text */ - "Size of buffer for CLI command input.\n" - "You may need to increase this if you have big VCL files and use " - "the vcl.inline CLI command.\n" - "NB: Must be specified with -p to have effect.", + "DEPRECATED: This parameter is ignored.\n" + "Memory for the CLI command buffer is now dynamically allocated.", /* l-text */ "", /* func */ NULL ) From phk at FreeBSD.org Mon Sep 25 16:53:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Sep 2017 16:53:05 +0000 (UTC) Subject: [master] 7b15782 Move more stuff out of $ABI VRT Message-ID: <20170925165305.8F2736117C@lists.varnish-cache.org> commit 7b1578204fdcf6bf4f6c6a5492042a3e87533fb5 Author: Poul-Henning Kamp Date: Mon Sep 25 16:52:17 2017 +0000 Move more stuff out of $ABI VRT diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 6d642aa..2556a07 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -67,25 +67,10 @@ struct vfp_entry { uint64_t bytes_out; }; - -extern const struct vfp vfp_gunzip; -extern const struct vfp vfp_gzip; -extern const struct vfp vfp_testgunzip; -extern const struct vfp vfp_esi; -extern const struct vfp vfp_esi_gzip; - -struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *); -void VFP_Setup(struct vfp_ctx *vc); -int VFP_Open(struct vfp_ctx *bo); -void VFP_Close(struct vfp_ctx *bo); enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp); enum vfp_status VFP_Error(struct vfp_ctx *, const char *fmt, ...) __v_printflike(2, 3); -/* cache_fetch_proc.c */ -enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr); -void VFP_Extend(const struct vfp_ctx *, ssize_t sz); - /* Deliver processors ------------------------------------------------*/ enum vdp_action { @@ -110,8 +95,6 @@ struct vdp_entry { int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len); void VDP_push(struct req *, vdp_bytes *func, void *priv, int bottom, const char *id); -void VDP_close(struct req *req); -int VDP_DeliverObj(struct req *req); vdp_bytes VDP_gunzip; vdp_bytes VDP_ESI; diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index b6cec52..3434ce9 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -31,6 +31,8 @@ #include "VSC_main.h" +struct vfp; + /* Prototypes etc ----------------------------------------------------*/ /* cache_acceptor.c */ @@ -72,11 +74,27 @@ void CLI_Init(void); void CLI_Run(void); void CLI_AddFuncs(struct cli_proto *p); +/* cache_deliver_proc.c */ +void VDP_close(struct req *req); +int VDP_DeliverObj(struct req *req); + /* cache_expire.c */ void EXP_Init(void); /* cache_fetch_proc.c */ void VFP_Init(void); +enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr); +void VFP_Extend(const struct vfp_ctx *, ssize_t sz); +struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *); +void VFP_Setup(struct vfp_ctx *vc); +int VFP_Open(struct vfp_ctx *bo); +void VFP_Close(struct vfp_ctx *bo); + +extern const struct vfp vfp_gunzip; +extern const struct vfp vfp_gzip; +extern const struct vfp vfp_testgunzip; +extern const struct vfp vfp_esi; +extern const struct vfp vfp_esi_gzip; /* cache_http.c */ void HTTP_Init(void); From phk at FreeBSD.org Mon Sep 25 18:20:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Sep 2017 18:20:06 +0000 (UTC) Subject: [master] 8b73891 Give VDPs a describing structure like VFPs have it. Saves workspace too. Message-ID: <20170925182006.6414F61811@lists.varnish-cache.org> commit 8b73891e1d3d07f016a2fe5c4108065699f0fb27 Author: Poul-Henning Kamp Date: Mon Sep 25 18:19:20 2017 +0000 Give VDPs a describing structure like VFPs have it. Saves workspace too. diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index ad8f46f..c1b079e 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -64,7 +64,7 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len) assert(act > VDP_NULL || len > 0); /* Call the present layer, while pointing to the next layer down */ - retval = vdpe->func(req, act, &vdpe->priv, ptr, len); + retval = vdpe->vdp->func(req, act, &vdpe->priv, ptr, len); if (retval && (req->vdpe_retval == 0 || retval < req->vdpe_retval)) req->vdpe_retval = retval; /* Latch error value */ req->vdpe_nxt = vdpe; @@ -72,52 +72,44 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len) } void -VDP_push(struct req *req, vdp_bytes *func, void *priv, int bottom, - const char *id) +VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom) { struct vdp_entry *vdpe; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - AN(func); + AN(vdp); + AN(vdp->name); + AN(vdp->func); vdpe = WS_Alloc(req->ws, sizeof *vdpe); if (vdpe == NULL) return; INIT_OBJ(vdpe, VDP_ENTRY_MAGIC); - vdpe->func = func; + vdpe->vdp = vdp; vdpe->priv = priv; - vdpe->id = id; if (bottom) VTAILQ_INSERT_TAIL(&req->vdpe, vdpe, list); else VTAILQ_INSERT_HEAD(&req->vdpe, vdpe, list); req->vdpe_nxt = VTAILQ_FIRST(&req->vdpe); - AZ(vdpe->func(req, VDP_INIT, &vdpe->priv, NULL, 0)); -} - -static void -vdp_pop(struct req *req, vdp_bytes *func) -{ - struct vdp_entry *vdpe; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - vdpe = VTAILQ_FIRST(&req->vdpe); - CHECK_OBJ_NOTNULL(vdpe, VDP_ENTRY_MAGIC); - assert(vdpe->func == func); - VTAILQ_REMOVE(&req->vdpe, vdpe, list); - AZ(vdpe->func(req, VDP_FINI, &vdpe->priv, NULL, 0)); - AZ(vdpe->priv); - req->vdpe_nxt = VTAILQ_FIRST(&req->vdpe); + AZ(vdpe->vdp->func(req, VDP_INIT, &vdpe->priv, NULL, 0)); } void VDP_close(struct req *req) { + struct vdp_entry *vdpe; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - while (!VTAILQ_EMPTY(&req->vdpe)) - vdp_pop(req, VTAILQ_FIRST(&req->vdpe)->func); + while (!VTAILQ_EMPTY(&req->vdpe)) { + vdpe = VTAILQ_FIRST(&req->vdpe); + CHECK_OBJ_NOTNULL(vdpe, VDP_ENTRY_MAGIC); + VTAILQ_REMOVE(&req->vdpe, vdpe, list); + AZ(vdpe->vdp->func(req, VDP_FINI, &vdpe->priv, NULL, 0)); + AZ(vdpe->priv); + req->vdpe_nxt = VTAILQ_FIRST(&req->vdpe); + } } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index d5fd97a..d9ec496 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -254,8 +254,8 @@ ved_decode_len(struct req *req, const uint8_t **pp) /*--------------------------------------------------------------------- */ -int __match_proto__(vdp_bytes) -VDP_ESI(struct req *req, enum vdp_action act, void **priv, +static int __match_proto__(vdp_bytes) +ved_vdp(struct req *req, enum vdp_action act, void **priv, const void *ptr, ssize_t len) { uint8_t *q, *r; @@ -436,6 +436,11 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv, } } +const struct vdp VDP_esi = { + .name = "esi", + .func = ved_vdp, +}; + /* * Account body bytes on req * Push bytes to preq @@ -523,6 +528,11 @@ ved_pretend_gzip(struct req *req, enum vdp_action act, void **priv, return (ved_bytes(req, preq, VDP_FLUSH, NULL, 0)); } +static const struct vdp ved_vdp_pgz = { + .name = "PGZ", + .func = ved_pretend_gzip, +}; + /*--------------------------------------------------------------------- * Include an object in a gzip'ed ESI object delivery * @@ -779,6 +789,11 @@ ved_vdp_bytes(struct req *req, enum vdp_action act, void **priv, return (ved_bytes(req, preq, act, ptr, len)); } +static const struct vdp ved_ved = { + .name = "VED", + .func = ved_vdp_bytes, +}; + /*--------------------------------------------------------------------*/ static void __match_proto__(vtr_deliver_f) @@ -805,9 +820,9 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) ved_stripgzip(req, boc); } else { if (ecx->isgzip && !i) - VDP_push(req, ved_pretend_gzip, ecx, 1, "PGZ"); + VDP_push(req, &ved_vdp_pgz, ecx, 1); else - VDP_push(req, ved_vdp_bytes, ecx->preq, 1, "VED"); + VDP_push(req, &ved_ved, ecx->preq, 1); (void)VDP_DeliverObj(req); (void)VDP_bytes(req, VDP_FLUSH, NULL, 0); } diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 2556a07..459c9fb 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -47,12 +47,12 @@ typedef enum vfp_status typedef void vfp_fini_f(struct vfp_ctx *, struct vfp_entry *); struct vfp { - const char *name; - vfp_init_f *init; - vfp_pull_f *pull; - vfp_fini_f *fini; - const void *priv1; - intptr_t priv2; + const char *name; + vfp_init_f *init; + vfp_pull_f *pull; + vfp_fini_f *fini; + const void *priv1; + intptr_t priv2; }; struct vfp_entry { @@ -83,18 +83,18 @@ enum vdp_action { typedef int vdp_bytes(struct req *, enum vdp_action, void **priv, const void *ptr, ssize_t len); +struct vdp { + const char *name; + vdp_bytes *func; +}; + struct vdp_entry { unsigned magic; #define VDP_ENTRY_MAGIC 0x353eb781 - vdp_bytes *func; + const struct vdp *vdp; void *priv; - const char *id; VTAILQ_ENTRY(vdp_entry) list; }; int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len); -void VDP_push(struct req *, vdp_bytes *func, void *priv, int bottom, - const char *id); - -vdp_bytes VDP_gunzip; -vdp_bytes VDP_ESI; +void VDP_push(struct req *, const struct vdp *, void *priv, int bottom); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 4c24e4b..0eb086d 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -284,8 +284,8 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, ssize_t *plen, enum vgz_flag flags) * VDP for gunzip'ing */ -int __match_proto__(vdp_bytes) -VDP_gunzip(struct req *req, enum vdp_action act, void **priv, +static int __match_proto__(vdp_bytes) +vdp_gunzip(struct req *req, enum vdp_action act, void **priv, const void *ptr, ssize_t len) { enum vgzret_e vr; @@ -327,7 +327,7 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv, * If the size is non-zero AND we are the top * VDP (ie: no ESI), we know what size the output will be. */ - if (u != 0 && VTAILQ_FIRST(&req->vdpe)->func == VDP_gunzip) + if (u != 0 && VTAILQ_FIRST(&req->vdpe)->vdp == &VDP_gunzip) req->resp_len = u; return (0); @@ -364,6 +364,11 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv, return (0); } +const struct vdp VDP_gunzip = { + .name = "gunzip", + .func = vdp_gunzip, +}; + /*--------------------------------------------------------------------*/ void diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index 3434ce9..197510d 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -78,6 +78,9 @@ void CLI_AddFuncs(struct cli_proto *p); void VDP_close(struct req *req); int VDP_DeliverObj(struct req *req); +extern const struct vdp VDP_gunzip; +extern const struct vdp VDP_esi; + /* cache_expire.c */ void EXP_Init(void); diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index 0af1a08..ced39c7 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -84,6 +84,11 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv, vrg_priv->range_off >= vrg_priv->range_high ? 1 : 0); } +static const struct vdp vrg_vdp = { + .name = "RNG", + .func = vrg_range_bytes, +}; + /*--------------------------------------------------------------------*/ static const char * @@ -170,7 +175,7 @@ vrg_dorange(struct req *req, const char *r) vrg_priv->range_off = 0; vrg_priv->range_low = low; vrg_priv->range_high = high + 1; - VDP_push(req, vrg_range_bytes, vrg_priv, 1, "RNG"); + VDP_push(req, &vrg_vdp, vrg_priv, 1); http_PutResponse(req->resp, "HTTP/1.1", 206, NULL); return (NULL); } diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index a0caba3..c96430b 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -370,12 +370,12 @@ cnt_transmit(struct worker *wrk, struct req *req) if (sendbody >= 0) { if (!req->disable_esi && req->resp_len != 0 && ObjHasAttr(wrk, req->objcore, OA_ESIDATA)) - VDP_push(req, VDP_ESI, NULL, 0, "ESI"); + VDP_push(req, &VDP_esi, NULL, 0); if (cache_param->http_gzip_support && ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) && !RFC2616_Req_Gzip(req->http)) - VDP_push(req, VDP_gunzip, NULL, 1, "GUZ"); + VDP_push(req, &VDP_gunzip, NULL, 1); if (cache_param->http_range_support && http_IsStatus(req->resp, 200)) { diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index b335471..96174a9 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -58,6 +58,11 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv, return (0); } +static const struct vdp v1d_vdp = { + .name = "V1B", + .func = v1d_bytes, +}; + static void v1d_error(struct req *req, const char *msg) { @@ -110,7 +115,7 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody) http_SetHeader(req->resp, "Connection: keep-alive"); if (sendbody && req->resp_len != 0) - VDP_push(req, v1d_bytes, NULL, 1, "V1B"); + VDP_push(req, &v1d_vdp, NULL, 1); AZ(req->wrk->v1l); V1L_Reserve(req->wrk, req->ws, &req->sp->fd, req->vsl, req->t_prev); diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index a9d4ad5..11ca12b 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -96,6 +96,11 @@ h2_bytes(struct req *req, enum vdp_action act, void **priv, return (0); } +static const struct vdp h2_vdp = { + .name = "H2B", + .func = h2_bytes, +}; + static inline size_t h2_status(uint8_t *p, uint16_t status) { size_t l = 1; @@ -261,7 +266,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) WS_Release(req->ws, 0); if (sendbody) { - VDP_push(req, h2_bytes, NULL, 1, "H2"); + VDP_push(req, &h2_vdp, NULL, 1); err = VDP_DeliverObj(req); /*XXX*/(void)err; } From phk at FreeBSD.org Mon Sep 25 18:20:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Sep 2017 18:20:06 +0000 (UTC) Subject: [master] 3e2e3fb Name variables which point to struct vdp_entry_s "vdpe" to make life easier for patch in the pipeline. Message-ID: <20170925182006.3EC2E6180F@lists.varnish-cache.org> commit 3e2e3fbda283893b4a15e1984fe95a31a594f7b9 Author: Poul-Henning Kamp Date: Mon Sep 25 17:43:15 2017 +0000 Name variables which point to struct vdp_entry_s "vdpe" to make life easier for patch in the pipeline. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b6e6825..c228b69 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -574,9 +574,9 @@ struct req { struct objcore *stale_oc; /* Deliver pipeline */ - struct vdp_entry_s vdp; - struct vdp_entry *vdp_nxt; - unsigned vdp_retval; + struct vdp_entry_s vdpe; + struct vdp_entry *vdpe_nxt; + unsigned vdpe_retval; /* Delivery mode */ unsigned res_mode; diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index 5d3b23c..ad8f46f 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -39,7 +39,7 @@ * This function picks and calls the next delivery processor from the * list. The return value is the return value of the delivery * processor. Upon seeing a non-zero return value, that lowest value - * observed is latched in req->vdp_retval and all subsequent calls to + * observed is latched in req->vdpe_retval and all subsequent calls to * VDP_bytes will return that value directly without calling the next * processor. * @@ -52,63 +52,63 @@ int VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len) { int retval; - struct vdp_entry *vdp; + struct vdp_entry *vdpe; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); assert(act == VDP_NULL || act == VDP_FLUSH); - if (req->vdp_retval) - return (req->vdp_retval); - vdp = req->vdp_nxt; - CHECK_OBJ_NOTNULL(vdp, VDP_ENTRY_MAGIC); - req->vdp_nxt = VTAILQ_NEXT(vdp, list); + if (req->vdpe_retval) + return (req->vdpe_retval); + vdpe = req->vdpe_nxt; + CHECK_OBJ_NOTNULL(vdpe, VDP_ENTRY_MAGIC); + req->vdpe_nxt = VTAILQ_NEXT(vdpe, list); assert(act > VDP_NULL || len > 0); /* Call the present layer, while pointing to the next layer down */ - retval = vdp->func(req, act, &vdp->priv, ptr, len); - if (retval && (req->vdp_retval == 0 || retval < req->vdp_retval)) - req->vdp_retval = retval; /* Latch error value */ - req->vdp_nxt = vdp; - return (req->vdp_retval); + retval = vdpe->func(req, act, &vdpe->priv, ptr, len); + if (retval && (req->vdpe_retval == 0 || retval < req->vdpe_retval)) + req->vdpe_retval = retval; /* Latch error value */ + req->vdpe_nxt = vdpe; + return (req->vdpe_retval); } void VDP_push(struct req *req, vdp_bytes *func, void *priv, int bottom, const char *id) { - struct vdp_entry *vdp; + struct vdp_entry *vdpe; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AN(func); - vdp = WS_Alloc(req->ws, sizeof *vdp); - if (vdp == NULL) + vdpe = WS_Alloc(req->ws, sizeof *vdpe); + if (vdpe == NULL) return; - INIT_OBJ(vdp, VDP_ENTRY_MAGIC); - vdp->func = func; - vdp->priv = priv; - vdp->id = id; + INIT_OBJ(vdpe, VDP_ENTRY_MAGIC); + vdpe->func = func; + vdpe->priv = priv; + vdpe->id = id; if (bottom) - VTAILQ_INSERT_TAIL(&req->vdp, vdp, list); + VTAILQ_INSERT_TAIL(&req->vdpe, vdpe, list); else - VTAILQ_INSERT_HEAD(&req->vdp, vdp, list); - req->vdp_nxt = VTAILQ_FIRST(&req->vdp); + VTAILQ_INSERT_HEAD(&req->vdpe, vdpe, list); + req->vdpe_nxt = VTAILQ_FIRST(&req->vdpe); - AZ(vdp->func(req, VDP_INIT, &vdp->priv, NULL, 0)); + AZ(vdpe->func(req, VDP_INIT, &vdpe->priv, NULL, 0)); } static void vdp_pop(struct req *req, vdp_bytes *func) { - struct vdp_entry *vdp; + struct vdp_entry *vdpe; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - vdp = VTAILQ_FIRST(&req->vdp); - CHECK_OBJ_NOTNULL(vdp, VDP_ENTRY_MAGIC); - assert(vdp->func == func); - VTAILQ_REMOVE(&req->vdp, vdp, list); - AZ(vdp->func(req, VDP_FINI, &vdp->priv, NULL, 0)); - AZ(vdp->priv); - req->vdp_nxt = VTAILQ_FIRST(&req->vdp); + vdpe = VTAILQ_FIRST(&req->vdpe); + CHECK_OBJ_NOTNULL(vdpe, VDP_ENTRY_MAGIC); + assert(vdpe->func == func); + VTAILQ_REMOVE(&req->vdpe, vdpe, list); + AZ(vdpe->func(req, VDP_FINI, &vdpe->priv, NULL, 0)); + AZ(vdpe->priv); + req->vdpe_nxt = VTAILQ_FIRST(&req->vdpe); } void @@ -116,8 +116,8 @@ VDP_close(struct req *req) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - while (!VTAILQ_EMPTY(&req->vdp)) - vdp_pop(req, VTAILQ_FIRST(&req->vdp)->func); + while (!VTAILQ_EMPTY(&req->vdpe)) + vdp_pop(req, VTAILQ_FIRST(&req->vdpe)->func); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 4370866..4c24e4b 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -327,7 +327,7 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv, * If the size is non-zero AND we are the top * VDP (ie: no ESI), we know what size the output will be. */ - if (u != 0 && VTAILQ_FIRST(&req->vdp)->func == VDP_gunzip) + if (u != 0 && VTAILQ_FIRST(&req->vdpe)->func == VDP_gunzip) req->resp_len = u; return (0); @@ -355,7 +355,7 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv, return (-1); if (vg->m_len == vg->m_sz || vr != VGZ_OK) { if (VDP_bytes(req, VDP_FLUSH, vg->m_buf, vg->m_len)) - return (req->vdp_retval); + return (req->vdpe_retval); vg->m_len = 0; VGZ_Obuf(vg, vg->m_buf, vg->m_sz); } diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 2d06616..56ed74c 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -132,8 +132,8 @@ Req_New(const struct worker *wrk, struct sess *sp) req->t_prev = NAN; req->t_req = NAN; - req->vdp_nxt = 0; - VTAILQ_INIT(&req->vdp); + req->vdpe_nxt = 0; + VTAILQ_INIT(&req->vdpe); return (req); } diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 9e1fbe5..a0caba3 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -793,7 +793,7 @@ cnt_recv(struct worker *wrk, struct req *req) req->director_hint = VCL_DefaultDirector(req->vcl); AN(req->director_hint); - req->vdp_retval = 0; + req->vdpe_retval = 0; req->d_ttl = -1; req->disable_esi = 0; req->hash_always_miss = 0; diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index e6a6845..b335471 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -46,7 +46,7 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv, if (act == VDP_INIT || act == VDP_FINI) return (0); - AZ(req->vdp_nxt); /* always at the bottom of the pile */ + AZ(req->vdpe_nxt); /* always at the bottom of the pile */ if (len > 0) wl = V1L_Write(req->wrk, ptr, len); From phk at FreeBSD.org Mon Sep 25 18:55:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Sep 2017 18:55:06 +0000 (UTC) Subject: [master] b1ce702 Adjust test-case for less workspace per VDP Message-ID: <20170925185506.7D7A26130E@lists.varnish-cache.org> commit b1ce7022907ca5e22139dbf25377c9a3e4312220 Author: Poul-Henning Kamp Date: Mon Sep 25 18:53:49 2017 +0000 Adjust test-case for less workspace per VDP diff --git a/bin/varnishtest/tests/r02275.vtc b/bin/varnishtest/tests/r02275.vtc index 0a56c16..a705169 100644 --- a/bin/varnishtest/tests/r02275.vtc +++ b/bin/varnishtest/tests/r02275.vtc @@ -17,7 +17,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { if (req.url == "/1") { vtc.workspace_alloc(client, - -1 * (40 + vtc.typesize("p") * 25)); + -1 * (32 + vtc.typesize("p") * 25)); } else { vtc.workspace_alloc(client, -1 * (56 + vtc.typesize("p") * 25)); From phk at FreeBSD.org Tue Sep 26 06:34:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Sep 2017 06:34:07 +0000 (UTC) Subject: [master] 02a8578 Be consistent about upper/lower VTLA Message-ID: <20170926063407.4AE54614BC@lists.varnish-cache.org> commit 02a8578dd29e7db83554f96e6af2c2f4b7260e06 Author: Poul-Henning Kamp Date: Tue Sep 26 06:32:06 2017 +0000 Be consistent about upper/lower VTLA diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index a548d60..3b909e4 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -273,14 +273,14 @@ vfp_esi_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) vfe->priv1 = NULL; } -const struct vfp vfp_esi = { +const struct vfp VFP_esi = { .name = "esi", .init = vfp_esi_init, .pull = vfp_esi_pull, .fini = vfp_esi_fini, }; -const struct vfp vfp_esi_gzip = { +const struct vfp VFP_esi_gzip = { .name = "esi_gzip", .init = vfp_esi_gzip_init, .pull = vfp_esi_gzip_pull, diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 01d1eac..65071b1 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -574,19 +574,19 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->do_gzip == 0 || bo->do_gunzip == 0); if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) - vbf_vfp_push(bo, &vfp_gunzip); + vbf_vfp_push(bo, &VFP_gunzip); if (bo->htc->content_length != 0) { if (bo->do_esi && bo->do_gzip) { - vbf_vfp_push(bo, &vfp_esi_gzip); + vbf_vfp_push(bo, &VFP_esi_gzip); } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { - vbf_vfp_push(bo, &vfp_esi_gzip); + vbf_vfp_push(bo, &VFP_esi_gzip); } else if (bo->do_esi) { - vbf_vfp_push(bo, &vfp_esi); + vbf_vfp_push(bo, &VFP_esi); } else if (bo->do_gzip) { - vbf_vfp_push(bo, &vfp_gzip); + vbf_vfp_push(bo, &VFP_gzip); } else if (bo->is_gzip && !bo->do_gunzip) { - vbf_vfp_push(bo, &vfp_testgunzip); + vbf_vfp_push(bo, &VFP_testgunzip); } } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 0eb086d..029e2c4 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -664,7 +664,7 @@ vfp_gzip_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) /*--------------------------------------------------------------------*/ -const struct vfp vfp_gunzip = { +const struct vfp VFP_gunzip = { .name = "gunzip", .init = vfp_gzip_init, .pull = vfp_gunzip_pull, @@ -673,7 +673,7 @@ const struct vfp vfp_gunzip = { .priv2 = VFP_GUNZIP, }; -const struct vfp vfp_gzip = { +const struct vfp VFP_gzip = { .name = "gzip", .init = vfp_gzip_init, .pull = vfp_gzip_pull, @@ -682,7 +682,7 @@ const struct vfp vfp_gzip = { .priv2 = VFP_GZIP, }; -const struct vfp vfp_testgunzip = { +const struct vfp VFP_testgunzip = { .name = "testgunzip", .init = vfp_gzip_init, .pull = vfp_testgunzip_pull, diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index 197510d..5faec37 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -93,11 +93,11 @@ void VFP_Setup(struct vfp_ctx *vc); int VFP_Open(struct vfp_ctx *bo); void VFP_Close(struct vfp_ctx *bo); -extern const struct vfp vfp_gunzip; -extern const struct vfp vfp_gzip; -extern const struct vfp vfp_testgunzip; -extern const struct vfp vfp_esi; -extern const struct vfp vfp_esi_gzip; +extern const struct vfp VFP_gunzip; +extern const struct vfp VFP_gzip; +extern const struct vfp VFP_testgunzip; +extern const struct vfp VFP_esi; +extern const struct vfp VFP_esi_gzip; /* cache_http.c */ void HTTP_Init(void); From hermunn at varnish-software.com Tue Sep 26 07:24:05 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Tue, 26 Sep 2017 07:24:05 +0000 (UTC) Subject: [4.1] d98c850 Remove referenses to repo.varnish-cache.org Message-ID: <20170926072405.0FC1E61343@lists.varnish-cache.org> commit d98c85013cdeea045670785c10d7416c659260aa Author: Simon Vikstrom Date: Tue Sep 12 08:05:27 2017 +0200 Remove referenses to repo.varnish-cache.org diff --git a/README.Packaging b/README.Packaging index 6663f88..ab77d1f 100644 --- a/README.Packaging +++ b/README.Packaging @@ -13,7 +13,7 @@ Official packages ----------------- The official Debian and Redhat packages are built by the Varnish Cache team -and made available on https://repo.varnish-cache.org/ . +and made available on https://packagecloud.io/varnishcache/ . Packaging files and scripts for Debian and Redhat: diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index eb876dc..3a49138 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -31,7 +31,7 @@ Red Hat / CentOS ---------------- We try to keep the latest version available as prebuilt RPMs (el5 and el6) -on `repo.varnish-cache.org `_. See the online +on `packagecloud.io/varnishcache `_. See the online `Red Hat installation instructions `_ for more information. @@ -62,7 +62,7 @@ want to compile Varnish from source for other reasons, follow these steps: Download the appropriate release tarball, which you can find on -http://repo.varnish-cache.org/source/ . +https://varnish-cache.org/releases/ . Alternatively, if you want to hack on Varnish, you should clone our git repository by doing. From phk at FreeBSD.org Tue Sep 26 07:25:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Sep 2017 07:25:05 +0000 (UTC) Subject: [master] c6ec0b4 Remove vfp->priv2, it's surplus to requirements. Message-ID: <20170926072505.A35EB61512@lists.varnish-cache.org> commit c6ec0b497890bc477485af16fbfad00c20df84c5 Author: Poul-Henning Kamp Date: Tue Sep 26 06:50:22 2017 +0000 Remove vfp->priv2, it's surplus to requirements. diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 459c9fb..20c770d 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -27,7 +27,6 @@ * */ -struct busyobj; struct req; struct vfp_entry; struct vfp_ctx; @@ -52,7 +51,6 @@ struct vfp { vfp_pull_f *pull; vfp_fini_f *fini; const void *priv1; - intptr_t priv2; }; struct vfp_entry { diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 029e2c4..6736242 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -437,10 +437,6 @@ VGZ_Destroy(struct vgz **vgp) /*--------------------------------------------------------------------*/ -#define VFP_GUNZIP 0 -#define VFP_GZIP 1 -#define VFP_TESTGUNZIP 2 - static enum vfp_status __match_proto__(vfp_init_f) vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) { @@ -454,14 +450,14 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) return (VFP_NULL); } - if (vfe->vfp->priv2 == VFP_GZIP) { + if (vfe->vfp == &VFP_gzip) { if (http_GetHdr(vc->http, H_Content_Encoding, NULL)) return (VFP_NULL); vg = VGZ_NewGzip(vc->wrk->vsl, vfe->vfp->priv1); } else { if (!http_HdrIs(vc->http, H_Content_Encoding, "gzip")) return (VFP_NULL); - if (vfe->vfp->priv2 == VFP_GUNZIP) + if (vfe->vfp == &VFP_gunzip) vg = VGZ_NewGunzip(vc->wrk->vsl, vfe->vfp->priv1); else vg = VGZ_NewTestGunzip(vc->wrk->vsl, vfe->vfp->priv1); @@ -474,16 +470,16 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) VGZ_Ibuf(vg, vg->m_buf, 0); AZ(vg->m_len); - if (vfe->vfp->priv2 == VFP_GUNZIP || vfe->vfp->priv2 == VFP_GZIP) { + if (vfe->vfp == &VFP_gunzip || vfe->vfp == &VFP_gzip) { http_Unset(vc->http, H_Content_Encoding); http_Unset(vc->http, H_Content_Length); RFC2616_Weaken_Etag(vc->http); } - if (vfe->vfp->priv2 == VFP_GZIP) + if (vfe->vfp == &VFP_gzip) http_SetHeader(vc->http, "Content-Encoding: gzip"); - if (vfe->vfp->priv2 == VFP_GZIP || vfe->vfp->priv2 == VFP_TESTGUNZIP) + if (vfe->vfp == &VFP_gzip || vfe->vfp == &VFP_testgunzip) RFC2616_Vary_AE(vc->http); return (VFP_OK); @@ -670,7 +666,6 @@ const struct vfp VFP_gunzip = { .pull = vfp_gunzip_pull, .fini = vfp_gzip_fini, .priv1 = "U F -", - .priv2 = VFP_GUNZIP, }; const struct vfp VFP_gzip = { @@ -679,7 +674,6 @@ const struct vfp VFP_gzip = { .pull = vfp_gzip_pull, .fini = vfp_gzip_fini, .priv1 = "G F -", - .priv2 = VFP_GZIP, }; const struct vfp VFP_testgunzip = { @@ -688,5 +682,4 @@ const struct vfp VFP_testgunzip = { .pull = vfp_testgunzip_pull, .fini = vfp_gzip_fini, .priv1 = "u F -", - .priv2 = VFP_TESTGUNZIP, }; From phk at FreeBSD.org Tue Sep 26 07:25:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Sep 2017 07:25:05 +0000 (UTC) Subject: [master] 52b51aa Streamline VFP filter pushing Message-ID: <20170926072505.C57F861516@lists.varnish-cache.org> commit 52b51aa170fd65780be0387a02aeb6752e671657 Author: Poul-Henning Kamp Date: Tue Sep 26 07:24:26 2017 +0000 Streamline VFP filter pushing diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 0b9d62f..521c6ac 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -38,7 +38,6 @@ #include "cache.h" #include "hash/hash_slinger.h" -#include "cache/cache_filter.h" static struct mempool *vbopool; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 65071b1..cf2605b 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -510,26 +510,9 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) /*-------------------------------------------------------------------- */ -#define vbf_vfp_push(bo, vfp) \ - do { \ - if (VFP_Push((bo)->vfc, (vfp)) == NULL) { \ - (bo)->htc->doclose = SC_OVERLOAD; \ - VDI_Finish((bo)->wrk, bo); \ - return (F_STP_ERROR); \ - } \ - } while (0) - -static enum fetch_step -vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) +static int +vbf_figure_out_vfp(struct busyobj *bo) { - const char *p; - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); - - assert(wrk->handling == VCL_RET_DELIVER); - /* * The VCL variables beresp.do_g[un]zip tells us how we want the * object processed before it is stored. @@ -543,60 +526,70 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) * */ - /* We do nothing unless the param is set */ - if (!cache_param->http_gzip_support) - bo->do_gzip = bo->do_gunzip = 0; - - if (bo->htc->content_length == 0) + /* No body or no GZIP supprt -> done */ + if (bo->htc->body_status == BS_NONE || + bo->htc->content_length == 0 || + !cache_param->http_gzip_support) { http_Unset(bo->beresp, H_Content_Encoding); - - if (bo->htc->body_status != BS_NONE) { - bo->is_gzip = - http_HdrIs(bo->beresp, H_Content_Encoding, "gzip"); - bo->is_gunzip = - !http_GetHdr(bo->beresp, H_Content_Encoding, NULL); - assert(bo->is_gzip == 0 || bo->is_gunzip == 0); + bo->do_gzip = bo->do_gunzip = 0; + bo->do_stream = 0; + return (0); } - /* We won't gunzip unless it is non-empty and gzip'ed */ - if (bo->htc->body_status == BS_NONE || - bo->htc->content_length == 0 || - (bo->do_gunzip && !bo->is_gzip)) + bo->is_gzip = http_HdrIs(bo->beresp, H_Content_Encoding, "gzip"); + bo->is_gunzip = !http_GetHdr(bo->beresp, H_Content_Encoding, NULL); + assert(bo->is_gzip == 0 || bo->is_gunzip == 0); + + /* We won't gunzip unless it is gzip'ed */ + if (bo->do_gunzip && !bo->is_gzip) bo->do_gunzip = 0; - /* We wont gzip unless it is non-empty and ungzip'ed */ - if (bo->htc->body_status == BS_NONE || - bo->htc->content_length == 0 || - (bo->do_gzip && !bo->is_gunzip)) + /* We wont gzip unless if it already is gzip'ed */ + if (bo->do_gzip && !bo->is_gunzip) bo->do_gzip = 0; /* But we can't do both at the same time */ assert(bo->do_gzip == 0 || bo->do_gunzip == 0); if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) - vbf_vfp_push(bo, &VFP_gunzip); - - if (bo->htc->content_length != 0) { - if (bo->do_esi && bo->do_gzip) { - vbf_vfp_push(bo, &VFP_esi_gzip); - } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { - vbf_vfp_push(bo, &VFP_esi_gzip); - } else if (bo->do_esi) { - vbf_vfp_push(bo, &VFP_esi); - } else if (bo->do_gzip) { - vbf_vfp_push(bo, &VFP_gzip); - } else if (bo->is_gzip && !bo->do_gunzip) { - vbf_vfp_push(bo, &VFP_testgunzip); - } + if (VFP_Push(bo->vfc, &VFP_gunzip) == NULL) + return (-1); + + if (bo->do_esi && (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip))) + return (VFP_Push(bo->vfc, &VFP_esi_gzip) == NULL ? -1 : 0); + + if (bo->do_esi) + return (VFP_Push(bo->vfc, &VFP_esi) == NULL ? -1 : 0); + + if (bo->do_gzip) + return (VFP_Push(bo->vfc, &VFP_gzip) == NULL ? -1 : 0); + + if (bo->is_gzip && !bo->do_gunzip) + return (VFP_Push(bo->vfc, &VFP_testgunzip) == NULL ? -1 : 0); + + return (0); +} + +static enum fetch_step +vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) +{ + const char *p; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); + + assert(wrk->handling == VCL_RET_DELIVER); + + if (vbf_figure_out_vfp(bo)) { + (bo)->htc->doclose = SC_OVERLOAD; + VDI_Finish((bo)->wrk, bo); + return (F_STP_ERROR); } if (bo->fetch_objcore->flags & OC_F_PRIVATE) AN(bo->uncacheable); - /* No reason to try streaming a non-existing body */ - if (bo->htc->body_status == BS_NONE) - bo->do_stream = 0; - bo->fetch_objcore->boc->len_so_far = 0; if (VFP_Open(bo->vfc)) { diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 6736242..a085511 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -445,11 +445,6 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (http_HdrIs(vc->http, H_Content_Length, "0")) { - http_Unset(vc->http, H_Content_Encoding); - return (VFP_NULL); - } - if (vfe->vfp == &VFP_gzip) { if (http_GetHdr(vc->http, H_Content_Encoding, NULL)) return (VFP_NULL); From fgsch at lodoss.net Tue Sep 26 07:26:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 26 Sep 2017 07:26:04 +0000 (UTC) Subject: [4.1] aa9fc51 Ignore the alternate stack if the handler is off Message-ID: <20170926072604.C1C056177F@lists.varnish-cache.org> commit aa9fc51c00bdfd8e12d4b385555c9e8a02fdca56 Author: Federico G. Schwindt Date: Sun Sep 24 21:56:38 2017 +0100 Ignore the alternate stack if the handler is off diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index d8b1684..378be3d 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -116,7 +116,8 @@ void THR_Init(void) { #ifdef HAVE_SIGALTSTACK - AZ(sigaltstack(&altstack, NULL)); + if (altstack.ss_sp != NULL) + AZ(sigaltstack(&altstack, NULL)); #endif } diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index d8008af..f199fc9 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -39,4 +39,13 @@ client c1 { delay 7 -varnish v1 -cliok "panic.show" +varnish v1 -cliok "panic.clear" + +# Also check without the handler +varnish v1 -cliok "param.set sigsegv_handler off" +varnish v1 -vcl+backend {} -start + +client c1 { + txreq + rxresp +} -run From phk at FreeBSD.org Tue Sep 26 20:49:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Sep 2017 20:49:07 +0000 (UTC) Subject: [master] 4376215 Morph VDI_Healthy() into VRT_Healthy() and move the rest of the VDI_ functions out of $ABI VRT. Message-ID: <20170926204907.DEC4061D59@lists.varnish-cache.org> commit 4376215b4c3c492d532b6782178a62c57a3aed43 Author: Poul-Henning Kamp Date: Tue Sep 26 20:47:24 2017 +0000 Morph VDI_Healthy() into VRT_Healthy() and move the rest of the VDI_ functions out of $ABI VRT. diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 0f65369..3b2df2c 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -39,6 +39,8 @@ #include "cache_director.h" +#include "vrt.h" + /* Resolve director --------------------------------------------------*/ static const struct director * @@ -172,13 +174,16 @@ VDI_Http1Pipe(struct req *req, struct busyobj *bo) */ int -VDI_Healthy(const struct director *d, const struct busyobj *bo) +VRT_Healthy(VRT_CTX, VCL_BACKEND be) { - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - if (d->healthy == NULL) + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (be == NULL) + return (0); + CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); + if (be->healthy == NULL) return (1); - return (d->healthy(d, bo, NULL)); + return (be->healthy(be, ctx->bo, NULL)); } /* Dump panic info ----------------------------------------------------- diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index a02e086..8f60d6a 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -37,18 +37,10 @@ * */ -/*-------------------------------------------------------------------- - * A director is a piece of code which selects one of possibly multiple - * backends to use. - */ - - typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *, double *changed); - typedef const struct director *vdi_resolve_f(const struct director *, struct worker *, struct busyobj *); - typedef int vdi_gethdrs_f(const struct director *, struct worker *, struct busyobj *); typedef int vdi_getbody_f(const struct director *, struct worker *, @@ -79,16 +71,3 @@ struct director { void *priv; const void *priv2; }; - -/* cache_director.c */ - -int VDI_GetHdr(struct worker *, struct busyobj *); -int VDI_GetBody(struct worker *, struct busyobj *); -const struct suckaddr *VDI_GetIP(struct worker *, struct busyobj *); - -void VDI_Finish(struct worker *wrk, struct busyobj *bo); - -enum sess_close VDI_Http1Pipe(struct req *, struct busyobj *); - -int VDI_Healthy(const struct director *, const struct busyobj *); -void VDI_Panic(const struct director *, struct vsb *, const char *nm); diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index 5faec37..2dcf32d 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -49,6 +49,14 @@ void VBT_Init(void); /* cache_backend_poll.c */ void VBP_Init(void); +/* cache_director.c */ +int VDI_GetHdr(struct worker *, struct busyobj *); +int VDI_GetBody(struct worker *, struct busyobj *); +const struct suckaddr *VDI_GetIP(struct worker *, struct busyobj *); +void VDI_Finish(struct worker *wrk, struct busyobj *bo); +enum sess_close VDI_Http1Pipe(struct req *, struct busyobj *); +void VDI_Panic(const struct director *, struct vsb *, const char *nm); + /* cache_exp.c */ double EXP_Ttl(const struct req *, const struct objcore *); void EXP_Insert(struct worker *wrk, struct objcore *oc); diff --git a/include/vrt.h b/include/vrt.h index fc08b68..27fd57b 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -48,7 +48,9 @@ * binary/load-time compatible, increment MAJOR version * * - * 6.1 (unreleased): + * 6.2 (scheduled for: 2018-03-15) + * VRT_Healthy() added + * 6.1 (2017-09-15 aka 5.2) * http_CollectHdrSep added * VRT_purge modified (may fail a transaction, signature changed) * 6.0 (2017-03-15): @@ -77,7 +79,7 @@ #define VRT_MAJOR_VERSION 6U -#define VRT_MINOR_VERSION 1U +#define VRT_MINOR_VERSION 2U /***********************************************************************/ @@ -355,6 +357,11 @@ void VRT_synth_page(VRT_CTX, const char *, ...); /* Backend related */ struct director *VRT_new_backend(VRT_CTX, const struct vrt_backend *); void VRT_delete_backend(VRT_CTX, struct director **); +int VRT_backend_healthy(VRT_CTX, struct director *); + + +/* cache_director.c */ +int VRT_Healthy(VRT_CTX, VCL_BACKEND); /* Suckaddr related */ int VRT_VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst); diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 28cfe2f..915b7f2 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -198,10 +198,8 @@ VCL_BOOL __match_proto__(td_std_healthy) vmod_healthy(VRT_CTX, VCL_BACKEND be) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (be == NULL) - return (0); - CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - return (VDI_Healthy(be, ctx->bo)); + CHECK_OBJ_ORNULL(be, DIRECTOR_MAGIC); + return (VRT_Healthy(ctx, be)); } VCL_INT __match_proto__(td_std_port) From phk at FreeBSD.org Tue Sep 26 21:53:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Sep 2017 21:53:08 +0000 (UTC) Subject: [master] 86ecb84 Pass mgt_cls via the heritage structure. Message-ID: <20170926215308.35133611D3@lists.varnish-cache.org> commit 86ecb8429d59460cf1cfc74a62a74626f5310ec1 Author: Poul-Henning Kamp Date: Tue Sep 26 21:31:49 2017 +0000 Pass mgt_cls via the heritage structure. diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index 905dee5..e7e5001 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -126,7 +126,7 @@ CLI_Init(void) cls = VCLS_New(cli_cb_before, cli_cb_after, &cache_param->cli_buffer, &cache_param->cli_limit); AN(cls); - VCLS_Clone(cls, mgt_cls); + VCLS_Clone(cls, heritage.cls); CLI_AddFuncs(cli_cmds); } diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index 3d5a3ae..78e6599 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -76,6 +76,3 @@ const struct transport *XPORT_Find(const char *name); /* cache/cache_vcl.c */ int VCL_TestLoad(const char *); - -/* mgt_cli.c */ -extern struct VCLS *mgt_cls; diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h index 95f6c3e..238c293 100644 --- a/bin/varnishd/common/heritage.h +++ b/bin/varnishd/common/heritage.h @@ -33,6 +33,7 @@ struct vsmw; struct suckaddr; struct listen_sock; struct transport; +struct VCLS; struct listen_arg { unsigned magic; @@ -81,6 +82,8 @@ struct heritage { char *panic_str; ssize_t panic_str_len; + + struct VCLS *cls; }; extern struct heritage heritage; diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index b5b46a4..7594bd4 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -65,6 +65,7 @@ void MCH_TrackHighFd(int fd); void MCH_Cli_Fail(void); /* mgt_cli.c */ +extern struct VCLS *mgt_cls; typedef void mgt_cli_close_f(void *priv); void mgt_cli_setup(int fdi, int fdo, int auth, const char *ident, diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 38d0674..6aec3f4 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -338,7 +338,6 @@ mgt_launch_child(struct cli *cli) } if (pid == 0) { - /* Redirect stdin/out/err */ VFIL_null_fd(STDIN_FILENO); assert(dup2(heritage.std_fd, STDOUT_FILENO) == STDOUT_FILENO); @@ -363,7 +362,11 @@ mgt_launch_child(struct cli *cli) if (close(i) == 0) VFIL_null_fd(i); } + mgt_ProcTitle("Child"); + + heritage.cls = mgt_cls; + if (mgt_param.sigsegv_handler) { memset(&sa, 0, sizeof sa); sa.sa_sigaction = child_signal_handler; From phk at FreeBSD.org Tue Sep 26 21:53:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Sep 2017 21:53:08 +0000 (UTC) Subject: [master] 9c8609d Pass ident via heritage. Message-ID: <20170926215308.54660611E1@lists.varnish-cache.org> commit 9c8609de2569edf3088dd2cf6f4fe5c5fe587993 Author: Poul-Henning Kamp Date: Tue Sep 26 21:40:12 2017 +0000 Pass ident via heritage. diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 6e5a660..4cadaea 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -630,7 +630,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, VSB_printf(pan_vsb, "version = %s, vrt api = %u.%u\n", VCS_version, VRT_MAJOR_VERSION, VRT_MINOR_VERSION); VSB_printf(pan_vsb, "ident = %s,%s\n", - VSB_data(vident) + 1, Waiter_GetName()); + heritage.ident + 1, Waiter_GetName()); VSB_printf(pan_vsb, "now = %f (mono), %f (real)\n", VTIM_mono(), VTIM_real()); diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index 78e6599..b969cc3 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -50,15 +50,9 @@ # define MAX_THREAD_POOLS 32 #endif -/* Name of transient storage */ -#define TRANSIENT_STORAGE "Transient" - extern pid_t mgt_pid; #define ASSERT_MGT() do { assert(getpid() == mgt_pid);} while (0) -/* varnishd.c */ -extern struct vsb *vident; // XXX: -> heritage ? - /* Really belongs in mgt.h, but storage_file chokes on both */ void MCH_Fd_Inherit(int fd, const char *what); diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h index 238c293..461c387 100644 --- a/bin/varnishd/common/heritage.h +++ b/bin/varnishd/common/heritage.h @@ -84,6 +84,8 @@ struct heritage { ssize_t panic_str_len; struct VCLS *cls; + + const char *ident; }; extern struct heritage heritage; diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 7594bd4..4573fbd 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -135,6 +135,7 @@ extern const struct jail_tech jail_tech_unix; extern const struct jail_tech jail_tech_solaris; /* mgt_main.c */ +extern struct vsb *vident; extern struct VSC_mgt *VSC_C_mgt; struct choice { const char *name; diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 6aec3f4..9d908fb 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -366,6 +366,7 @@ mgt_launch_child(struct cli *cli) mgt_ProcTitle("Child"); heritage.cls = mgt_cls; + heritage.ident = VSB_data(vident) + 1; if (mgt_param.sigsegv_handler) { memset(&sa, 0, sizeof sa); diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index b1d0288..4146ff9 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -46,6 +46,9 @@ static VTAILQ_HEAD(, stevedore) stevedores = VTAILQ_HEAD_INITIALIZER(stevedores); +/* Name of transient storage */ +#define TRANSIENT_STORAGE "Transient" + struct stevedore *stv_transient; /*--------------------------------------------------------------------*/ From phk at FreeBSD.org Tue Sep 26 21:53:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Sep 2017 21:53:08 +0000 (UTC) Subject: [master] bfbb26e No need for this to live in common.h Message-ID: <20170926215308.7F4C9611E5@lists.varnish-cache.org> commit bfbb26e211a9105ddcbf9fd275ff0777db0cd26b Author: Poul-Henning Kamp Date: Tue Sep 26 21:47:36 2017 +0000 No need for this to live in common.h diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index b969cc3..850ad05 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -46,10 +46,6 @@ /**********************************************************************/ -#if !defined(MAX_THREAD_POOLS) -# define MAX_THREAD_POOLS 32 -#endif - extern pid_t mgt_pid; #define ASSERT_MGT() do { assert(getpid() == mgt_pid);} while (0) diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index d4eec41..f27f04f 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -287,6 +287,10 @@ init_params(struct cli *cli) def = low; MCF_ParamConf(MCF_DEFAULT, "thread_pool_stack", "%jdb", (intmax_t)def); +#if !defined(MAX_THREAD_POOLS) +# define MAX_THREAD_POOLS 32 +#endif + MCF_ParamConf(MCF_MAXIMUM, "thread_pools", "%d", MAX_THREAD_POOLS); MCF_InitParams(cli); From phk at FreeBSD.org Wed Sep 27 08:45:11 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Sep 2017 08:45:11 +0000 (UTC) Subject: [master] 8bd3b43 Move shared stuff from common.h to heritage.h Message-ID: <20170927084511.7791B618E7@lists.varnish-cache.org> commit 8bd3b43ff831a64c1a8eef6de2f3205699d8d9ee Author: Poul-Henning Kamp Date: Wed Sep 27 07:33:10 2017 +0000 Move shared stuff from common.h to heritage.h diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 004e217..26c4772 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -36,6 +36,7 @@ #include #include "cache.h" +#include "common/heritage.h" #include "vrt.h" #include "vcl.h" diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index 850ad05..9b71491 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -58,11 +58,3 @@ void MCH_Fd_Inherit(int fd, const char *what); fprintf(stderr, "(-? gives usage)\n"); \ exit(2); \ } while (0) - -/* cache/cache_acceptor.c */ -struct transport; -void XPORT_Init(void); -const struct transport *XPORT_Find(const char *name); - -/* cache/cache_vcl.c */ -int VCL_TestLoad(const char *); diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h index 461c387..f2df8c1 100644 --- a/bin/varnishd/common/heritage.h +++ b/bin/varnishd/common/heritage.h @@ -1,3 +1,4 @@ + /*- * Copyright (c) 2006 Verdens Gang AS * Copyright (c) 2006-2011 Varnish Software AS @@ -90,4 +91,13 @@ struct heritage { extern struct heritage heritage; +/* cache/cache_main.c */ void child_main(void); + +/* cache/cache_vcl.c */ +int VCL_TestLoad(const char *); + +/* cache/cache_acceptor.c */ +struct transport; +void XPORT_Init(void); +const struct transport *XPORT_Find(const char *name); diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 641131a..42f4b6d 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -40,6 +40,7 @@ #include #include "mgt/mgt.h" +#include "common/heritage.h" #include "storage/storage.h" #include "libvcc.h" From phk at FreeBSD.org Wed Sep 27 08:45:11 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Sep 2017 08:45:11 +0000 (UTC) Subject: [master] d8dfd9c Retire common.h Message-ID: <20170927084511.91710618E9@lists.varnish-cache.org> commit d8dfd9c12cd55474fb790b82ddfdff37dd6af084 Author: Poul-Henning Kamp Date: Wed Sep 27 07:51:47 2017 +0000 Retire common.h diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 7fe38a5..24b814b 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -139,7 +139,6 @@ nobase_pkginclude_HEADERS = \ cache/cache_filter.h \ cache/cache_backend.h \ cache/cache_director.h \ - common/common.h \ common/common_vsm.h \ common/com_params.h \ waiter/waiter.h diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index c228b69..7fcdd52 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -35,8 +35,16 @@ #define VARNISH_CACHE_CHILD 1 #include +#include -#include "common/common.h" +#include + +#include "miniobj.h" +#include "vas.h" +#include "vcs.h" +#include "vdef.h" +#include "vqueue.h" +#include "vsb.h" #include "vapi/vsl_int.h" diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h deleted file mode 100644 index 9b71491..0000000 --- a/bin/varnishd/common/common.h +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2011 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. - * - */ - -#ifdef COMMON_COMMON_H -#error "Multiple includes of common/common.h" -#endif -#define COMMON_COMMON_H - -#include - -#include - -#include "miniobj.h" -#include "vas.h" -#include "vcs.h" -#include "vdef.h" -#include "vqueue.h" -#include "vsb.h" - -/**********************************************************************/ - -extern pid_t mgt_pid; -#define ASSERT_MGT() do { assert(getpid() == mgt_pid);} while (0) - -/* Really belongs in mgt.h, but storage_file chokes on both */ -void MCH_Fd_Inherit(int fd, const char *what); - -#define ARGV_ERR(...) \ - do { \ - fprintf(stderr, "Error: " __VA_ARGS__); \ - fprintf(stderr, "(-? gives usage)\n"); \ - exit(2); \ - } while (0) diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c index bc8dabf..1523cea 100644 --- a/bin/varnishd/common/common_vsc.c +++ b/bin/varnishd/common/common_vsc.c @@ -31,17 +31,21 @@ #include #include +#include #include #include #include -#include "common.h" #include "common/common_vsm.h" +#include "vdef.h" +#include "miniobj.h" +#include "vas.h" #include "vend.h" #include "vsmw.h" #include "vgz.h" #include "vmb.h" +#include "vqueue.h" #include "vapi/vsc_int.h" struct vsmw *proc_vsmw; diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h index f2df8c1..b12e9ea 100644 --- a/bin/varnishd/common/heritage.h +++ b/bin/varnishd/common/heritage.h @@ -87,10 +87,25 @@ struct heritage { struct VCLS *cls; const char *ident; + + long mgt_pid; }; extern struct heritage heritage; +#define ASSERT_MGT() do { assert(getpid() == heritage.mgt_pid);} while (0) + +/* Really belongs in mgt.h, but storage_file chokes on both */ +void MCH_Fd_Inherit(int fd, const char *what); + +#define ARGV_ERR(...) \ + do { \ + ASSERT_MGT(); \ + fprintf(stderr, "Error: " __VA_ARGS__); \ + fprintf(stderr, "(-? gives usage)\n"); \ + exit(2); \ + } while (0) + /* cache/cache_main.c */ void child_main(void); diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index 87db657..a4e9861 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -32,6 +32,7 @@ #include "config.h" #include "cache/cache.h" +#include "common/heritage.h" #include #include diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 4573fbd..5256a0a 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -33,7 +33,18 @@ #endif #define MGT_MGT_H -#include "common/common.h" + +#include + +#include + +#include "miniobj.h" +#include "vas.h" +#include "vcs.h" +#include "vdef.h" +#include "vqueue.h" +#include "vsb.h" + #include "common/com_params.h" #include "VSC_mgt.h" diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index f00e19a..dd031ed 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -44,6 +44,7 @@ #include #include "mgt/mgt.h" +#include "common/heritage.h" #include "vcli_serve.h" #include "vev.h" diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c index d241cf7..b413821 100644 --- a/bin/varnishd/mgt/mgt_jail.c +++ b/bin/varnishd/mgt/mgt_jail.c @@ -40,6 +40,7 @@ #include #include "mgt/mgt.h" +#include "common/heritage.h" #include "vav.h" /********************************************************************** diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index f9c0157..27cebb1 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -41,6 +41,7 @@ #include #include "mgt/mgt.h" +#include "common/heritage.h" #ifdef __linux__ #include diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index f27f04f..be1bb67 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -61,7 +61,6 @@ struct heritage heritage; unsigned d_flag = 0; -pid_t mgt_pid; struct vev_base *mgt_evb; int exit_status = 0; struct vsb *vident; @@ -202,7 +201,7 @@ mgt_secret_atexit(void) { /* Only master process */ - if (getpid() != mgt_pid) + if (getpid() != heritage.mgt_pid) return; VJ_master(JAIL_MASTER_FILE); (void)unlink("_.secret"); @@ -240,7 +239,7 @@ mgt_Cflag_atexit(void) { /* Only master process */ - if (getpid() != mgt_pid) + if (getpid() != heritage.mgt_pid) return; (void)rmdir("vmod_cache"); (void)unlink("_.pid"); @@ -313,7 +312,7 @@ mgt_initialize(struct cli *cli) static unsigned clilim = 32768; /* for ASSERT_MGT() */ - mgt_pid = getpid(); + heritage.mgt_pid = getpid(); /* Create a cli for convenience in otherwise CLI functions */ INIT_OBJ(cli, CLI_MAGIC); @@ -593,7 +592,7 @@ main(int argc, char * const *argv) if (!C_flag && !d_flag && !F_flag) { eric_fd = mgt_eric(); MCH_TrackHighFd(eric_fd); - mgt_pid = getpid(); + heritage.mgt_pid = getpid(); } VRND_SeedAll(); diff --git a/bin/varnishd/mgt/mgt_param_tcp.c b/bin/varnishd/mgt/mgt_param_tcp.c index 70ababc..ef55533 100644 --- a/bin/varnishd/mgt/mgt_param_tcp.c +++ b/bin/varnishd/mgt/mgt_param_tcp.c @@ -43,6 +43,7 @@ #include #include "mgt/mgt.h" +#include "common/heritage.h" #include "vtcp.h" diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index 6853a1f..eda3428 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -72,7 +72,7 @@ mgt_shm_atexit(void) { /* Do not let VCC kill our VSM */ - if (getpid() != mgt_pid) + if (getpid() != heritage.mgt_pid) return; VJ_master(JAIL_MASTER_FILE); VSMW_Destroy(&mgt_vsmw); diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 61aae33..8a879ab 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -40,6 +40,7 @@ #include #include "mgt/mgt.h" +#include "common/heritage.h" #include "libvcc.h" #include "vcli_serve.h" @@ -902,7 +903,7 @@ mgt_vcl_atexit(void) { struct vclprog *vp; - if (getpid() != mgt_pid) + if (getpid() != heritage.mgt_pid) return; active_vcl = NULL; do { diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index 4146ff9..c3e161d 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -39,6 +39,7 @@ #include #include "mgt/mgt.h" +#include "common/heritage.h" #include "vcli_serve.h" #include "storage/storage.h" diff --git a/bin/varnishd/storage/mgt_storage_persistent.c b/bin/varnishd/storage/mgt_storage_persistent.c index 747032b..d0155cd 100644 --- a/bin/varnishd/storage/mgt_storage_persistent.c +++ b/bin/varnishd/storage/mgt_storage_persistent.c @@ -36,6 +36,7 @@ #include "config.h" #include "cache/cache.h" +#include "common/heritage.h" #include diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index d620447..80e8fd8 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -41,6 +41,7 @@ #include #include "mgt/mgt.h" +#include "common/heritage.h" #include "storage/storage.h" #include "vnum.h" diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 675bf62..b0480b8 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -32,6 +32,7 @@ #include "config.h" #include "cache/cache.h" +#include "common/heritage.h" #include diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c index 083b741..7da5c4a 100644 --- a/bin/varnishd/storage/storage_malloc.c +++ b/bin/varnishd/storage/storage_malloc.c @@ -32,6 +32,7 @@ #include "config.h" #include "cache/cache.h" +#include "common/heritage.h" #include #include diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index 7a7b866..63ff47d 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -37,6 +37,7 @@ #include #include "cache/cache.h" +#include "common/heritage.h" #include diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index 01780d3..1ea8320 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -33,6 +33,7 @@ #include "mgt/mgt.h" #include "waiter/mgt_waiter.h" +#include "common/heritage.h" static const struct choice waiter_choice[] = { #define WAITER(nm) { #nm, &waiter_##nm }, From phk at FreeBSD.org Wed Sep 27 08:45:11 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Sep 2017 08:45:11 +0000 (UTC) Subject: [master] 75f057c Move the high-level param configuration to mgt_param.c Message-ID: <20170927084511.D2830618EF@lists.varnish-cache.org> commit 75f057cfadf54afee9fc9f49a4c4284329f7f49f Author: Poul-Henning Kamp Date: Wed Sep 27 08:23:51 2017 +0000 Move the high-level param configuration to mgt_param.c diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 4542aae..0262880 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -161,7 +161,6 @@ extern const char C_CLI[]; // CLI traffic between master and child /* mgt_param.c */ void MCF_InitParams(struct cli *); -void MCF_CollectParams(void); enum mcf_which_e { MCF_DEFAULT = 32, MCF_MINIMUM = 33, diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index be1bb67..0bc438a 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -249,53 +249,6 @@ mgt_Cflag_atexit(void) /*--------------------------------------------------------------------*/ static void -init_params(struct cli *cli) -{ - ssize_t def, low; - - MCF_CollectParams(); - - MCF_TcpParams(); - - if (sizeof(void *) < 8) { /*lint !e506 !e774 */ - /* - * Adjust default parameters for 32 bit systems to conserve - * VM space. - */ - MCF_ParamConf(MCF_DEFAULT, "workspace_client", "24k"); - MCF_ParamConf(MCF_DEFAULT, "workspace_backend", "16k"); - MCF_ParamConf(MCF_DEFAULT, "http_resp_size", "8k"); - MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); - MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); - MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G"); - } - -#if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux) - MCF_ParamConf(MCF_DEFAULT, "accept_filter", "off"); -#endif - - low = sysconf(_SC_THREAD_STACK_MIN); - MCF_ParamConf(MCF_MINIMUM, "thread_pool_stack", "%jdb", (intmax_t)low); - -#if defined(WITH_SANITIZERS) - def = 92 * 1024; -#else - def = 48 * 1024; -#endif - if (def < low) - def = low; - MCF_ParamConf(MCF_DEFAULT, "thread_pool_stack", "%jdb", (intmax_t)def); - -#if !defined(MAX_THREAD_POOLS) -# define MAX_THREAD_POOLS 32 -#endif - - MCF_ParamConf(MCF_MAXIMUM, "thread_pools", "%d", MAX_THREAD_POOLS); - - MCF_InitParams(cli); -} - -static void mgt_tests(void) { assert(VTIM_parse("Sun, 06 Nov 1994 08:49:37 GMT") == 784111777); @@ -323,7 +276,7 @@ mgt_initialize(struct cli *cli) mgt_cli_init_cls(); // CLI commands can be registered - init_params(cli); + MCF_InitParams(cli); cli_check(cli); } diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index dc25ea4..25b06df 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "mgt/mgt.h" #include "common/heritage.h" @@ -472,7 +473,7 @@ static struct cli_proto cli_params[] = { }; /*-------------------------------------------------------------------- - * Wash the min/max/default values, and leave the default set. + * Configure the parameters */ void @@ -481,11 +482,54 @@ MCF_InitParams(struct cli *cli) struct plist *pl; struct parspec *pp; struct vsb *vsb; + ssize_t def, low; + + MCF_AddParams(mgt_parspec); + MCF_AddParams(WRK_parspec); + MCF_AddParams(VSL_parspec); + + MCF_TcpParams(); + + if (sizeof(void *) < 8) { /*lint !e506 !e774 */ + /* + * Adjust default parameters for 32 bit systems to conserve + * VM space. + */ + MCF_ParamConf(MCF_DEFAULT, "workspace_client", "24k"); + MCF_ParamConf(MCF_DEFAULT, "workspace_backend", "16k"); + MCF_ParamConf(MCF_DEFAULT, "http_resp_size", "8k"); + MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); + MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); + MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G"); + } + +#if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux) + MCF_ParamConf(MCF_DEFAULT, "accept_filter", "off"); +#endif + + low = sysconf(_SC_THREAD_STACK_MIN); + MCF_ParamConf(MCF_MINIMUM, "thread_pool_stack", "%jdb", (intmax_t)low); + +#if defined(WITH_SANITIZERS) + def = 92 * 1024; +#else + def = 48 * 1024; +#endif + if (def < low) + def = low; + MCF_ParamConf(MCF_DEFAULT, "thread_pool_stack", "%jdb", (intmax_t)def); + +#if !defined(MAX_THREAD_POOLS) +# define MAX_THREAD_POOLS 32 +#endif + + MCF_ParamConf(MCF_MAXIMUM, "thread_pools", "%d", MAX_THREAD_POOLS); VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_params); vsb = VSB_new_auto(); AN(vsb); + VTAILQ_FOREACH(pl, &phead, list) { pp = pl->spec; @@ -504,17 +548,6 @@ MCF_InitParams(struct cli *cli) /*--------------------------------------------------------------------*/ void -MCF_CollectParams(void) -{ - - MCF_AddParams(mgt_parspec); - MCF_AddParams(WRK_parspec); - MCF_AddParams(VSL_parspec); -} - -/*--------------------------------------------------------------------*/ - -void MCF_ParamConf(enum mcf_which_e which, const char *param, const char *fmt, ...) { struct parspec *pp; From phk at FreeBSD.org Wed Sep 27 08:45:11 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Sep 2017 08:45:11 +0000 (UTC) Subject: [master] 5d547d7 Rename com_params.h to common_param.h for consistency Message-ID: <20170927084511.B4E31618EC@lists.varnish-cache.org> commit 5d547d79b5c1516c005e3ba23ca416b7d6134859 Author: Poul-Henning Kamp Date: Wed Sep 27 08:12:25 2017 +0000 Rename com_params.h to common_param.h for consistency diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 24b814b..d2d32e6 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -140,7 +140,7 @@ nobase_pkginclude_HEADERS = \ cache/cache_backend.h \ cache/cache_director.h \ common/common_vsm.h \ - common/com_params.h \ + common/common_param.h \ waiter/waiter.h pkgdatadir = ${datarootdir}/${PACKAGE}/vcl diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7fcdd52..7f0a3c7 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -59,7 +59,7 @@ #include #include -#include "common/com_params.h" +#include "common/common_param.h" /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/common/com_params.h b/bin/varnishd/common/com_params.h deleted file mode 100644 index 07080d3..0000000 --- a/bin/varnishd/common/com_params.h +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2011 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. - * - * This file contains the heritage passed when mgt forks cache - */ - -#ifdef COMMON_COM_PARAMS_H -#error "Multiple includes of common/com_params.h" -#endif -#define COMMON_COM_PARAMS_H - -#include "vre.h" - -#define VSM_CLASS_PARAM "Params" - -enum debug_bits { -#define DEBUG_BIT(U, l, d) DBG_##U, -#include "tbl/debug_bits.h" - DBG_Reserved -}; - -enum feature_bits { -#define FEATURE_BIT(U, l, d, ld) FEATURE_##U, -#include "tbl/feature_bits.h" - FEATURE_Reserved -}; - -struct poolparam { - unsigned min_pool; - unsigned max_pool; - double max_age; -}; - -struct params { - -#define ptyp_bool unsigned -#define ptyp_bytes ssize_t -#define ptyp_bytes_u unsigned -#define ptyp_double double -#define ptyp_poolparam struct poolparam -#define ptyp_timeout double -#define ptyp_uint unsigned -#define ptyp_vsl_buffer unsigned -#define ptyp_vsl_reclen unsigned -#define PARAM(nm, ty, mi, ma, de, un, fl, st, lt, fn) ptyp_##ty nm; -#include -#undef ptyp_bool -#undef ptyp_bytes -#undef ptyp_bytes_u -#undef ptyp_double -#undef ptyp_poolparam -#undef ptyp_timeout -#undef ptyp_uint -#undef ptyp_vsl_buffer -#undef ptyp_vsl_reclen - - /* Unprivileged user / group */ - uid_t uid; - gid_t gid; - - /* Worker threads and pool */ - unsigned wthread_min; - unsigned wthread_max; - unsigned wthread_reserve; - double wthread_timeout; - unsigned wthread_pools; - double wthread_add_delay; - double wthread_fail_delay; - double wthread_destroy_delay; - unsigned wthread_stats_rate; - ssize_t wthread_stacksize; - unsigned wthread_queue_limit; - - struct vre_limits vre_limits; - - struct poolparam req_pool; - struct poolparam sess_pool; - struct poolparam vbo_pool; - - uint8_t vsl_mask[256>>3]; - uint8_t debug_bits[(DBG_Reserved+7)>>3]; - uint8_t feature_bits[(FEATURE_Reserved+7)>>3]; -}; diff --git a/bin/varnishd/common/common_param.h b/bin/varnishd/common/common_param.h new file mode 100644 index 0000000..a131697 --- /dev/null +++ b/bin/varnishd/common/common_param.h @@ -0,0 +1,108 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2011 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. + * + * This file contains the heritage passed when mgt forks cache + */ + +#ifdef COMMON_COMMON_PARAM_H +#error "Multiple includes of common/common_param.h" +#endif +#define COMMON_COMMON_PARAM_H + +#include "vre.h" + +#define VSM_CLASS_PARAM "Params" + +enum debug_bits { +#define DEBUG_BIT(U, l, d) DBG_##U, +#include "tbl/debug_bits.h" + DBG_Reserved +}; + +enum feature_bits { +#define FEATURE_BIT(U, l, d, ld) FEATURE_##U, +#include "tbl/feature_bits.h" + FEATURE_Reserved +}; + +struct poolparam { + unsigned min_pool; + unsigned max_pool; + double max_age; +}; + +struct params { + +#define ptyp_bool unsigned +#define ptyp_bytes ssize_t +#define ptyp_bytes_u unsigned +#define ptyp_double double +#define ptyp_poolparam struct poolparam +#define ptyp_timeout double +#define ptyp_uint unsigned +#define ptyp_vsl_buffer unsigned +#define ptyp_vsl_reclen unsigned +#define PARAM(nm, ty, mi, ma, de, un, fl, st, lt, fn) ptyp_##ty nm; +#include +#undef ptyp_bool +#undef ptyp_bytes +#undef ptyp_bytes_u +#undef ptyp_double +#undef ptyp_poolparam +#undef ptyp_timeout +#undef ptyp_uint +#undef ptyp_vsl_buffer +#undef ptyp_vsl_reclen + + /* Unprivileged user / group */ + uid_t uid; + gid_t gid; + + /* Worker threads and pool */ + unsigned wthread_min; + unsigned wthread_max; + unsigned wthread_reserve; + double wthread_timeout; + unsigned wthread_pools; + double wthread_add_delay; + double wthread_fail_delay; + double wthread_destroy_delay; + unsigned wthread_stats_rate; + ssize_t wthread_stacksize; + unsigned wthread_queue_limit; + + struct vre_limits vre_limits; + + struct poolparam req_pool; + struct poolparam sess_pool; + struct poolparam vbo_pool; + + uint8_t vsl_mask[256>>3]; + uint8_t debug_bits[(DBG_Reserved+7)>>3]; + uint8_t feature_bits[(FEATURE_Reserved+7)>>3]; +}; diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 5256a0a..4542aae 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -45,7 +45,7 @@ #include "vqueue.h" #include "vsb.h" -#include "common/com_params.h" +#include "common/common_param.h" #include "VSC_mgt.h" From phk at FreeBSD.org Wed Sep 27 08:45:12 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Sep 2017 08:45:12 +0000 (UTC) Subject: [master] 33cd88b Typo in previous Message-ID: <20170927084512.15C0B618F7@lists.varnish-cache.org> commit 33cd88b44d22b5cf0dfd44e40dd17052f0e9fba9 Author: Poul-Henning Kamp Date: Wed Sep 27 08:33:46 2017 +0000 Typo in previous diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index b8f23bf..87f1d92 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -227,4 +227,4 @@ extern unsigned mgt_vcc_unsafe_path; #endif #define MGT_FEATURE(x) COM_FEATURE(mgt_param.feature_bits, x) -#define MGT_DO_DEBUG(x) COM_DO_DEBUG(mgt_param.feature_bits, x) +#define MGT_DO_DEBUG(x) COM_DO_DEBUG(mgt_param.debug_bits, x) From phk at FreeBSD.org Wed Sep 27 08:45:11 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Sep 2017 08:45:11 +0000 (UTC) Subject: [master] 519f383 Don't have two copies of the param->bitmap magic Message-ID: <20170927084511.EF4E8618F4@lists.varnish-cache.org> commit 519f3839e0b26b304306a9bf5b64bbefc87d705d Author: Poul-Henning Kamp Date: Wed Sep 27 08:32:32 2017 +0000 Don't have two copies of the param->bitmap magic diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7f0a3c7..987cbd1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1062,19 +1062,8 @@ Tlen(const txt t) */ #define W_TIM_real(w) ((w)->lastused = VTIM_real()) -static inline int -FEATURE(enum feature_bits x) -{ - return (cache_param->feature_bits[(unsigned)x>>3] & - (0x80U >> ((unsigned)x & 7))); -} - -static inline int -DO_DEBUG(enum debug_bits x) -{ - return (cache_param->debug_bits[(unsigned)x>>3] & - (0x80U >> ((unsigned)x & 7))); -} +#define FEATURE(x) COM_FEATURE(cache_param->feature_bits, x) +#define DO_DEBUG(x) COM_DO_DEBUG(cache_param->debug_bits, x) #define DSL(debug_bit, id, ...) \ do { \ diff --git a/bin/varnishd/common/common_param.h b/bin/varnishd/common/common_param.h index a131697..ee9a12b 100644 --- a/bin/varnishd/common/common_param.h +++ b/bin/varnishd/common/common_param.h @@ -44,12 +44,25 @@ enum debug_bits { DBG_Reserved }; +static inline int +COM_DO_DEBUG(uint8_t volatile *p, enum debug_bits x) +{ + return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))); +} + enum feature_bits { #define FEATURE_BIT(U, l, d, ld) FEATURE_##U, #include "tbl/feature_bits.h" FEATURE_Reserved }; +static inline int +COM_FEATURE(uint8_t volatile *p, enum feature_bits x) +{ + return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))); +} + + struct poolparam { unsigned min_pool; unsigned max_pool; diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 0262880..b8f23bf 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -226,16 +226,5 @@ extern unsigned mgt_vcc_unsafe_path; #error "Keep pthreads out of in manager process" #endif -static inline int -MGT_FEATURE(enum feature_bits x) -{ - return (mgt_param.feature_bits[(unsigned)x>>3] & - (0x80U >> ((unsigned)x & 7))); -} - -static inline int -MGT_DO_DEBUG(enum debug_bits x) -{ - return (mgt_param.debug_bits[(unsigned)x>>3] & - (0x80U >> ((unsigned)x & 7))); -} +#define MGT_FEATURE(x) COM_FEATURE(mgt_param.feature_bits, x) +#define MGT_DO_DEBUG(x) COM_DO_DEBUG(mgt_param.feature_bits, x) From hermunn at varnish-software.com Wed Sep 27 09:47:04 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Wed, 27 Sep 2017 09:47:04 +0000 (UTC) Subject: [4.1] cdc5cf3 Update changelog Message-ID: <20170927094704.705746172C@lists.varnish-cache.org> commit cdc5cf330850d668c041c4b252b71f4846c0e2c3 Author: P?l Hermunn Johansen Date: Wed Sep 27 11:42:33 2017 +0200 Update changelog diff --git a/doc/changes.rst b/doc/changes.rst index 78670a1..ae32686 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -2,7 +2,35 @@ Varnish Cache 4.1.9-beta1 (unreleased) ====================================== +Changes since 4.1.8: + * Added ``bereq.is_bgfetch`` which is true for background fetches. +* Add the vtc feature ignore_unknown_macro. +* Expose to VCL whether or not a fetch is a background fetch (bgfetch) +* Ignore req.ttl when keeping track of epired objects (see 2422_) +* Move the cli buffer to VSB (from stack). This deprecates the parameter + cli_buffer. + +.. _2422: https://github.com/varnishcache/varnish-cache/pull/2422 + +Bugs fixed +---------- + +* 2337_ and 2366_ - Both Upgrade and Connection headers are needed for + WebSocket now +* 2372_ - Fix problem with purging and the n_obj_purged counter +* 2373_ - VSC n_vcl, n_vcl_avail, n_vcl_discard are gauge +* 2380_ - Correct regexp in examples. +* 2390_ - Straighten locking wrt vcl_active +* 2429_ - Avoid buffer read overflow on vcl_error and -sfile + +.. _2337: https://github.com/varnishcache/varnish-cache/issues/2337 +.. _2366: https://github.com/varnishcache/varnish-cache/issues/2366 +.. _2372: https://github.com/varnishcache/varnish-cache/pull/2372 +.. _2373: https://github.com/varnishcache/varnish-cache/issues/2373 +.. _2380: https://github.com/varnishcache/varnish-cache/issues/2380 +.. _2390: https://github.com/varnishcache/varnish-cache/issues/2390 +.. _2429: https://github.com/varnishcache/varnish-cache/pull/2429 ================================ Varnish Cache 4.1.8 (2017-08-02) From nils.goroll at uplex.de Wed Sep 27 12:11:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Sep 2017 12:11:05 +0000 (UTC) Subject: [master] cf3c9d9 varnishtest: change varnish -expect to accept PATTERN and update SMA checks Message-ID: <20170927121105.C816562F3A@lists.varnish-cache.org> commit cf3c9d9213c12e3c58a391b068398f8fd1d1c17c Author: Nils Goroll Date: Wed Sep 27 14:06:59 2017 +0200 varnishtest: change varnish -expect to accept PATTERN and update SMA checks In varnishtest, varnish checks now use -expect PATTERN OP NUMBER PATTERN being a glob pattern (see fnmatch(3)). Make all vtc checking for SMA counters stevedore-type agnostic by matching on SM? diff --git a/bin/varnishtest/tests/b00002.vtc b/bin/varnishtest/tests/b00002.vtc index d0f3cc6..f56fae0 100644 --- a/bin/varnishtest/tests/b00002.vtc +++ b/bin/varnishtest/tests/b00002.vtc @@ -35,7 +35,7 @@ client c1 { delay .1 varnish v1 -expect n_object == 0 -varnish v1 -expect SMA.Transient.g_alloc == 0 +varnish v1 -expect SM?.Transient.g_alloc == 0 varnish v1 -expect sess_conn == 1 varnish v1 -expect client_req == 1 varnish v1 -expect s_sess == 1 diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index 2c0cf66..f9ebad6 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -37,13 +37,13 @@ client c1 { expect resp.bodylen == 1048290 } -run -varnish v1 -expect SMA.Transient.g_bytes == 0 -varnish v1 -expect SMA.s0.g_bytes == 0 -varnish v1 -expect SMA.s0.g_space > 1000000 -varnish v1 -expect SMA.s1.g_bytes > 1000000 -varnish v1 -expect SMA.s1.g_space < 200 -varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SM?.Transient.g_bytes == 0 +varnish v1 -expect SM?.s0.g_bytes == 0 +varnish v1 -expect SM?.s0.g_space > 1000000 +varnish v1 -expect SM?.s1.g_bytes > 1000000 +varnish v1 -expect SM?.s1.g_space < 200 +varnish v1 -expect SM?.s2.g_bytes == 0 +varnish v1 -expect SM?.s2.g_space > 1000000 client c1 { txreq -url /bar @@ -52,13 +52,13 @@ client c1 { expect resp.bodylen == 1048291 } -run -varnish v1 -expect SMA.Transient.g_bytes == 0 -varnish v1 -expect SMA.s0.g_bytes == 0 -varnish v1 -expect SMA.s0.g_space > 1000000 -varnish v1 -expect SMA.s1.g_bytes > 1000000 -varnish v1 -expect SMA.s1.g_space < 200 -varnish v1 -expect SMA.s2.g_bytes > 1000000 -varnish v1 -expect SMA.s2.g_space < 200 +varnish v1 -expect SM?.Transient.g_bytes == 0 +varnish v1 -expect SM?.s0.g_bytes == 0 +varnish v1 -expect SM?.s0.g_space > 1000000 +varnish v1 -expect SM?.s1.g_bytes > 1000000 +varnish v1 -expect SM?.s1.g_space < 200 +varnish v1 -expect SM?.s2.g_bytes > 1000000 +varnish v1 -expect SM?.s2.g_space < 200 client c1 { txreq -url /burp @@ -67,13 +67,13 @@ client c1 { expect resp.bodylen == 1048292 } -run -varnish v1 -expect SMA.Transient.g_bytes == 0 -varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 200 -varnish v1 -expect SMA.s1.g_bytes > 1000000 -varnish v1 -expect SMA.s1.g_space < 200 -varnish v1 -expect SMA.s2.g_bytes > 1000000 -varnish v1 -expect SMA.s2.g_space < 200 +varnish v1 -expect SM?.Transient.g_bytes == 0 +varnish v1 -expect SM?.s0.g_bytes > 1000000 +varnish v1 -expect SM?.s0.g_space < 200 +varnish v1 -expect SM?.s1.g_bytes > 1000000 +varnish v1 -expect SM?.s1.g_space < 200 +varnish v1 -expect SM?.s2.g_bytes > 1000000 +varnish v1 -expect SM?.s2.g_space < 200 client c1 { txreq -url /foo1 diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index 4d3850f..96fb58a 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -30,13 +30,13 @@ client c1 { expect resp.bodylen == 1048288 } -run -varnish v1 -expect SMA.Transient.g_bytes == 0 -varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 193 -varnish v1 -expect SMA.s1.g_bytes == 0 -varnish v1 -expect SMA.s1.g_space > 1000000 -varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SM?.Transient.g_bytes == 0 +varnish v1 -expect SM?.s0.g_bytes > 1000000 +varnish v1 -expect SM?.s0.g_space < 193 +varnish v1 -expect SM?.s1.g_bytes == 0 +varnish v1 -expect SM?.s1.g_space > 1000000 +varnish v1 -expect SM?.s2.g_bytes == 0 +varnish v1 -expect SM?.s2.g_space > 1000000 client c1 { txreq -url /bar @@ -46,13 +46,13 @@ client c1 { } -run varnish v1 -expect n_lru_nuked == 1 -varnish v1 -expect SMA.Transient.g_bytes == 0 -varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 1192 -varnish v1 -expect SMA.s1.g_bytes == 0 -varnish v1 -expect SMA.s1.g_space > 1000000 -varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SM?.Transient.g_bytes == 0 +varnish v1 -expect SM?.s0.g_bytes > 1000000 +varnish v1 -expect SM?.s0.g_space < 1192 +varnish v1 -expect SM?.s1.g_bytes == 0 +varnish v1 -expect SM?.s1.g_space > 1000000 +varnish v1 -expect SM?.s2.g_bytes == 0 +varnish v1 -expect SM?.s2.g_space > 1000000 client c1 { txreq -url /foo @@ -62,10 +62,10 @@ client c1 { } -run varnish v1 -expect n_lru_nuked == 2 -varnish v1 -expect SMA.Transient.g_bytes == 0 -varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 1194 -varnish v1 -expect SMA.s1.g_bytes == 0 -varnish v1 -expect SMA.s1.g_space > 1000000 -varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SM?.Transient.g_bytes == 0 +varnish v1 -expect SM?.s0.g_bytes > 1000000 +varnish v1 -expect SM?.s0.g_space < 1194 +varnish v1 -expect SM?.s1.g_bytes == 0 +varnish v1 -expect SM?.s1.g_space > 1000000 +varnish v1 -expect SM?.s2.g_bytes == 0 +varnish v1 -expect SM?.s2.g_space > 1000000 diff --git a/bin/varnishtest/tests/c00046.vtc b/bin/varnishtest/tests/c00046.vtc index 9a3dfec..3666ed8 100644 --- a/bin/varnishtest/tests/c00046.vtc +++ b/bin/varnishtest/tests/c00046.vtc @@ -23,13 +23,13 @@ client c1 { expect resp.bodylen == 1000000 } -run -varnish v1 -expect SMA.Transient.g_bytes == 0 -varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 100000 -varnish v1 -expect SMA.s1.g_bytes == 0 -varnish v1 -expect SMA.s1.g_space > 1000000 -varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SM?.Transient.g_bytes == 0 +varnish v1 -expect SM?.s0.g_bytes > 1000000 +varnish v1 -expect SM?.s0.g_space < 100000 +varnish v1 -expect SM?.s1.g_bytes == 0 +varnish v1 -expect SM?.s1.g_space > 1000000 +varnish v1 -expect SM?.s2.g_bytes == 0 +varnish v1 -expect SM?.s2.g_space > 1000000 server s1 -wait { rxreq @@ -45,13 +45,13 @@ client c1 { } -run varnish v1 -expect n_lru_nuked == 1 -varnish v1 -expect SMA.Transient.g_bytes == 0 -varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 100000 -varnish v1 -expect SMA.s1.g_bytes == 0 -varnish v1 -expect SMA.s1.g_space > 1000000 -varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SM?.Transient.g_bytes == 0 +varnish v1 -expect SM?.s0.g_bytes > 1000000 +varnish v1 -expect SM?.s0.g_space < 100000 +varnish v1 -expect SM?.s1.g_bytes == 0 +varnish v1 -expect SM?.s1.g_space > 1000000 +varnish v1 -expect SM?.s2.g_bytes == 0 +varnish v1 -expect SM?.s2.g_space > 1000000 server s1 -wait { rxreq @@ -67,10 +67,10 @@ client c1 { } -run varnish v1 -expect n_lru_nuked == 2 -varnish v1 -expect SMA.Transient.g_bytes == 0 -varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 100000 -varnish v1 -expect SMA.s1.g_bytes == 0 -varnish v1 -expect SMA.s1.g_space > 1000000 -varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SM?.Transient.g_bytes == 0 +varnish v1 -expect SM?.s0.g_bytes > 1000000 +varnish v1 -expect SM?.s0.g_space < 100000 +varnish v1 -expect SM?.s1.g_bytes == 0 +varnish v1 -expect SM?.s1.g_space > 1000000 +varnish v1 -expect SM?.s2.g_bytes == 0 +varnish v1 -expect SM?.s2.g_space > 1000000 diff --git a/bin/varnishtest/tests/c00073.vtc b/bin/varnishtest/tests/c00073.vtc index de94671..78cfabb 100644 --- a/bin/varnishtest/tests/c00073.vtc +++ b/bin/varnishtest/tests/c00073.vtc @@ -22,9 +22,9 @@ client c1 { } -start barrier b1 sync -varnish v1 -expect SMA.s0.g_bytes > 10000 +varnish v1 -expect SM?.s0.g_bytes > 10000 barrier b2 sync client c1 -wait -varnish v1 -expect SMA.s0.g_bytes < 6000 +varnish v1 -expect SM?.s0.g_bytes < 6000 diff --git a/bin/varnishtest/tests/g00002.vtc b/bin/varnishtest/tests/g00002.vtc index b722617..c440a23 100644 --- a/bin/varnishtest/tests/g00002.vtc +++ b/bin/varnishtest/tests/g00002.vtc @@ -34,7 +34,7 @@ client c1 { } -run # If this fails, the multiple storage allocations did not happen -varnish v1 -expect SMA.s0.c_req > 2 +varnish v1 -expect SM?.s0.c_req > 2 client c1 { # See varnish can gunzip it. diff --git a/bin/varnishtest/tests/r01140.vtc b/bin/varnishtest/tests/r01140.vtc index 098a653..994107c 100644 --- a/bin/varnishtest/tests/r01140.vtc +++ b/bin/varnishtest/tests/r01140.vtc @@ -36,7 +36,7 @@ client c1 { delay .1 -varnish v1 -expect SMA.s0.g_space < 1000 +varnish v1 -expect SM?.s0.g_space < 1000 client c1 { txreq -url /url2 diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc index 42a87a3..72661d9 100644 --- a/bin/varnishtest/tests/r01175.vtc +++ b/bin/varnishtest/tests/r01175.vtc @@ -18,4 +18,4 @@ client c1 { expect resp.status == 503 } -run -varnish v1 -expect SMA.test.c_fail < 5 +varnish v1 -expect SM?.test.c_fail < 5 diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index dd8c65f..f4d5efb 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -34,8 +34,8 @@ client c1 { delay .1 -varnish v1 -expect SMA.Transient.g_bytes > 1048000 -varnish v1 -expect SMA.Transient.g_space < 200 +varnish v1 -expect SM?.Transient.g_bytes > 1048000 +varnish v1 -expect SM?.Transient.g_space < 200 client c1 { # No space for this object (more than 256 bytes in headers). Don't wait @@ -45,7 +45,7 @@ client c1 { } -run # Three failures, one for obj2, one for vcl_backend_error{}, one for synth objcore -varnish v1 -expect SMA.Transient.c_fail == 3 +varnish v1 -expect SM?.Transient.c_fail == 3 client c1 { # Check that Varnish is still alive diff --git a/bin/varnishtest/tests/r01821.vtc b/bin/varnishtest/tests/r01821.vtc index bdeeb5f..3c7c02c 100644 --- a/bin/varnishtest/tests/r01821.vtc +++ b/bin/varnishtest/tests/r01821.vtc @@ -22,5 +22,5 @@ client c1 { logexpect l1 -wait -varnish v1 -expect SMA.Transient.c_bytes != 0 -varnish v1 -expect SMA.Transient.g_bytes < 65536 +varnish v1 -expect SM?.Transient.c_bytes != 0 +varnish v1 -expect SM?.Transient.g_bytes < 65536 diff --git a/bin/varnishtest/tests/r01914.vtc b/bin/varnishtest/tests/r01914.vtc index a14f053..b6a9269 100644 --- a/bin/varnishtest/tests/r01914.vtc +++ b/bin/varnishtest/tests/r01914.vtc @@ -30,15 +30,15 @@ client c1 { rxresp } -run -varnish v1 -expect SMA.s0.c_bytes > 0 -varnish v1 -expect SMA.s1.c_bytes == 0 -varnish v1 -expect SMA.Transient.c_bytes > 0 +varnish v1 -expect SM?.s0.c_bytes > 0 +varnish v1 -expect SM?.s1.c_bytes == 0 +varnish v1 -expect SM?.Transient.c_bytes > 0 client c1 { txreq -url /1 -bodylen 100 rxresp } -run -varnish v1 -expect SMA.s0.c_bytes > 0 -varnish v1 -expect SMA.s1.c_bytes > 0 -varnish v1 -expect SMA.Transient.c_bytes > 0 +varnish v1 -expect SM?.s0.c_bytes > 0 +varnish v1 -expect SM?.s1.c_bytes > 0 +varnish v1 -expect SM?.Transient.c_bytes > 0 diff --git a/bin/varnishtest/tests/r02406.vtc b/bin/varnishtest/tests/r02406.vtc index 3f3d018..05ad838 100644 --- a/bin/varnishtest/tests/r02406.vtc +++ b/bin/varnishtest/tests/r02406.vtc @@ -8,5 +8,5 @@ varnish v1 -vcl { } } -start -varnish v1 -expect SMA.acme_example_com_static_assets_malloc_storage.c_req == 0 +varnish v1 -expect SM?.acme_example_com_static_assets_malloc_storage.c_req == 0 varnish v1 -expect VBE.vcl1.be_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789.req == 0 diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 9f97f46..5a5951a 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -851,7 +851,7 @@ varnish_vsc(const struct varnish *v, const char *arg) */ struct stat_priv { - char target_name[256]; + char target_pattern[256]; uintmax_t val; const struct varnish *v; }; @@ -864,7 +864,7 @@ do_expect_cb(void *priv, const struct VSC_point * const pt) if (pt == NULL) return(0); - if (strcmp(pt->name, sp->target_name)) + if (fnmatch(sp->target_pattern, pt->name, 0)) return(0); AZ(strcmp(pt->ctype, "uint64_t")); @@ -897,9 +897,9 @@ varnish_expect(const struct varnish *v, char * const *av) } p = strrchr(r, '.'); if (p == NULL) { - bprintf(sp.target_name, "MAIN.%s", r); + bprintf(sp.target_pattern, "MAIN.%s", r); } else { - bprintf(sp.target_name, "%s", r); + bprintf(sp.target_pattern, "%s", r); } sp.val = 0; @@ -965,7 +965,13 @@ varnish_expect(const struct varnish *v, char * const *av) * process in the background, waiting for the ``-start`` switch to actually * start the child. * - * With: + * Types used in the description below: + * + * PATTERN + * is a 'glob' style pattern (ie: fnmatch(3)) as used in shell filename + * expansion. + * + * Arguments: * * vNAME * Identify the Varnish server with a string, it must starts with 'v'. @@ -1030,17 +1036,15 @@ varnish_expect(const struct varnish *v, char * const *av) * anything, -cliok expects 200, -clierr expects STATUS, and * -cliexpect expects the REGEXP to match the returned response. * - * \-expect STRING OP NUMBER - * Look into the VSM and make sure the counter identified by STRING has - * a correct value. OP can be ==, >, >=, <, <=. For example:: + * \-expect PATTERN OP NUMBER + * Look into the VSM and make sure the first VSC counter identified by + * PATTERN has a correct value. OP can be ==, >, >=, <, <=. For + * example:: * - * varnish v1 -expect SMA.s1.g_space > 1000000 + * varnish v1 -expect SM?.s1.g_space > 1000000 * * \-vsc PATTERN - * Dump VSC counters matching PATTERN. The PATTERN is a 'glob' - * style pattern (ie: fnmatch(3)) as used in shell filename expansion. - * To see all counters use pattern "*", to see all counters about - * requests use "*req*". + * Dump VSC counters matching PATTERN. * * \-vsl_catchup * Wait until the logging thread has idled to make sure that all From phk at FreeBSD.org Wed Sep 27 21:49:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Sep 2017 21:49:06 +0000 (UTC) Subject: [master] df0a067 Make the VSC-set create/destroy functions part of VRT Message-ID: <20170927214906.47CCF6274B@lists.varnish-cache.org> commit df0a067deb035035bafcb0cb4173c1d3cd7c2752 Author: Poul-Henning Kamp Date: Wed Sep 27 21:47:39 2017 +0000 Make the VSC-set create/destroy functions part of VRT diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index d2d32e6..84c1df2 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -139,7 +139,6 @@ nobase_pkginclude_HEADERS = \ cache/cache_filter.h \ cache/cache_backend.h \ cache/cache_director.h \ - common/common_vsm.h \ common/common_param.h \ waiter/waiter.h diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 1c24dc2..4099403 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -36,7 +36,6 @@ #include #include "common/heritage.h" -#include "common/common_vsm.h" #include "vend.h" #include "vgz.h" @@ -501,8 +500,8 @@ VSM_Init(void) VSC_C_main = VSC_main_New(""); AN(VSC_C_main); - AN(proc_vsmw); - vsl_head = VSMW_Allocf(proc_vsmw, VSL_CLASS, + AN(heritage.proc_vsmw); + vsl_head = VSMW_Allocf(heritage.proc_vsmw, VSL_CLASS, cache_param->vsl_space, VSL_CLASS); AN(vsl_head); vsl_segsize = ((cache_param->vsl_space - sizeof *vsl_head) / diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c index 1523cea..95952ed 100644 --- a/bin/varnishd/common/common_vsc.c +++ b/bin/varnishd/common/common_vsc.c @@ -36,19 +36,18 @@ #include #include -#include "common/common_vsm.h" - #include "vdef.h" #include "miniobj.h" #include "vas.h" #include "vend.h" -#include "vsmw.h" #include "vgz.h" #include "vmb.h" +#include "vrt.h" +#include "vsmw.h" #include "vqueue.h" #include "vapi/vsc_int.h" -struct vsmw *proc_vsmw; +#include "common/heritage.h" /*--------------------------------------------------------------------*/ @@ -69,7 +68,7 @@ vsc_callback_f *vsc_lock; vsc_callback_f *vsc_unlock; void * -VSC_Alloc(const char *nm, size_t sd, size_t sj, const unsigned char *zj, +VRT_VSC_Alloc(const char *nm, size_t sd, size_t sj, const unsigned char *zj, size_t szj, const char *fmt, va_list va) { char *p; @@ -85,8 +84,8 @@ VSC_Alloc(const char *nm, size_t sd, size_t sj, const unsigned char *zj, else bprintf(buf, "%s.%s", nm, fmt); - AN(proc_vsmw); - p = VSMW_Allocv(proc_vsmw, VSC_CLASS, 8 + sd + sj, buf, va); + AN(heritage.proc_vsmw); + p = VSMW_Allocv(heritage.proc_vsmw, VSC_CLASS, 8 + sd + sj, buf, va); AN(p); memset(&vz, 0, sizeof vz); @@ -111,19 +110,19 @@ VSC_Alloc(const char *nm, size_t sd, size_t sj, const unsigned char *zj, } void -VSC_Destroy(const char *nm, const void *p) +VRT_VSC_Destroy(const char *nm, const void *p) { struct vsc_segs *vsg; if (vsc_lock != NULL) vsc_lock(); - AN(proc_vsmw); + AN(heritage.proc_vsmw); VTAILQ_FOREACH(vsg, &vsc_seglist, list) { if (vsg->ptr != p) continue; assert(vsg->nm == nm); - VSMW_Free(proc_vsmw, &vsg->seg); + VSMW_Free(heritage.proc_vsmw, &vsg->seg); VTAILQ_REMOVE(&vsc_seglist, vsg, list); FREE_OBJ(vsg); break; diff --git a/bin/varnishd/common/common_vsm.h b/bin/varnishd/common/common_vsm.h deleted file mode 100644 index f675d07..0000000 --- a/bin/varnishd/common/common_vsm.h +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2017 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. - * - */ - -#ifdef COMMON_COMMON_VSM_H -#error "Multiple includes of common/common_vsm.h" -#endif -#define COMMON_COMMON_VSM_H - -struct vsmw; - -extern struct vsmw *proc_vsmw; - -typedef void vsc_callback_f(void); - -extern vsc_callback_f *vsc_lock; -extern vsc_callback_f *vsc_unlock; - -void *VSC_Alloc(const char *, size_t, size_t, const unsigned char *, size_t, - const char *, va_list); -void VSC_Destroy(const char *, const void *); diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h index b12e9ea..ebc30fe 100644 --- a/bin/varnishd/common/heritage.h +++ b/bin/varnishd/common/heritage.h @@ -89,6 +89,8 @@ struct heritage { const char *ident; long mgt_pid; + + struct vsmw *proc_vsmw; }; extern struct heritage heritage; @@ -116,3 +118,9 @@ int VCL_TestLoad(const char *); struct transport; void XPORT_Init(void); const struct transport *XPORT_Find(const char *name); + +/* common/common_vsc.c */ +typedef void vsc_callback_f(void); +extern vsc_callback_f *vsc_lock; +extern vsc_callback_f *vsc_unlock; + diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 9d908fb..1c1c41b 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -46,7 +46,6 @@ #include "mgt/mgt.h" #include "common/heritage.h" -#include "common/common_vsm.h" #include "vbm.h" #include "vcli_serve.h" @@ -397,8 +396,8 @@ mgt_launch_child(struct cli *cli) VJ_subproc(JAIL_SUBPROC_WORKER); - proc_vsmw = VSMW_New(heritage.vsm_fd, 0640, "_.index"); - AN(proc_vsmw); + heritage.proc_vsmw = VSMW_New(heritage.vsm_fd, 0640, "_.index"); + AN(heritage.proc_vsmw); child_main(); diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index eda3428..954c6e2 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -42,7 +42,6 @@ #include "mgt/mgt.h" #include "common/heritage.h" -#include "common/common_vsm.h" #include "vsm_priv.h" #include "vsmw.h" @@ -101,7 +100,7 @@ mgt_SHM_Init(void) mgt_vsmw = VSMW_New(fd, 0640, "_.index"); AN(mgt_vsmw); - proc_vsmw = mgt_vsmw; + heritage.proc_vsmw = mgt_vsmw; /* Setup atexit handler */ AZ(atexit(mgt_shm_atexit)); diff --git a/include/vrt.h b/include/vrt.h index 27fd57b..bb875e3 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -50,6 +50,8 @@ * * 6.2 (scheduled for: 2018-03-15) * VRT_Healthy() added + * VRT_VSC_Alloc() added + * VRT_VSC_Destroy() added * 6.1 (2017-09-15 aka 5.2) * http_CollectHdrSep added * VRT_purge modified (may fail a transaction, signature changed) @@ -411,3 +413,9 @@ typedef int vcl_init_f(VRT_CTX); typedef void vcl_fini_f(VRT_CTX); typedef void vcl_func_f(VRT_CTX); typedef int vmod_event_f(VRT_CTX, struct vmod_priv *, enum vcl_event_e); + +#ifdef va_start // XXX: hackish +void *VRT_VSC_Alloc(const char *, size_t, size_t, const unsigned char *, size_t, + const char *, va_list); +void VRT_VSC_Destroy(const char *, const void *); +#endif diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py index d21e06b..854968e 100644 --- a/lib/libvcc/vsctool.py +++ b/lib/libvcc/vsctool.py @@ -162,7 +162,7 @@ class vscset(object): fo.write('#include \n') fo.write('#include "vdef.h"\n') fo.write('#include "vas.h"\n') - fo.write('#include "common/common_vsm.h"\n') + fo.write('#include "vrt.h"\n') fo.write('#include "VSC_%s.h"\n' % self.name) fo.write("\n") @@ -187,7 +187,7 @@ class vscset(object): fo.write("\t" + self.struct + " *retval;\n") fo.write("\n") fo.write("\tva_start(ap, fmt);\n") - fo.write("\tretval = VSC_Alloc") + fo.write("\tretval = VRT_VSC_Alloc") fo.write("(vsc_" + self.name + "_name, ") fo.write("sizeof(" + self.struct + "),\n\t ") fo.write("vsc_" + self.name + "_jsonlen, ") @@ -205,7 +205,7 @@ class vscset(object): fo.write("{\n") fo.write("\n") fo.write("\tAN(pp);\n") - fo.write('\tVSC_Destroy(vsc_%s_name, *pp);\n' % self.name) + fo.write('\tVRT_VSC_Destroy(vsc_%s_name, *pp);\n' % self.name) fo.write("\t*pp = NULL;\n") fo.write("}\n") From phk at FreeBSD.org Wed Sep 27 22:13:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Sep 2017 22:13:04 +0000 (UTC) Subject: [master] e72dc77 Constify. Message-ID: <20170927221304.BBEA262EF6@lists.varnish-cache.org> commit e72dc77ce99d4dbcc649a96598a6cabb883dc59a Author: Poul-Henning Kamp Date: Wed Sep 27 22:11:46 2017 +0000 Constify. diff --git a/bin/varnishd/common/common_param.h b/bin/varnishd/common/common_param.h index ee9a12b..2366527 100644 --- a/bin/varnishd/common/common_param.h +++ b/bin/varnishd/common/common_param.h @@ -45,7 +45,7 @@ enum debug_bits { }; static inline int -COM_DO_DEBUG(uint8_t volatile *p, enum debug_bits x) +COM_DO_DEBUG(const volatile uint8_t *p, enum debug_bits x) { return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))); } @@ -57,7 +57,7 @@ enum feature_bits { }; static inline int -COM_FEATURE(uint8_t volatile *p, enum feature_bits x) +COM_FEATURE(const volatile uint8_t *p, enum feature_bits x) { return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))); } From hermunn at varnish-software.com Thu Sep 28 07:52:06 2017 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Thu, 28 Sep 2017 07:52:06 +0000 (UTC) Subject: [4.1] a8cd0c8 Update changelog: Separate stack for signals Message-ID: <20170928075206.7391262CA9@lists.varnish-cache.org> commit a8cd0c8cccf5940950b06b84be1720719c365651 Author: P?l Hermunn Johansen Date: Thu Sep 28 09:50:34 2017 +0200 Update changelog: Separate stack for signals diff --git a/doc/changes.rst b/doc/changes.rst index ae32686..558be47 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -7,9 +7,10 @@ Changes since 4.1.8: * Added ``bereq.is_bgfetch`` which is true for background fetches. * Add the vtc feature ignore_unknown_macro. * Expose to VCL whether or not a fetch is a background fetch (bgfetch) -* Ignore req.ttl when keeping track of epired objects (see 2422_) +* Ignore req.ttl when keeping track of expired objects (see 2422_) * Move the cli buffer to VSB (from stack). This deprecates the parameter cli_buffer. +* Use a separate stack for signals. .. _2422: https://github.com/varnishcache/varnish-cache/pull/2422 From phk at FreeBSD.org Thu Sep 28 07:58:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 28 Sep 2017 07:58:07 +0000 (UTC) Subject: [master] e469c07 Polishing Message-ID: <20170928075807.0E5BD62F66@lists.varnish-cache.org> commit e469c070f592a47d5f363deae4ce4c00997a8308 Author: Poul-Henning Kamp Date: Thu Sep 28 06:55:05 2017 +0000 Polishing diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 987cbd1..38a7203 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -41,7 +41,6 @@ #include "miniobj.h" #include "vas.h" -#include "vcs.h" #include "vdef.h" #include "vqueue.h" #include "vsb.h" @@ -80,7 +79,7 @@ enum body_status { enum req_body_state_e { #define REQ_BODY(U) REQ_BODY_##U, -#include +#include "tbl/req_body.h" }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 4cadaea..5e1b8b6 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -36,6 +36,7 @@ #include #include "vtim.h" +#include "vcs.h" #include "cache.h" #include "cache_transport.h" From phk at FreeBSD.org Thu Sep 28 07:58:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 28 Sep 2017 07:58:07 +0000 (UTC) Subject: [master] dc10c2f Polish Message-ID: <20170928075807.2377D62F69@lists.varnish-cache.org> commit dc10c2f8cae894411435bfbd9214169e4f22a007 Author: Poul-Henning Kamp Date: Thu Sep 28 07:18:49 2017 +0000 Polish diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 38a7203..3bcc3ae 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -50,9 +50,6 @@ #include #include -#ifdef HAVE_PTHREAD_NP_H -#include -#endif #include #include #include diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 4d82fb6..cd95431 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -34,6 +34,10 @@ #include #include +#ifdef HAVE_PTHREAD_NP_H +# include +#endif + #include "common/heritage.h" #include "vcli_serve.h" From phk at FreeBSD.org Thu Sep 28 07:58:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 28 Sep 2017 07:58:07 +0000 (UTC) Subject: [master] 411edd8 Reduce #include pollution by cache.h Message-ID: <20170928075807.6125262F78@lists.varnish-cache.org> commit 411edd87478f40bad6d2cdc9f2d3a3de2666067c Author: Poul-Henning Kamp Date: Thu Sep 28 07:55:59 2017 +0000 Reduce #include pollution by cache.h varnishd sources now use cache_priv.h as primary #include, and that includes cache.h, rather than the other way around. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 84c1df2..598ada1 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -147,7 +147,6 @@ pkgdatadir = ${datarootdir}/${PACKAGE}/vcl varnishd_CFLAGS = \ @PCRE_CFLAGS@ \ @SAN_CFLAGS@ \ - -DVARNISHD_IS_NOT_A_VMOD \ -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \ -DVARNISH_VMOD_DIR='"${pkglibdir}/vmods"' \ -DVARNISH_VCL_DIR='"${pkgsysconfdir}:${pkgdatadir}"' diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 3bcc3ae..3c34417 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -34,29 +34,20 @@ */ #define VARNISH_CACHE_CHILD 1 +#include +#include #include #include - #include +#include "vdef.h" + #include "miniobj.h" #include "vas.h" -#include "vdef.h" #include "vqueue.h" -#include "vsb.h" #include "vapi/vsl_int.h" -#include - -#include -#include -#include -#include -#include - -#include "common/common_param.h" - /*--------------------------------------------------------------------*/ enum req_fsm_nxt { @@ -1074,7 +1065,3 @@ Tlen(const txt t) "MAGIC 0x%08x (Should:%s/0x%08x)\n", \ (ptr)->magic, #exp, exp); \ } while(0) - -#ifdef VARNISHD_IS_NOT_A_VMOD -# include "cache/cache_priv.h" -#endif diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index a5131a0..22b42ab 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -33,7 +33,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include #include diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 35f1cdb..20568b6 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -34,7 +34,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "vrt.h" #include "vtcp.h" diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 22d10c4..7d72e18 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -36,7 +36,7 @@ #include #include -#include "cache.h" +#include "cache_priv.h" #include "vcli_serve.h" #include "vrt.h" diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index c1935dd..307513a 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -41,7 +41,7 @@ #include #include -#include "cache.h" +#include "cache_priv.h" #include "binary_heap.h" #include "vcli_serve.h" diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index b13a4aa..dc10d5d 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -36,7 +36,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "vrt.h" #include "vsa.h" diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 43f89b2..96254f2 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -32,7 +32,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "cache_ban.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c index c98baa6..ab0f685 100644 --- a/bin/varnishd/cache/cache_ban_build.c +++ b/bin/varnishd/cache/cache_ban_build.c @@ -32,7 +32,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "cache_ban.h" #include "vend.h" diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c index ad1bd12..dfc9981 100644 --- a/bin/varnishd/cache/cache_ban_lurker.c +++ b/bin/varnishd/cache/cache_ban_lurker.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include "cache_ban.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 521c6ac..043aca7 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -35,7 +35,7 @@ #include #include -#include "cache.h" +#include "cache_priv.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index e7e5001..b9d82da 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -36,7 +36,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include "common/heritage.h" #include "vcli_serve.h" diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index c1b079e..e0d9496 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include "cache_filter.h" /* VDP_bytes diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 3b2df2c..6f9a6a2 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -35,7 +35,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include "cache_director.h" diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index d9ec496..6818fa2 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 3b909e4..a6799b6 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -33,7 +33,7 @@ #include #include -#include "cache.h" +#include "cache_priv.h" #include "cache_filter.h" #include "cache_vgz.h" diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 6866767..771bf80 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include "cache_vgz.h" #include "cache_esi.h" diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index f0ca523..19324f7 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -34,7 +34,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "binary_heap.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index cf2605b..2898a9d 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include "cache_director.h" #include "cache_filter.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index fcc4924..4773b97 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -31,7 +31,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "cache_filter.h" #include "vcli_serve.h" diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index a085511..a933101 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -40,7 +40,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "cache_filter.h" #include "cache_vgz.h" #include "vend.h" diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 2e9baf9..3d83bee 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -52,7 +52,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include #include diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index e1b9117..70b7c1a 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -32,7 +32,7 @@ #include "config.h" #include -#include "cache.h" +#include "cache_priv.h" #include #include "vend.h" diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 52cec50..5837957 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -35,7 +35,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include #include diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index cd95431..e3edb72 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include #include diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 160d1da..6f60d72 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -31,7 +31,7 @@ #include "config.h" #include -#include "cache.h" +#include "cache_priv.h" #include #include diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index a139bcf..b5c30c0 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -83,7 +83,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "cache_obj.h" #include "vend.h" #include "storage/storage.h" diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 5e1b8b6..44b84a2 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -38,7 +38,7 @@ #include "vtim.h" #include "vcs.h" -#include "cache.h" +#include "cache_priv.h" #include "cache_transport.h" #include "cache_filter.h" diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index e25b3a0..aa47190 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -37,7 +37,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "cache_pool.h" static pthread_t thr_pool_herder; diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index 2dcf32d..5af6041 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -29,6 +29,18 @@ * Stuff that should *never* be exposed to a VMOD */ +#include "cache.h" + +#include "vsb.h" + +#include + +#include +#include +#include + +#include "common/common_param.h" + #include "VSC_main.h" struct vfp; @@ -139,9 +151,6 @@ int Pool_TrySumstat(const struct worker *wrk); void Pool_PurgeStat(unsigned nobj); int Pool_Task_Any(struct pool_task *task, enum task_prio prio); -/* cache_proxy.c [VPX] */ -task_func_t VPX_Proto_Sess; - /* cache_range.c [VRG] */ void VRG_dorange(struct req *req, const char *r); diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index ced39c7..e4f8433 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -29,8 +29,8 @@ #include "config.h" -#include "cache/cache.h" -#include "cache/cache_filter.h" +#include "cache_priv.h" +#include "cache_filter.h" #include "vct.h" diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 56ed74c..65c2830 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -32,7 +32,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include #include diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 3cda426..83b1006 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -32,7 +32,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "cache_filter.h" #include "vtim.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index c96430b..4823871 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -38,7 +38,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include "cache_director.h" #include "cache_filter.h" #include "cache_transport.h" diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 67679e1..f1171c2 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -31,7 +31,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "vtim.h" diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index ea18156..28f1ce2 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -36,7 +36,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include #include diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 4099403..9b28b25 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include #include diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index d5d3e4b..04ab24c 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -58,7 +58,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "vct.h" #include "vend.h" diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 26c4772..a667309 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -35,7 +35,7 @@ #include #include -#include "cache.h" +#include "cache_priv.h" #include "common/heritage.h" #include "vrt.h" diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 4f4c64b..8b16942 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include "cache_director.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 000d505..b85367b 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -34,7 +34,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "vrt.h" diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c index f8be46f..6f58480 100644 --- a/bin/varnishd/cache/cache_vrt_re.c +++ b/bin/varnishd/cache/cache_vrt_re.c @@ -33,7 +33,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "vrt.h" diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 1cdb983..3fd5eb4 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -32,7 +32,7 @@ #include -#include "cache.h" +#include "cache_priv.h" #include "common/heritage.h" #include "cache_director.h" diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index cb73247..d325b9d 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include #include diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index b7729b1..6c391ea 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -34,7 +34,7 @@ #include #include -#include "cache.h" +#include "cache_priv.h" #include "cache_pool.h" #include "vtim.h" diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index 270aa16..5167247 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache.h" +#include "cache_priv.h" #include diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index a4e9861..23e4ef9 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index b84eee1..d48e3e7 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -34,7 +34,7 @@ #include -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "hash/hash_slinger.h" #include "vmb.h" diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c index ffaa2d5..d68ae8a 100644 --- a/bin/varnishd/hash/hash_simple_list.c +++ b/bin/varnishd/hash/hash_simple_list.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index 96174a9..b3f6cf1 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "cache/cache_filter.h" #include "cache_http1.h" diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index 3e230cb..d1b5bf0 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include #include diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 5657e6f..06df250 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -33,7 +33,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include #include diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c index 8215fab..46f583a 100644 --- a/bin/varnishd/http1/cache_http1_line.c +++ b/bin/varnishd/http1/cache_http1_line.c @@ -35,7 +35,7 @@ #include "config.h" #include -#include "cache/cache.h" +#include "cache/cache_priv.h" #include #include diff --git a/bin/varnishd/http1/cache_http1_pipe.c b/bin/varnishd/http1/cache_http1_pipe.c index 49a10e5..37032e4 100644 --- a/bin/varnishd/http1/cache_http1_pipe.c +++ b/bin/varnishd/http1/cache_http1_pipe.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include #include diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index 2e691fd..0bc6df9 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -45,7 +45,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "cache/cache_transport.h" #include "cache_http1.h" diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c index 35c13a6..fd770ea 100644 --- a/bin/varnishd/http1/cache_http1_vfp.c +++ b/bin/varnishd/http1/cache_http1_vfp.c @@ -38,7 +38,7 @@ #include #include -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "cache/cache_filter.h" #include "cache_http1.h" diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 11ca12b..0277b21 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index 460b43f..973827d 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include #include @@ -92,7 +92,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) static h2_error h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) { - /* XXX: This might belong in cache/cache_http.c */ + /* XXX: This might belong in cache/cache_priv.http.c */ unsigned n; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); diff --git a/bin/varnishd/http2/cache_http2_panic.c b/bin/varnishd/http2/cache_http2_panic.c index b0f1a12..b160343 100644 --- a/bin/varnishd/http2/cache_http2_panic.c +++ b/bin/varnishd/http2/cache_http2_panic.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "cache/cache_transport.h" #include "http2/cache_http2.h" diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 4eff4e0..13ee528 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include #include diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index fa837c9..b17b4f2 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "cache/cache_transport.h" #include "http2/cache_http2.h" diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index e70341f..8785e47 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index 8444f39..f381641 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include diff --git a/bin/varnishd/storage/mgt_storage_persistent.c b/bin/varnishd/storage/mgt_storage_persistent.c index d0155cd..9e6255e 100644 --- a/bin/varnishd/storage/mgt_storage_persistent.c +++ b/bin/varnishd/storage/mgt_storage_persistent.c @@ -35,7 +35,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index fb280af..084c82d 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -33,7 +33,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include #include diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index b0480b8..287d05b 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/storage/storage_lru.c b/bin/varnishd/storage/storage_lru.c index e7f0bff..33dca6b 100644 --- a/bin/varnishd/storage/storage_lru.c +++ b/bin/varnishd/storage/storage_lru.c @@ -32,7 +32,7 @@ #include -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "hash/hash_slinger.h" #include "storage/storage.h" diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c index 7da5c4a..60cd988 100644 --- a/bin/varnishd/storage/storage_malloc.c +++ b/bin/varnishd/storage/storage_malloc.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 6c4d79e..af22649 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -35,7 +35,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 36aa348..e0115c0 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -34,7 +34,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include #include diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index 63ff47d..fc75ddb 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -36,7 +36,7 @@ #include "config.h" #include -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index ad33b7e..d07166d 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "cache/cache_obj.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 80a2f1f..b7afaf3 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache/cache.h" +#include "cache/cache_priv.h" #include diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 129bb87..fa381e9 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -39,7 +39,7 @@ #include -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "waiter/waiter.h" #include "waiter/waiter_priv.h" diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 50bdad3..546e1df 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -33,7 +33,7 @@ #if defined(HAVE_KQUEUE) -#include "cache/cache.h" +#include "cache/cache_priv.h" #include diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index fefe22f..6c953c6 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -34,7 +34,7 @@ #include #include -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "waiter/waiter.h" #include "waiter/waiter_priv.h" diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index a7f76c9..50f8b1d 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -73,7 +73,7 @@ #include #include -#include "cache/cache.h" +#include "cache/cache_priv.h" #include "waiter/waiter.h" #include "waiter/waiter_priv.h" diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 40702d1..73dd831 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -29,6 +29,7 @@ #include "config.h" #include #include +#include #include "vdef.h" #include "vrt.h" diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 8a1fe41..e538543 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -31,6 +31,9 @@ #include #include #include +#include +#include +#include #include "cache/cache.h" @@ -41,6 +44,8 @@ #include "vtim.h" #include "vcc_if.h" +#include "common/common_param.h" + #define WARN_RETIRED() \ do { \ VSL(SLT_Error, 0, \ diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c index 10f97aa..af61742 100644 --- a/lib/libvmod_debug/vmod_debug_dyn.c +++ b/lib/libvmod_debug/vmod_debug_dyn.c @@ -30,6 +30,8 @@ #include #include +#include +#include #include "cache/cache.h" diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index ea758ed..9dfef9d 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -29,6 +29,7 @@ #include "config.h" #include +#include #include "cache/cache.h" diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 3e1794f..9a4d392 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -29,6 +29,7 @@ #include "config.h" #include +#include #include "cache/cache.h" #include "cache/cache_director.h" diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index 71a4366..60fa834 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -29,6 +29,7 @@ #include "config.h" #include +#include #include "cache/cache.h" #include "cache/cache_director.h" diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index 3932938..8a867cc 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -29,6 +29,7 @@ #include "config.h" #include +#include #include "cache/cache.h" #include "cache/cache_director.h" diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index f36d2d5..7fc5056 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -29,8 +29,10 @@ #include "config.h" +#include #include #include +#include #include "cache/cache.h" #include "cache/cache_director.h" diff --git a/lib/libvmod_directors/shard_hash.c b/lib/libvmod_directors/shard_hash.c index 365f86b..64e7e15 100644 --- a/lib/libvmod_directors/shard_hash.c +++ b/lib/libvmod_directors/shard_hash.c @@ -30,6 +30,8 @@ #include "config.h" +#include + #include "cache/cache.h" #include "vrt.h" diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 8765ef9..c85c9b4 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "cache/cache.h" diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 915b7f2..91f29ca 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -34,7 +34,9 @@ #include #include +#include #include +#include #include "cache/cache.h" diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index 24dd571..13b85de 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -30,7 +30,10 @@ #include "config.h" #include +#include +#include #include +#include #include diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c index c2a7e5f..8a69921 100644 --- a/lib/libvmod_std/vmod_std_fileread.c +++ b/lib/libvmod_std/vmod_std_fileread.c @@ -40,6 +40,7 @@ #include "config.h" #include +#include #include "cache/cache.h" diff --git a/lib/libvmod_std/vmod_std_querysort.c b/lib/libvmod_std/vmod_std_querysort.c index 2180ff9..3efe155 100644 --- a/lib/libvmod_std/vmod_std_querysort.c +++ b/lib/libvmod_std/vmod_std_querysort.c @@ -29,6 +29,7 @@ #include "config.h" #include +#include #include "cache/cache.h" diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c index 9fd3fc4..840df35 100644 --- a/lib/libvmod_vtc/vmod_vtc.c +++ b/lib/libvmod_vtc/vmod_vtc.c @@ -31,6 +31,8 @@ #include #include +#include +#include #include "cache/cache.h" From phk at FreeBSD.org Thu Sep 28 08:53:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 28 Sep 2017 08:53:06 +0000 (UTC) Subject: [master] f840c63 rename cache_priv.h to cache_varnishd.h which is more precise Message-ID: <20170928085306.5E419621F0@lists.varnish-cache.org> commit f840c637d9044d2b8fabbfbd56e4d612235b7634 Author: Poul-Henning Kamp Date: Thu Sep 28 08:25:20 2017 +0000 rename cache_priv.h to cache_varnishd.h which is more precise diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 598ada1..b0b0b05 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -117,8 +117,8 @@ noinst_HEADERS = \ cache/cache_esi.h \ cache/cache_obj.h \ cache/cache_pool.h \ - cache/cache_priv.h \ cache/cache_transport.h \ + cache/cache_varnishd.h \ cache/cache_vgz.h \ common/heritage.h \ hash/hash_slinger.h \ diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 3c34417..a0586c5 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -28,12 +28,6 @@ * */ -/* - * This macro can be used in .h files to isolate bits that the manager - * should not (need to) see, such as pthread mutexes etc. - */ -#define VARNISH_CACHE_CHILD 1 - #include #include #include diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 22b42ab..663e7c2 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -33,7 +33,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 20568b6..95f2ff2 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -34,7 +34,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "vrt.h" #include "vtcp.h" diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 7d72e18..d7f126d 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -36,7 +36,7 @@ #include #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "vcli_serve.h" #include "vrt.h" diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 307513a..55f7e27 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -41,7 +41,7 @@ #include #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "binary_heap.h" #include "vcli_serve.h" diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index dc10d5d..ce3f052 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -36,7 +36,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "vrt.h" #include "vsa.h" diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 96254f2..8caac84 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -32,7 +32,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_ban.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c index ab0f685..717f5c5 100644 --- a/bin/varnishd/cache/cache_ban_build.c +++ b/bin/varnishd/cache/cache_ban_build.c @@ -32,7 +32,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_ban.h" #include "vend.h" diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c index dfc9981..f721394 100644 --- a/bin/varnishd/cache/cache_ban_lurker.c +++ b/bin/varnishd/cache/cache_ban_lurker.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_ban.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 043aca7..bb13378 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -35,7 +35,7 @@ #include #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index b9d82da..066398b 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -36,7 +36,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "common/heritage.h" #include "vcli_serve.h" diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index e0d9496..342696f 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_filter.h" /* VDP_bytes diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 6f9a6a2..d9bd52a 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -35,7 +35,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_director.h" diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 6818fa2..4076985 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index a6799b6..071fb79 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -33,7 +33,7 @@ #include #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_filter.h" #include "cache_vgz.h" diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 771bf80..5ce78bd 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_vgz.h" #include "cache_esi.h" diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 19324f7..2648c06 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -34,7 +34,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "binary_heap.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2898a9d..7efc8b0 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_director.h" #include "cache_filter.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 4773b97..dd36a4a 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -31,7 +31,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_filter.h" #include "vcli_serve.h" diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index a933101..f2b638a 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -40,7 +40,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_filter.h" #include "cache_vgz.h" #include "vend.h" diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 3d83bee..8f1c79b 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -52,7 +52,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 70b7c1a..9c4dac8 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -32,7 +32,7 @@ #include "config.h" #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include "vend.h" diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 5837957..05086d9 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -35,7 +35,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index e3edb72..778790b 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 6f60d72..f2cc1c8 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -31,7 +31,7 @@ #include "config.h" #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index b5c30c0..a3f2d18 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -83,7 +83,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_obj.h" #include "vend.h" #include "storage/storage.h" diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 44b84a2..c20fa63 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -38,7 +38,7 @@ #include "vtim.h" #include "vcs.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_transport.h" #include "cache_filter.h" diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index aa47190..3e7a670 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -37,7 +37,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_pool.h" static pthread_t thr_pool_herder; diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h deleted file mode 100644 index 5af6041..0000000 --- a/bin/varnishd/cache/cache_priv.h +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2015 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. - * - * Stuff that should *never* be exposed to a VMOD - */ - -#include "cache.h" - -#include "vsb.h" - -#include - -#include -#include -#include - -#include "common/common_param.h" - -#include "VSC_main.h" - -struct vfp; - -/* Prototypes etc ----------------------------------------------------*/ - -/* cache_acceptor.c */ -void VCA_Init(void); -void VCA_Shutdown(void); - -/* cache_backend_cfg.c */ -void VBE_InitCfg(void); -void VBE_Poll(void); - -/* cache_backend_tcp.c */ -void VBT_Init(void); - -/* cache_backend_poll.c */ -void VBP_Init(void); - -/* cache_director.c */ -int VDI_GetHdr(struct worker *, struct busyobj *); -int VDI_GetBody(struct worker *, struct busyobj *); -const struct suckaddr *VDI_GetIP(struct worker *, struct busyobj *); -void VDI_Finish(struct worker *wrk, struct busyobj *bo); -enum sess_close VDI_Http1Pipe(struct req *, struct busyobj *); -void VDI_Panic(const struct director *, struct vsb *, const char *nm); - -/* cache_exp.c */ -double EXP_Ttl(const struct req *, const struct objcore *); -void EXP_Insert(struct worker *wrk, struct objcore *oc); -void EXP_Remove(struct objcore *); - -#define EXP_Dttl(req, oc) (oc->ttl - (req->t_req - oc->t_origin)) - -/* From cache_main.c */ -void BAN_Init(void); -void BAN_Compile(void); -void BAN_Shutdown(void); - -/* From cache_hash.c */ -void BAN_NewObjCore(struct objcore *oc); -void BAN_DestroyObj(struct objcore *oc); -int BAN_CheckObject(struct worker *, struct objcore *, struct req *); - -/* cache_busyobj.c */ -void VBO_Init(void); - -/* cache_cli.c [CLI] */ -void CLI_Init(void); -void CLI_Run(void); -void CLI_AddFuncs(struct cli_proto *p); - -/* cache_deliver_proc.c */ -void VDP_close(struct req *req); -int VDP_DeliverObj(struct req *req); - -extern const struct vdp VDP_gunzip; -extern const struct vdp VDP_esi; - -/* cache_expire.c */ -void EXP_Init(void); - -/* cache_fetch_proc.c */ -void VFP_Init(void); -enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr); -void VFP_Extend(const struct vfp_ctx *, ssize_t sz); -struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *); -void VFP_Setup(struct vfp_ctx *vc); -int VFP_Open(struct vfp_ctx *bo); -void VFP_Close(struct vfp_ctx *bo); - -extern const struct vfp VFP_gunzip; -extern const struct vfp VFP_gzip; -extern const struct vfp VFP_testgunzip; -extern const struct vfp VFP_esi; -extern const struct vfp VFP_esi_gzip; - -/* cache_http.c */ -void HTTP_Init(void); - -/* cache_main.c */ -void THR_SetName(const char *name); -const char* THR_GetName(void); -void THR_SetBusyobj(const struct busyobj *); -struct busyobj * THR_GetBusyobj(void); -void THR_SetRequest(const struct req *); -struct req * THR_GetRequest(void); -void THR_Init(void); - -/* cache_lck.c */ -void LCK_Init(void); - -/* cache_obj.c */ -void ObjInit(void); - -/* cache_panic.c */ -void PAN_Init(void); -int PAN_already(struct vsb *, const void *); - -/* cache_pool.c */ -void Pool_Init(void); -int Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio); -int Pool_Task_Arg(struct worker *, enum task_prio, task_func_t *, - const void *arg, size_t arg_len); -void Pool_Sumstat(const struct worker *w); -int Pool_TrySumstat(const struct worker *wrk); -void Pool_PurgeStat(unsigned nobj); -int Pool_Task_Any(struct pool_task *task, enum task_prio prio); - -/* cache_range.c [VRG] */ -void VRG_dorange(struct req *req, const char *r); - -/* cache_session.c */ -void SES_NewPool(struct pool *, unsigned pool_no); -void SES_DestroyPool(struct pool *); - -/* cache_shmlog.c */ -extern struct VSC_main *VSC_C_main; -void VSM_Init(void); -void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len); -void VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, - uint32_t vxid); -void VSL_End(struct vsl_log *vsl); - -/* cache_vary.c */ -int VRY_Create(struct busyobj *bo, struct vsb **psb); -int VRY_Match(struct req *, const uint8_t *vary); -void VRY_Prep(struct req *); -void VRY_Clear(struct req *); -enum vry_finish_flag { KEEP, DISCARD }; -void VRY_Finish(struct req *req, enum vry_finish_flag); - -/* cache_vcl.c */ -struct director *VCL_DefaultDirector(const struct vcl *); -const struct vrt_backend_probe *VCL_DefaultProbe(const struct vcl *); -void VCL_Init(void); -void VCL_Panic(struct vsb *, const struct vcl *); -void VCL_Poll(void); -void VCL_Ref(struct vcl *); -void VCL_Refresh(struct vcl **); -void VCL_Rel(struct vcl **); -const char *VCL_Return_Name(unsigned); - - -/* cache_vrt.c */ -void VRTPRIV_init(struct vrt_privs *privs); -void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id); -void pan_privs(struct vsb *, const struct vrt_privs *); - -/* cache_vrt_vmod.c */ -void VMOD_Init(void); -void VMOD_Panic(struct vsb *); - -/* http1/cache_http1_pipe.c */ -void V1P_Init(void); - -/* cache_http2_deliver.c */ -void V2D_Init(void); - -/* stevedore.c */ -void STV_open(void); -void STV_close(void); -const struct stevedore *STV_find(const char *); -const struct stevedore *STV_next(void); -int STV_BanInfoDrop(const uint8_t *ban, unsigned len); -int STV_BanInfoNew(const uint8_t *ban, unsigned len); -void STV_BanExport(const uint8_t *banlist, unsigned len); - -/* storage_persistent.c */ -void SMP_Ready(void); - diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index e4f8433..7ee0b11 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_filter.h" #include "vct.h" diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 65c2830..66fdbd3 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -32,7 +32,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 83b1006..0ddac6b 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -32,7 +32,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_filter.h" #include "vtim.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 4823871..8625d69 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -38,7 +38,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_director.h" #include "cache_filter.h" #include "cache_transport.h" diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index f1171c2..cef9b39 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -31,7 +31,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "vtim.h" diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 28f1ce2..bd0716e 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -36,7 +36,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 9b28b25..c129fa3 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h new file mode 100644 index 0000000..c85a452 --- /dev/null +++ b/bin/varnishd/cache/cache_varnishd.h @@ -0,0 +1,224 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2015 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. + * + * Stuff that should *never* be exposed to a VMOD + */ + +#include "cache.h" + +#include "vsb.h" + +#include + +#include +#include +#include + +#include "common/common_param.h" + +#include "VSC_main.h" + +/* -------------------------------------------------------------------*/ +/* + * This macro can be used in .h files to isolate bits that the manager + * should not (need to) see, such as pthread mutexes etc. + */ +#define VARNISH_CACHE_CHILD 1 + +/* -------------------------------------------------------------------*/ + +struct vfp; + +/* Prototypes etc ----------------------------------------------------*/ + +/* cache_acceptor.c */ +void VCA_Init(void); +void VCA_Shutdown(void); + +/* cache_backend_cfg.c */ +void VBE_InitCfg(void); +void VBE_Poll(void); + +/* cache_backend_tcp.c */ +void VBT_Init(void); + +/* cache_backend_poll.c */ +void VBP_Init(void); + +/* cache_director.c */ +int VDI_GetHdr(struct worker *, struct busyobj *); +int VDI_GetBody(struct worker *, struct busyobj *); +const struct suckaddr *VDI_GetIP(struct worker *, struct busyobj *); +void VDI_Finish(struct worker *wrk, struct busyobj *bo); +enum sess_close VDI_Http1Pipe(struct req *, struct busyobj *); +void VDI_Panic(const struct director *, struct vsb *, const char *nm); + +/* cache_exp.c */ +double EXP_Ttl(const struct req *, const struct objcore *); +void EXP_Insert(struct worker *wrk, struct objcore *oc); +void EXP_Remove(struct objcore *); + +#define EXP_Dttl(req, oc) (oc->ttl - (req->t_req - oc->t_origin)) + +/* From cache_main.c */ +void BAN_Init(void); +void BAN_Compile(void); +void BAN_Shutdown(void); + +/* From cache_hash.c */ +void BAN_NewObjCore(struct objcore *oc); +void BAN_DestroyObj(struct objcore *oc); +int BAN_CheckObject(struct worker *, struct objcore *, struct req *); + +/* cache_busyobj.c */ +void VBO_Init(void); + +/* cache_cli.c [CLI] */ +void CLI_Init(void); +void CLI_Run(void); +void CLI_AddFuncs(struct cli_proto *p); + +/* cache_deliver_proc.c */ +void VDP_close(struct req *req); +int VDP_DeliverObj(struct req *req); + +extern const struct vdp VDP_gunzip; +extern const struct vdp VDP_esi; + +/* cache_expire.c */ +void EXP_Init(void); + +/* cache_fetch_proc.c */ +void VFP_Init(void); +enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr); +void VFP_Extend(const struct vfp_ctx *, ssize_t sz); +struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *); +void VFP_Setup(struct vfp_ctx *vc); +int VFP_Open(struct vfp_ctx *bo); +void VFP_Close(struct vfp_ctx *bo); + +extern const struct vfp VFP_gunzip; +extern const struct vfp VFP_gzip; +extern const struct vfp VFP_testgunzip; +extern const struct vfp VFP_esi; +extern const struct vfp VFP_esi_gzip; + +/* cache_http.c */ +void HTTP_Init(void); + +/* cache_main.c */ +void THR_SetName(const char *name); +const char* THR_GetName(void); +void THR_SetBusyobj(const struct busyobj *); +struct busyobj * THR_GetBusyobj(void); +void THR_SetRequest(const struct req *); +struct req * THR_GetRequest(void); +void THR_Init(void); + +/* cache_lck.c */ +void LCK_Init(void); + +/* cache_obj.c */ +void ObjInit(void); + +/* cache_panic.c */ +void PAN_Init(void); +int PAN_already(struct vsb *, const void *); + +/* cache_pool.c */ +void Pool_Init(void); +int Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio); +int Pool_Task_Arg(struct worker *, enum task_prio, task_func_t *, + const void *arg, size_t arg_len); +void Pool_Sumstat(const struct worker *w); +int Pool_TrySumstat(const struct worker *wrk); +void Pool_PurgeStat(unsigned nobj); +int Pool_Task_Any(struct pool_task *task, enum task_prio prio); + +/* cache_range.c [VRG] */ +void VRG_dorange(struct req *req, const char *r); + +/* cache_session.c */ +void SES_NewPool(struct pool *, unsigned pool_no); +void SES_DestroyPool(struct pool *); + +/* cache_shmlog.c */ +extern struct VSC_main *VSC_C_main; +void VSM_Init(void); +void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len); +void VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, + uint32_t vxid); +void VSL_End(struct vsl_log *vsl); + +/* cache_vary.c */ +int VRY_Create(struct busyobj *bo, struct vsb **psb); +int VRY_Match(struct req *, const uint8_t *vary); +void VRY_Prep(struct req *); +void VRY_Clear(struct req *); +enum vry_finish_flag { KEEP, DISCARD }; +void VRY_Finish(struct req *req, enum vry_finish_flag); + +/* cache_vcl.c */ +struct director *VCL_DefaultDirector(const struct vcl *); +const struct vrt_backend_probe *VCL_DefaultProbe(const struct vcl *); +void VCL_Init(void); +void VCL_Panic(struct vsb *, const struct vcl *); +void VCL_Poll(void); +void VCL_Ref(struct vcl *); +void VCL_Refresh(struct vcl **); +void VCL_Rel(struct vcl **); +const char *VCL_Return_Name(unsigned); + + +/* cache_vrt.c */ +void VRTPRIV_init(struct vrt_privs *privs); +void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id); +void pan_privs(struct vsb *, const struct vrt_privs *); + +/* cache_vrt_vmod.c */ +void VMOD_Init(void); +void VMOD_Panic(struct vsb *); + +/* http1/cache_http1_pipe.c */ +void V1P_Init(void); + +/* cache_http2_deliver.c */ +void V2D_Init(void); + +/* stevedore.c */ +void STV_open(void); +void STV_close(void); +const struct stevedore *STV_find(const char *); +const struct stevedore *STV_next(void); +int STV_BanInfoDrop(const uint8_t *ban, unsigned len); +int STV_BanInfoNew(const uint8_t *ban, unsigned len); +void STV_BanExport(const uint8_t *banlist, unsigned len); + +/* storage_persistent.c */ +void SMP_Ready(void); + diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 04ab24c..379f7b3 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -58,7 +58,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "vct.h" #include "vend.h" diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index a667309..6ef4221 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -35,7 +35,7 @@ #include #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "common/heritage.h" #include "vrt.h" diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 8b16942..79fd1ba 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_director.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index b85367b..b344756 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -34,7 +34,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "vrt.h" diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c index 6f58480..ed9d4fa 100644 --- a/bin/varnishd/cache/cache_vrt_re.c +++ b/bin/varnishd/cache/cache_vrt_re.c @@ -33,7 +33,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "vrt.h" diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 3fd5eb4..9d4db8e 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -32,7 +32,7 @@ #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "common/heritage.h" #include "cache_director.h" diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index d325b9d..04502db 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include #include diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 6c391ea..167481f 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -34,7 +34,7 @@ #include #include -#include "cache_priv.h" +#include "cache_varnishd.h" #include "cache_pool.h" #include "vtim.h" diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index 5167247..a58f657 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache_priv.h" +#include "cache_varnishd.h" #include diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index 23e4ef9..781dce7 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index d48e3e7..e548965 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -34,7 +34,7 @@ #include -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "hash/hash_slinger.h" #include "vmb.h" diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c index d68ae8a..16b3e70 100644 --- a/bin/varnishd/hash/hash_simple_list.c +++ b/bin/varnishd/hash/hash_simple_list.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index b3f6cf1..7ed54a6 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "cache/cache_filter.h" #include "cache_http1.h" diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index d1b5bf0..3304664 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include #include diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 06df250..b694623 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -33,7 +33,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include #include diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c index 46f583a..476c8e3 100644 --- a/bin/varnishd/http1/cache_http1_line.c +++ b/bin/varnishd/http1/cache_http1_line.c @@ -35,7 +35,7 @@ #include "config.h" #include -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include #include diff --git a/bin/varnishd/http1/cache_http1_pipe.c b/bin/varnishd/http1/cache_http1_pipe.c index 37032e4..cb7de49 100644 --- a/bin/varnishd/http1/cache_http1_pipe.c +++ b/bin/varnishd/http1/cache_http1_pipe.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include #include diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index 0bc6df9..4cc8b4d 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -45,7 +45,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "cache/cache_transport.h" #include "cache_http1.h" diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c index fd770ea..38cfde8 100644 --- a/bin/varnishd/http1/cache_http1_vfp.c +++ b/bin/varnishd/http1/cache_http1_vfp.c @@ -38,7 +38,7 @@ #include #include -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "cache/cache_filter.h" #include "cache_http1.h" diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 0277b21..f01a120 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index 973827d..7689838 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include #include @@ -92,7 +92,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) static h2_error h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) { - /* XXX: This might belong in cache/cache_priv.http.c */ + /* XXX: This might belong in cache/cache_varnishd.http.c */ unsigned n; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); diff --git a/bin/varnishd/http2/cache_http2_panic.c b/bin/varnishd/http2/cache_http2_panic.c index b160343..da8c5eb 100644 --- a/bin/varnishd/http2/cache_http2_panic.c +++ b/bin/varnishd/http2/cache_http2_panic.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "cache/cache_transport.h" #include "http2/cache_http2.h" diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 13ee528..8828593 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include #include diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index b17b4f2..ecbda33 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "cache/cache_transport.h" #include "http2/cache_http2.h" diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 8785e47..f679a3a 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index f381641..b3aaf1d 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include diff --git a/bin/varnishd/storage/mgt_storage_persistent.c b/bin/varnishd/storage/mgt_storage_persistent.c index 9e6255e..b15be3f 100644 --- a/bin/varnishd/storage/mgt_storage_persistent.c +++ b/bin/varnishd/storage/mgt_storage_persistent.c @@ -35,7 +35,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 084c82d..cab8ac1 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -33,7 +33,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include #include diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 287d05b..c3fbd9f 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/storage/storage_lru.c b/bin/varnishd/storage/storage_lru.c index 33dca6b..4374c58 100644 --- a/bin/varnishd/storage/storage_lru.c +++ b/bin/varnishd/storage/storage_lru.c @@ -32,7 +32,7 @@ #include -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "hash/hash_slinger.h" #include "storage/storage.h" diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c index 60cd988..0468835 100644 --- a/bin/varnishd/storage/storage_malloc.c +++ b/bin/varnishd/storage/storage_malloc.c @@ -31,7 +31,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index af22649..72dd6de 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -35,7 +35,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index e0115c0..bacf18e 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -34,7 +34,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include #include diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index fc75ddb..aedb02b 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -36,7 +36,7 @@ #include "config.h" #include -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "common/heritage.h" #include diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index d07166d..2716159 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -29,7 +29,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "cache/cache_obj.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index b7afaf3..f4ec53b 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -30,7 +30,7 @@ #include "config.h" -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index fa381e9..cede609 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -39,7 +39,7 @@ #include -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "waiter/waiter.h" #include "waiter/waiter_priv.h" diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 546e1df..00b1e3b 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -33,7 +33,7 @@ #if defined(HAVE_KQUEUE) -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 6c953c6..363db64 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -34,7 +34,7 @@ #include #include -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "waiter/waiter.h" #include "waiter/waiter_priv.h" diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 50f8b1d..428e8e4 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -73,7 +73,7 @@ #include #include -#include "cache/cache_priv.h" +#include "cache/cache_varnishd.h" #include "waiter/waiter.h" #include "waiter/waiter_priv.h" From phk at FreeBSD.org Thu Sep 28 08:53:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 28 Sep 2017 08:53:06 +0000 (UTC) Subject: [master] 9d91bcc Give objhead its own include separate from the nuts&bolts of hash slingers. Message-ID: <20170928085306.75C08621F3@lists.varnish-cache.org> commit 9d91bcca79a3125c852ee429e4d86342bfd2eb21 Author: Poul-Henning Kamp Date: Thu Sep 28 08:51:33 2017 +0000 Give objhead its own include separate from the nuts&bolts of hash slingers. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index b0b0b05..1d60d91 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -116,6 +116,7 @@ noinst_HEADERS = \ cache/cache_ban.h \ cache/cache_esi.h \ cache/cache_obj.h \ + cache/cache_objhead.h \ cache/cache_pool.h \ cache/cache_transport.h \ cache/cache_varnishd.h \ diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 8caac84..e2b16ee 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -34,8 +34,8 @@ #include "cache_varnishd.h" #include "cache_ban.h" +#include "cache_objhead.h" -#include "hash/hash_slinger.h" #include "vcli_serve.h" #include "vend.h" #include "vmb.h" diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c index f721394..ba3447e 100644 --- a/bin/varnishd/cache/cache_ban_lurker.c +++ b/bin/varnishd/cache/cache_ban_lurker.c @@ -31,9 +31,10 @@ #include "config.h" #include "cache_varnishd.h" + #include "cache_ban.h" +#include "cache_objhead.h" -#include "hash/hash_slinger.h" #include "vtim.h" static struct objcore oc_mark_cnt = { .magic = OBJCORE_MAGIC, }; diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index bb13378..b7c9947 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -37,7 +37,7 @@ #include "cache_varnishd.h" -#include "hash/hash_slinger.h" +#include "cache_objhead.h" static struct mempool *vbopool; diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 2648c06..a9b7a7e 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -35,9 +35,9 @@ #include #include "cache_varnishd.h" +#include "cache_objhead.h" #include "binary_heap.h" -#include "hash/hash_slinger.h" #include "vtim.h" struct exp_priv { diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 7efc8b0..ca8c89c 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -32,6 +32,7 @@ #include "cache_varnishd.h" #include "cache_director.h" #include "cache_filter.h" +#include "cache_objhead.h" #include "hash/hash_slinger.h" #include "storage/storage.h" #include "vrt.h" diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 8f1c79b..004b86d 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -52,14 +52,16 @@ #include "config.h" -#include "cache_varnishd.h" - #include #include +#include "cache_varnishd.h" + +#include "cache/cache_objhead.h" #include "cache/cache_transport.h" #include "hash/hash_slinger.h" + #include "vsha256.h" #include "vtim.h" diff --git a/bin/varnishd/cache/cache_objhead.h b/bin/varnishd/cache/cache_objhead.h new file mode 100644 index 0000000..f4b7055 --- /dev/null +++ b/bin/varnishd/cache/cache_objhead.h @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2015 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. + * + */ + +struct hash_slinger; + +struct objhead { + unsigned magic; +#define OBJHEAD_MAGIC 0x1b96615d + + int refcnt; + struct lock mtx; + VTAILQ_HEAD(,objcore) objcs; + uint8_t digest[DIGEST_LEN]; + VTAILQ_HEAD(, req) waitinglist; + + /*---------------------------------------------------- + * The fields below are for the sole private use of + * the hash implementation(s). + */ + union { + struct { + VTAILQ_ENTRY(objhead) u_n_hoh_list; + void *u_n_hoh_head; + } n; + } _u; +#define hoh_list _u.n.u_n_hoh_list +#define hoh_head _u.n.u_n_hoh_head +}; + +void HSH_Fail(struct objcore *); +void HSH_Kill(struct objcore *); +void HSH_Insert(struct worker *, const void *hash, struct objcore *, + struct ban *); +void HSH_Unbusy(struct worker *, struct objcore *); +int HSH_Snipe(const struct worker *, struct objcore *); +struct boc *HSH_RefBoc(const struct objcore *); +void HSH_DerefBoc(struct worker *wrk, struct objcore *); +void HSH_DeleteObjHead(const struct worker *, struct objhead *); +int HSH_DerefObjHead(struct worker *, struct objhead **); + +int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax); +#define HSH_RUSH_POLICY -1 +#define HSH_RUSH_ALL INT_MAX + +enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **, + int always_insert); +void HSH_Ref(struct objcore *o); +void HSH_AddString(struct req *, void *ctx, const char *str); +unsigned HSH_Purge(struct worker *, struct objhead *, double ttl, double grace, + double keep); +struct objcore *HSH_Private(const struct worker *wrk); +void HSH_Abandon(struct objcore *oc); diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 0ddac6b..b7de15a 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -34,10 +34,12 @@ #include "cache_varnishd.h" #include "cache_filter.h" +#include "cache_objhead.h" +#include "cache_transport.h" + #include "vtim.h" -#include "hash/hash_slinger.h" #include "storage/storage.h" -#include "cache_transport.h" +#include "hash/hash_slinger.h" /*---------------------------------------------------------------------- * Pull the req.body in via/into a objcore diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 8625d69..987f3d0 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -41,6 +41,7 @@ #include "cache_varnishd.h" #include "cache_director.h" #include "cache_filter.h" +#include "cache_objhead.h" #include "cache_transport.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index c85a452..ca00a44 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -44,13 +44,6 @@ #include "VSC_main.h" /* -------------------------------------------------------------------*/ -/* - * This macro can be used in .h files to isolate bits that the manager - * should not (need to) see, such as pthread mutexes etc. - */ -#define VARNISH_CACHE_CHILD 1 - -/* -------------------------------------------------------------------*/ struct vfp; diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 79fd1ba..e1766c4 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -34,7 +34,7 @@ #include "cache_varnishd.h" #include "cache_director.h" -#include "hash/hash_slinger.h" +#include "cache_objhead.h" #include "vav.h" #include "vrt.h" #include "vcl.h" diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index 781dce7..c9e0d7f 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -31,12 +31,13 @@ #include "config.h" -#include "cache/cache_varnishd.h" -#include "common/heritage.h" - #include #include +#include "cache/cache_varnishd.h" +#include "cache/cache_objhead.h" +#include "common/heritage.h" + #include "hash/hash_slinger.h" static struct VSC_lck *lck_hcl; diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index e548965..417673c 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -35,6 +35,7 @@ #include #include "cache/cache_varnishd.h" +#include "cache/cache_objhead.h" #include "hash/hash_slinger.h" #include "vmb.h" diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c index 16b3e70..188c5ce 100644 --- a/bin/varnishd/hash/hash_simple_list.c +++ b/bin/varnishd/hash/hash_simple_list.c @@ -32,6 +32,7 @@ #include "config.h" #include "cache/cache_varnishd.h" +#include "cache/cache_objhead.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 3d86c20..d6cad78 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -28,17 +28,15 @@ * */ -struct sess; -struct req; -struct objcore; struct worker; +struct objhead; typedef void hash_init_f(int ac, char * const *av); typedef void hash_start_f(void); typedef void hash_prep_f(struct worker *); -typedef struct objhead *hash_lookup_f(struct worker *wrk, const void *digest, - struct objhead **nobj); -typedef int hash_deref_f(struct objhead *obj); +typedef struct objhead *hash_lookup_f(struct worker *, const void *digest, + struct objhead **); +typedef int hash_deref_f(struct objhead *); struct hash_slinger { unsigned magic; @@ -59,60 +57,12 @@ enum lookup_e { HSH_EXPBUSY }; -/* cache_hash.c */ -struct ban; -void HSH_Cleanup(struct worker *w); -enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **, - int always_insert); -void HSH_Ref(struct objcore *o); -void HSH_Init(const struct hash_slinger *slinger); -void HSH_AddString(struct req *, void *ctx, const char *str); -void HSH_Insert(struct worker *, const void *hash, struct objcore *, - struct ban *); -unsigned HSH_Purge(struct worker *, struct objhead *, double ttl, double grace, - double keep); -void HSH_config(const char *h_arg); -struct boc *HSH_RefBoc(const struct objcore *); -void HSH_DerefBoc(struct worker *wrk, struct objcore *); -struct objcore *HSH_Private(const struct worker *wrk); -void HSH_Abandon(struct objcore *oc); -int HSH_Snipe(const struct worker *, struct objcore *); -void HSH_Kill(struct objcore *); - -#ifdef VARNISH_CACHE_CHILD - -struct objhead { - unsigned magic; -#define OBJHEAD_MAGIC 0x1b96615d +/* mgt_hash.c */ +void HSH_config(const char *); - int refcnt; - struct lock mtx; - VTAILQ_HEAD(,objcore) objcs; - uint8_t digest[DIGEST_LEN]; - VTAILQ_HEAD(, req) waitinglist; - - /*---------------------------------------------------- - * The fields below are for the sole private use of - * the hash implementation(s). - */ - union { - struct { - VTAILQ_ENTRY(objhead) u_n_hoh_list; - void *u_n_hoh_head; - } n; - } _u; -#define hoh_list _u.n.u_n_hoh_list -#define hoh_head _u.n.u_n_hoh_head -}; - -void HSH_Fail(struct objcore *); -void HSH_Unbusy(struct worker *, struct objcore *); -void HSH_DeleteObjHead(const struct worker *, struct objhead *); -int HSH_DerefObjHead(struct worker *, struct objhead **); -int HSH_DerefObjCore(struct worker *, struct objcore **, int); -#define HSH_RUSH_POLICY -1 -#define HSH_RUSH_ALL INT_MAX -#endif /* VARNISH_CACHE_CHILD */ +/* cache_hash.c */ +void HSH_Init(const struct hash_slinger *); +void HSH_Cleanup(struct worker *); extern const struct hash_slinger hsl_slinger; extern const struct hash_slinger hcl_slinger; diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index b694623..58748d3 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -39,9 +39,9 @@ #include #include +#include "cache/cache_objhead.h" #include "cache/cache_transport.h" #include "cache_http1.h" -#include "hash/hash_slinger.h" #include "vtcp.h" diff --git a/bin/varnishd/storage/storage_lru.c b/bin/varnishd/storage/storage_lru.c index 4374c58..32d142e 100644 --- a/bin/varnishd/storage/storage_lru.c +++ b/bin/varnishd/storage/storage_lru.c @@ -33,7 +33,7 @@ #include #include "cache/cache_varnishd.h" -#include "hash/hash_slinger.h" +#include "cache/cache_objhead.h" #include "storage/storage.h" diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 72dd6de..bfc082a 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -43,10 +43,10 @@ #include #include "cache/cache_obj.h" +#include "cache/cache_objhead.h" #include "storage/storage.h" #include "storage/storage_simple.h" -#include "hash/hash_slinger.h" #include "vcli_serve.h" #include "vsha256.h" #include "vtim.h" diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index bacf18e..6718065 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -34,19 +34,20 @@ #include "config.h" -#include "cache/cache_varnishd.h" #include #include -#include "storage/storage.h" -#include "storage/storage_simple.h" +#include "cache/cache_varnishd.h" -#include "hash/hash_slinger.h" #include "vsha256.h" #include "vend.h" #include "vtim.h" +#include "cache/cache_objhead.h" + +#include "storage/storage.h" +#include "storage/storage_simple.h" #include "storage/storage_persistent.h" /* diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 2716159..38e21f2 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -32,7 +32,7 @@ #include "cache/cache_varnishd.h" #include "cache/cache_obj.h" -#include "hash/hash_slinger.h" +#include "cache/cache_objhead.h" #include "storage/storage.h" #include "storage/storage_simple.h" From nils.goroll at uplex.de Thu Sep 28 10:31:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Sep 2017 10:31:06 +0000 (UTC) Subject: [master] ba54815 Revert "Drop long broken umem code" Message-ID: <20170928103106.AD64562C0E@lists.varnish-cache.org> commit ba54815bc5d5d3a6e8a5df81eb463ec899a5643f Author: Nils Goroll Date: Tue Sep 26 15:03:34 2017 +0200 Revert "Drop long broken umem code" This reverts commit 766dee06e1eba0309453a1c6e1115975b46eed8b. Conflicts: bin/varnishd/mgt/mgt_main.c diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 1d60d91..228c83d 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -101,6 +101,7 @@ varnishd_SOURCES = \ storage/storage_persistent_silo.c \ storage/storage_persistent_subr.c \ storage/storage_simple.c \ + storage/storage_umem.c \ waiter/mgt_waiter.c \ waiter/cache_waiter.c \ waiter/cache_waiter_epoll.c \ @@ -161,7 +162,7 @@ varnishd_LDADD = \ @SAN_LDFLAGS@ \ @JEMALLOC_LDADD@ \ @PCRE_LIBS@ \ - ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${RT_LIBS} ${LIBM} + ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${RT_LIBS} ${LIBM} ${UMEM_LIBS} noinst_PROGRAMS = vhp_gen_hufdec vhp_gen_hufdec_SOURCES = hpack/vhp_gen_hufdec.c diff --git a/bin/varnishd/Makefile.phk b/bin/varnishd/Makefile.phk index f018d00..6882faa 100644 --- a/bin/varnishd/Makefile.phk +++ b/bin/varnishd/Makefile.phk @@ -89,6 +89,7 @@ PROG_SRC += storage/storage_persistent.c PROG_SRC += storage/storage_persistent_silo.c PROG_SRC += storage/storage_persistent_subr.c PROG_SRC += storage/storage_simple.c +PROG_SRC += storage/storage_umem.c PROG_SRC += waiter/cache_waiter.c PROG_SRC += waiter/cache_waiter_epoll.c diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 0bc438a..dd340db 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -126,6 +126,9 @@ usage(void) printf(FMT, "-s [name=]kind[,options]", "Storage specification"); printf(FMT, "", "Can be specified multiple times."); +#ifdef HAVE_LIBUMEM + printf(FMT, "", " -s umem"); +#endif printf(FMT, "", " -s malloc"); printf(FMT, "", " -s file"); diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index c3e161d..ae2428f 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -122,6 +122,9 @@ static const struct choice STV_choice[] = { { "malloc", &sma_stevedore }, { "deprecated_persistent", &smp_stevedore }, { "persistent", &smp_fake_stevedore }, +#if defined(HAVE_LIBUMEM) && 0 + { "umem", &smu_stevedore }, +#endif { NULL, NULL } }; diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c new file mode 100644 index 0000000..edc798f --- /dev/null +++ b/bin/varnishd/storage/storage_umem.c @@ -0,0 +1,170 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2011 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. + * + * Storage method based on umem_alloc(3MALLOC) + */ + +//lint -e{766} +#include "config.h" + +#if defined(HAVE_LIBUMEM) && 0 + +#include +#include +#include + +#include "cache/cache.h" +#include "cache/cache_obj.h" +#include "storage/storage.h" +#include "storage/storage_simple.h" + +static size_t smu_max = SIZE_MAX; +static MTX smu_mtx; + +struct smu { + struct storage s; + size_t sz; +}; + +static struct storage * +smu_alloc(const struct stevedore *st, size_t size) +{ + struct smu *smu; + + Lck_Lock(&smu_mtx); + VSC_C_main->sma_nreq++; + if (VSC_C_main->sma_nbytes + size > smu_max) + size = 0; + else { + VSC_C_main->sma_nobj++; + VSC_C_main->sma_nbytes += size; + VSC_C_main->sma_balloc += size; + } + Lck_Unlock(&smu_mtx); + + if (size == 0) + return (NULL); + + smu = umem_zalloc(sizeof *smu, UMEM_DEFAULT); + if (smu == NULL) + return (NULL); + smu->sz = size; + smu->s.priv = smu; + smu->s.ptr = umem_alloc(size, UMEM_DEFAULT); + XXXAN(smu->s.ptr); + smu->s.len = 0; + smu->s.space = size; + smu->s.fd = -1; + smu->s.stevedore = st; + smu->s.magic = STORAGE_MAGIC; + return (&smu->s); +} + +static void +smu_free(struct storage *s) +{ + struct smu *smu; + + CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC); + smu = s->priv; + assert(smu->sz == smu->s.space); + Lck_Lock(&smu_mtx); + VSC_C_main->sma_nobj--; + VSC_C_main->sma_nbytes -= smu->sz; + VSC_C_main->sma_bfree += smu->sz; + Lck_Unlock(&smu_mtx); + umem_free(smu->s.ptr, smu->s.space); + umem_free(smu, sizeof *smu); +} + +static void +smu_trim(const struct storage *s, size_t size) +{ + struct smu *smu; + void *p; + + CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC); + smu = s->priv; + assert(smu->sz == smu->s.space); + if ((p = umem_alloc(size, UMEM_DEFAULT)) != NULL) { + memcpy(p, smu->s.ptr, size); + umem_free(smu->s.ptr, smu->s.space); + Lck_Lock(&smu_mtx); + VSC_C_main->sma_nbytes -= (smu->sz - size); + VSC_C_main->sma_bfree += smu->sz - size; + smu->sz = size; + Lck_Unlock(&smu_mtx); + smu->s.ptr = p; + smu->s.space = size; + } +} + +static void +smu_init(struct stevedore *parent, int ac, char * const *av) +{ + const char *e; + uintmax_t u; + + (void)parent; + + AZ(av[ac]); + if (ac > 1) + ARGV_ERR("(-sumem) too many arguments\n"); + + if (ac == 0 || *av[0] == '\0') + return; + + e = VNUM_2bytes(av[0], &u, 0); + if (e != NULL) + ARGV_ERR("(-sumem) size \"%s\": %s\n", av[0], e); + if ((u != (uintmax_t)(size_t)u)) + ARGV_ERR("(-sumem) size \"%s\": too big\n", av[0]); + smu_max = u; +} + +static void +smu_open(const struct stevedore *st) +{ + (void)st; + AZ(pthread_mutex_init(&smu_mtx, NULL)); +} + +const struct stevedore smu_stevedore = { + .magic = STEVEDORE_MAGIC, + .name = "umem", + .init = smu_init, + .open = smu_open, + .alloc = smu_alloc, + .free = smu_free, + .trim = smu_trim, + .allocobj = SML_allocobj, + .panic = SML_panic, + .methods = &SML_methods, +}; + +#endif /* HAVE_UMEM_H */ diff --git a/config.phk b/config.phk index b54257a..4111c35 100644 --- a/config.phk +++ b/config.phk @@ -71,7 +71,8 @@ if true ; then sys/filio.h \ sys/mount.h \ sys/statvfs.h \ - sys/vfs.h + sys/vfs.h \ + umem.h do if [ -f /usr/include/$i ] ; then n=`echo $i | tr '[a-z/.]' '[A-Z__]'` @@ -295,6 +296,7 @@ exit 0 # SO_SNDTIMEO_WORKS + # VCC_CC + # HAVE_EPOLL_CTL - +# HAVE_LIBUMEM - # USE_PCRE_JIT - # _FILE_OFFSET_BITS - # diff --git a/configure.ac b/configure.ac index fa43c1e..5e20c0a 100644 --- a/configure.ac +++ b/configure.ac @@ -87,6 +87,9 @@ if test "x$ax_cv_curses" != xyes; then AC_MSG_ERROR([requires an X/Open-compatible Curses library]) fi +# Userland slab allocator from Solaris, ported to other systems +AC_CHECK_HEADERS([umem.h], [_VARNISH_CHECK_LIB(umem, umem_alloc)]) + # XXX: This _may_ be for OS/X AC_CHECK_LIBM AC_SUBST(LIBM) From nils.goroll at uplex.de Thu Sep 28 10:31:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Sep 2017 10:31:06 +0000 (UTC) Subject: [master] 8d49338 Copy storage_malloc to storage_umem and rename sma->smu Message-ID: <20170928103106.CEFDF62C11@lists.varnish-cache.org> commit 8d49338c34606889bc94658b2d8e3c67f8cb3e55 Author: Nils Goroll Date: Tue Sep 26 15:13:49 2017 +0200 Copy storage_malloc to storage_umem and rename sma->smu diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 228c83d..a1dc890 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -265,6 +265,18 @@ nodist_varnishd_SOURCES += VSC_sma.c ####################################################################### +VSC_smu.c VSC_smu.h: $(srcdir)/smu.vsc $(top_srcdir)/lib/libvcc/vsctool.py + $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/smu.vsc + +$(varnishd_OBJECTS): VSC_smu.h + +EXTRA_DIST += smu.vsc +DISTCLEANFILES += VSC_smu.c VSC_smu.h +BUILT_SOURCES += VSC_smu.c VSC_smu.h +nodist_varnishd_SOURCES += VSC_smu.c + +####################################################################### + VSC_smf.c VSC_smf.h: $(srcdir)/smf.vsc $(top_srcdir)/lib/libvcc/vsctool.py $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/smf.vsc diff --git a/bin/varnishd/smu.vsc b/bin/varnishd/smu.vsc new file mode 100644 index 0000000..89af32b --- /dev/null +++ b/bin/varnishd/smu.vsc @@ -0,0 +1,62 @@ +.. + This is *NOT* a RST file but the syntax has been chosen so + that it may become an RST file at some later date. + +.. varnish_vsc_begin:: smu + :oneliner: Umem Stevedore Counters + :order: 40 + +.. varnish_vsc:: c_req + :type: counter + :level: info + :oneliner: Allocator requests + + Number of times the storage has been asked to provide a storage segment. + +.. varnish_vsc:: c_fail + :type: counter + :level: info + :oneliner: Allocator failures + + Number of times the storage has failed to provide a storage segment. + +.. varnish_vsc:: c_bytes + :type: counter + :level: info + :format: bytes + :oneliner: Bytes allocated + + Number of total bytes allocated by this storage. + +.. varnish_vsc:: c_freed + :type: counter + :level: info + :format: bytes + :oneliner: Bytes freed + + Number of total bytes returned to this storage. + +.. varnish_vsc:: g_alloc + :type: gauge + :level: info + :oneliner: Allocations outstanding + + Number of storage allocations outstanding. + +.. varnish_vsc:: g_bytes + :type: gauge + :level: info + :format: bytes + :oneliner: Bytes outstanding + + Number of bytes allocated from the storage. + +.. varnish_vsc:: g_space + :type: gauge + :level: info + :format: bytes + :oneliner: Bytes available + + Number of bytes left in the storage. + +.. varnish_vsc_end:: smu diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 0a61d8d..08f23c9 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -145,6 +145,7 @@ int LRU_NukeOne(struct worker *, struct lru *); void LRU_Touch(struct worker *, struct objcore *, double now); /*--------------------------------------------------------------------*/ +extern const struct stevedore smu_stevedore; extern const struct stevedore sma_stevedore; extern const struct stevedore smf_stevedore; extern const struct stevedore smp_stevedore; diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c index edc798f..10833c1 100644 --- a/bin/varnishd/storage/storage_umem.c +++ b/bin/varnishd/storage/storage_umem.c @@ -1,9 +1,11 @@ /*- * Copyright (c) 2006 Verdens Gang AS * Copyright (c) 2006-2011 Varnish Software AS + * Copyright 2017 UPLEX - Nils Goroll Systemoptimierung * All rights reserved. * - * Author: Poul-Henning Kamp + * Authors: Poul-Henning Kamp + * Nils Goroll * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,102 +28,149 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Storage method based on umem_alloc(3MALLOC) + * Storage method based on libumem */ -//lint -e{766} #include "config.h" -#if defined(HAVE_LIBUMEM) && 0 +#if defined(HAVE_LIBUMEM) + +#include "cache/cache.h" #include #include -#include -#include "cache/cache.h" -#include "cache/cache_obj.h" #include "storage/storage.h" #include "storage/storage_simple.h" -static size_t smu_max = SIZE_MAX; -static MTX smu_mtx; +#include "vrt.h" +#include "vnum.h" + +#include "VSC_smu.h" + +struct smu_sc { + unsigned magic; +#define SMU_SC_MAGIC 0x1ac8a345 + struct lock smu_mtx; + size_t smu_max; + size_t smu_alloc; + struct VSC_smu *stats; +}; struct smu { + unsigned magic; +#define SMU_MAGIC 0x69ae9bb9 struct storage s; size_t sz; + struct smu_sc *sc; }; -static struct storage * +static struct VSC_lck *lck_smu; + +static struct storage * __match_proto__(sml_alloc_f) smu_alloc(const struct stevedore *st, size_t size) { - struct smu *smu; + struct smu_sc *smu_sc; + struct smu *smu = NULL; + void *p; - Lck_Lock(&smu_mtx); - VSC_C_main->sma_nreq++; - if (VSC_C_main->sma_nbytes + size > smu_max) + CAST_OBJ_NOTNULL(smu_sc, st->priv, SMU_SC_MAGIC); + Lck_Lock(&smu_sc->smu_mtx); + smu_sc->stats->c_req++; + if (smu_sc->smu_alloc + size > smu_sc->smu_max) { + smu_sc->stats->c_fail++; size = 0; - else { - VSC_C_main->sma_nobj++; - VSC_C_main->sma_nbytes += size; - VSC_C_main->sma_balloc += size; + } else { + smu_sc->smu_alloc += size; + smu_sc->stats->c_bytes += size; + smu_sc->stats->g_alloc++; + smu_sc->stats->g_bytes += size; + if (smu_sc->smu_max != SIZE_MAX) + smu_sc->stats->g_space -= size; } - Lck_Unlock(&smu_mtx); + Lck_Unlock(&smu_sc->smu_mtx); if (size == 0) return (NULL); - smu = umem_zalloc(sizeof *smu, UMEM_DEFAULT); - if (smu == NULL) + /* + * Do not collaps the smu allocation with smu->s.ptr: it is not + * a good idea. Not only would it make ->trim impossible, + * performance-wise it would be a catastropy with chunksized + * allocations growing another full page, just to accommodate the smu. + */ + + p = malloc(size); + if (p != NULL) { + ALLOC_OBJ(smu, SMU_MAGIC); + if (smu != NULL) + smu->s.ptr = p; + else + free(p); + } + if (smu == NULL) { + Lck_Lock(&smu_sc->smu_mtx); + /* + * XXX: Not nice to have counters go backwards, but we do + * XXX: Not want to pick up the lock twice just for stats. + */ + smu_sc->stats->c_fail++; + smu_sc->smu_alloc -= size; + smu_sc->stats->c_bytes -= size; + smu_sc->stats->g_alloc--; + smu_sc->stats->g_bytes -= size; + if (smu_sc->smu_max != SIZE_MAX) + smu_sc->stats->g_space += size; + Lck_Unlock(&smu_sc->smu_mtx); return (NULL); + } + smu->sc = smu_sc; smu->sz = size; smu->s.priv = smu; - smu->s.ptr = umem_alloc(size, UMEM_DEFAULT); - XXXAN(smu->s.ptr); smu->s.len = 0; smu->s.space = size; - smu->s.fd = -1; - smu->s.stevedore = st; smu->s.magic = STORAGE_MAGIC; return (&smu->s); } -static void +static void __match_proto__(sml_free_f) smu_free(struct storage *s) { + struct smu_sc *smu_sc; struct smu *smu; CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC); - smu = s->priv; + CAST_OBJ_NOTNULL(smu, s->priv, SMU_MAGIC); + smu_sc = smu->sc; assert(smu->sz == smu->s.space); - Lck_Lock(&smu_mtx); - VSC_C_main->sma_nobj--; - VSC_C_main->sma_nbytes -= smu->sz; - VSC_C_main->sma_bfree += smu->sz; - Lck_Unlock(&smu_mtx); - umem_free(smu->s.ptr, smu->s.space); - umem_free(smu, sizeof *smu); + Lck_Lock(&smu_sc->smu_mtx); + smu_sc->smu_alloc -= smu->sz; + smu_sc->stats->g_alloc--; + smu_sc->stats->g_bytes -= smu->sz; + smu_sc->stats->c_freed += smu->sz; + if (smu_sc->smu_max != SIZE_MAX) + smu_sc->stats->g_space += smu->sz; + Lck_Unlock(&smu_sc->smu_mtx); + free(smu->s.ptr); + free(smu); } -static void -smu_trim(const struct storage *s, size_t size) +static VCL_BYTES __match_proto__(stv_var_used_space) +smu_used_space(const struct stevedore *st) { - struct smu *smu; - void *p; + struct smu_sc *smu_sc; - CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC); - smu = s->priv; - assert(smu->sz == smu->s.space); - if ((p = umem_alloc(size, UMEM_DEFAULT)) != NULL) { - memcpy(p, smu->s.ptr, size); - umem_free(smu->s.ptr, smu->s.space); - Lck_Lock(&smu_mtx); - VSC_C_main->sma_nbytes -= (smu->sz - size); - VSC_C_main->sma_bfree += smu->sz - size; - smu->sz = size; - Lck_Unlock(&smu_mtx); - smu->s.ptr = p; - smu->s.space = size; - } + CAST_OBJ_NOTNULL(smu_sc, st->priv, SMU_SC_MAGIC); + return (smu_sc->smu_alloc); +} + +static VCL_BYTES __match_proto__(stv_var_free_space) +smu_free_space(const struct stevedore *st) +{ + struct smu_sc *smu_sc; + + CAST_OBJ_NOTNULL(smu_sc, st->priv, SMU_SC_MAGIC); + return (smu_sc->smu_max - smu_sc->smu_alloc); } static void @@ -129,8 +178,14 @@ smu_init(struct stevedore *parent, int ac, char * const *av) { const char *e; uintmax_t u; + struct smu_sc *sc; - (void)parent; + ASSERT_MGT(); + ALLOC_OBJ(sc, SMU_SC_MAGIC); + AN(sc); + sc->smu_max = SIZE_MAX; + assert(sc->smu_max == SIZE_MAX); + parent->priv = sc; AZ(av[ac]); if (ac > 1) @@ -144,14 +199,27 @@ smu_init(struct stevedore *parent, int ac, char * const *av) ARGV_ERR("(-sumem) size \"%s\": %s\n", av[0], e); if ((u != (uintmax_t)(size_t)u)) ARGV_ERR("(-sumem) size \"%s\": too big\n", av[0]); - smu_max = u; + if (u < 1024*1024) + ARGV_ERR("(-sumem) size \"%s\": too smull, " + "did you forget to specify M or G?\n", av[0]); + + sc->smu_max = u; } -static void -smu_open(const struct stevedore *st) +static void __match_proto__(storage_open_f) +smu_open(struct stevedore *st) { - (void)st; - AZ(pthread_mutex_init(&smu_mtx, NULL)); + struct smu_sc *smu_sc; + + ASSERT_CLI(); + st->lru = LRU_Alloc(); + if (lck_smu == NULL) + lck_smu = Lck_CreateClass("smu"); + CAST_OBJ_NOTNULL(smu_sc, st->priv, SMU_SC_MAGIC); + Lck_New(&smu_sc->smu_mtx, lck_smu); + smu_sc->stats = VSC_smu_New(st->ident); + if (smu_sc->smu_max != SIZE_MAX) + smu_sc->stats->g_space = smu_sc->smu_max; } const struct stevedore smu_stevedore = { @@ -159,12 +227,13 @@ const struct stevedore smu_stevedore = { .name = "umem", .init = smu_init, .open = smu_open, - .alloc = smu_alloc, - .free = smu_free, - .trim = smu_trim, + .sml_alloc = smu_alloc, + .sml_free = smu_free, .allocobj = SML_allocobj, .panic = SML_panic, .methods = &SML_methods, + .var_free_space = smu_free_space, + .var_used_space = smu_used_space, }; #endif /* HAVE_UMEM_H */ diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 2d68243..3c3142f 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -128,6 +128,7 @@ COUNTERS = \ $(top_srcdir)/bin/varnishd/mgt.vsc \ $(top_srcdir)/bin/varnishd/mempool.vsc \ $(top_srcdir)/bin/varnishd/sma.vsc \ + $(top_srcdir)/bin/varnishd/smu.vsc \ $(top_srcdir)/bin/varnishd/smf.vsc \ $(top_srcdir)/bin/varnishd/vbe.vsc \ $(top_srcdir)/bin/varnishd/lck.vsc From nils.goroll at uplex.de Thu Sep 28 10:31:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Sep 2017 10:31:06 +0000 (UTC) Subject: [master] 12e6ca9 Actually use libumem in storage_umem Message-ID: <20170928103106.EA82A62C15@lists.varnish-cache.org> commit 12e6ca9d79712d28f0db96a28d27304d5278da8d Author: Nils Goroll Date: Tue Sep 26 17:22:10 2017 +0200 Actually use libumem in storage_umem diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index ae2428f..71324a5 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -122,7 +122,7 @@ static const struct choice STV_choice[] = { { "malloc", &sma_stevedore }, { "deprecated_persistent", &smp_stevedore }, { "persistent", &smp_fake_stevedore }, -#if defined(HAVE_LIBUMEM) && 0 +#if defined(HAVE_LIBUMEM) { "umem", &smu_stevedore }, #endif { NULL, NULL } diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c index 10833c1..54d5c08 100644 --- a/bin/varnishd/storage/storage_umem.c +++ b/bin/varnishd/storage/storage_umem.c @@ -39,32 +39,75 @@ #include #include +#include #include "storage/storage.h" #include "storage/storage_simple.h" #include "vrt.h" #include "vnum.h" +#include "common/heritage.h" #include "VSC_smu.h" struct smu_sc { unsigned magic; -#define SMU_SC_MAGIC 0x1ac8a345 +#define SMU_SC_MAGIC 0x7695f68e struct lock smu_mtx; size_t smu_max; size_t smu_alloc; struct VSC_smu *stats; + umem_cache_t *smu_cache; }; struct smu { unsigned magic; -#define SMU_MAGIC 0x69ae9bb9 +#define SMU_MAGIC 0x3773300c struct storage s; size_t sz; struct smu_sc *sc; }; +/* init required per cache get: + smu->sz = size + smu->s.ptr; + smu->s.space = size +*/ + +static inline void +smu_smu_init(struct smu *smu, struct smu_sc *sc) +{ + INIT_OBJ(smu, SMU_MAGIC); + smu->s.magic = STORAGE_MAGIC; + smu->s.priv = smu; + smu->sc = sc; +} + +static int __match_proto__(umem_constructor_t) +smu_smu_constructor(void *buffer, void *callback_data, int flags) +{ + struct smu *smu = buffer; + struct smu_sc *sc; + + (void) flags; + CAST_OBJ_NOTNULL(sc, callback_data, SMU_SC_MAGIC); + smu_smu_init(smu, sc); + return (0); +} + +static void __match_proto__(umem_destructor_t) + smu_smu_destructor(void *buffer, void *callback_data) +{ + struct smu *smu; + struct smu_sc *sc; + + CAST_OBJ_NOTNULL(smu, buffer, SMU_MAGIC); + CAST_OBJ_NOTNULL(sc, callback_data, SMU_SC_MAGIC); + CHECK_OBJ_NOTNULL(&(smu->s), STORAGE_MAGIC); + assert(smu->s.priv == smu); + assert(smu->sc == sc); +} + static struct VSC_lck *lck_smu; static struct storage * __match_proto__(sml_alloc_f) @@ -100,13 +143,14 @@ smu_alloc(const struct stevedore *st, size_t size) * allocations growing another full page, just to accommodate the smu. */ - p = malloc(size); + p = umem_alloc(size, UMEM_DEFAULT); if (p != NULL) { - ALLOC_OBJ(smu, SMU_MAGIC); + AN(smu_sc->smu_cache); + smu = umem_cache_alloc(smu_sc->smu_cache, UMEM_DEFAULT); if (smu != NULL) smu->s.ptr = p; else - free(p); + umem_free(p, size); } if (smu == NULL) { Lck_Lock(&smu_sc->smu_mtx); @@ -124,35 +168,33 @@ smu_alloc(const struct stevedore *st, size_t size) Lck_Unlock(&smu_sc->smu_mtx); return (NULL); } - smu->sc = smu_sc; smu->sz = size; - smu->s.priv = smu; - smu->s.len = 0; smu->s.space = size; - smu->s.magic = STORAGE_MAGIC; return (&smu->s); } static void __match_proto__(sml_free_f) smu_free(struct storage *s) { - struct smu_sc *smu_sc; struct smu *smu; + struct smu_sc *sc; CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC); CAST_OBJ_NOTNULL(smu, s->priv, SMU_MAGIC); - smu_sc = smu->sc; - assert(smu->sz == smu->s.space); - Lck_Lock(&smu_sc->smu_mtx); - smu_sc->smu_alloc -= smu->sz; - smu_sc->stats->g_alloc--; - smu_sc->stats->g_bytes -= smu->sz; - smu_sc->stats->c_freed += smu->sz; - if (smu_sc->smu_max != SIZE_MAX) - smu_sc->stats->g_space += smu->sz; - Lck_Unlock(&smu_sc->smu_mtx); - free(smu->s.ptr); - free(smu); + CAST_OBJ_NOTNULL(sc, smu->sc, SMU_SC_MAGIC); + + Lck_Lock(&sc->smu_mtx); + sc->smu_alloc -= smu->sz; + sc->stats->g_alloc--; + sc->stats->g_bytes -= smu->sz; + sc->stats->c_freed += smu->sz; + if (sc->smu_max != SIZE_MAX) + sc->stats->g_space += smu->sz; + Lck_Unlock(&sc->smu_mtx); + + umem_free(smu->s.ptr, smu->sz); + smu_smu_init(smu, sc); + umem_cache_free(sc->smu_cache, smu); } static VCL_BYTES __match_proto__(stv_var_used_space) @@ -220,6 +262,38 @@ smu_open(struct stevedore *st) smu_sc->stats = VSC_smu_New(st->ident); if (smu_sc->smu_max != SIZE_MAX) smu_sc->stats->g_space = smu_sc->smu_max; + + smu_sc->smu_cache = umem_cache_create(st->ident, + sizeof(struct smu), + 0, // align + smu_smu_constructor, + smu_smu_destructor, + NULL, // reclaim + smu_sc, // callback_data + NULL, // source + 0 // cflags + ); + AN(smu_sc->smu_cache); +} + +static void __match_proto__(storage_close_f) +smu_close(const struct stevedore *st, int warn) +{ + struct smu_sc *smu_sc; + + ASSERT_CLI(); + + CAST_OBJ_NOTNULL(smu_sc, st->priv, SMU_SC_MAGIC); + if (warn) + return; + umem_cache_destroy(smu_sc->smu_cache); + smu_sc->smu_cache = NULL; + + /* + XXX TODO? + - LRU_Free + - Lck Destroy + */ } const struct stevedore smu_stevedore = { @@ -227,6 +301,7 @@ const struct stevedore smu_stevedore = { .name = "umem", .init = smu_init, .open = smu_open, + .close = smu_close, .sml_alloc = smu_alloc, .sml_free = smu_free, .allocobj = SML_allocobj, From nils.goroll at uplex.de Thu Sep 28 10:31:07 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Sep 2017 10:31:07 +0000 (UTC) Subject: [master] 0fe2834 Introduce a storage backend type (stevedore) 'default' which resolves to umem or malloc Message-ID: <20170928103107.47C9A62C1A@lists.varnish-cache.org> commit 0fe283433ae2eb4509f3625c9dbb7e018a654293 Author: Nils Goroll Date: Tue Sep 26 16:49:28 2017 +0200 Introduce a storage backend type (stevedore) 'default' which resolves to umem or malloc On platforms where umem is available (specifically Solaris descendents), we want to make umem the default allocator for performance reasons and also for vtc coverage while still keeping the malloc type as fallback option. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index dd340db..aa1bb74 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -127,7 +127,10 @@ usage(void) printf(FMT, "-s [name=]kind[,options]", "Storage specification"); printf(FMT, "", "Can be specified multiple times."); #ifdef HAVE_LIBUMEM + printf(FMT, "", " -s default (=umem)"); printf(FMT, "", " -s umem"); +#else + printf(FMT, "", " -s default (=malloc)"); #endif printf(FMT, "", " -s malloc"); printf(FMT, "", " -s file"); @@ -437,7 +440,7 @@ main(int argc, char * const *argv) const char *n_arg = NULL; const char *P_arg = NULL; const char *S_arg = NULL; - const char *s_arg = "malloc,100m"; + const char *s_arg = "default,100m"; const char *W_arg = NULL; int s_arg_given = 0; int novcl = 0; diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index 71324a5..ef44695 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -124,6 +124,9 @@ static const struct choice STV_choice[] = { { "persistent", &smp_fake_stevedore }, #if defined(HAVE_LIBUMEM) { "umem", &smu_stevedore }, + { "default", &smu_stevedore }, +#else + { "default", &sma_stevedore }, #endif { NULL, NULL } }; @@ -217,7 +220,7 @@ STV_Config_Transient(void) VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_stv); if (stv_transient == NULL) - STV_Config(TRANSIENT_STORAGE "=malloc"); + STV_Config(TRANSIENT_STORAGE "=default"); AN(stv_transient); VTAILQ_INSERT_TAIL(&stevedores, stv_transient, list); } diff --git a/bin/varnishtest/tests/b00002.vtc b/bin/varnishtest/tests/b00002.vtc index f56fae0..26591b0 100644 --- a/bin/varnishtest/tests/b00002.vtc +++ b/bin/varnishtest/tests/b00002.vtc @@ -5,7 +5,7 @@ server s1 { txresp -hdr "Cache-Control: max-age=120" -hdr "Connection: close" -body "012345\n" } -start -varnish v1 -vcl+backend { +varnish v1 -arg "-sTransient=default,1m" -vcl+backend { sub vcl_recv { return(pass); } diff --git a/bin/varnishtest/tests/b00006.vtc b/bin/varnishtest/tests/b00006.vtc index b7d1c8b..c89915b 100644 --- a/bin/varnishtest/tests/b00006.vtc +++ b/bin/varnishtest/tests/b00006.vtc @@ -1,11 +1,11 @@ -varnishtest "Check that -s malloc works" +varnishtest "Check that -s default works" server s1 { rxreq txresp -hdr "Connection: close" -body "012345\n" } -start -varnish v1 -arg "-s malloc" -vcl+backend {} -start +varnish v1 -arg "-s default" -vcl+backend {} -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/c00018.vtc b/bin/varnishtest/tests/c00018.vtc index f61b6c5..96368b9 100644 --- a/bin/varnishtest/tests/c00018.vtc +++ b/bin/varnishtest/tests/c00018.vtc @@ -91,7 +91,7 @@ logexpect l1 -v v1 -g raw { expect 0 1007 VCL_call {^PASS$} expect 0 1007 VCL_return {^fetch$} expect 0 1007 Link {^bereq 1008 pass$} - expect 0 1007 Storage {^malloc Transient$} + expect 0 1007 Storage {^(malloc|umem) Transient$} expect 0 1007 RespProtocol {^HTTP/1.1$} expect 0 1007 RespStatus {^100$} expect 0 1007 RespReason {^Continue$} @@ -107,7 +107,7 @@ logexpect l1 -v v1 -g raw { expect 0 1009 ReqHeader {^Content-Length: 20$} expect 0 1009 ReqHeader {^X-Forwarded-For:} expect 0 1009 VCL_call {^RECV$} - expect 0 1009 Storage {^malloc Transient$} + expect 0 1009 Storage {^(malloc|umem) Transient$} expect 0 1009 RespProtocol {^HTTP/1.1$} expect 0 1009 RespStatus {^100$} expect 0 1009 RespReason {^Continue$} diff --git a/bin/varnishtest/tests/c00027.vtc b/bin/varnishtest/tests/c00027.vtc index d9c7e8e..5c22daf 100644 --- a/bin/varnishtest/tests/c00027.vtc +++ b/bin/varnishtest/tests/c00027.vtc @@ -18,7 +18,7 @@ server s1 { txresp -body "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" } -start -varnish v1 -arg "-s malloc,1M" -vcl+backend { +varnish v1 -arg "-s default,1M" -vcl+backend { sub vcl_backend_response { set beresp.ttl = 10m; } diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index f9ebad6..5701cf4 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -18,9 +18,10 @@ server s1 { } -start varnish v1 \ - -arg "-ss1=malloc,1m" \ - -arg "-ss2=malloc,1m" \ - -arg "-ss0=malloc,1m" \ + -arg "-ss1=default,1m" \ + -arg "-ss2=default,1m" \ + -arg "-ss0=default,1m" \ + -arg "-sTransient=default" \ -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index 96fb58a..896a520 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -10,9 +10,10 @@ server s1 { } -start varnish v1 \ - -arg "-smalloc,1m" \ - -arg "-smalloc,1m" \ - -arg "-smalloc,1m" \ + -arg "-sdefault,1m" \ + -arg "-sdefault,1m" \ + -arg "-sdefault,1m" \ + -arg "-sTransient=default" \ -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; diff --git a/bin/varnishtest/tests/c00046.vtc b/bin/varnishtest/tests/c00046.vtc index 3666ed8..55832f3 100644 --- a/bin/varnishtest/tests/c00046.vtc +++ b/bin/varnishtest/tests/c00046.vtc @@ -6,9 +6,10 @@ server s1 { } -start varnish v1 \ - -arg "-smalloc,1m" \ - -arg "-smalloc,1m" \ - -arg "-smalloc,1m" \ + -arg "-sdefault,1m" \ + -arg "-sdefault,1m" \ + -arg "-sdefault,1m" \ + -arg "-sTransient=default" \ -vcl+backend { sub vcl_backend_response { set beresp.storage = storage.s0; diff --git a/bin/varnishtest/tests/c00073.vtc b/bin/varnishtest/tests/c00073.vtc index 78cfabb..812ac98 100644 --- a/bin/varnishtest/tests/c00073.vtc +++ b/bin/varnishtest/tests/c00073.vtc @@ -14,7 +14,7 @@ server s1 { } -start varnish v1 \ - -arg "-s malloc,1m" -vcl+backend { } -start + -arg "-s default,1m" -vcl+backend { } -start client c1 { txreq diff --git a/bin/varnishtest/tests/c00075.vtc b/bin/varnishtest/tests/c00075.vtc index ab87fbc..6cafdde 100644 --- a/bin/varnishtest/tests/c00075.vtc +++ b/bin/varnishtest/tests/c00075.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 \ - -arg "-s malloc,1m" -vcl+backend { } -start + -arg "-s default,1m" -vcl+backend { } -start varnish v1 -cliok "debug.fragfetch 1024" diff --git a/bin/varnishtest/tests/c00078.vtc b/bin/varnishtest/tests/c00078.vtc index 613b971..b1fcc60 100644 --- a/bin/varnishtest/tests/c00078.vtc +++ b/bin/varnishtest/tests/c00078.vtc @@ -6,9 +6,9 @@ server s1 -repeat 6 { } -start varnish v1 \ - -arg "-ss1=malloc,1m" \ - -arg "-ss2=malloc,1m" \ - -arg "-ss0=malloc,1m" \ + -arg "-ss1=default,1m" \ + -arg "-ss2=default,1m" \ + -arg "-ss0=default,1m" \ -vcl+backend { import vtc; sub vcl_backend_response { diff --git a/bin/varnishtest/tests/c00084.vtc b/bin/varnishtest/tests/c00084.vtc index 6ec8dee..3a4c77c 100644 --- a/bin/varnishtest/tests/c00084.vtc +++ b/bin/varnishtest/tests/c00084.vtc @@ -1,6 +1,6 @@ varnishtest "legal symbol names" -varnish v1 -arg "-s my-store=malloc" -vcl { +varnish v1 -arg "-s my-store=default" -vcl { import directors; acl my-acl { "127.0.0.1"; } diff --git a/bin/varnishtest/tests/e00007.vtc b/bin/varnishtest/tests/e00007.vtc index 635f19e..015ffbb 100644 --- a/bin/varnishtest/tests/e00007.vtc +++ b/bin/varnishtest/tests/e00007.vtc @@ -31,7 +31,7 @@ server s1 { } } -start -varnish v1 -arg "-smalloc,2m" -vcl+backend { +varnish v1 -arg "-sdefault,2m" -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/g00002.vtc b/bin/varnishtest/tests/g00002.vtc index c440a23..30b05ad 100644 --- a/bin/varnishtest/tests/g00002.vtc +++ b/bin/varnishtest/tests/g00002.vtc @@ -12,7 +12,7 @@ server s1 { } -start varnish v1 \ - -arg "-smalloc,2m" \ + -arg "-sdefault,2m" \ -cliok "param.set http_gzip_support true" \ -cliok "param.set gzip_memlevel 1" \ -vcl+backend { diff --git a/bin/varnishtest/tests/r00776.vtc b/bin/varnishtest/tests/r00776.vtc index 530168d..59e5f65 100644 --- a/bin/varnishtest/tests/r00776.vtc +++ b/bin/varnishtest/tests/r00776.vtc @@ -9,7 +9,7 @@ server s1 { varnish v1 \ -arg "-p fetch_chunksize=4k" \ - -arg "-s malloc,1m" -vcl+backend { } -start + -arg "-s default,1m" -vcl+backend { } -start client c1 { txreq diff --git a/bin/varnishtest/tests/r01036.vtc b/bin/varnishtest/tests/r01036.vtc index 97c68e8..94a13ef 100644 --- a/bin/varnishtest/tests/r01036.vtc +++ b/bin/varnishtest/tests/r01036.vtc @@ -7,7 +7,7 @@ server s1 { txresp -bodylen 1572864 } -start -varnish v1 -arg "-smalloc,1M" -arg "-pgzip_level=0" -vcl+backend { +varnish v1 -arg "-sdefault,1M" -arg "-pgzip_level=0" -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; set beresp.do_gzip = true; diff --git a/bin/varnishtest/tests/r01037.vtc b/bin/varnishtest/tests/r01037.vtc index 6bf8a3c..066d1e2 100644 --- a/bin/varnishtest/tests/r01037.vtc +++ b/bin/varnishtest/tests/r01037.vtc @@ -14,7 +14,7 @@ server s1 { chunkedlen 0 } -start -varnish v1 -arg "-smalloc,1M" -arg "-pgzip_level=0" -vcl+backend { +varnish v1 -arg "-sdefault,1M" -arg "-pgzip_level=0" -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; set beresp.do_gzip = true; diff --git a/bin/varnishtest/tests/r01140.vtc b/bin/varnishtest/tests/r01140.vtc index 994107c..1c9bd49 100644 --- a/bin/varnishtest/tests/r01140.vtc +++ b/bin/varnishtest/tests/r01140.vtc @@ -19,7 +19,7 @@ server s1 { } -start varnish v1 -arg "-p nuke_limit=0 -p shortlived=0" \ - -arg "-smalloc,1m" -vcl+backend { + -arg "-sdefault,1m" -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; # Unset Date header to not change the object sizes diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc index 72661d9..5b7a748 100644 --- a/bin/varnishtest/tests/r01175.vtc +++ b/bin/varnishtest/tests/r01175.vtc @@ -1,11 +1,11 @@ -varnishtest "#1175 - -smalloc c_fail incremented by allocations, not bytes" +varnishtest "#1175 - -sdefault c_fail incremented by allocations, not bytes" server s1 { rxreq txresp -nolen -hdr "Content-Length: 1048576" } -start -varnish v1 -arg "-s test=malloc,1M" -vcl+backend { +varnish v1 -arg "-s test=default,1M" -vcl+backend { sub vcl_backend_response { set beresp.storage = storage.test; set beresp.do_stream = false; diff --git a/bin/varnishtest/tests/r01176.vtc b/bin/varnishtest/tests/r01176.vtc index 0af3a5f..0e4df2f 100644 --- a/bin/varnishtest/tests/r01176.vtc +++ b/bin/varnishtest/tests/r01176.vtc @@ -1,11 +1,11 @@ -varnishtest "-s Transient=malloc crash" +varnishtest "-s Transient=default crash" server s1 { rxreq txresp } -start -varnish v1 -arg "-s Transient=malloc" -vcl+backend {} -start +varnish v1 -arg "-s Transient=default" -vcl+backend {} -start client c1 { txreq diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index f4d5efb..5612acb 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -11,7 +11,7 @@ server s1 { varnish v1 \ -arg "-p nuke_limit=0" \ - -arg "-sTransient=malloc,1m" \ + -arg "-sTransient=default,1m" \ -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; diff --git a/bin/varnishtest/tests/r01637.vtc b/bin/varnishtest/tests/r01637.vtc index 1c7489c..ee0093b 100644 --- a/bin/varnishtest/tests/r01637.vtc +++ b/bin/varnishtest/tests/r01637.vtc @@ -23,7 +23,7 @@ server s1 { txresp -bodylen 9000 } -start -varnish v1 -arg "-smalloc,1M" -arg "-p nuke_limit=0 -p gzip_level=0" \ +varnish v1 -arg "-sdefault,1M" -arg "-p nuke_limit=0 -p gzip_level=0" \ -vcl+backend { sub vcl_backend_response { if (bereq.url == "/url5") { diff --git a/bin/varnishtest/tests/r01764.vtc b/bin/varnishtest/tests/r01764.vtc index e5b8211..9f4e4cf 100644 --- a/bin/varnishtest/tests/r01764.vtc +++ b/bin/varnishtest/tests/r01764.vtc @@ -24,7 +24,7 @@ server s1 { txresp -bodylen 1000000 } -start -varnish v1 -arg "-smalloc,1M" -arg "-p nuke_limit=1" -vcl+backend { +varnish v1 -arg "-sdefault,1M" -arg "-p nuke_limit=1" -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; } diff --git a/bin/varnishtest/tests/r01821.vtc b/bin/varnishtest/tests/r01821.vtc index 3c7c02c..af6e934 100644 --- a/bin/varnishtest/tests/r01821.vtc +++ b/bin/varnishtest/tests/r01821.vtc @@ -5,7 +5,7 @@ server s1 -repeat 2 { txresp -bodylen 65535 } -start -varnish v1 -vcl+backend { +varnish v1 -arg "-s Transient=default" -vcl+backend { sub vcl_backend_response { set beresp.uncacheable = true; } diff --git a/bin/varnishtest/tests/r01914.vtc b/bin/varnishtest/tests/r01914.vtc index b6a9269..d7f1b20 100644 --- a/bin/varnishtest/tests/r01914.vtc +++ b/bin/varnishtest/tests/r01914.vtc @@ -9,7 +9,11 @@ server s1 { txresp } -start -varnish v1 -arg "-s malloc,1MB" -arg "-s malloc,1MB" -vcl+backend { +varnish v1 \ + -arg "-s default,1MB" \ + -arg "-s default,1MB" \ + -arg "-s Transient=default" \ + -vcl+backend { import std; sub vcl_recv { if (req.url == "/1") { diff --git a/bin/varnishtest/tests/r01941.vtc b/bin/varnishtest/tests/r01941.vtc index 188125c..79f21c9 100644 --- a/bin/varnishtest/tests/r01941.vtc +++ b/bin/varnishtest/tests/r01941.vtc @@ -24,7 +24,7 @@ server s1 { } -start varnish v1 -arg "-pfetch_chunksize=4k" \ - -arg "-smalloc,1m" -vcl+backend { + -arg "-sdefault,1m" -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/r02321.vtc b/bin/varnishtest/tests/r02321.vtc index 33c7658..1596456 100644 --- a/bin/varnishtest/tests/r02321.vtc +++ b/bin/varnishtest/tests/r02321.vtc @@ -1,19 +1,19 @@ varnishtest "Storage name collisions" # intentional collision -shell -err -expect "Error: (-s main=malloc,100m) 'main' is already defined" { +shell -err -expect "Error: (-s main=default,100m) 'main' is already defined" { exec varnishd -a :0 -f '' -n ${tmpdir} \ - -s main=malloc,10m -s main=malloc,100m + -s main=default,10m -s main=default,100m } # pseudo-accidental collision -shell -err -expect "Error: (-s s0=malloc,100m) 's0' is already defined" { +shell -err -expect "Error: (-s s0=default,100m) 's0' is already defined" { exec varnishd -a :0 -f '' -n ${tmpdir} \ - -s malloc,10m -s s0=malloc,100m + -s default,10m -s s0=default,100m } # Transient collision -shell -err -expect "Error: (-s Transient=malloc,100m) 'Transient' is already defined" { +shell -err -expect "Error: (-s Transient=default,100m) 'Transient' is already defined" { exec varnishd -a :0 -f '' -n ${tmpdir} \ - -s Transient=malloc,10m -s Transient=malloc,100m + -s Transient=default,10m -s Transient=default,100m } diff --git a/bin/varnishtest/tests/r02325.vtc b/bin/varnishtest/tests/r02325.vtc index 7b357e5..fab645a 100644 --- a/bin/varnishtest/tests/r02325.vtc +++ b/bin/varnishtest/tests/r02325.vtc @@ -1,7 +1,7 @@ varnishtest "validate storage identifiers" shell -err -expect {Error: invalid -s name "///"=[...]} { - varnishd -a :0 -n ${tmpdir} -F -f '' -s ///=malloc + varnishd -a :0 -n ${tmpdir} -F -f '' -s ///=default } shell -err -expect {Error: Empty named -s argument "foo="} { varnishd -a :0 -n ${tmpdir} -F -f '' -s foo= diff --git a/bin/varnishtest/tests/r02406.vtc b/bin/varnishtest/tests/r02406.vtc index 05ad838..68068db 100644 --- a/bin/varnishtest/tests/r02406.vtc +++ b/bin/varnishtest/tests/r02406.vtc @@ -1,6 +1,6 @@ varnishtest "Long backend and storage names" -varnish v1 -arg "-s acme_example_com_static_assets_malloc_storage=malloc" +varnish v1 -arg "-s acme_example_com_static_assets_default_storage=default" varnish v1 -vcl { backend be_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789 { @@ -8,5 +8,5 @@ varnish v1 -vcl { } } -start -varnish v1 -expect SM?.acme_example_com_static_assets_malloc_storage.c_req == 0 +varnish v1 -expect SM?.acme_example_com_static_assets_default_storage.c_req == 0 varnish v1 -expect VBE.vcl1.be_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789.req == 0 diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc index d6b1996..71fa666 100644 --- a/bin/varnishtest/tests/v00010.vtc +++ b/bin/varnishtest/tests/v00010.vtc @@ -24,7 +24,7 @@ server s1 { txresp -hdr "Foo: foo" -body "abcdef\n" } -start -varnish v1 -arg "-smalloc,1m" -vcl+backend { +varnish v1 -arg "-sdefault,1m" -vcl+backend { import vtc; sub vcl_backend_response { diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 195a33b..7c31eea 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -273,10 +273,20 @@ Storage Backend The following storage types are available: +-s + + The default storage type resolves to umem where available and malloc + otherwise. + -s malloc is a memory based backend. +-s + + umem is a storage backend which is more efficient than malloc on + platforms where it is available. + -s The file backend stores data in a file on disk. The file will be diff --git a/doc/sphinx/tutorial/putting_varnish_on_port_80.rst b/doc/sphinx/tutorial/putting_varnish_on_port_80.rst index 16d38bc..b1c254b 100644 --- a/doc/sphinx/tutorial/putting_varnish_on_port_80.rst +++ b/doc/sphinx/tutorial/putting_varnish_on_port_80.rst @@ -19,7 +19,7 @@ some text that looks like this:: -T localhost:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ - -s malloc,256m" + -s default,256m" Change it to:: @@ -27,7 +27,7 @@ Change it to:: -T localhost:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ - -s malloc,256m" + -s default,256m" Debian (v8+) / Ubuntu (v15.04+) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -40,7 +40,7 @@ Applying changes to the default service is best done by creating a new file [Service] ExecStart= - ExecStart=/usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m + ExecStart=/usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s default,256m This will override the ExecStart part of the default configuration shipped with Varnish Cache. diff --git a/doc/sphinx/users-guide/command-line.rst b/doc/sphinx/users-guide/command-line.rst index ad04c02..3356ea4 100644 --- a/doc/sphinx/users-guide/command-line.rst +++ b/doc/sphinx/users-guide/command-line.rst @@ -74,9 +74,9 @@ Other options Varnish comes with an abundance of useful command line arguments. We recommend that you study them but not necessary use them all, but to get started, the above will be sufficient. -By default Varnish will use 100 megabytes of malloc(3) storage -for caching objects, if you want to cache more than that, you -should look at the '-s' argument. +By default Varnish will use 100 megabytes of virtual memory (malloc(3) +or libumem(3lib)) storage for caching objects, if you want to cache +more than that, you should look at the '-s' argument. .. XXX: 3? benc diff --git a/doc/sphinx/users-guide/storage-backends.rst b/doc/sphinx/users-guide/storage-backends.rst index 1f04269..a631106 100644 --- a/doc/sphinx/users-guide/storage-backends.rst +++ b/doc/sphinx/users-guide/storage-backends.rst @@ -13,6 +13,14 @@ configuration is to use the malloc backend with a limited size. For a serious Varnish deployment you probably would want to adjust the storage settings. +default +~~~~~~~ + +syntax: default[,size] + +The default storage backend is an alias to umem, where available, or +malloc otherwise. + malloc ~~~~~~ @@ -45,6 +53,24 @@ malloc's performance is bound to memory speed so it is very fast. If the dataset is bigger than available memory performance will depend on the operating systems ability to page effectively. +umem +~~~~ + +syntax: umem[,size] + +Umem is a better alternative to the malloc backend where `libumem`_ is +available. All other configuration aspects are considered equal to +malloc. + +`libumem`_ implements a slab allocator similar to the kernel memory +allocator used in virtually all modern operating systems and is +considered more efficient and scalable than classical +implementations. In particular, `libumem`_ is included in the family +of OpenSolaris descendent operating systems where jemalloc(3) is not +commonly available. + +.. _libumem: http://dtrace.org/blogs/ahl/2004/07/13/number-11-of-20-libumem/ + file ~~~~ From nils.goroll at uplex.de Thu Sep 28 10:43:04 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Sep 2017 10:43:04 +0000 (UTC) Subject: [master] de30689 missed to reflect an include change Message-ID: <20170928104304.9C28C62157@lists.varnish-cache.org> commit de30689ea6620b3b5f6c4b59829b0ec6ece5f335 Author: Nils Goroll Date: Thu Sep 28 12:41:05 2017 +0200 missed to reflect an include change diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c index 54d5c08..bb4ccdb 100644 --- a/bin/varnishd/storage/storage_umem.c +++ b/bin/varnishd/storage/storage_umem.c @@ -35,7 +35,7 @@ #if defined(HAVE_LIBUMEM) -#include "cache/cache.h" +#include "cache/cache_varnishd.h" #include #include From dridi.boukelmoune at gmail.com Thu Sep 28 11:48:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 28 Sep 2017 11:48:04 +0000 (UTC) Subject: [master] 908de35 Collateral typo Message-ID: <20170928114804.96C706211C@lists.varnish-cache.org> commit 908de3585752a710e9ffe213407b4bd0dfcd3f82 Author: Dridi Boukelmoune Date: Thu Sep 28 13:46:52 2017 +0200 Collateral typo diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index 7689838..3d7c2d0 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -92,7 +92,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) static h2_error h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) { - /* XXX: This might belong in cache/cache_varnishd.http.c */ + /* XXX: This might belong in cache/cache_http.c */ unsigned n; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);