GNOME Bugzilla – Bug 584246
GResolver needs to call res_init() when network state changes
Last modified: 2009-08-19 16:10:05 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.)
sounds good to me. stat() seems better as it doesn't imply requiring a mainloop.
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().
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.
ok. committed