Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2013-11-12
15:50 • Ticket [5425f2c082] Async socket connect may flag error and still connects s... artifact: 8cad74d1f3 user: max
13:27 • Closed ticket [5425f2c082]. artifact: afb5164b9c user: max
12:22 • Ticket [5425f2c082]: 4 changes artifact: f6cf3e6f3c user: dkf
11:45
Fix [5425f2c082]: [fconfigure -error] breaks the background processing of a pending [socket -async]. check-in: 80ca9fe746 user: max tags: trunk
08:55 • Ticket [13d3af3ad5] IPV6 only used for IPV4/IPV6 sockets on windows status s... artifact: 3049e8d5b2 user: oehhar
08:54 • Ticket [5425f2c082] Async socket connect may flag error and still connects s... artifact: db83032388 user: oehhar
08:52 • New ticket [5425f2c082]. artifact: 68344473ee user: oehhar

Async socket connect may flag error and still connects

Closed5425f2c08257f7d9660276c4c8f764ad2d178e1cCreated 13 years agoUpdated 13 years ago
Descriptionwiki2013-11-12 08:52:47

Issue

In an asyncroneous socket connect, there might be errors flagged even if the connect finally succeedes.

This appeared on MAC-OS X with tcl8.6.1.

Demo

We have a server socket on an IPV6 enabled system which only binds to the IPV4 address. This might be done in a tclsh console with the following program:
% proc accept {s a p} {
     puts ok
}
% socket -server accept -myaddr 127.0.0.1 61680
sock192
% vwait a

In a second tclsh, the following is run:

% set client [socket -async localhost 61680]
sock103825910
% fconfigure $client -error
connection refused
% update
% fconfigure $client -error
% fconfigure $client -sockname
::1 localhost 64153

The issue is the flagged "connection refused" and the final connect.

References

Reported by DKF on Ticket [13d3af3ad5] and copied here by oehhar.

Referenced by2
  • 80ca9fe746Fix [5425f2c082]: [fconfigure -error] breaks the background processing of a pending [socket -async]. check-in2013-11-12 11:45:04
  • 3049e8d5b2Ticket [13d3af3ad5] IPV6 only used for IPV4/IPV6 sockets on windows status still Open with 5 other changes ticket2013-11-12 08:55:46
oehhar Ticket [5425f2c082]: 4 changes [History diff]2013-11-12 08:54:02
dkfhtml2013-11-12 12:22:33

To be clear, the issue is that looking at the transient error prevents the client from ever connecting. That's much more serious than merely seeing a transient error.

maxplain2013-11-12 13:27:29
Fixed in [80ca9fe746] and [f644fb5a9f].

When implementing multi-address [socket -async], I thought it would only be used together with fileevent, and [fconfigure -error] would not be called before the readable event has fired. But now I see that -async without fileevent even makes sense, e.g. to trace the addresses that were tried and why each of them failed, so the error caching (reading SO_ERROR is destructive) needs to go both ways, from the event handler hidden behind [socket -async] to [fconfigure -error] and vice versa.
maxplain2013-11-12 15:50:56
Just for completeness: the tracing I mentioned in the last comment doesn't work as I thought, because [fconfigure -peername] is not available before the socket is connected.
Log in (anonymous is fine) to add a comment.