]> err.no Git - varnish/commitdiff
Handle CLI trouble with the childproc
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 7 Aug 2006 16:15:00 +0000 (16:15 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 7 Aug 2006 16:15:00 +0000 (16:15 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@730 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/mgt_cli.c

index aac03ae39ed5f5b3814811b34b2d386868ecf04d..a605e3346b0f4cf6aaa5ac7a36039ded93c9444a 100644 (file)
@@ -86,7 +86,6 @@ mcf_passthru(struct cli *cli, char **av, void *priv)
        free(p);
 
        i = cli_readres(cli_i, &u, &p, 3.0);
-       assert(i == 0);
        cli_result(cli, u);
        cli_out(cli, "%s", p);
        free(p);
@@ -174,7 +173,7 @@ int
 mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...)
 {
        char *p;
-       int i;
+       int i, j;
        va_list ap;
        unsigned u;
 
@@ -186,9 +185,16 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...)
        if (i < 0)
                return (i);
        assert(p[i - 1] == '\n');
-       i = write(cli_o, p, strlen(p));
-       assert(i == strlen(p));
+       j = write(cli_o, p, i);
        free(p);
+       if (j != i) {
+               free(p);
+               if (status != NULL)
+                       *status = CLIS_COMMS;
+               if (resp != NULL)
+                       *resp = strdup("CLI communication error");
+               return (CLIS_COMMS);
+       }
 
        i = cli_readres(cli_i, &u, resp, 3.0);
        assert(i == 0);