|
38 | 38 | InputDispatcher = Callable[[Mapping[str, Any]], Any] |
39 | 39 |
|
40 | 40 | _AUTH_TIMEOUT_S = 60.0 |
41 | | -# Ceiling for the pre-auth handshake step (TLS wrap + WS upgrade GET). |
42 | | -# Legitimate handshakes complete in milliseconds; 5 s is generous enough |
43 | | -# to absorb scheduler starvation on slow CI runners but short enough to |
44 | | -# fast-fail when a client speaks the wrong protocol (e.g. plain-TCP auth |
45 | | -# bytes hitting a WS server). Kept distinct from _AUTH_TIMEOUT_S so the |
46 | | -# subsequent auth-message exchange retains its longer budget. |
47 | | -_HANDSHAKE_RECV_TIMEOUT_S = 5.0 |
48 | 41 | _DEFAULT_QUALITY = 70 |
49 | 42 |
|
50 | 43 |
|
@@ -561,18 +554,6 @@ def _accept_loop(self) -> None: |
561 | 554 | continue |
562 | 555 | except OSError: |
563 | 556 | return |
564 | | - # accept() returns a new socket that INHERITS the listener's |
565 | | - # 0.5 s timeout. That is fine for the accept poll itself but |
566 | | - # fatally tight for the handshake that follows: a slow CI |
567 | | - # runner can't deliver the TLS / WS upgrade request inside |
568 | | - # 500 ms, the recv times out, server drops, and the client's |
569 | | - # separate auth wait ticks down to its own timeout. Promote |
570 | | - # to a handshake-specific budget — long enough for runner |
571 | | - # starvation, short enough to fast-fail on protocol mismatch. |
572 | | - try: |
573 | | - client_sock.settimeout(_HANDSHAKE_RECV_TIMEOUT_S) |
574 | | - except OSError: |
575 | | - pass |
576 | 557 | wrapped = self._maybe_wrap_tls(client_sock, address) |
577 | 558 | if wrapped is None: |
578 | 559 | continue |
@@ -613,9 +594,7 @@ def _maybe_wrap_tls(self, client_sock: socket.socket, |
613 | 594 | if self._ssl_context is None: |
614 | 595 | return client_sock |
615 | 596 | try: |
616 | | - # Use the handshake-specific budget so a peer that never |
617 | | - # speaks TLS (or cuts off mid-ClientHello) fails fast. |
618 | | - client_sock.settimeout(_HANDSHAKE_RECV_TIMEOUT_S) |
| 597 | + client_sock.settimeout(_AUTH_TIMEOUT_S) |
619 | 598 | wrapped = self._ssl_context.wrap_socket( |
620 | 599 | client_sock, server_side=True, |
621 | 600 | ) |
|
0 commit comments