]> err.no Git - varnish/commitdiff
Make the compile shared object be named $mumble.so to cater for
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 11 Aug 2008 15:08:38 +0000 (15:08 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 11 Aug 2008 15:08:38 +0000 (15:08 +0000)
Solaris tool-chains.

Simplified slightly from submitted patch.

Submitted by: Theo Schlossnagle

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3081 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/mgt_vcc.c

index 47abf1250fa7e39e202f4938fd1e653c1708a06b..1b85f2cb208d44279e661d2cc1edf0cb5221a880 100644 (file)
@@ -141,7 +141,8 @@ mgt_run_cc(const char *source, struct vsb *sb)
        char cmdline[1024];
        struct vsb cmdsb;
        char sf[] = "./vcl.########.c";
-       char *of;
+       char of[sizeof sf + 1];
+       char *retval;
        int p[2], sfd, srclen, status;
        pid_t pid;
        void *dlh;
@@ -167,10 +168,11 @@ mgt_run_cc(const char *source, struct vsb *sb)
        AZ(close(sfd));
 
        /* Name the output shared library by overwriting the final 'c' */
-       of = strdup(sf);
-       XXXAN(of);
-       assert(of[sizeof sf - 2] == 'c');
-       of[sizeof sf - 2] = 'o';
+       memcpy(of, sf, sizeof sf);
+       assert(sf[sizeof sf - 2] == 'c');
+       of[sizeof sf - 2] = 's';
+       of[sizeof sf - 1] = 'o';
+       of[sizeof sf] = '\0';
        AN(vsb_new(&cmdsb, cmdline, sizeof cmdline, 0));
        mgt_make_cc_cmd(&cmdsb, sf, of);
        vsb_finish(&cmdsb);
@@ -181,7 +183,6 @@ mgt_run_cc(const char *source, struct vsb *sb)
                vsb_printf(sb, "%s(): pipe() failed: %s",
                    __func__, strerror(errno));
                (void)unlink(sf);
-               free(of);
                return (NULL);
        }
        assert(p[0] > STDERR_FILENO);
@@ -192,7 +193,6 @@ mgt_run_cc(const char *source, struct vsb *sb)
                AZ(close(p[0]));
                AZ(close(p[1]));
                (void)unlink(sf);
-               free(of);
                return (NULL);
        }
        if (pid == 0) {
@@ -217,7 +217,6 @@ mgt_run_cc(const char *source, struct vsb *sb)
                vsb_printf(sb, "%s(): waitpid() failed: %s",
                    __func__, strerror(errno));
                (void)unlink(of);
-               free(of);
                return (NULL);
        }
        if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
@@ -229,7 +228,6 @@ mgt_run_cc(const char *source, struct vsb *sb)
                if (WCOREDUMP(status))
                        vsb_printf(sb, ", core dumped");
                (void)unlink(of);
-               free(of);
                return (NULL);
        }
 
@@ -239,7 +237,6 @@ mgt_run_cc(const char *source, struct vsb *sb)
                    "%s(): failed to load compiled VCL program:\n  %s",
                    __func__, dlerror());
                (void)unlink(of);
-               free(of);
                return (NULL);
        }
 
@@ -249,7 +246,9 @@ mgt_run_cc(const char *source, struct vsb *sb)
         */
 
        AZ(dlclose(dlh));
-       return (of);
+       retval = strdup(of);
+       XXXAN(retval);
+       return (retval);
 }
 
 /*--------------------------------------------------------------------*/