Tcl Source Code

View Ticket
Login
Ticket UUID: d22dc7e9ca3577d84c76cf0091d9db9eb9245da2
Title: socket -async leaves the socket non-blocking when the connect succeeds at once
Type: Bug Created on: 2026-10-12 08:41:35
Submitter: serhiy.storchaka Assigned to:
Subsystem: 27. Channel Types Severity: Minor
Priority: 5 Medium Last modified: 2026-10-12 08:44:36
Status: Open Closed by:
Resolution: None Closed on:
Version: 8.6.18, 9.0.5, 9.1.0
Description:

On illumos (OpenIndiana), a non-blocking connect() to a local listener succeeds at once instead of returning EINPROGRESS; on DragonFly this happens for IPv6 (::1). TcpConnect() makes the socket non-blocking for socket -async but restores the blocking mode only when the connect finishes in the background. So after such an immediate connect the socket stays non-blocking while the channel is blocking, and a blocking gets returns an empty string at once. This fails socket-14.7.0 and 14.7.1 on illumos and socket-14.7.1 on DragonFly.

This is a regression of [219061] (HP-UX, fixed in 8.3.1 by resetting the socket to blocking mode when the connect succeeds at once). Since the 2011 rework the blocking mode, cached since [3401422], is restored only after a connect finishing in the background; [3428753] fixed only the flag for connections completing at once.

Proposed fix in branch unix-async-connect-immediate-success.