Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/server.py @ 41493:6bbb12cba5a8
server: skip logging of ECONNRESET
I believe this was exposed by 5492dc20, because the sending of the 500
would have already failed and prevented this logging. On Python 3,
this will be a ConnectionResetError, which is a subtype of OSError,
which is why we check for both OSError and socket.error.
Bonus: this fixes a race in test-hgweb.t where sometimes the
ECONNRESET wouldn't happen, because now we just don't log those
errors.
Differential Revision: https://phab.mercurial-scm.org/D5764
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 30 Jan 2019 17:24:57 -0500 |
parents | 9b2b8794f801 |
children | e554cfd93975 |
comparison
equal
deleted
inserted
replaced
41492:8e0dd36f7a97 | 41493:6bbb12cba5a8 |
---|---|
98 raise | 98 raise |
99 | 99 |
100 def do_POST(self): | 100 def do_POST(self): |
101 try: | 101 try: |
102 self.do_write() | 102 self.do_write() |
103 except Exception: | 103 except Exception as e: |
104 # I/O below could raise another exception. So log the original | 104 # I/O below could raise another exception. So log the original |
105 # exception first to ensure it is recorded. | 105 # exception first to ensure it is recorded. |
106 tb = r"".join(traceback.format_exception(*sys.exc_info())) | 106 if not (isinstance(e, (OSError, socket.error)) |
107 # We need a native-string newline to poke in the log | 107 and e.errno == errno.ECONNRESET): |
108 # message, because we won't get a newline when using an | 108 tb = r"".join(traceback.format_exception(*sys.exc_info())) |
109 # r-string. This is the easy way out. | 109 # We need a native-string newline to poke in the log |
110 newline = chr(10) | 110 # message, because we won't get a newline when using an |
111 self.log_error(r"Exception happened during processing " | 111 # r-string. This is the easy way out. |
112 r"request '%s':%s%s", self.path, newline, tb) | 112 newline = chr(10) |
113 self.log_error(r"Exception happened during processing " | |
114 r"request '%s':%s%s", self.path, newline, tb) | |
113 | 115 |
114 self._start_response(r"500 Internal Server Error", []) | 116 self._start_response(r"500 Internal Server Error", []) |
115 self._write(b"Internal Server Error") | 117 self._write(b"Internal Server Error") |
116 self._done() | 118 self._done() |
117 | 119 |