From 0b0013770df651550f1f7f195f3fc6189b873b78 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 5 Aug 2006 15:38:27 +0000 Subject: [PATCH] Polish the debugstunt and make it possible to avoid it. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@672 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/varnishd.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index f41e45a9..d6706e25 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -267,22 +267,31 @@ DebugStunt(void) assert(j == i); while (1) { + if (pfd[0].fd == -1 && pfd[1].fd == -1) + break; i = poll(pfd, 2, INFTIM); for (k = 0; k < 2; k++) { if (pfd[k].revents == 0) continue; - if (pfd[k].revents != POLLIN) - exit (2); + if (pfd[k].revents != POLLIN) { + printf("k %d rev %d\n", k, pfd[k].revents); + pfd[k].fd = -1; + } j = read(pipes[k][0], buf, sizeof buf); - if (j == 0) - exit (0); + if (j == 0) { + printf("k %d eof\n", k); + pfd[k].fd = -1; + } if (j > 0) { i = write(pipes[k][1], buf, j); - if (i != j) - err(1, "i = %d j = %d\n", i, j); + if (i != j) { + printf("k %d write (%d %d)\n", k, i, j); + pfd[k].fd = -1; + } } } } + exit (0); } @@ -380,7 +389,7 @@ main(int argc, char *argv[]) VSL_MgtInit(SHMLOG_FILENAME, 8*1024*1024); - if (dflag) + if (dflag == 1) DebugStunt(); daemon(dflag, dflag); if (dflag) -- 2.39.5