[master] 30e9021 VMOD blob: rename subblob() as sub().
Geoff Simmons
geoff at uplex.de
Mon Sep 11 23:02:03 UTC 2017
commit 30e90214e162a7749c1b7a43dea2468ee8082e98
Author: Geoff Simmons <geoff at uplex.de>
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;
}
More information about the varnish-commit
mailing list