r621 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Aug 3 13:45:23 CEST 2006


Author: phk
Date: 2006-08-03 13:45:23 +0200 (Thu, 03 Aug 2006)
New Revision: 621

Modified:
   trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Make the pipe-stunt debug process smarter.


Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c	2006-08-03 10:37:22 UTC (rev 620)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c	2006-08-03 11:45:23 UTC (rev 621)
@@ -556,6 +556,7 @@
 	pfd[1].fd = pipes[1][0];
 	pfd[1].events = POLLIN;
 
+	signal(SIGPIPE, SIG_IGN);
 	signal(SIGINT, DebugSigPass);
 	i = read(pipes[1][0], buf, sizeof buf - 1);
 	buf[i] = '\0';
@@ -569,15 +570,17 @@
 	while (1) {
 		i = poll(pfd, 2, INFTIM);
 		for (k = 0; k < 2; k++) {
-			if (pfd[k].revents) {
-				j = read(pipes[k][0], buf, sizeof buf);
-				if (j == 0)
-					exit (0);
-				if (j > 0) {
-					i = write(pipes[k][1], buf, j);
-					if (i != j)
-						err(1, "i = %d j = %d\n", i, j);
-				}
+			if (pfd[k].revents == 0)
+				continue;
+			if (pfd[k].revents != POLLIN)
+				exit (2);
+			j = read(pipes[k][0], buf, sizeof buf);
+			if (j == 0)
+				exit (0);
+			if (j > 0) {
+				i = write(pipes[k][1], buf, j);
+				if (i != j)
+					err(1, "i = %d j = %d\n", i, j);
 			}
 		}
 	}




More information about the varnish-commit mailing list