#1668 fconfigure -sockname performance issue

obsolete: 8.3.2
closed-fixed
5
2001-12-13
2001-11-06
Anonymous
No

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

Discussion

  • 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.

     
  • 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.)

     
    • assigned_to: andreas_kupries --> dkf
    • status: open --> open-fixed
     
  • 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.

     
  • Bugfix, unified diff

     
    Attachments
    • assigned_to: dkf --> andreas_kupries
     
  • Logged In: YES
    user_id=79902

    Looks OK to me; "Make It So!"

     
  • Logged In: YES
    user_id=75003

    Committed to head.

     
    • status: open-fixed --> closed-fixed