On May 4,  5:38pm, sbaid...@redhat.com (Stanislav Baiduzhyi) wrote:
-- Subject: DNS resolution fails after resolv.conf update

| Hi All,
| 
| We are facing an issue with DNS server caching on RHEL-based distros: after 
| the update of resolv.conf java application cannot resolve the hosts any more.
| 
| Reproducer is very simple:
| 1. Clean /etc/resolv.conf or connect to vpn and use vpn-only nameserver.
| 2. Launch the minimal java app [1].
| 3. Restore the /etc/resolv.conf or disconnect from vpn (/etc/resolv.conf 
| should be updated with accessible nameserver at this moment).
| 4. Notice that name resolution continues to fail.
| 
| I've prepared a small webrev that fixes the issue [2], but would like to hear 
| some ideas/criticism first. If the patch looks ok to everyone, please create 
| an issue for this, and I will submit it for approval/sponsorship.
| 
| [1]: 
| 
https://e61b615da46327c9050d624b0a3783ba21c6b125.googledrive.com/host/0B5Kp-cB1sXJrfnZ4NHZ0S1V3UTJZcDFra3RwUFZjQXY5WVZzUkwtTTd0Z1IyR1JmbDZPSVk/resolvconf-reinit/ResolvingHost.java
| 
| [2]:
| 
https://e61b615da46327c9050d624b0a3783ba21c6b125.googledrive.com/host/0B5Kp-cB1sXJrfnZ4NHZ0S1V3UTJZcDFra3RwUFZjQXY5WVZzUkwtTTd0Z1IyR1JmbDZPSVk/resolvconf-reinit/

I don't think it is the job of the JDK to handle this. For example
many systems (like NetBSD for example) work just fine without
needing this, because their libc keeps track of resolv.conf changes.

On other systems, calling res_init() does not even work properly
because the getaddrinfo() call uses the re-entrant API to be thread
safe (res_ninit()/res_nsend() etc.).

Additionally res_init() isn't even thread-safe (on most implementations),
so multiple threads calling it at the same time can corrupt the
resolver state.

Fixing it the way you propose means that every application that
does hostname/address resolution would need to be modified in order
to work.

christos

Reply via email to