Commit db7b5df
committed
Merge bitcoin/bitcoin#28551: http: bugfix: allow server shutdown in case of remote client disconnection
68f23f5 http: bugfix: track closed connection (stickies-v)
084d037 http: log connection instead of request count (stickies-v)
41f9027 http: refactor: use encapsulated HTTPRequestTracker (stickies-v)
Pull request description:
#26742 significantly increased the http server shutdown speed, but also introduced a bug (#27722 - see bitcoin/bitcoin#27722 (comment) for steps to reproduce on master) that causes http server shutdown to halt in case of a remote client disconnection. This happens because `evhttp_request_set_on_complete_cb` is never called and thus the request is never removed from `g_requests`.
This PR fixes that bug, and improves robustness of the code by encapsulating the request tracking logic. Earlier approaches (#27909, #27245, #19434) attempted to resolve this but [imo are fundamentally unsafe](bitcoin/bitcoin#27909 (comment)) because of differences in lifetime between an `evhttp_request` and `evhttp_connection`.
We don't need to keep track of open requests or connections, we just [need to ensure](bitcoin/bitcoin#19420 (comment)) that there are no active requests on server shutdown. Because a connection can have multiple requests, and a request can be completed in various ways (the request actually being handled, or the client performing a remote disconnect), keeping a counter per connection seems like the approach with the least overhead to me.
Fixes #27722
ACKs for top commit:
vasild:
ACK 68f23f5
theStack:
ACK 68f23f5
Tree-SHA512: dfa711ff55ec75ba44d73e9e6fac16b0be25cf3c20868c2145a844a7878ad9fc6998d9ff62d72f3a210bfa411ef03d3757b73d68a7c22926e874c421e51444d61 file changed
+66
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
152 | 206 | | |
153 | | - | |
154 | | - | |
155 | | - | |
| 207 | + | |
156 | 208 | | |
157 | 209 | | |
158 | 210 | | |
| |||
210 | 262 | | |
211 | 263 | | |
212 | 264 | | |
213 | | - | |
| 265 | + | |
| 266 | + | |
214 | 267 | | |
215 | | - | |
216 | | - | |
| 268 | + | |
217 | 269 | | |
218 | | - | |
219 | | - | |
220 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
221 | 274 | | |
222 | 275 | | |
223 | 276 | | |
224 | 277 | | |
225 | 278 | | |
226 | 279 | | |
227 | 280 | | |
228 | | - | |
229 | 281 | | |
230 | 282 | | |
231 | 283 | | |
| |||
473 | 525 | | |
474 | 526 | | |
475 | 527 | | |
476 | | - | |
477 | | - | |
478 | | - | |
| 528 | + | |
| 529 | + | |
479 | 530 | | |
480 | | - | |
481 | | - | |
482 | | - | |
| 531 | + | |
483 | 532 | | |
484 | 533 | | |
485 | 534 | | |
| |||
0 commit comments