[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r6356 - in /fsf/trunk/libc: ChangeLog nscd/connections.c sysdeps/posix/getaddrinfo.c
- To: commits@xxxxxxxxxx
- Subject: [commits] r6356 - in /fsf/trunk/libc: ChangeLog nscd/connections.c sysdeps/posix/getaddrinfo.c
- From: eglibc@xxxxxxxxxx
- Date: Sat, 14 Jun 2008 07:04:27 -0000
Author: eglibc
Date: Sat Jun 14 00:04:26 2008
New Revision: 6356
Log:
Import glibc-mainline for 2008-06-14
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/nscd/connections.c
fsf/trunk/libc/sysdeps/posix/getaddrinfo.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sat Jun 14 00:04:26 2008
@@ -1,3 +1,11 @@
+2008-06-13 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * sysdeps/posix/getaddrinfo.c: Move _res_hconf_init call to a
+ better place so it is not called when nscd is used.
+
+ * nscd/connections.c: Also recognize and handle changes to the
+ resolver configuration file.
+
2008-06-12 Ulrich Drepper <drepper@xxxxxxxxxx>
* time/strftime.c: Pass reference to tzset_called around to handle
Modified: fsf/trunk/libc/nscd/connections.c
==============================================================================
--- fsf/trunk/libc/nscd/connections.c (original)
+++ fsf/trunk/libc/nscd/connections.c Sat Jun 14 00:04:26 2008
@@ -51,6 +51,7 @@
#include "nscd.h"
#include "dbg_log.h"
#include "selinux.h"
+#include <resolv/resolv.h>
#ifdef HAVE_SENDFILE
# include <kernel-features.h>
#endif
@@ -228,6 +229,9 @@
#ifdef HAVE_INOTIFY
/* Inotify descriptor. */
static int inotify_fd = -1;
+
+/* Watch descriptor for resolver configuration file. */
+static int resolv_conf_descr = -1;
#endif
/* Number of times clients had to wait. */
@@ -824,7 +828,7 @@
if (dbs[cnt].check_file)
{
#ifdef HAVE_INOTIFY
- if (inotify_fd == -1
+ if (inotify_fd < 0
|| (dbs[cnt].inotify_descr
= inotify_add_watch (inotify_fd, dbs[cnt].filename,
IN_DELETE_SELF | IN_MODIFY)) < 0)
@@ -845,6 +849,14 @@
dbs[cnt].file_mtime = st.st_mtime;
}
}
+
+#ifdef HAVE_INOTIFY
+ if (cnt == hstdb && inotify_fd >= -1)
+ /* We also monitor the resolver configuration file. */
+ resolv_conf_descr = inotify_add_watch (inotify_fd,
+ _PATH_RESCONF,
+ IN_DELETE_SELF | IN_MODIFY);
+#endif
}
/* Create the socket. */
@@ -1798,6 +1810,7 @@
{
if (conns[1].revents != 0)
{
+ bool done[lastdb] = { false, };
union
{
struct inotify_event i;
@@ -1810,12 +1823,21 @@
{
/* Check which of the files changed. */
for (size_t dbcnt = 0; dbcnt < lastdb; ++dbcnt)
- if (inev.i.wd == dbs[dbcnt].inotify_descr)
+ if (!done[dbcnt]
+ && (inev.i.wd == dbs[dbcnt].inotify_descr
+ || (dbcnt == hstdb
+ && inev.i.wd == resolv_conf_descr)))
{
- pthread_mutex_trylock (&dbs[dbcnt].prune_lock);
+ if (dbcnt == hstdb
+ && inev.i.wd == resolv_conf_descr)
+ res_init ();
+
+ pthread_mutex_lock (&dbs[dbcnt].prune_lock);
dbs[dbcnt].clear_cache = 1;
pthread_mutex_unlock (&dbs[dbcnt].prune_lock);
pthread_cond_signal (&dbs[dbcnt].prune_cond);
+
+ done[dbcnt] = true;
break;
}
}
Modified: fsf/trunk/libc/sysdeps/posix/getaddrinfo.c
==============================================================================
--- fsf/trunk/libc/sysdeps/posix/getaddrinfo.c (original)
+++ fsf/trunk/libc/sysdeps/posix/getaddrinfo.c Sat Jun 14 00:04:26 2008
@@ -684,6 +684,9 @@
"dns [!UNAVAIL=return] files",
&nip);
+ /* Initialize configurations. */
+ if (__builtin_expect (!_res_hconf.initialized, 0))
+ _res_hconf_init ();
if (__res_maybe_init (&_res, 0) == -1)
no_more = 1;
@@ -882,9 +885,6 @@
atr->addr[0] = htonl (INADDR_LOOPBACK);
}
}
-
- if (pai == NULL)
- return 0;
{
struct gaih_servtuple *st2;
@@ -2091,10 +2091,6 @@
if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
return EAI_BADFLAGS;
- /* Initialize configurations. */
- if (__builtin_expect (!_res_hconf.initialized, 0))
- _res_hconf_init ();
-
struct in6addrinfo *in6ai = NULL;
size_t in6ailen = 0;
bool seen_ipv4 = false;
@@ -2149,11 +2145,7 @@
else
pservice = NULL;
- struct addrinfo **end;
- if (pai)
- end = &p;
- else
- end = NULL;
+ struct addrinfo **end = &p;
unsigned int naddrs = 0;
if (hints->ai_family == AF_UNSPEC || hints->ai_family == AF_INET
@@ -2167,12 +2159,11 @@
return -(last_i & GAIH_EAI);
}
- if (end)
- while (*end)
- {
- end = &((*end)->ai_next);
- ++nresults;
- }
+ while (*end)
+ {
+ end = &((*end)->ai_next);
+ ++nresults;
+ }
}
else
{
@@ -2368,9 +2359,6 @@
return 0;
}
- if (pai == NULL && last_i == 0)
- return 0;
-
return last_i ? -(last_i & GAIH_EAI) : EAI_NONAME;
}
libc_hidden_def (getaddrinfo)