Repository navigation
Commit e53a32d
committed
net/tcp: End a blocking connect() at the send timeout.
psock_tcp_connect() waits for the handshake without a time limit. A
blocking connect() to a peer that drops the SYNs waits until the SYN
retransmissions give up, about 70 s, whatever SO_SNDTIMEO says.
Linux ends the wait at the send timeout with EINPROGRESS, as if the
socket were non-blocking (socket(7), SO_SNDTIMEO), and the connection
goes on. Do the same: wait at most SO_SNDTIMEO. When it expires,
connect() gives EINPROGRESS and the connection monitor takes the
connection over, as for a non-blocking connect(): poll() reports
POLLOUT when the handshake completes, and SO_ERROR gives the error of a
connection that fails.
tcp_start_monitor() takes a connection in TCP_SYN_SENT as one in
progress when the socket is connecting, not only when it is
non-blocking.
A result that the event handler sets just before the wait ends (with
the timeout or a signal) is now used, as the handler already tore its
callback down.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>1 parent 7fba6cc commit e53a32d
2 files changed
Lines changed: 18 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
301 | 302 | | |
302 | 303 | | |
303 | 304 | | |
| |||
388 | 389 | | |
389 | 390 | | |
390 | 391 | | |
391 | | - | |
| 392 | + | |
392 | 393 | | |
393 | 394 | | |
394 | 395 | | |
395 | | - | |
| 396 | + | |
| 397 | + | |
396 | 398 | | |
397 | 399 | | |
398 | 400 | | |
| |||
401 | 403 | | |
402 | 404 | | |
403 | 405 | | |
404 | | - | |
405 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
406 | 409 | | |
407 | 410 | | |
408 | | - | |
| 411 | + | |
409 | 412 | | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | 413 | | |
415 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
416 | 419 | | |
417 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
418 | 423 | | |
419 | | - | |
| 424 | + | |
| 425 | + | |
420 | 426 | | |
421 | 427 | | |
422 | 428 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
0 commit comments