* nscd/connections.c (dbs): Use
	PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP for .lock.
	Pretty printing.

	* nscd/hstcache.c (cache_addhst): Don't automatically add IPv6
	address.  Suggested by Philip Blundell.
This commit is contained in:
Ulrich Drepper 2000-01-19 00:10:36 +00:00
parent c7e85d0c08
commit 9e56c380bc
5 changed files with 27 additions and 25 deletions

View File

@ -1,5 +1,12 @@
2000-01-18 Ulrich Drepper <drepper@cygnus.com> 2000-01-18 Ulrich Drepper <drepper@cygnus.com>
* nscd/connections.c (dbs): Use
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP for .lock.
Pretty printing.
* nscd/hstcache.c (cache_addhst): Don't automatically add IPv6
address. Suggested by Philip Blundell.
* posix/TESTS: Fix expected result for test cases with * with no * posix/TESTS: Fix expected result for test cases with * with no
leading expression. leading expression.

View File

@ -315,8 +315,8 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
else else
{ {
/* Put a bad page at the bottom of the stack */ /* Put a bad page at the bottom of the stack */
guardaddr = (void *)new_thread_bottom - stacksize;
guardsize = attr->__guardsize; guardsize = attr->__guardsize;
guardaddr = (void *)new_thread_bottom - guardsize;
if (mmap ((caddr_t) guardaddr, guardsize, 0, MAP_FIXED, -1, 0) if (mmap ((caddr_t) guardaddr, guardsize, 0, MAP_FIXED, -1, 0)
== MAP_FAILED) == MAP_FAILED)
{ {
@ -512,7 +512,7 @@ static void pthread_free(pthread_descr th)
/* One fewer threads in __pthread_handles */ /* One fewer threads in __pthread_handles */
__pthread_handles_num--; __pthread_handles_num--;
/* Destroy read lock list, and list of free read lock structures. /* Destroy read lock list, and list of free read lock structures.
If the former is not empty, it means the thread exited while If the former is not empty, it means the thread exited while
holding read locks! */ holding read locks! */

View File

@ -43,6 +43,11 @@ __BEGIN_DECLS
{ {0, 0}, 0, NULL, NULL, NULL, \ { {0, 0}, 0, NULL, NULL, NULL, \
PTHREAD_RWLOCK_DEFAULT_NP, PTHREAD_PROCESS_PRIVATE } PTHREAD_RWLOCK_DEFAULT_NP, PTHREAD_PROCESS_PRIVATE }
#endif #endif
#ifdef __USE_GNU
# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
{ {0, 0}, 0, NULL, NULL, NULL, \
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, PTHREAD_PROCESS_PRIVATE }
#endif
/* Values for attributes. */ /* Values for attributes. */

View File

@ -69,7 +69,7 @@ const char *serv2str[LASTREQ] =
static struct database dbs[lastdb] = static struct database dbs[lastdb] =
{ {
[pwddb] = { [pwddb] = {
lock: PTHREAD_RWLOCK_INITIALIZER, lock: PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP,
enabled: 0, enabled: 0,
check_file: 1, check_file: 1,
filename: "/etc/passwd", filename: "/etc/passwd",
@ -79,7 +79,7 @@ static struct database dbs[lastdb] =
negtimeout: 20 negtimeout: 20
}, },
[grpdb] = { [grpdb] = {
lock: PTHREAD_RWLOCK_INITIALIZER, lock: PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP,
enabled: 0, enabled: 0,
check_file: 1, check_file: 1,
filename: "/etc/group", filename: "/etc/group",
@ -89,7 +89,7 @@ static struct database dbs[lastdb] =
negtimeout: 60 negtimeout: 60
}, },
[hstdb] = { [hstdb] = {
lock: PTHREAD_RWLOCK_INITIALIZER, lock: PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP,
enabled: 0, enabled: 0,
check_file: 1, check_file: 1,
filename: "/etc/hosts", filename: "/etc/hosts",
@ -461,11 +461,11 @@ nscd_run (void *p)
#endif #endif
/* It should not be possible to crash the nscd with a silly /* It should not be possible to crash the nscd with a silly
request (i.e., a terribly large key. We limit the size request (i.e., a terribly large key). We limit the size
to 1kb. */ to 1kb. */
if (req.key_len < 0 || req.key_len > 1024) if (req.key_len < 0 || req.key_len > 1024)
{ {
dbg_log (_("key length in request too long: %Zd"), req.key_len); dbg_log (_("key length in request too long: %zd"), req.key_len);
close (fd); close (fd);
continue; continue;
} }
@ -504,7 +504,7 @@ nscd_run (void *p)
void void
start_threads (void) start_threads (void)
{ {
long i; long int i;
pthread_attr_t attr; pthread_attr_t attr;
pthread_t th; pthread_t th;

View File

@ -1,5 +1,5 @@
/* Cache handling for host lookup. /* Cache handling for host lookup.
Copyright (C) 1998, 1999 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@ -30,13 +30,11 @@
#include <unistd.h> #include <unistd.h>
#include <libintl.h> #include <libintl.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <arpa/nameser.h>
#include "nscd.h" #include "nscd.h"
#include "dbg_log.h" #include "dbg_log.h"
/* Get implementation for some internal functions. */
#include "../resolv/mapv4v6addr.h"
/* This is the standard reply in case the service is disabled. */ /* This is the standard reply in case the service is disabled. */
static const hst_response_header disabled = static const hst_response_header disabled =
@ -160,8 +158,8 @@ cache_addhst (struct database *db, int fd, request_header *req, void *key,
+ h_name_len + h_name_len
+ h_aliases_cnt * sizeof (size_t) + h_aliases_cnt * sizeof (size_t)
+ h_addr_list_cnt * (hst->h_length + h_addr_list_cnt * (hst->h_length
+ (hst->h_length == INADDRSZ + (hst->h_length == NS_INADDRSZ
? IN6ADDRSZ : 0))); ? NS_IN6ADDRSZ : 0)));
data = (struct hostdata *) malloc (total + req->key_len); data = (struct hostdata *) malloc (total + req->key_len);
if (data == NULL) if (data == NULL)
@ -186,14 +184,6 @@ cache_addhst (struct database *db, int fd, request_header *req, void *key,
for (cnt = 0; cnt < h_addr_list_cnt; ++cnt) for (cnt = 0; cnt < h_addr_list_cnt; ++cnt)
cp = mempcpy (cp, hst->h_addr_list[cnt], hst->h_length); cp = mempcpy (cp, hst->h_addr_list[cnt], hst->h_length);
/* And the generated IPv6 addresses if necessary. */
if (hst->h_length == INADDRSZ)
{
/* Generate the IPv6 addresses. */
for (cnt = 0; cnt < h_addr_list_cnt; cp += IN6ADDRSZ, ++cnt)
map_v4v6_address (hst->h_addr_list[cnt], cp);
}
/* Then the aliases. */ /* Then the aliases. */
aliases = cp; aliases = cp;
for (cnt = 0; cnt < h_aliases_cnt; ++cnt) for (cnt = 0; cnt < h_aliases_cnt; ++cnt)
@ -214,7 +204,7 @@ cache_addhst (struct database *db, int fd, request_header *req, void *key,
unnecessarily let the receiver wait. */ unnecessarily let the receiver wait. */
written = write (fd, data, total); written = write (fd, data, total);
addr_list_type = (hst->h_length == INADDRSZ addr_list_type = (hst->h_length == NS_INADDRSZ
? GETHOSTBYADDR : GETHOSTBYADDRv6); ? GETHOSTBYADDR : GETHOSTBYADDRv6);
/* Compute the timeout time. */ /* Compute the timeout time. */
@ -349,7 +339,7 @@ addhstbyaddr (struct database *db, int fd, request_header *req,
seteuid (uid); seteuid (uid);
} }
while (__gethostbyaddr_r (key, INADDRSZ, AF_INET, &resultbuf, buffer, while (__gethostbyaddr_r (key, NS_INADDRSZ, AF_INET, &resultbuf, buffer,
buflen, &hst, &h_errno) != 0 buflen, &hst, &h_errno) != 0
&& h_errno == NETDB_INTERNAL && h_errno == NETDB_INTERNAL
&& errno == ERANGE) && errno == ERANGE)
@ -438,7 +428,7 @@ addhstbyaddrv6 (struct database *db, int fd, request_header *req,
seteuid (uid); seteuid (uid);
} }
while (__gethostbyaddr_r (key, IN6ADDRSZ, AF_INET6, &resultbuf, while (__gethostbyaddr_r (key, NS_IN6ADDRSZ, AF_INET6, &resultbuf,
buffer, buflen, &hst, &h_errno) != 0 buffer, buflen, &hst, &h_errno) != 0
&& h_errno == NETDB_INTERNAL && h_errno == NETDB_INTERNAL
&& errno == ERANGE) && errno == ERANGE)