From: des Date: Mon, 18 Jun 2007 07:52:19 +0000 (+0000) Subject: Since the previous commit added a chdir() to our temp directory, we can stop X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62d093983c3f2667b16736f90c7aa189a5dfb4a3;p=varnish 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: svn+ssh://projects.linpro.no/svn/varnish/trunk@1533 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/mgt_vcc.c b/varnish-cache/bin/varnishd/mgt_vcc.c index e8e288e6..08e99af4 100644 --- a/varnish-cache/bin/varnishd/mgt_vcc.c +++ b/varnish-cache/bin/varnishd/mgt_vcc.c @@ -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); } diff --git a/varnish-cache/bin/varnishd/stevedore.h b/varnish-cache/bin/varnishd/stevedore.h index 8a96d5e8..3267aa10 100644 --- a/varnish-cache/bin/varnishd/stevedore.h +++ b/varnish-cache/bin/varnishd/stevedore.h @@ -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); diff --git a/varnish-cache/bin/varnishd/storage_file.c b/varnish-cache/bin/varnishd/storage_file.c index 57baf0a1..b531fc04 100644 --- a/varnish-cache/bin/varnishd/storage_file.c +++ b/varnish-cache/bin/varnishd/storage_file.c @@ -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 diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index 923fde26..27294e99 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -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();