After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 584246 - GResolver needs to call res_init() when network state changes
GResolver needs to call res_init() when network state changes
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: network
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-05-30 00:00 UTC by Dan Winship
Modified: 2009-08-19 16:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Re-run res_init() when resolv.conf changes (12.40 KB, patch)
2009-08-10 22:00 UTC, Dan Winship
none Details | Review

Description Dan Winship 2009-05-30 00:00:08 UTC
As seen in bug 532367 / bug 579092, we need to call res_init() if resolv.conf changes, to notice the new nameserver addresses. (We need to do this at the GResolver level rather than just saying the apps should call res_init() themselves, because in the case of GUnixResolver, calling res_init() in the main process isn't going to do anything to the forked-off resolver processes.) (Also, I'm assuming this is a unix-only thing and we don't need to do anything special on Windows at all.)

Assuming we don't want to wait for D-Bus support in glib so we can listen for the NetworkManager signal, we could either stat() /etc/resolv.conf on each call, or else set up a GFileMonitor on it. Each is wasteful in its own way, but I think I prefer the former.

I'm working on a patch, though the GUnixResolver bits are a bit awkward and will require some testing. (We need to free the existing _g_asyncns_t and create a new one, but the old one may have queries pending on it, so we need to wait until they complete before freeing it.)
Comment 1 Alexander Larsson 2009-06-01 18:13:58 UTC
sounds good to me. stat() seems better as it doesn't imply requiring a mainloop.
Comment 2 Dan Winship 2009-08-10 22:00:09 UTC
Created attachment 140384 [details] [review]
Re-run res_init() when resolv.conf changes

libc caches the contents of resolv.conf, so if it changes (eg, because
the network state changed), we need re-run res_init().
Comment 3 Alexander Larsson 2009-08-19 12:48:46 UTC
Looks ok to me, but really I consider you more or less maintainer of this stuff, you don't need my OK to fix it.
Comment 4 Dan Winship 2009-08-19 16:10:05 UTC
ok. committed