diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ChangeLog.ja | 5 | ||||
-rw-r--r-- | libsylph/socket.c | 23 |
3 files changed, 33 insertions, 0 deletions
@@ -1,5 +1,10 @@ 2006-12-13 + * libsylph/socket.c: Unix: reload /etc/resolv.conf if it has been + modified. + +2006-12-13 + * libsylph/ssl.c: ssl_init(): read /etc/ssl/certs if exist. * src/main.c: call sock_init() and ssl_init() after parse_cmd_opt() for debug option. diff --git a/ChangeLog.ja b/ChangeLog.ja index cd73b445..f72006bd 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,10 @@ 2006-12-13 + * libsylph/socket.c: /etc/resolv.conf が変更されていれば再読み込み + するようにした。 + +2006-12-13 + * libsylph/ssl.c: ssl_init(): /etc/ssl/certs が存在すれば読み込む ようにした。 * src/main.c: parse_cmd_opt() の後に sock_init() と ssl_init() を diff --git a/libsylph/socket.c b/libsylph/socket.c index 3e0982d1..c79e377c 100644 --- a/libsylph/socket.c +++ b/libsylph/socket.c @@ -35,7 +35,9 @@ # include <sys/un.h> # include <netinet/in.h> # include <arpa/inet.h> +# include <resolv.h> # include <netdb.h> +# include <sys/stat.h> #endif /* G_OS_WIN32 */ #include <unistd.h> #include <stdio.h> @@ -621,6 +623,21 @@ static gint sock_connect_with_timeout(gint sock, return ret; } +static void resolver_init(void) +{ +#ifdef G_OS_UNIX + static time_t resolv_conf_mtime = 0; + struct stat s; + + if (g_stat("/etc/resolv.conf", &s) == 0 && + s.st_mtime != resolv_conf_mtime) { + debug_print("Reloading /etc/resolv.conf\n"); + resolv_conf_mtime = s.st_mtime; + res_init(); + } +#endif +} + struct hostent *my_gethostbyname(const gchar *hostname) { struct hostent *hp; @@ -684,6 +701,8 @@ static gint sock_connect_by_hostname(gint sock, const gchar *hostname, struct hostent *hp; struct sockaddr_in ad; + resolver_init(); + memset(&ad, 0, sizeof(ad)); ad.sin_family = AF_INET; ad.sin_port = htons(port); @@ -729,6 +748,8 @@ static SockDesc sock_connect_by_getaddrinfo(const gchar *hostname, gushort port) struct addrinfo hints, *res, *ai; gchar port_str[6]; + resolver_init(); + memset(&hints, 0, sizeof(hints)); /* hints.ai_flags = AI_CANONNAME; */ hints.ai_family = AF_UNSPEC; @@ -1094,6 +1115,8 @@ static SockLookupData *sock_get_address_info_async(const gchar *hostname, gint pipe_fds[2]; pid_t pid; + resolver_init(); + if (pipe(pipe_fds) < 0) { perror("pipe"); func(NULL, data); |