From: Colin Leroy Date: Wed, 30 Mar 2005 16:11:22 +0000 (+0000) Subject: 2005-03-30 [colin] 1.9.6cvs13 X-Git-Tag: rel_1_9_9~51 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=bcfdfaf9b30a20ab826faf0c081396b079cfcafc 2005-03-30 [colin] 1.9.6cvs13 * src/common/socket.c Force the glibc to read resolv.conf again when it has changed. Should fix issues when changing networks on a laptop and not restarting sylpheed. (I'll check tomorrow if a similar hack has to be done if the route changes). --- diff --git a/ChangeLog-gtk2.claws b/ChangeLog-gtk2.claws index 0b5463471..2a79f5ec9 100644 --- a/ChangeLog-gtk2.claws +++ b/ChangeLog-gtk2.claws @@ -1,3 +1,12 @@ +2005-03-30 [colin] 1.9.6cvs13 + + * src/common/socket.c + Force the glibc to read resolv.conf again when + it has changed. Should fix issues when changing + networks on a laptop and not restarting sylpheed. + (I'll check tomorrow if a similar hack has to be + done if the route changes). + 2005-03-30 [paul] 1.9.6cvs12 partial sync with main: diff --git a/PATCHSETS b/PATCHSETS index e569fc0a7..59b78330e 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -429,3 +429,4 @@ ( cvs diff -u -r 1.100.2.14 -r 1.100.2.15 AUTHORS; cvs diff -u -r 1.2504.2.55 -r 1.2504.2.56 ChangeLog.claws; cvs diff -u -r 1.382.2.113 -r 1.382.2.114 src/compose.c; cvs diff -u -r 1.9.2.10 -r 1.9.2.11 src/gtk/gtkaspell.c; ) > 1.9.6cvs10.patchset ( cvs diff -u -r 1.16.2.14 -r 1.16.2.15 src/msgcache.c; cvs diff -u -r 1.5 -r 1.6 src/msgcache.h; ) > 1.9.6cvs11.patchset ( cvs diff -u -r 1.12.2.20 -r 1.12.2.21 src/action.c; cvs diff -u -r 1.5.10.7 -r 1.5.10.8 src/addrgather.c; cvs diff -u -r 1.6.10.4 -r 1.6.10.5 src/addrharvest.c; cvs diff -u -r 1.2.4.5 -r 1.2.4.6 src/browseldap.c; cvs diff -u -r 1.382.2.114 -r 1.382.2.115 src/compose.c; cvs diff -u -r 1.3.2.7 -r 1.3.2.8 src/exphtmldlg.c; cvs diff -u -r 1.1.4.9 -r 1.1.4.10 src/expldifdlg.c; cvs diff -u -r 1.12.2.6 -r 1.12.2.7 src/html.c; cvs diff -u -r 1.3.2.1 -r 1.3.2.2 src/html.h; cvs diff -u -r 1.4.12.4 -r 1.4.12.5 src/importmutt.c; cvs diff -u -r 1.1.14.4 -r 1.1.14.5 src/importpine.c; cvs diff -u -r 1.115.2.30 -r 1.115.2.31 src/main.c; cvs diff -u -r 1.274.2.32 -r 1.274.2.33 src/mainwindow.c; cvs diff -u -r 1.94.2.48 -r 1.94.2.49 src/messageview.c; cvs diff -u -r 1.204.2.33 -r 1.204.2.34 src/prefs_common.c; cvs diff -u -r 1.103.2.13 -r 1.103.2.14 src/prefs_common.h; cvs diff -u -r 1.47.2.17 -r 1.47.2.18 src/procheader.c; cvs diff -u -r 1.395.2.61 -r 1.395.2.62 src/summaryview.c; cvs diff -u -r 1.68.2.6 -r 1.68.2.7 src/summaryview.h; cvs diff -u -r 1.96.2.50 -r 1.96.2.51 src/textview.c; cvs diff -u -r 1.36.2.26 -r 1.36.2.27 src/common/utils.c; cvs diff -u -r 1.5.2.10 -r 1.5.2.11 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.8 -r 1.4.2.9 src/gtk/gtkutils.h; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/pgpmime/passphrase.c; ) > 1.9.6cvs12.patchset +( cvs diff -u -r 1.13.2.10 -r 1.13.2.11 src/common/socket.c; ) > 1.9.6cvs13.patchset diff --git a/configure.ac b/configure.ac index 55706c376..719785d09 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=9 MICRO_VERSION=6 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=12 +EXTRA_VERSION=13 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/common/socket.c b/src/common/socket.c index 45e96963b..3f6ee3e11 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -26,9 +26,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -161,6 +163,25 @@ gint sock_set_io_timeout(guint sec) return 0; } +void refresh_resolvers(void) +{ + 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. Maybe that should be #ifdef'ed, I don't + * know if it'd work on BSDs. + * 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. */ +} + gint fd_connect_unix(const gchar *path) { gint sock; @@ -403,7 +424,7 @@ static gint sock_connect_with_timeout(gint sock, { gint ret; void (*prev_handler)(gint); - + alarm(0); prev_handler = signal(SIGALRM, timeout_handler); if (sigsetjmp(jmpenv, 1)) { @@ -426,7 +447,7 @@ struct hostent *my_gethostbyname(const gchar *hostname) { struct hostent *hp; void (*prev_handler)(gint); - + alarm(0); prev_handler = signal(SIGALRM, timeout_handler); if (sigsetjmp(jmpenv, 1)) { @@ -483,6 +504,8 @@ static gint sock_connect_by_hostname(gint sock, const gchar *hostname, ad.sin_family = AF_INET; ad.sin_port = htons(port); + refresh_resolvers(); + if (!my_inet_aton(hostname, &ad.sin_addr)) { if ((hp = my_gethostbyname(hostname)) == NULL) { fprintf(stderr, "%s: unknown host.\n", hostname); @@ -510,6 +533,8 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port) struct addrinfo hints, *res, *ai; gchar port_str[6]; + refresh_resolvers(); + memset(&hints, 0, sizeof(hints)); /* hints.ai_flags = AI_CANONNAME; */ hints.ai_family = AF_UNSPEC; @@ -867,6 +892,8 @@ static SockLookupData *sock_get_address_info_async(const gchar *hostname, SockLookupData *lookup_data = NULL; gint pipe_fds[2]; pid_t pid; + + refresh_resolvers(); if (pipe(pipe_fds) < 0) { perror("pipe");