summary refs log tree commit diff
path: root/nscd/hstcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'nscd/hstcache.c')
-rw-r--r--nscd/hstcache.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index 4333917ba0..51e2273960 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -1,5 +1,5 @@
 /* Cache handling for host lookup.
-   Copyright (C) 1998-2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1998-2008, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -80,7 +80,7 @@ static const hst_response_header notfound =
 static void
 cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	      const void *key, struct hostent *hst, uid_t owner,
-	      struct hashentry *he, struct datahead *dh, int errval,
+	      struct hashentry *const he, struct datahead *dh, int errval,
 	      int32_t ttl)
 {
   bool all_written = true;
@@ -120,7 +120,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	    all_written = false;
 
 	  dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
-				   IDX_result_data);
+				   1);
 	  /* If we cannot permanently store the result, so be it.  */
 	  if (dataset != NULL)
 	    {
@@ -150,9 +150,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 			 + sizeof (struct dataset) + req->key_len, MS_ASYNC);
 		}
 
-	      /* Now get the lock to safely insert the records.  */
-	      pthread_rwlock_rdlock (&db->lock);
-
 	      (void) cache_add (req->type, &dataset->strdata, req->key_len,
 				&dataset->head, true, db, owner, he == NULL);
 
@@ -162,8 +159,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	      if (dh != NULL)
 		dh->usable = false;
 	    }
-	  else
-	    ++db->head->addfailed;
 	}
     }
   else
@@ -221,13 +216,8 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	 questionable whether it is worthwhile complicating the cache
 	 handling just for handling such a special case. */
       if (he == NULL && h_addr_list_cnt == 1)
-	{
-	  dataset = (struct dataset *) mempool_alloc (db,
-						      total + req->key_len,
-						      IDX_result_data);
-	  if (dataset == NULL)
-	    ++db->head->addfailed;
-	}
+	dataset = (struct dataset *) mempool_alloc (db, total + req->key_len,
+						    1);
 
       if (dataset == NULL)
 	{
@@ -316,7 +306,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 		  struct dataset *newp
 		    = (struct dataset *) mempool_alloc (db,
 							total + req->key_len,
-							IDX_result_data);
+							1);
 		  if (newp != NULL)
 		    {
 		      /* Adjust pointers into the memory block.  */
@@ -329,8 +319,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 		      dataset = memcpy (newp, dataset, total + req->key_len);
 		      alloca_used = false;
 		    }
-		  else
-		    ++db->head->addfailed;
 		}
 
 	      /* Mark the old record as obsolete.  */
@@ -400,9 +388,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	  addr_list_type = (hst->h_length == NS_INADDRSZ
 			    ? GETHOSTBYADDR : GETHOSTBYADDRv6);
 
-	  /* Now get the lock to safely insert the records.  */
-	  pthread_rwlock_rdlock (&db->lock);
-
 	  /* NB: the following code is really complicated.  It has
 	     seemlingly duplicated code paths which do the same.  The
 	     problem is that we always must add the hash table entry