Commit aa7e0dd
committed
TCPIP: fix stale accept futex notifications
A TCP child socket can become visible and accept-ready to `FreeRTOS_accept()`
before `on_tcp_connect()` increments the accept futex. If a waiter accepts the
child while the counter is zero, the old futex consume helper does not decrement
it to -1, because -1 represents an invalid futex. The delayed `on_tcp_connect`
callback then increments the counter to one, though no connection is pending.
This leaves pending multi-waiters with a misleading futex. They will repeatedly
treat the socket as ready, call `accept()`, and never block, defeating the purpose
of multi-waiter waiting.
Use a signed counter and always decrement after a successful accept. An early
accept records a temporary negative debt that the callback later repays. Reserve
INT32_MIN for an invalid futex so that normal negative debt cannot conflict with
the sentinel value.1 parent ba80e0a commit aa7e0dd
3 files changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
| 408 | + | |
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| |||
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
430 | | - | |
431 | | - | |
| 430 | + | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
0 commit comments