Hi Christos, On Monday 04 May 2015 21:16:40 Christos Zoulas wrote: > 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.
Normally I would agree with you, but if the OS does not provide that functionality for any reason we still have to provide working solution from java perspective. > 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. Good point. I see that some patches to glibc to handle this issue are using lock mechanism, plus Bernd suggested to use a separate thread for this. I'll try implementing both of those variants and will return with another webrev. -- Regards, Stas