Tcl Source Code

View Ticket
Login
Ticket UUID: 478565
Title: fconfigure -sockname performance issue
Type: Bug Version: obsolete: 8.3.2
Submitter: nobody Created on: 2001-11-06 05:25:50
Subsystem: 24. Channel Commands Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2001-12-14 01:07:47
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2001-12-13 18:07:47
Description:
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
User Comments: andreas_kupries added on 2001-12-14 01:07:47:
Logged In: YES 
user_id=75003

Committed to head.

dkf added on 2001-12-13 21:55:36:
Logged In: YES 
user_id=79902

Looks OK to me; "Make It So!"

andreas_kupries added on 2001-12-12 02:20:06:

File Added - 14522: 478565.diff

andreas_kupries added on 2001-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.

dkf added on 2001-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.)

nobody added on 2001-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.

Attachments: