From: phk Date: Mon, 7 Aug 2006 16:15:00 +0000 (+0000) Subject: Handle CLI trouble with the childproc X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76ad3b35cca9b725affe8e3fc55cec81524c1462;p=varnish Handle CLI trouble with the childproc git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@730 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/mgt_cli.c b/varnish-cache/bin/varnishd/mgt_cli.c index aac03ae3..a605e334 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.c +++ b/varnish-cache/bin/varnishd/mgt_cli.c @@ -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);