]> err.no Git - varnish/commitdiff
Since the previous commit added a chdir() to our temp directory, we can stop
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 18 Jun 2007 07:52:19 +0000 (07:52 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 18 Jun 2007 07:52:19 +0000 (07:52 +0000)
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

varnish-cache/bin/varnishd/mgt_vcc.c
varnish-cache/bin/varnishd/stevedore.h
varnish-cache/bin/varnishd/storage_file.c
varnish-cache/bin/varnishd/varnishd.c

index e8e288e6766deaa4e56d62bbc1e2fa0699b2d729..08e99af4f15fddc851ba837ba59a501118556381 100644 (file)
@@ -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);
 }
index 8a96d5e8a9f8575707aef60d192561938ab1a4a9..3267aa101a2d6f4525f8e84049e5f54eebd836f3 100644 (file)
@@ -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);
index 57baf0a1fa4a76b3f7705aa6fb1bb752d13fa9de..b531fc043c52663d92461dfe3a7a97ab9a6b9a57 100644 (file)
@@ -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
index 923fde26e01cc2e80512b7695603d52fa9b53fa2..27294e99f287596a78be283f0b4e20c5f620abac 100644 (file)
@@ -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();