about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2014-06-01 16:51:44 -0300
committerAlexandre Oliva <aoliva@redhat.com>2014-11-07 07:18:53 -0200
commit91bbe1798129768e77cffecf324400fa4d31ad10 (patch)
treed96618fff091bbdc722d18e1e987c01e89760cdc
parentbc3ac8b1779e8b180762841048601b90f469d6e5 (diff)
downloadglibc-91bbe1798129768e77cffecf324400fa4d31ad10.tar.gz
glibc-91bbe1798129768e77cffecf324400fa4d31ad10.tar.xz
glibc-91bbe1798129768e77cffecf324400fa4d31ad10.zip
-rw-r--r--nscd/hstcache.c60
1 files changed, 18 insertions, 42 deletions
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index d4f1ad2fc4..d7908d9bff 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -233,12 +233,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
       bool alloca_used = false;
       dataset = NULL;
 
-      /* If the record contains more than one IP address (used for
-	 load balancing etc) don't cache the entry.  This is something
-	 the current cache handling cannot handle and it is more than
-	 questionable whether it is worthwhile complicating the cache
-	 handling just for handling such a special case. */
-      if (he == NULL && h_addr_list_cnt == 1)
+      if (he == NULL)
 	dataset = (struct dataset *) mempool_alloc (db, total + req->key_len,
 						    1);
 
@@ -312,33 +307,29 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	      /* The data has not changed.  We will just bump the
 		 timeout value.  Note that the new record has been
 		 allocated on the stack and need not be freed.  */
-	      assert (h_addr_list_cnt == 1);
 	      dh->ttl = dataset->head.ttl;
 	      dh->timeout = dataset->head.timeout;
 	      ++dh->nreloads;
 	    }
 	  else
 	    {
-	      if (h_addr_list_cnt == 1)
+	      /* We have to create a new record.  Just allocate
+		 appropriate memory and copy it.  */
+	      struct dataset *newp
+		= (struct dataset *) mempool_alloc (db,
+						    total + req->key_len,
+						    1);
+	      if (newp != NULL)
 		{
-		  /* We have to create a new record.  Just allocate
-		     appropriate memory and copy it.  */
-		  struct dataset *newp
-		    = (struct dataset *) mempool_alloc (db,
-							total + req->key_len,
-							1);
-		  if (newp != NULL)
-		    {
-		      /* Adjust pointers into the memory block.  */
-		      addresses = (char *) newp + (addresses
-						   - (char *) dataset);
-		      aliases = (char *) newp + (aliases - (char *) dataset);
-		      assert (key_copy != NULL);
-		      key_copy = (char *) newp + (key_copy - (char *) dataset);
-
-		      dataset = memcpy (newp, dataset, total + req->key_len);
-		      alloca_used = false;
-		    }
+		  /* Adjust pointers into the memory block.  */
+		  addresses = (char *) newp + (addresses
+					       - (char *) dataset);
+		  aliases = (char *) newp + (aliases - (char *) dataset);
+		  assert (key_copy != NULL);
+		  key_copy = (char *) newp + (key_copy - (char *) dataset);
+
+		  dataset = memcpy (newp, dataset, total + req->key_len);
+		  alloca_used = false;
 		}
 
 	      /* Mark the old record as obsolete.  */
@@ -386,13 +377,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	}
 
       /* Add the record to the database.  But only if it has not been
-	 stored on the stack.
-
-	 If the record contains more than one IP address (used for
-	 load balancing etc) don't cache the entry.  This is something
-	 the current cache handling cannot handle and it is more than
-	 questionable whether it is worthwhile complicating the cache
-	 handling just for handling such a special case. */
+	 stored on the stack.  */
       if (! alloca_used)
 	{
 	  /* If necessary, we also propagate the data to disk.  */
@@ -405,15 +390,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 		     + total + req->key_len, MS_ASYNC);
 	    }
 
-	  /* 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
-	     with the FIRST flag set first.  Otherwise we get dangling
-	     pointers in case memory allocation fails.  */
-	  assert (hst->h_addr_list[1] == NULL);
-
-	  /* Avoid adding names if more than one address is available.  See
-	     above for more info.  */
 	  assert (req->type == GETHOSTBYNAME
 		  || req->type == GETHOSTBYNAMEv6
 		  || req->type == GETHOSTBYADDR