D5764: server: skip logging of ECONNRESET

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Wed Jan 30 19:12:03 EST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG39bac0bdcddf: server: skip logging of ECONNRESET (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5764?vs=13608&id=13612

REVISION DETAIL
  https://phab.mercurial-scm.org/D5764

AFFECTED FILES
  mercurial/hgweb/server.py
  tests/test-hgweb.t

CHANGE DETAILS

diff --git a/tests/test-hgweb.t b/tests/test-hgweb.t
--- a/tests/test-hgweb.t
+++ b/tests/test-hgweb.t
@@ -911,18 +911,6 @@
 errors
 
   $ cat errors.log | "$PYTHON" $TESTDIR/filtertraceback.py
-  $LOCALIP - - [$ERRDATE$] Exception happened during processing request '/?cmd=spam': (glob)
-  Traceback (most recent call last):
-  error: [Errno 104] $ECONNRESET$
-  
-  $LOCALIP - - [$ERRDATE$] Exception happened during processing request '/spam': (glob)
-  Traceback (most recent call last):
-  error: [Errno 104] $ECONNRESET$
-  
-  $LOCALIP - - [$ERRDATE$] Exception happened during processing request '/spam/tip/foo': (glob)
-  Traceback (most recent call last):
-  error: [Errno 104] $ECONNRESET$
-  
   $ rm -f errors.log
 
 Uncaught exceptions result in a logged error and canned HTTP response
diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -100,16 +100,18 @@
     def do_POST(self):
         try:
             self.do_write()
-        except Exception:
+        except Exception as e:
             # I/O below could raise another exception. So log the original
             # exception first to ensure it is recorded.
-            tb = r"".join(traceback.format_exception(*sys.exc_info()))
-            # We need a native-string newline to poke in the log
-            # message, because we won't get a newline when using an
-            # r-string. This is the easy way out.
-            newline = chr(10)
-            self.log_error(r"Exception happened during processing "
-                           r"request '%s':%s%s", self.path, newline, tb)
+            if not (isinstance(e, (OSError, socket.error))
+                    and e.errno == errno.ECONNRESET):
+                tb = r"".join(traceback.format_exception(*sys.exc_info()))
+                # We need a native-string newline to poke in the log
+                # message, because we won't get a newline when using an
+                # r-string. This is the easy way out.
+                newline = chr(10)
+                self.log_error(r"Exception happened during processing "
+                               r"request '%s':%s%s", self.path, newline, tb)
 
             self._start_response(r"500 Internal Server Error", [])
             self._write(b"Internal Server Error")



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list