[master] 3a56dbd Also correctly initialize subsequent references to vmods.

Poul-Henning Kamp phk at varnish-cache.org
Mon Mar 28 10:10:59 CEST 2011


commit 3a56dbdd70cfddfe4e497b0ff94e4c094c8f64f1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 28 08:10:12 2011 +0000

    Also correctly initialize subsequent references to vmods.
    
    Fixes:	878
    
    Solved by:	tmagnien

diff --git a/bin/varnishd/cache_vrt_vmod.c b/bin/varnishd/cache_vrt_vmod.c
index 0c74e02..77e37e7 100644
--- a/bin/varnishd/cache_vrt_vmod.c
+++ b/bin/varnishd/cache_vrt_vmod.c
@@ -90,19 +90,20 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, const char *path)
 
 		x = dlsym(v->hdl, "Vmod_Name");
 		AN(x);
+		/* XXX: check that name is correct */
 
 		x = dlsym(v->hdl, "Vmod_Len");
 		AN(x);
 		i = x;
-		assert(len == *i);
+		v->funclen = *i;
 
 		x = dlsym(v->hdl, "Vmod_Func");
 		AN(x);
-		memcpy(ptr, x, len);
-
 		v->funcs = x;
-		v->funclen = *i;
 	}
+
+	assert(len == v->funclen);
+	memcpy(ptr, v->funcs, v->funclen);
 	v->ref++;
 
 	*hdl = v;
diff --git a/bin/varnishtest/tests/r00878.vtc b/bin/varnishtest/tests/r00878.vtc
new file mode 100644
index 0000000..c57e511
--- /dev/null
+++ b/bin/varnishtest/tests/r00878.vtc
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+test "Loading vmods in subsequent VCLs"
+
+server s1 {
+	rxreq 
+	txresp -bodylen 4
+} -start
+
+varnish v1 -vcl+backend {
+        import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ;
+	sub vcl_deliver {
+		set resp.http.who = std.author(phk);
+	}
+} -start
+
+
+client c1 {
+	txreq
+	rxresp
+} -run
+varnish v1 -vcl+backend {
+        import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ;
+	sub vcl_deliver {
+		set resp.http.who = std.author(des);
+	}
+}
+
+client c1 {
+	txreq
+	rxresp
+} -run
+
+varnish v1 -vcl+backend {
+        import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ;
+	sub vcl_deliver {
+		set resp.http.who = std.author(kristian);
+	}
+}
+
+client c1 {
+	txreq
+	rxresp
+} -run



More information about the varnish-commit mailing list