[PATCH] Change hash_data() input type to BLOB

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Apr 20 07:50:16 CEST 2015


--------
In message <CAJV_h0ZYRsugxTZQiUj1h6STXApruXggU5uFhLF_1SNafgUw+g at mail.gmail.com>
, Federico Schwindt writes:

>I had some time in my recent flights so I decided to give it a shot.
>As discussed at VDD15Q1, this changes the hash_data input to BLOB and adds
>automatic conversion from STRING to BLOB.
>
>There are a few downsides with this approach:

Yes, that's been holding me from doing what you have done.

>A better alternative would be to teach vcc to issue two different calls
>depending on the input, e.g. for BLOBs it will use VRT_hashblob(), for
>anything else use VRT_hashstring(), so point 1 and 2 only affect users of
>hash_data(req.body).

That's by far my preference and it becomes non-messy if we insist that
you can never get vcc_Expr() to do anything with a BLOB, apart from
returning it to you.  That means that we will not do things like

	BLOB = BLOB + BLOB

but we can do stuff like:

	BLOB = std.blob_concat(BLOB, blob("Hello World"))

In practice we would need to pass a flag to vcc_Expr() saying "I want
a FOO but BLOB is also OK" and I have a hard time seeing FOO take
any other value than STRING/STRING_LIST.

(The clean solution is to turn enum var_type into a bitmap, if anybody
feels like it.)

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



More information about the varnish-dev mailing list