View Issue Details

IDProjectCategoryView StatusLast Update
0020484FPCPackagespublic2016-03-07 18:53
ReporterAnton S. Assigned ToMichael Van Canneyt  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformMacOSOS X 
Product Version2.4.4 
Target Version2.7.1Fixed in Version2.6.4 
Summary0020484: NetDB unable to resolve DNS when application was launched without network
DescriptionIf network is down when the application is launched then ResolveName and/or ResolveHostByName fails (one returns a negative value and other returns False), and even after the network is went online every subsequent call to ResolveName and/or ResolveHostByName will still fail.

I have a clue that this happens because when you start the app and there is no network connection /etc/resolv.conf file is pointing to no file (because /etc/resolv.conf is a link and /var/run/resolv.conf in not present) and because inside netdb's InitResolver, CheckResolveFileAge is set to False the file with resolve dns server is never reread (never updated by CheckResolveFile) on subsequent calls, so even if network goes up ResolveHostByName always return False leaving 0.0.0.0 as ip...
But even if you set CheckResolveFileAge to True then it still fails because ResolveFileAge will contain the FileAge of the link /etc/resolv.conf and not the FileAge of new/updated /var/run/resolv.conf, so ResolveFileAge<FileAge(ResolveFileName) will be always False and GetDnsServers never called again.
Steps To ReproduceShutdown your network
Launch attached test application and click on Button
Restore your network and wait until it acquire IP and DNS addresses
Click again on Button
Additional InformationThe discussion related to how i'v found this bug:
http://www.lazarus.freepascal.org/index.php/topic,14857.msg79133.html#msg79133

And as i can see from related bug it also happens on Debian.

Can this be short term solution?
{$ifdef darwin}
  SResolveFile = '/var/run/resolv.conf';
{$else}
  SResolveFile = '/etc/resolv.conf';
{$endif}
Tagsgethostbyname, netdb, ResolveHostByName, ResolveName
Fixed in Revision23891
FPCOldBugId
FPCTarget
Attached Files

Relationships

related to 0019493 closedMichael Van Canneyt NETDB ResolveName unstable on Debian? Affects Indy 10.2.0.3 - causes intermittent EIdResolveError 
related to 0022130 closedMichael Van Canneyt lazy initialization of fcl-net.netdb 

Activities

2011-10-14 15:36

 

DNSTest.zip (5,530 bytes)

Anton S.

2011-10-14 15:40

reporter   ~0052976

I can't set a related bug, it's 19493.

Michael Van Canneyt

2013-01-07 12:25

administrator   ~0064710

The bug was that the resolv.conf filename is empty if it is not found.
When checking, an empty file is checked. I fixed that.

PS. Determining file age always follows the link unless you instruct it otherwise.

Anton S.

2016-03-07 18:53

reporter   ~0090740

Working.

Issue History

Date Modified Username Field Change
2011-10-14 15:36 Anton S. New Issue
2011-10-14 15:36 Anton S. File Added: DNSTest.zip
2011-10-14 15:39 Anton S. Tag Attached: gethostbyname
2011-10-14 15:39 Anton S. Tag Attached: netdb
2011-10-14 15:39 Anton S. Tag Attached: ResolveHostByName
2011-10-14 15:39 Anton S. Tag Attached: ResolveName
2011-10-14 15:40 Anton S. Note Added: 0052976
2011-10-14 15:51 Jonas Maebe Relationship added related to 0019493
2011-10-14 17:33 Michael Van Canneyt Status new => assigned
2011-10-14 17:33 Michael Van Canneyt Assigned To => Michael Van Canneyt
2012-05-25 13:41 Marco van de Voort Relationship added related to 0022130
2013-01-07 12:25 Michael Van Canneyt Fixed in Revision => 23336
2013-01-07 12:25 Michael Van Canneyt Status assigned => resolved
2013-01-07 12:25 Michael Van Canneyt Fixed in Version => 2.7.1
2013-01-07 12:25 Michael Van Canneyt Resolution open => fixed
2013-01-07 12:25 Michael Van Canneyt Note Added: 0064710
2013-01-07 12:25 Michael Van Canneyt Target Version => 2.7.1
2014-03-04 17:46 Jonas Maebe Fixed in Revision 23336 => 23891
2014-03-04 17:46 Jonas Maebe Fixed in Version 2.7.1 => 2.6.4
2016-03-07 18:53 Anton S. Note Added: 0090740
2016-03-07 18:53 Anton S. Status resolved => closed