Project

General

Profile

Actions

Bug #5095

closed

Resolv should call res_init()

Added by opoplawski (Orion Poplawski) over 12 years ago. Updated about 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
[ruby-core:38500]

Description

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.

Updated by drbrain (Eric Hodel) over 12 years ago

  • Status changed from Open to Rejected

Resolv is pure ruby and does not use resolver(3) to perform name lookups.

If /etc/resolv.conf has changed you should create a new Resolve::DNS instance.

Updated by daniel@rimspace.net (Daniel Pittman) about 12 years ago

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...

Actions

Also available in: Atom PDF

Like0
Like0Like0