Commit b879d12a authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

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.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1533 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent bafc9878
......@@ -140,13 +140,13 @@ static char *
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 @@ mgt_CallCc(const char *source, struct vsb *sb)
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 @@ mgt_CallCc(const char *source, struct vsb *sb)
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 @@ mgt_CallCc(const char *source, struct vsb *sb)
j++;
}
vsb_cat(sb, buf);
}
}
i = pclose(fo);
if (j == 0 && i != 0)
......@@ -228,7 +228,6 @@ mgt_CallCc(const char *source, struct vsb *sb)
/* clean up and return */
unlink(sf);
free(sf);
fclose(fs);
return (of);
}
......
......@@ -33,7 +33,7 @@ struct stevedore;
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);
......
......@@ -242,7 +242,7 @@ smf_initfile(struct smf_sc *sc, const char *size, int newfile)
}
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 @@ smf_init(struct stevedore *parent, const char *spec, const char *varnish_name)
/* 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
......
......@@ -150,7 +150,7 @@ setup_storage(const char *s_arg)
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 @@ main(int argc, char *argv[])
char *p;
struct cli cli[1];
struct pidfh *pfh = NULL;
char buf[BUFSIZ];
setbuf(stdout, NULL);
setbuf(stderr, NULL);
......@@ -524,8 +523,7 @@ main(int argc, char *argv[])
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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment