r1571 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Mon Jun 25 22:44:06 CEST 2007
Author: phk
Date: 2007-06-25 22:44:06 +0200 (Mon, 25 Jun 2007)
New Revision: 1571
Modified:
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/include/libvcl.h
trunk/varnish-cache/lib/libvcl/vcc_compile.c
Log:
Make it possible to pass a filedescriptor to VCC_CompileFile() if the file
is already open. The filedescriptor will be closed.
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-06-25 17:04:09 UTC (rev 1570)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-06-25 20:44:06 UTC (rev 1571)
@@ -258,7 +258,7 @@
{
char *csrc, *vf = NULL;
- csrc = VCC_CompileFile(sb, fn);
+ csrc = VCC_CompileFile(sb, fn, -1);
if (csrc != NULL) {
if (C_flag)
fputs(csrc, stdout);
Modified: trunk/varnish-cache/include/libvcl.h
===================================================================
--- trunk/varnish-cache/include/libvcl.h 2007-06-25 17:04:09 UTC (rev 1570)
+++ trunk/varnish-cache/include/libvcl.h 2007-06-25 20:44:06 UTC (rev 1571)
@@ -30,7 +30,7 @@
*/
char *VCC_Compile(struct vsb *sb, const char *b, const char *e);
-char *VCC_CompileFile(struct vsb *sb, const char *fn);
+char *VCC_CompileFile(struct vsb *sb, const char *fn, int fd);
void VCC_InitCompile(const char *default_vcl);
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-06-25 17:04:09 UTC (rev 1570)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-06-25 20:44:06 UTC (rev 1571)
@@ -377,17 +377,19 @@
/*--------------------------------------------------------------------*/
static struct source *
-vcc_file_source(struct vsb *sb, const char *fn)
+vcc_file_source(struct vsb *sb, const char *fn, int fd)
{
char *f;
- int fd, i;
+ int i;
struct stat st;
- fd = open(fn, O_RDONLY);
if (fd < 0) {
- vsb_printf(sb, "Cannot open file '%s': %s\n",
- fn, strerror(errno));
- return (NULL);
+ fd = open(fn, O_RDONLY);
+ if (fd < 0) {
+ vsb_printf(sb, "Cannot open file '%s': %s\n",
+ fn, strerror(errno));
+ return (NULL);
+ }
}
assert(0 == fstat(fd, &st));
f = malloc(st.st_size + 1);
@@ -429,7 +431,7 @@
}
assert(t2 != NULL);
- sp = vcc_file_source(tl->sb, t1->dec);
+ sp = vcc_file_source(tl->sb, t1->dec, -1);
if (sp == NULL) {
vcc_ErrWhere(tl, t1);
return;
@@ -653,12 +655,12 @@
*/
char *
-VCC_CompileFile(struct vsb *sb, const char *fn)
+VCC_CompileFile(struct vsb *sb, const char *fn, int fd)
{
struct source *sp;
char *r;
- sp = vcc_file_source(sb, fn);
+ sp = vcc_file_source(sb, fn, fd);
if (sp == NULL)
return (NULL);
r = vcc_CompileSource(sb, sp);
More information about the varnish-commit
mailing list