#27 avoid slow getHostName() when name passed in

pending-fixed
None
5
2012-11-04
2011-09-15
SteveT
No

On certain networks, getHostName() is very slow (10 or 20 seconds).
I am calling "JmDNS.create(addr, hostname)". Note the passing of an alread-known hostname. However, there is some code in HostInfo.java which calls getHostName() even if hostname was passed in (see patch). This patch alleviated this in my application. I post it here for possible inclusion in JmDNS. If my thinking is not correct, or I am missing some critical usage which forces the lookup, please advise. I'm always trying to learn.
Regards,
SteveT

Discussion

  • SteveT

    SteveT - 2011-09-15

    patch to only call getHostName() if name not passed in

     
  • SteveT

    SteveT - 2012-01-03

    any thoughts on this change?

     
  • Pierre Frisch

    Pierre Frisch - 2012-01-03

    This is radical change on the API. The name passed in JmDNS is not currently used for anything except as an identifier. The hostname is a completely different notion. Why is hostname slow on your machine. It should not be as this is typically cached by the system.

     
  • SteveT

    SteveT - 2012-01-04

    Not following how this changes the API. The current code is always doing a lookup of the hostname from the address, throwing away the 2nd parm (identifier) altogether. Why allow passing the identifier in if it is not going to be used at all?

    The problem shows up on networks that are not connected to the internet and have no DNS server. Android devices try the lookup every time in this situation. Perhaps they only cache valid values.

     
  • Pierre Frisch

    Pierre Frisch - 2012-11-04
    • assigned_to: nobody --> spearway
    • status: open --> pending-fixed