diff options
Diffstat (limited to 'nscd/hstcache.c')
-rw-r--r-- | nscd/hstcache.c | 58 |
1 files changed, 17 insertions, 41 deletions
diff --git a/nscd/hstcache.c b/nscd/hstcache.c index e27ece5..99d2998 100644 --- a/nscd/hstcache.c +++ b/nscd/hstcache.c @@ -1,20 +1,22 @@ /* Cache handling for host lookup. - Copyright (C) 1998-2005, 2006 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ #include <alloca.h> #include <assert.h> @@ -36,9 +38,6 @@ #include "nscd.h" #include "dbg_log.h" -#ifdef HAVE_SENDFILE -# include <kernel-features.h> -#endif /* This is the standard reply in case the service is disabled. */ @@ -116,8 +115,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, written = total = sizeof (notfound); if (fd != -1) - written = TEMP_FAILURE_RETRY (send (fd, ¬found, total, - MSG_NOSIGNAL)); + written = TEMP_FAILURE_RETRY (write (fd, ¬found, total)); dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len); /* If we cannot permanently store the result, so be it. */ @@ -329,30 +327,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, unnecessarily keep the receiver waiting. */ assert (fd != -1); -#ifdef HAVE_SENDFILE - if (__builtin_expect (db->mmap_used, 1) && !alloca_used) - { - assert (db->wr_fd != -1); - assert ((char *) &dataset->resp > (char *) db->data); - assert ((char *) &dataset->resp - (char *) db->head - + total - <= (sizeof (struct database_pers_head) - + db->head->module * sizeof (ref_t) - + db->head->data_size)); - written = sendfileall (fd, db->wr_fd, - (char *) &dataset->resp - - (char *) db->head, total); -# ifndef __ASSUME_SENDFILE - if (written == -1 && errno == ENOSYS) - goto use_write; -# endif - } - else -# ifndef __ASSUME_SENDFILE - use_write: -# endif -#endif - written = writeall (fd, &dataset->resp, total); + written = TEMP_FAILURE_RETRY (write (fd, &dataset->resp, total)); } /* Add the record to the database. But only if it has not been @@ -478,10 +453,11 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req, { char *old_buffer = buffer; errno = 0; +#define INCR 1024 if (__builtin_expect (buflen > 32768, 0)) { - buflen *= 2; + buflen += INCR; buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen); if (buffer == NULL) { @@ -502,7 +478,7 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req, else /* Allocate a new buffer on the stack. If possible combine it with the previously allocated buffer. */ - buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen); + buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR); } #if 0 |