]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(no commit message)
authorAlexandre Oliva <aoliva@redhat.com>
Sun, 1 Jun 2014 19:51:44 +0000 (16:51 -0300)
committerAlexandre Oliva <aoliva@redhat.com>
Fri, 7 Nov 2014 09:18:53 +0000 (07:18 -0200)
nscd/hstcache.c

index d4f1ad2fc478030c9ce0a1ff6cbda9892ae8a8c3..d7908d9bff526b1a0cbfe26e4a9d6279099a0357 100644 (file)
@@ -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