Cache network interface information
[platform/upstream/glibc.git] / nscd / hstcache.c
index 101ad2a..4d68ade 100644 (file)
@@ -141,10 +141,15 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
                                        MSG_NOSIGNAL)) != total)
            all_written = false;
 
-         dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
-                                  1);
          /* If we cannot permanently store the result, so be it.  */
-         if (dataset != NULL)
+         if (__builtin_expect (db->negtimeout == 0, 0))
+           {
+             /* Mark the old entry as obsolete.  */
+             if (dh != NULL)
+               dh->usable = false;
+           }
+         else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
+                                                 + req->key_len), 1)) != NULL)
            {
              dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
              dataset->head.recsize = total;
@@ -190,7 +195,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
       size_t h_aliases_cnt;
       uint32_t *h_aliases_len;
       size_t h_addr_list_cnt;
-      int addr_list_type;
       char *addresses;
       char *aliases;
       char *key_copy = NULL;
@@ -409,9 +413,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
                     + total + req->key_len, MS_ASYNC);
            }
 
-         addr_list_type = (hst->h_length == NS_INADDRSZ
-                           ? GETHOSTBYADDR : GETHOSTBYADDRv6);
-
          /* 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