Setting SIG_IGN for SIGPIPE errors (#6764)
* Setting SIG_IGN for SIGPIPE errors The issue was reported in https://github.com/mitmproxy/mitmproxy/issues/6744 Problem description: When there is a sudden surge of requests, mitmproxy will hit SIGPIPE (broken pipe) errors because it was trying to write to a closed socket. The stacktrace is: File "asyncio/runners.py", line 44, in run File "asyncio/base_events.py", line 636, in run_until_complete File "asyncio/base_events.py", line 603, in run_forever File "asyncio/base_events.py", line 1909, in _run_once File "asyncio/events.py", line 80, in _run File "mitmproxy/proxy/server.py", line 294, in handle_connection File "mitmproxy/proxy/server.py", line 407, in server_event File "asyncio/streams.py", line 325, in write File "asyncio/selector_events.py", line 924, in write When this happens, the process terminates unless handled The fix will allow the process to continue to run. * add changelog entry * [autofix.ci] apply automated fixes * Handling SIGPIPE only in non-Windows platforms * [autofix.ci] apply automated fixes * nit: make check platform-agnostic --------- Co-authored-by: changsin <changsin@strac.io> Co-authored-by: Maximilian Hils <github@maximilianhils.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
ccf45a92e4
commit
8cf0cba1cb
|
@ -21,8 +21,12 @@
|
|||
([#6747](https://github.com/mitmproxy/mitmproxy/pull/6747), @jlaine)
|
||||
* Fix a bug where async `client_connected` handlers would crash mitmproxy.
|
||||
([#6749](https://github.com/mitmproxy/mitmproxy/pull/6749), @mhils)
|
||||
* Add button to close flow details panel
|
||||
* Add button to close flow details panel
|
||||
([#6734](https://github.com/mitmproxy/mitmproxy/pull/6734), @lups2000)
|
||||
* Ignore SIGPIPE signals when there is lots of traffic.
|
||||
Socket errors are handled directly and do not require extra signals
|
||||
that generate noise.
|
||||
([#6764](https://github.com/mitmproxy/mitmproxy/pull/6764), @changsin)
|
||||
* Add primitive websocket interception and modification
|
||||
([#6766](https://github.com/mitmproxy/mitmproxy/pull/6766), @errorxyz)
|
||||
|
||||
|
|
|
@ -120,6 +120,10 @@ def run(
|
|||
# but signal.signal just works fine for our purposes.
|
||||
signal.signal(signal.SIGINT, _sigint)
|
||||
signal.signal(signal.SIGTERM, _sigterm)
|
||||
# to fix the issue mentioned https://github.com/mitmproxy/mitmproxy/issues/6744
|
||||
# by setting SIGPIPE to SIG_IGN, the process will not terminate and continue to run
|
||||
if hasattr(signal, "SIGPIPE"):
|
||||
signal.signal(signal.SIGPIPE, signal.SIG_IGN)
|
||||
|
||||
await master.run()
|
||||
return master
|
||||
|
|
Loading…
Reference in New Issue