Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-27
12:11
Rebase fix for [251f46655c] to trunk leaf check-in: e39964e8b4 user: jan.nijtmans tags: unix-async-close-pending, core-unix-async-close-pending
2026-10-16
21:17 • Closed ticket [1329568fff]: socket -async and puts: Inadequate documentation... artifact: d89f277197 user: serhiy.storchaka
21:16 • Ticket [251f46655c] close of a pending socket -async fails and loses the buffere... artifact: c41312943f user: serhiy.storchaka
21:14
Fix [251f46655c]: close of a pending socket -async fails and loses the buffered output. Do not shut ... check-in: a430d26e7c user: serhiy.storchaka tags: unix-async-close-pending
21:08 • Ticket [251f46655c] close of a pending socket -async fails and loses the buffere... artifact: b5fe37a4a9 user: serhiy.storchaka
20:59 • Ticket [251f46655c]: 2 changes artifact: 6a7b59dd02 user: serhiy.storchaka
20:59 • New ticket [251f46655c]. artifact: 389047f354 user: serhiy.storchaka

close of a pending socket -async fails and loses the buffered output

Open251f46655c1a8b588b01f00f43c435c04ad10c75Created 47 days agoUpdated 47 days ago
Descriptionwiki2026-10-16 20:59:21
On Unix, closing a [socket -async] channel while the connection is still being established loses the data written to it:
set s [socket -async $host $port]   ;# connect still pending
puts $s hello
close $s   ;# error: transport endpoint is not connected; the server gets nothing

The same happens for a non-blocking channel, where the error is also raised by close.

8.6 sends the data. Since [d5bc305ad2] Tcl_Close() always shuts down the read side before flushing, and TcpClose2Proc() calls shutdown(SHUT_RD) on the still connecting socket, which aborts the connect on Linux.

Referenced by3
  • e39964e8b4Rebase fix for [251f46655c] to trunk check-in2026-11-27 12:11:00
  • d89f277197Closed ticket [1329568fff]: [socket -async] and [puts]: Inadequate documentation? plus 4 other changes ticket2026-10-16 21:17:47
  • a430d26e7cFix [251f46655c]: close of a pending socket -async fails and loses the buffered output. Do not shut down the read side of a socket while its async connect is pending: on Linux this aborts the connection attempt. check-in2026-10-16 21:14:48
serhiy.storchaka Ticket [251f46655c]: 2 changes [History diff]2026-10-16 20:59:35
serhiy.storchaka Ticket [251f46655c]: 4 changes [History diff]2026-10-16 21:08:27
serhiy.storchakawiki2026-10-16 21:16:36

Proposed fix in branch unix-async-close-pending: TcpClose2Proc() does not shut down the read side while the connect is pending. Test socket-14.20. This also fixes [chan close $s read] on a pending socket, which aborted the connect even in 8.6.

Log in (anonymous is fine) to add a comment.