#3997 dns resolver problem

obsolete: 8.5.2
closed-out-of-date
Reinhard Max
8
2012-05-17
2008-05-12
Anonymous
No

I have a problem to resolv reverse DNS in tcl interpreter compiled with treads in my server socket code. If host is available i reverse DNS zone it is ok but if host is not available tcl returns last position from /etc/hosts file.
This situation is only on tcl compiled with threads. I check 8.5.2, 8.4.15, 8.4.18

No threaded interpreter:
logger: Opening SMTP connection from 172.16.17.222

Threaded interpreter:
logger: Opening SMTP connection from osiolek

Last position from my /etc/hosts
172.16.55.11 osiolek

fconfigure returns bad hostname

Sample code:
if {[catch {set RemoteName [lindex [fconfigure $channel -peername] 1]} err]} {
logger "Can't read client name"
after 0 "close $channel"
return
}

Linux distributions: SLES 9, SLES 10, Ubuntu

j.lewandowski@dominet.pl

Discussion

  • Logged In: YES
    user_id=2091947
    Originator: NO

    my observations:

    with nothreaded interpreter:

    set hostip [lindex [fconfigure $channel -peername] 0] returns client(host) IP
    set hostname [lindex [fconfigure $channel -peername] 1] returns client(host) NAME (from DNS or /etc/hosts)
    set hostport [lindex [fconfigure $channel -peername] 2] returns client(host) PORT

    but with threaded interpreter "fconfigure -peername" returns good client IP, NAME and PORT doesn't exists (!).

    Darek. d.wapinski@dominet.pl

     
  • Logged In: YES
    user_id=79902
    Originator: NO

    Looks like there's thread-safety problems in TclpGetHostByAddr when built under modern Linux. Should review to see if replacing with getaddrinfo (which is *supposed* to be thread-safe) is practical.

     
    • labels: 104253 --> 27. Channel Types
    • assigned_to: nobody --> andreas_kupries
    • milestone: --> obsolete: 8.5.2
    • priority: 5 --> 8
     
  • Logged In: YES
    user_id=2091947
    Originator: NO

    Maybe problem is because gethostbyaddr_r return more than one error conditions:
    http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/apis/tsghosta.htm

    "
    Error Conditions

    When the gethostbyaddr_r() function fails, h_errno (defined in <netdb.h>) can be set to:

    [HOST_NOT_FOUND]
    [NO_DATA]
    [NO_RECOVERY]
    [TRY_AGAIN]
    [EINVAL]
    "

    In TclpGetHostByAddr(const char *addr, int length, int type) in tclUnixCompat.c we have only NULL? If I reduce TclpGetHostByAddr() to:

    struct hostent *
    TclpGetHostByAddr(
    const char *addr,
    int length,
    int type)
    {
    return gethostbyaddr(addr, length, type);
    }

    everything is OK. But this is NOT answer.

     
  • Tcl 8.6 uses getaddrinfo() now which is documented as thread safe. (It also supports IPv6, which is why we switched to GAI.)

     
    • assigned_to: andreas_kupries --> rmax
    • status: open --> closed-out-of-date