From ac27c3f84b2390677de94640aadf9c4f15760f7a Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Thu, 22 May 2008 18:04:40 +1200 Subject: [PATCH] Silence secondary errors on fatal shutdowns. This patch causes fatal() errors to set the shutdown flag before aborting. The result of this is that secondary errors not related to the fatal condition but caused during the shutdown sequence no longer confuse the error traces. It also cleans up a little broken whitespace formatting in the snmp_core.cc --- src/snmp_core.cc | 9 +++++---- src/tools.cc | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/snmp_core.cc b/src/snmp_core.cc index bc93140b3a..1fa2fc6a23 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -414,9 +414,7 @@ snmpConnectionOpen(void) len = sizeof(struct sockaddr_in); memset(&xaddr, '\0', len); - x = getsockname(theOutSnmpConnection, - - (struct sockaddr *) &xaddr, &len); + x = getsockname(theOutSnmpConnection, (struct sockaddr *) &xaddr, &len); if (x < 0) debugs(51, 1, "theOutSnmpConnection FD " << theOutSnmpConnection << ": getsockname: " << xstrerror()); @@ -441,7 +439,8 @@ snmpConnectionShutdown(void) * and 'out' sockets might be just one FD. This prevents this * function from executing repeatedly. When we are really ready to * exit or restart, main will comm_close the 'out' descriptor. - */ theInSnmpConnection = -1; + */ + theInSnmpConnection = -1; /* * Normally we only write to the outgoing SNMP socket, but we @@ -462,6 +461,8 @@ snmpConnectionClose(void) if (theOutSnmpConnection > -1) { debugs(49, 1, "FD " << theOutSnmpConnection << " Closing SNMP socket"); comm_close(theOutSnmpConnection); + /* make sure the SNMP out connection is unset */ + theOutSnmpConnection = -1; } } diff --git a/src/tools.cc b/src/tools.cc index 3c6e191d1f..65a6b16eb7 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -462,6 +462,9 @@ fatal_common(const char *message) void fatal(const char *message) { + /* suppress secondary errors from the dying */ + shutting_down = 1; + releaseServerSockets(); /* check for store_dirs_rebuilding because fatal() is often * used in early initialization phases, long before we ever -- 2.47.3