Commit 59d551be authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r3494: Set the status to CLIS_COMMS if we fal to read the body.



git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@3683 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent edc37229
...@@ -123,7 +123,7 @@ cli_result(struct cli *cli, unsigned res) ...@@ -123,7 +123,7 @@ cli_result(struct cli *cli, unsigned res)
if (cli != NULL) if (cli != NULL)
cli->result = res; /*lint !e64 type mismatch */ cli->result = res; /*lint !e64 type mismatch */
else else
printf("CLI result = %d\n", res); printf("CLI result = %u\n", res);
} }
void void
...@@ -192,15 +192,16 @@ cli_readres(int fd, unsigned *status, char **ptr, double tmo) ...@@ -192,15 +192,16 @@ cli_readres(int fd, unsigned *status, char **ptr, double tmo)
{ {
char res[CLI_LINE0_LEN]; /* For NUL */ char res[CLI_LINE0_LEN]; /* For NUL */
int i, j; int i, j;
unsigned u, v; unsigned u, v, s;
char *p; char *p;
if (status == NULL)
status = &s;
if (ptr != NULL) if (ptr != NULL)
*ptr = NULL; *ptr = NULL;
i = read_tmo(fd, res, CLI_LINE0_LEN, tmo); i = read_tmo(fd, res, CLI_LINE0_LEN, tmo);
if (i != CLI_LINE0_LEN) { if (i != CLI_LINE0_LEN) {
if (status != NULL) *status = CLIS_COMMS;
*status = CLIS_COMMS;
if (ptr != NULL) if (ptr != NULL)
*ptr = strdup("CLI communication error"); *ptr = strdup("CLI communication error");
return (1); return (1);
...@@ -211,12 +212,12 @@ cli_readres(int fd, unsigned *status, char **ptr, double tmo) ...@@ -211,12 +212,12 @@ cli_readres(int fd, unsigned *status, char **ptr, double tmo)
res[CLI_LINE0_LEN - 1] = '\0'; res[CLI_LINE0_LEN - 1] = '\0';
j = sscanf(res, "%u %u\n", &u, &v); j = sscanf(res, "%u %u\n", &u, &v);
assert(j == 2); assert(j == 2);
if (status != NULL) *status = u;
*status = u;
p = malloc(v + 1); p = malloc(v + 1);
assert(p != NULL); assert(p != NULL);
i = read_tmo(fd, p, v + 1, tmo); i = read_tmo(fd, p, v + 1, tmo);
if (i < 0) { if (i < 0) {
*status = CLIS_COMMS;
free(p); free(p);
return (i); return (i);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment