Repository navigation
Commit d294ce8
committed
[BUG] Fix nonblocking send/recv handling in the ext/http embedded server
The embedded HttpServer mishandled nonblocking send()/recv() results:
- sendMore() fell through to sendBuffer.erase(0, sent) when send() returned
-1 (EWOULDBLOCK). With sent == -1 the erase count becomes SIZE_MAX and the
whole unsent response is wiped. It now never erases on a failed send, and
re-registers for writability on a genuine would-block so the buffer is
kept. Fixes #4281.
- onSocketReadable() closed the connection on any recv() <= 0, including the
transient -1/EWOULDBLOCK case. It now closes only on an orderly shutdown
(recv() == 0) or a real error, and ignores a transient would-block. Fixes
#4282.
- Both paths now capture the socket error immediately after send()/recv(),
before LOG_TRACE can clobber errno / the Winsock last error.
Add a Socket::ErrorAgain alias (EAGAIN, or WSAEWOULDBLOCK on Windows), since
EAGAIN and EWOULDBLOCK may be distinct values on some POSIX systems.
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>1 parent 780d404 commit d294ce8
3 files changed
Lines changed: 32 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
285 | 286 | | |
286 | | - | |
| 287 | + | |
287 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
288 | 301 | | |
289 | | - | |
290 | 302 | | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | 303 | | |
295 | 304 | | |
296 | 305 | | |
| |||
339 | 348 | | |
340 | 349 | | |
341 | 350 | | |
| 351 | + | |
342 | 352 | | |
343 | | - | |
| 353 | + | |
344 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
345 | 363 | | |
346 | 364 | | |
347 | | - | |
| 365 | + | |
348 | 366 | | |
349 | 367 | | |
350 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
414 | | - | |
| 414 | + | |
| 415 | + | |
415 | 416 | | |
416 | | - | |
| 417 | + | |
| 418 | + | |
417 | 419 | | |
418 | 420 | | |
419 | 421 | | |
| |||
0 commit comments