Commit 4ccc008
authored
Treat abortive-close posix reasons as client closures in logging (#663)
Bandit.Logger.maybe_log_protocol_error/4 only suppressed logging for
%Bandit.TransportError{error: :closed}, so a client that aborts a
connection (RST) during HTTP/2 init - before conn_data/peer_data can
be obtained - gets logged at ERROR level even with the default
log_client_closures: false, because peername/1 surfaces a different
posix reason (e.g. :enotconn, :einval, :econnaborted, :econnreset)
for an abortive close rather than :closed.
A peer that is already gone is a client closure regardless of which
of these reasons the socket happens to report, so treat all of them
the same way :closed is treated.
Adds an HTTP2ProtocolTest case that opens a TLS connection with
linger: {true, 0} (forcing an abortive RST close) and closes it
immediately, before any HTTP/2 bytes are exchanged, then asserts
nothing is logged at the default settings - the same connection-init
code path as the reported issue. Transport.tls_client/2 gains an
optional third `opts` argument so the test can pass linger through
to the underlying :ssl.connect call.
Also loosens two pre-existing HTTP/1 logging assertions that
hardcoded "closed" as the only expected posix reason in the log
message text; on this platform an abortive close of an in-flight
request can legitimately surface as :econnreset or similar, which is
exactly the class of reason this fix now handles consistently.
Fixes #6471 parent 274eb55 commit 4ccc008
4 files changed
Lines changed: 44 additions & 11 deletions
File tree
- lib/bandit
- test
- bandit
- http1
- http2
- support
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
6 | 12 | | |
7 | 13 | | |
8 | 14 | | |
9 | | - | |
| 15 | + | |
| 16 | + | |
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| |||
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
95 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
96 | 104 | | |
97 | 105 | | |
98 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
53 | 67 | | |
54 | 68 | | |
55 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
0 commit comments