Mailing List Archive

r1533 - trunk/varnish-cache/bin/varnishd
Author: des
Date: 2007-06-18 09:52:19 +0200 (Mon, 18 Jun 2007)
New Revision: 1533

Modified:
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/bin/varnishd/stevedore.h
trunk/varnish-cache/bin/varnishd/storage_file.c
trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Since the previous commit added a chdir() to our temp directory, we can stop
juggling file names and simply do everything relative to our cwd.


Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-06-18 07:31:50 UTC (rev 1532)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-06-18 07:52:19 UTC (rev 1533)
@@ -140,13 +140,13 @@
mgt_CallCc(const char *source, struct vsb *sb)
{
FILE *fo, *fs;
- char *of, *sf, buf[BUFSIZ];
- int i, j, sfd;
+ char sf[] = "./vcl.XXXXXXXX";
+ char *of;
+ char buf[BUFSIZ];
+ int i, j, len, sfd;
void *p;

/* Create temporary C source file */
- asprintf(&sf, "/tmp/%s/vcl.XXXXXXXX", params->name);
- assert(sf != NULL);
sfd = mkstemp(sf);
if (sfd < 0) {
vsb_printf(sb,
@@ -156,7 +156,7 @@
return (NULL);
}
fs = fdopen(sfd, "r+");
- assert(fs != NULL);
+ AN(fs);

if (fputs(source, fs) < 0 || fflush(fs)) {
vsb_printf(sb,
@@ -169,16 +169,16 @@
rewind(fs);

/* Name the output shared library */
- asprintf(&of, "/tmp/%s/vcl.XXXXXXXX", params->name);
- assert(of != NULL);
- of = mktemp(of);
- assert(of != NULL);
+ of = strdup(sf);
+ AN(of);
+ memcpy(of, "./bin", 5);

/* Attempt to open a pipe to the system C-compiler */
- sprintf(buf,
- "ln -f %s /tmp/%s/_.c ;" /* XXX: for debugging */
+ len = snprintf(buf, sizeof buf,
+ "ln -f %s _.c ;" /* XXX: for debugging */
"exec cc -fpic -shared -Wl,-x -o %s -x c - < %s 2>&1",
- sf, params->name, of, sf);
+ sf, of, sf);
+ xxxassert(len < sizeof buf);

fo = popen(buf, "r");
if (fo == NULL) {
@@ -201,7 +201,7 @@
j++;
}
vsb_cat(sb, buf);
- }
+ }

i = pclose(fo);
if (j == 0 && i != 0)
@@ -228,7 +228,6 @@

/* clean up and return */
unlink(sf);
- free(sf);
fclose(fs);
return (of);
}

Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h 2007-06-18 07:31:50 UTC (rev 1532)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h 2007-06-18 07:52:19 UTC (rev 1533)
@@ -33,7 +33,7 @@
struct sess;
struct iovec;

-typedef void storage_init_f(struct stevedore *, const char *spec, const char *name);
+typedef void storage_init_f(struct stevedore *, const char *spec);
typedef void storage_open_f(struct stevedore *);
typedef struct storage *storage_alloc_f(struct stevedore *, size_t size);
typedef void storage_trim_f(struct storage *, size_t size);

Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c 2007-06-18 07:31:50 UTC (rev 1532)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c 2007-06-18 07:52:19 UTC (rev 1533)
@@ -242,7 +242,7 @@
}

static void
-smf_init(struct stevedore *parent, const char *spec, const char *varnish_name)
+smf_init(struct stevedore *parent, const char *spec)
{
char *size;
char *p, *q;
@@ -262,7 +262,7 @@

/* If no size specified, use 50% of filesystem free space */
if (spec == NULL || *spec == '\0')
- asprintf(&p, "/tmp/%s,50%%", varnish_name);
+ asprintf(&p, ".,50%%");
else if (strchr(spec, ',') == NULL)
asprintf(&p, "%s,", spec);
else

Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2007-06-18 07:31:50 UTC (rev 1532)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2007-06-18 07:52:19 UTC (rev 1533)
@@ -150,7 +150,7 @@
heritage.stevedore = malloc(sizeof *heritage.stevedore);
*heritage.stevedore = *stp;
if (stp->init != NULL)
- stp->init(heritage.stevedore, q, params->name);
+ stp->init(heritage.stevedore, q);
}

/*--------------------------------------------------------------------*/
@@ -410,7 +410,6 @@
char *p;
struct cli cli[1];
struct pidfh *pfh = NULL;
- char buf[BUFSIZ];

setbuf(stdout, NULL);
setbuf(stderr, NULL);
@@ -524,8 +523,7 @@
setup_storage(s_arg);
setup_hash(h_arg);

- sprintf(buf, "/tmp/%s/%s", params->name, SHMLOG_FILENAME);
- VSL_MgtInit(buf, 8*1024*1024);
+ VSL_MgtInit(SHMLOG_FILENAME, 8*1024*1024);

if (d_flag == 1)
DebugStunt();