[master] 3fe0d1d Get refcounting and testing thereoff correct in std.fileread()
Poul-Henning Kamp
phk at varnish-cache.org
Thu May 12 10:35:17 CEST 2011
commit 3fe0d1d96d9b0940b409c10aeaea95c13c9d243e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu May 12 08:34:57 2011 +0000
Get refcounting and testing thereoff correct in std.fileread()
diff --git a/bin/varnishtest/tests/m00004.vtc b/bin/varnishtest/tests/m00004.vtc
index 4aa4291..839d106 100644
--- a/bin/varnishtest/tests/m00004.vtc
+++ b/bin/varnishtest/tests/m00004.vtc
@@ -76,10 +76,7 @@ varnish v1 -cli "vcl.list"
varnish v1 -cli "vcl.discard vcl1"
varnish v1 -vcl+backend { }
-
-varnish v1 -cli "vcl.list"
-varnish v1 -cli "vcl.discard vcl2"
-
+varnish v1 -cli "vcl.use vcl3"
client c1 {
txreq -url "/one"
@@ -91,3 +88,8 @@ client c1 {
} -run
varnish v1 -cli "vcl.list"
+varnish v1 -cli "vcl.discard vcl2"
+
+client c1 -run
+
+varnish v1 -cli "vcl.list"
diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c
index 1890b76..f7654e2 100644
--- a/lib/libvmod_std/vmod_std_fileread.c
+++ b/lib/libvmod_std/vmod_std_fileread.c
@@ -37,12 +37,7 @@
* XXX: underlying file has been updated.
*/
-#include <fcntl.h>
-#include <pthread.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include "vrt.h"
#include "../../bin/varnishd/cache.h"
@@ -101,8 +96,11 @@ vmod_fileread(struct sess *sp, struct vmod_priv *priv, const char *file_name)
}
}
AZ(pthread_mutex_unlock(&frmtx));
- if (frf != NULL)
+ if (frf != NULL) {
+ priv->free = free_frfile;
+ priv->priv = frf;
return (frf->contents);
+ }
s = vreadfile(NULL, file_name, NULL);
if (s != NULL) {
More information about the varnish-commit
mailing list