Issue #5095 has been updated by Daniel Pittman.


Hi.  I only recently noticed this issue had been filed in response to an issue we had in Puppet.

Sadly, the subject is a little misleading, which led to the ticket being closed, when the actual issue is quite real.

We have this problem because we use `Net::HTTP` to make a request, which uses `TCPSocket`, which in turn uses `sock_addrinfo` down in the C code under Ruby 1.8.7 to resolve the name to an address.  I have not actually dug into the implementation of that, but it certainly doesn't look to be using the `Resolv` library.

Unfortunately, just loading `resolv-replace` wouldn't be enough, either: that uses Resolv to do the lookup, which is great, but it uses the class method family `Resolv.get*` to obtain the addresses.  They, in turn, use `Resolv::DefaultResolver`, which is created at load time for the `resolv` code and never replaced - and neither is there a mechanism for us to replace that at runtime without hacking directly into code in that class and, obviously, breaking if a newer version of Ruby changed the structure.

It would, ultimately, be great if the C implementation could support platform things like `res_init()` at the appropriate time, but even a fallback where we could use the Ruby level `Resolv` library without having to rewrite it ourselves or hack into the internals would be OK...


----------------------------------------
Bug #5095: Resolv should call res_init()
https://bugs.ruby-lang.org/issues/5095

Author: Orion Poplawski
Status: Rejected
Priority: Normal
Assignee: 
Category: lib
Target version: 
ruby -v: ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]


At least on linux, when /etc/resolv.conf changes it is necessary to call res_init() to load the new resolver information.  The Resolv library does not call res_init() and there appears to be no way to call it.

See http://projects.puppetlabs.com/issues/2776 for an example of the problem.


-- 
http://bugs.ruby-lang.org/