r3683 - branches/2.0/varnish-cache/lib/libvarnish

tfheen at projects.linpro.no tfheen at projects.linpro.no
Fri Feb 6 15:46:21 CET 2009


Author: tfheen
Date: 2009-02-06 15:46:21 +0100 (Fri, 06 Feb 2009)
New Revision: 3683

Modified:
   branches/2.0/varnish-cache/lib/libvarnish/cli_common.c
Log:
Merge r3494: Set the status to CLIS_COMMS if we fal to read the body.



Modified: branches/2.0/varnish-cache/lib/libvarnish/cli_common.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvarnish/cli_common.c	2009-02-06 14:41:34 UTC (rev 3682)
+++ branches/2.0/varnish-cache/lib/libvarnish/cli_common.c	2009-02-06 14:46:21 UTC (rev 3683)
@@ -123,7 +123,7 @@
 	if (cli != NULL)
 		cli->result = res;	/*lint !e64 type mismatch */
 	else
-		printf("CLI result = %d\n", res);
+		printf("CLI result = %u\n", res);
 }
 
 void
@@ -192,15 +192,16 @@
 {
 	char res[CLI_LINE0_LEN];	/* For NUL */
 	int i, j;
-	unsigned u, v;
+	unsigned u, v, s;
 	char *p;
 
+	if (status == NULL)
+		status = &s;
 	if (ptr != NULL)
 		*ptr = NULL;
 	i = read_tmo(fd, res, CLI_LINE0_LEN, tmo);
 	if (i != CLI_LINE0_LEN) {
-		if (status != NULL)
-			*status = CLIS_COMMS;
+		*status = CLIS_COMMS;
 		if (ptr != NULL)
 			*ptr = strdup("CLI communication error");
 		return (1);
@@ -211,12 +212,12 @@
 	res[CLI_LINE0_LEN - 1] = '\0';
 	j = sscanf(res, "%u %u\n", &u, &v);
 	assert(j == 2);
-	if (status != NULL)
-		*status = u;
+	*status = u;
 	p = malloc(v + 1);
 	assert(p != NULL);
 	i = read_tmo(fd, p, v + 1, tmo);
 	if (i < 0) {
+		*status = CLIS_COMMS;
 		free(p);
 		return (i);
 	}



More information about the varnish-commit mailing list