From 9caf4f1c67e137804f4bca9eb65bd0132424022a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 15 Jan 2003 10:52:50 +0000 Subject: Update. * nscd/nscd_getpw_r.c (nscd_getpw_r): Consolidate writing of the request with one writev call. Protect all read calls with TEMP_FAILURE_RETRY. * nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise. * nscd/nscd_gethst_r.c (nscd_gethst_r): Likewise. * nscd/hstcache.c: Use extend_alloca to reallocate alloca'd buffer. Protect writev calls with TEMP_FAILURE_RETRY. * nscd/grpcache.c: Likewise. * nscd/pwdcache.c: Likewise. --- nscd/grpcache.c | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'nscd/grpcache.c') diff --git a/nscd/grpcache.c b/nscd/grpcache.c index 41a36dc674..a8b33cab1a 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -1,5 +1,5 @@ /* Cache handling for group lookup. - Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1998. @@ -18,6 +18,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include #include #include #include @@ -95,7 +96,7 @@ cache_addgr (struct database *db, int fd, request_header *req, void *key, total = sizeof (notfound); - written = writev (fd, &iov_notfound, 1); + written = TEMP_FAILURE_RETRY (writev (fd, &iov_notfound, 1)); copy = malloc (req->key_len); if (copy == NULL) @@ -227,10 +228,11 @@ addgrbyname (struct database *db, int fd, request_header *req, { char *old_buffer = buffer; errno = 0; - buflen += 1024; +#define INCR 1024 if (__builtin_expect (buflen > 32768, 0)) { + buflen += INCR; buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen); if (buffer == NULL) { @@ -244,19 +246,9 @@ addgrbyname (struct database *db, int fd, request_header *req, use_malloc = true; } else - { - buffer = (char *) alloca (buflen); -#if _STACK_GROWS_DOWN - if (buffer + buflen == old_buffer) - buflen = 2 * buflen - 1024; -#elif _STACK_GROWS_UP - if (old_buffer + buflen - 1024 == buffer) - { - buffer = old_buffer; - buflen = 2 * buflen - 1024; - } -#endif - } + /* Allocate a new buffer on the stack. If possible combine it + with the previously allocated buffer. */ + buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR); } if (secure[grpdb]) @@ -309,10 +301,10 @@ addgrbygid (struct database *db, int fd, request_header *req, { char *old_buffer = buffer; errno = 0; - buflen += 1024; if (__builtin_expect (buflen > 32768, 0)) { + buflen += INCR; buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen); if (buffer == NULL) { @@ -326,19 +318,9 @@ addgrbygid (struct database *db, int fd, request_header *req, use_malloc = true; } else - { - buffer = (char *) alloca (buflen); -#if _STACK_GROWS_DOWN - if (buffer + buflen == old_buffer) - buflen = 2 * buflen - 1024; -#elif _STACK_GROWS_UP - if (old_buffer + buflen - 1024 == buffer) - { - buffer = old_buffer; - buflen = 2 * buflen - 1024; - } -#endif - } + /* Allocate a new buffer on the stack. If possible combine it + with the previously allocated buffer. */ + buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR); } if (secure[grpdb]) -- cgit v1.2.3