Sometimes I find that when DNS name resolution is not immediately
successful, gethostbyname() may block for unacceptable time, causing my
client program to become unresponsive. My question is, how should I
implement either DNS timeouts, or totally asynchronous DNS name
resolution? Do I need to write a proper DNS client from scratch from the
RFC? This is worse on some platforms than others.
Also gethostbyname() is poor because it is returning a pointer to static
data structure, and I currently must use mutexes to protect this call in
the multithreaded code. My code must be portable across HP/UX, Irix,
AIX, Linux, Solaris, Tru64, and Windows, so I have minimal choice about
what functions to use (gethostbyname_r() not supported on everything)
Thanks for any feedback on this.
|
|
0
|
|
|
|
Reply
|
root
|
3/31/2006 3:46:11 PM |
|
root wrote:
> Sometimes I find that when DNS name resolution is not immediately
> successful, gethostbyname() may block for unacceptable time, causing my
> client program to become unresponsive. My question is, how should I
> implement either DNS timeouts, or totally asynchronous DNS name
> resolution? Do I need to write a proper DNS client from scratch from the
> RFC? This is worse on some platforms than others.
> Also gethostbyname() is poor because it is returning a pointer to static
> data structure, and I currently must use mutexes to protect this call in
> the multithreaded code. My code must be portable across HP/UX, Irix,
> AIX, Linux, Solaris, Tru64, and Windows, so I have minimal choice about
> what functions to use (gethostbyname_r() not supported on everything)
Try calling alarm() before the call to gethostbyname(), so that it is
interrupted when the alarm timeout reaches and SIGALRM is sent to your
application.
|
|
0
|
|
|
|
Reply
|
Maxim
|
3/31/2006 6:53:15 PM
|
|
On Fri, 31 Mar 2006 15:46:11 +0000, root wrote:
> Sometimes I find that when DNS name resolution is not immediately
> successful, gethostbyname() may block for unacceptable time, causing my
> client program to become unresponsive. My question is, how should I
> implement either DNS timeouts
For how long can you block? Regardless of how low you can set your
system resolver options, anything less than 5 seconds or so is asking for
a ton of false failures.
If 5 seconds is just fine, than the SIGALRM approach as suggested
elsewhere in this thread is fine.
> or totally asynchronous DNS name
> resolution? Do I need to write a proper DNS client from scratch from the
> RFC? This is worse on some platforms than others.
I know of three: ADNS, C-Ares and UDNS. I've used the first two, and have
stuck w/ C-Ares because I've written a library suite around it. UDNS
looks interesting but I haven't found occasion to try it out (it's a late
comer).
> Also gethostbyname() is poor because it is returning a pointer to static
> data structure, and I currently must use mutexes to protect this call in
> the multithreaded code. My code must be portable across HP/UX, Irix,
> AIX, Linux, Solaris, Tru64, and Windows, so I have minimal choice about
> what functions to use (gethostbyname_r() not supported on everything)
> Thanks for any feedback on this.
gethostbyname(3) is an old, ugly interface. You should be using
getnameinfo(3)--which is thread-safe by design--and if you want a
portable implementation you can pull it out of the portable-OpenSSH
source. AIX, Linux, Solaris and I think HP/UX should definitely have it.
I'm suspect that Irix or Tru64 will since I dunno how well they've been
maintained.
- Bill
|
|
0
|
|
|
|
Reply
|
William
|
4/1/2006 1:55:32 AM
|
|
|
2 Replies
582 Views
(page loaded in 0.05 seconds)
Similiar Articles: Asynchronous DNS name resolution / DNS timeouts - comp.unix ...Sometimes I find that when DNS name resolution is not immediately successful, gethostbyname() may block for unacceptable time, causing my client pro... Network Services (DNS) not working on Solaris 9 - comp.sys.sun ...Asynchronous DNS name resolution / DNS timeouts - comp.unix ... Network Services (DNS) not working on Solaris 9 - comp.sys.sun ... Asynchronous DNS name resolution / DNS ... fcntl() - ioctlsocket() - comp.unix.programmerAsynchronous DNS name resolution / DNS timeouts 2 299 root Automount NFS on Solaris 8 Broken ? - comp.unix.solarisAsynchronous DNS name resolution / DNS timeouts - comp.unix ... Automount NFS on Solaris 8 Broken ? - comp.unix.solaris We use staight NIS (no NIS+) for mail aliases and ... nptq -p slowness - comp.protocols.time.ntpAsynchronous DNS name resolution / DNS timeouts - comp.unix ... nptq -p slowness - comp.protocols.time.ntp A named querylog shows that it's due to DNS resolver delays ... hostname of nameserver? - comp.unix.solarisSo is this machine on a network where it will be a NIS client, or should it contact a nameserver to do name resolution through DNS? > If it want my DNS then why a ... How to disable AAAA queries by resolver? - comp.unix.solaris ...... lemonde.fr. (28) (DF) We are troubleshooting some sporadic dns resolution timeout issue... ... The answers I received were that the name needs to have a trailing dot ... ntpd, boot time, and hot plugging - comp.protocols.time.ntp ...Even though we do not currently have an asynchronous ... ntpd server, there could be very nasty name resolution ... was that if you make both dependent on DNS timeouts ... [comp.publish.cdrom] CD-Recordable FAQ, Part 1/4 - comp.publish ...Archive-name: cdrom/cd-recordable/part1 Posting-Frequency: monthly Last-modified: 2008/10/09 Version: 2.71 Send corrections and updates to And... Asynchronous DNS name resolution / DNS timeouts - comp.unix ...Sometimes I find that when DNS name resolution is not immediately successful, gethostbyname() may block for unacceptable time, causing my client pro... Unix & Linux: Asynchronous DNS name resolution / DNS timeouts ...programming.itags.org: Unix & Linux question: Asynchronous DNS name resolution / DNS timeouts, created at:Wed, 07 May 2008 12:36:00 GMT with 815 bytes, last updated ... 7/21/2012 8:17:42 PM
|