
martin at varnish-software
Jan 22, 2012, 9:53 AM
Post #1 of 1
(67 views)
Permalink
|
|
[PATCH 21/25] Add run-time parameter stream_pass_bufsize and VCL variable beresp.stream_pass_bufsize with test case
|
|
--- bin/varnishd/cache/cache.h | 1 + bin/varnishd/cache/cache_busyobj.c | 2 ++ bin/varnishd/cache/cache_vrt_var.c | 19 +++++++++++++++++++ bin/varnishd/common/params.h | 2 ++ bin/varnishd/mgt/mgt_param.c | 6 ++++++ bin/varnishtest/tests/t00009.vtc | 33 +++++++++++++++++++++++++++++++++ lib/libvcl/generate.py | 6 ++++++ 7 files changed, 69 insertions(+), 0 deletions(-) create mode 100644 bin/varnishtest/tests/t00009.vtc diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 880f5e3..fe65dbd 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -543,6 +543,7 @@ struct busyobj { ssize_t stream_max; struct storage *stream_frontchunk; unsigned stream_stopped; + ssize_t stream_pass_bufsize; }; /* Object structure --------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 6eec464..b39c170 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -144,6 +144,8 @@ VBO_GetBusyObj(struct worker *wrk) p += HTTP_estimate(vbo->nhttp); vbo->bo.beresp = HTTP_create(p, vbo->nhttp); + vbo->bo.stream_pass_bufsize = cache_param->stream_pass_bufsize; + return (&vbo->bo); } diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index e051dbb..e655abf 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -301,6 +301,25 @@ VRT_l_beresp_storage(struct sess *sp, const char *str, ...) sp->req->storage_hint = b; } +double +VRT_r_beresp_stream_pass_bufsize(const struct sess *sp) +{ + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); + return (sp->wrk->busyobj->stream_pass_bufsize); +} + +void +VRT_l_beresp_stream_pass_bufsize(const struct sess *sp, double val) +{ + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); + if (val >= 0.) + sp->wrk->busyobj->stream_pass_bufsize = val; + else + sp->wrk->busyobj->stream_pass_bufsize = 0; +} + /*--------------------------------------------------------------------*/ void diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index f726ce8..20b346a 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -100,6 +100,8 @@ struct params { ssize_t fetch_maxchunksize; ssize_t stream_maxchunksize; unsigned stream_grab_timeout; + ssize_t stream_pass_bufsize; + unsigned nuke_limit; #ifdef SENDFILE_WORKS diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 9b1467f..3a64b96 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -852,6 +852,12 @@ static const struct parspec input_parspec[] = { "grabbing a thread for background fetch.\n", EXPERIMENTAL, "100", "milliseconds" }, + { "stream_pass_bufsize", + tweak_bytes_u, &mgt_param.stream_pass_bufsize, 0, UINT_MAX, + "Default max amount of data to buffer when streaming passes. " + "Zero means unlimited.\n", + EXPERIMENTAL, + "10mb", "bytes" }, #ifdef SENDFILE_WORKS { "sendfile_threshold", tweak_bytes, &mgt_param.sendfile_threshold, 0, HUGE_VAL, diff --git a/bin/varnishtest/tests/t00009.vtc b/bin/varnishtest/tests/t00009.vtc new file mode 100644 index 0000000..834ba80 --- /dev/null +++ b/bin/varnishtest/tests/t00009.vtc @@ -0,0 +1,33 @@ +varnishtest "Test streaming vcl syntax" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p stream_pass_bufsize=1M" -vcl+backend { + sub vcl_fetch { + set beresp.do_stream = true; + set beresp.http.spb-orig = beresp.stream_pass_bufsize; + set beresp.stream_pass_bufsize = 1024B; + set beresp.stream_pass_bufsize = 1KB; + set beresp.stream_pass_bufsize = 10MB; + set beresp.stream_pass_bufsize = 1GB; + set beresp.stream_pass_bufsize = 0B - 1B; + set beresp.http.spb = beresp.stream_pass_bufsize; + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.spb-orig == "1048576.000" + expect resp.http.spb == "0.000" +} -run + +varnish v1 -badvcl { + backend default { .host = "127.0.0.1"; } + sub vcl_fetch { + set beresp.stream_pass_bufsize = 0; + } +} diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index b91f675..51b2294 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -331,6 +331,12 @@ sp_variables = ( ( 'fetch',), 'const struct sess *' ), + ('beresp.stream_pass_bufsize', + 'BYTES', + ( 'fetch',), + ( 'fetch',), + 'const struct sess *' + ), ('beresp.ttl', 'DURATION', ( 'fetch',), -- 1.7.4.1 _______________________________________________ varnish-dev mailing list varnish-dev [at] varnish-cache https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
|