fconfigure -sockname performance issue
Closed / Fixed478565ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-11-06 05:25:50
On Windows NT 4.0 SP6a with Tcl 8.3.2, using fconfigure -sockname on a server socket can
cause
a 10-20 second delay depending upon the system configuration.
The following code snippet illustrates the behavior:
proc ServerAccept { cid addr port } {
return
}
set sock [socket -server ServerAccept 0]
puts "socket: $sock"
set data [fconfigure $sock -sockname]
puts "DATA: $data"
fconfigure -sockname triggers a call to gethostbyaddr() on the local IP address, 0.0.0.0 in this
case. On NT 4.0 (but not Windows 2000 or UNIX), this leads to a 10-20 second delay while the
gethostbyaddr() call times out.
Although this is actually an NT issue and not a Tcl one, a simple workaround in the Tcl code would
be to avoid the gethostbyaddr() call if the IP address is 0.0.0.0 on NT 4.0. A workaround for the
end user with the current code is to add a line to c:\winnt\system32\drivers\etc\hosts:
0.0.0.0 0.0.0.0
nobodyplain2001-11-26 05:19:10
Logged In: NO This bug exist in Windows 98 and Tcl 8.3.4. Delay is ~16 seconds per [fconfigure -sockname sock???]. Adding 0.0.0.0 0.0.0.0 in hosts.sam not resolve problem.
dkfplain2001-11-26 20:31:34
Logged In: YES user_id=79902 It should be pretty trivial to detect '0.0.0.0' for ourselves and skip the name lookup in that case (it's not an address that should map to any particular name anyway.)
andreas_kupriesplain2001-12-12 02:20:05
Logged In: YES user_id=75003 Enclosed is a tentative patch which compiles and passes the testsuite. As my system is Win/2K I cannot check if the patch truly solves the problem for Win/NT. Assigning to Donal now for a quick lookover.
andreas_kupriesplain2001-12-12 02:20:06
File Added - 14522: 478565.diff
dkfplain2001-12-13 21:55:36
Logged In: YES user_id=79902 Looks OK to me; "Make It So!"
andreas_kupriesplain2001-12-14 01:07:47
Logged In: YES user_id=75003 Committed to head.
Log in (anonymous is fine) to add a comment.
Attachments:
- 478565.diff [download] added by andreas_kupries on 2001-12-12 02:20:06. [details]