From 52e813951a416588ad78e5ab9db3f3996d547ba5 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Thu, 11 Mar 2004 20:15:53 +0000 Subject: [PATCH] start tracking the 'broken pipe' error svn:r1261 --- src/or/buffers.c | 1 + src/or/main.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/or/buffers.c b/src/or/buffers.c index d42350b229..65b77e06e2 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -253,6 +253,7 @@ int flush_buf(int s, buf_t *buf, int *buf_flushlen) write_result = send(s, buf->mem, *buf_flushlen, 0); if (write_result < 0) { if(!ERRNO_EAGAIN(errno)) { /* it's a real error */ + assert(errno != EPIPE); /* get a stack trace to find epipe bugs */ return -1; } #ifdef MS_WINDOWS diff --git a/src/or/main.c b/src/or/main.c index fa7c6c8495..ff1d529121 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -631,6 +631,9 @@ static void catch(int the_signal) { if(options.PidFile) unlink(options.PidFile); exit(0); + case SIGPIPE: + log(LOG_WARN,"Bug: caught sigpipe. Ignoring."); + break; case SIGHUP: please_reset = 1; break; @@ -751,6 +754,7 @@ int tor_main(int argc, char *argv[]) { #ifndef MS_WINDOWS /* do signal stuff only on unix */ signal (SIGINT, catch); /* catch kills so we can exit cleanly */ signal (SIGTERM, catch); + signal (SIGPIPE, catch); signal (SIGUSR1, catch); /* to dump stats */ signal (SIGHUP, catch); /* to reload directory */ signal (SIGCHLD, catch); /* for exiting dns/cpu workers */