[Goodies-commits] r7526 - in xfce4-weather-plugin/trunk: . panel-plugin
Colin Leroy
colin at xfce.org
Thu Jun 11 09:27:22 CEST 2009
Author: colin
Date: 2009-06-11 07:27:22 +0000 (Thu, 11 Jun 2009)
New Revision: 7526
Modified:
xfce4-weather-plugin/trunk/ChangeLog
xfce4-weather-plugin/trunk/configure.in.in
xfce4-weather-plugin/trunk/panel-plugin/Makefile.am
xfce4-weather-plugin/trunk/panel-plugin/weather-http.c
Log:
2009-06-11 Colin Leroy <colin at colino.net>
* Fix bug #4118, "weather-plugin does not adapt to new network
configuration": use res_init() whenever /etc/resolv.conf changes.
Modified: xfce4-weather-plugin/trunk/ChangeLog
===================================================================
--- xfce4-weather-plugin/trunk/ChangeLog 2009-06-10 19:01:00 UTC (rev 7525)
+++ xfce4-weather-plugin/trunk/ChangeLog 2009-06-11 07:27:22 UTC (rev 7526)
@@ -1,3 +1,8 @@
+2009-06-11 Colin Leroy <colin at colino.net>
+
+ * Fix bug #4118, "weather-plugin does not adapt to new network
+ configuration": use res_init() whenever /etc/resolv.conf changes.
+
2007-11-18 Nick Schermer <nick at xfce.org>
* Post release bump, 0.6.3svn
Modified: xfce4-weather-plugin/trunk/configure.in.in
===================================================================
--- xfce4-weather-plugin/trunk/configure.in.in 2009-06-10 19:01:00 UTC (rev 7525)
+++ xfce4-weather-plugin/trunk/configure.in.in 2009-06-11 07:27:22 UTC (rev 7526)
@@ -65,6 +65,9 @@
XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.99.1])
XDT_CHECK_PACKAGE([LIBXML], [libxml-2.0], [2.4.0])
+AC_CHECK_LIB(resolv, res_query, [LIBRESOLV=-lresolv])
+AC_SUBST(LIBRESOLV)
+
dnl ***********************************
dnl *** Check for debugging support ***
dnl ***********************************
Modified: xfce4-weather-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/Makefile.am 2009-06-10 19:01:00 UTC (rev 7525)
+++ xfce4-weather-plugin/trunk/panel-plugin/Makefile.am 2009-06-11 07:27:22 UTC (rev 7526)
@@ -45,7 +45,8 @@
$(LIBXFCE4UTIL_LIBS) \
$(LIBXFCEGUI4_LIBS) \
$(GTK_LIBS) \
- $(LIBXML_LIBS)
+ $(LIBXML_LIBS) \
+ $(LIBRESOLV)
desktopdir = $(datadir)/xfce4/panel-plugins
desktop_in_in_files = weather.desktop.in.in
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-http.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-http.c 2009-06-10 19:01:00 UTC (rev 7525)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-http.c 2009-06-11 07:27:22 UTC (rev 7526)
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <errno.h>
#include <netdb.h>
#include <fcntl.h>
@@ -30,6 +31,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <netinet/in.h>
+#include <resolv.h>
#include <glib.h>
#include <gtk/gtk.h>
@@ -118,7 +120,25 @@
return FALSE;
}
+static void refresh_resolvers(void)
+{
+#ifdef G_OS_UNIX
+ static time_t resolv_conf_changed = (time_t)NULL;
+ struct stat s;
+ /* This makes the glibc re-read resolv.conf, if it changed
+ * since our startup.
+ * Why doesn't the glibc do it by itself?
+ */
+ if (stat("/etc/resolv.conf", &s) == 0) {
+ if (s.st_mtime > resolv_conf_changed) {
+ resolv_conf_changed = s.st_mtime;
+ res_init();
+ }
+ } /* else
+ we'll have bigger problems. */
+#endif /*G_OS_UNIX*/
+}
static gboolean
weather_http_receive_data_idle (gpointer user_data)
@@ -135,6 +155,9 @@
/* set the current time */
g_get_current_time (&timeout);
+ /* force the libc to get resolvers right, if they changed for some reason */
+ refresh_resolvers();
+
/* try to get the hostname */
host = gethostbyname (connection->proxy_host ? connection->proxy_host : connection->hostname);
if (G_UNLIKELY (host == NULL))
More information about the Goodies-commits
mailing list