]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* nscd/cache.c (cache_add): Before returning with failure and this
authorUlrich Drepper <drepper@redhat.com>
Sun, 11 May 2008 03:03:14 +0000 (03:03 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 11 May 2008 03:03:14 +0000 (03:03 +0000)
is the first use of the record, mark it as unusable.
* nscd/aicache.c: Don't touch the dataset after cache_add returns
reporting a failure.
* nscd/grpcache.c: Likewise
* nscd/hstcache.c: Likewise.
* nscd/initgrcache.c: Likewise.
* nscd/pwdcache.c: Likewise.
* nscd/servicecache.c: Likewise.

ChangeLog
nscd/aicache.c
nscd/grpcache.c
nscd/hstcache.c
nscd/initgrcache.c
nscd/pwdcache.c
nscd/servicescache.c

index 2385b10f77c8b0854c91ad4c78a34d8ad3b25862..fe91d7e408009c43dd5708b5e0e038b7452dc25f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-05-10  Ulrich Drepper  <drepper@redhat.com>
+
+       * nscd/cache.c (cache_add): Before returning with failure and this
+       is the first use of the record, mark it as unusable.
+       * nscd/aicache.c: Don't touch the dataset after cache_add returns
+       reporting a failure.
+       * nscd/grpcache.c: Likewise
+       * nscd/hstcache.c: Likewise.
+       * nscd/initgrcache.c: Likewise.
+       * nscd/pwdcache.c: Likewise.
+       * nscd/servicecache.c: Likewise.
+
 2008-05-10  Roland McGrath  <roland@redhat.com>
 
        [BZ #6505]
index 4db3e65bd1d519bcf135295d3a79fe12388b073f..918efc9f39e0ed4f3a11d1fed381bf3e933d4d83 100644 (file)
@@ -556,10 +556,8 @@ next_nip:
       /* Now get the lock to safely insert the records.  */
       pthread_rwlock_rdlock (&db->lock);
 
-      if (cache_add (req->type, key_copy, req->key_len, &dataset->head, true,
-                    db, uid) < 0)
-       /* Ensure the data can be recovered.  */
-       dataset->head.usable = false;
+      (void) cache_add (req->type, key_copy, req->key_len, &dataset->head,
+                       true, db, uid);
 
       pthread_rwlock_unlock (&db->lock);
 
index dbc406fcbdc16dda60f2662a0248337c290f5e96..9921ae313e0851bb8af90440cbca35a1d72b48db 100644 (file)
@@ -146,10 +146,8 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
              /* Now get the lock to safely insert the records.  */
              pthread_rwlock_rdlock (&db->lock);
 
-             if (cache_add (req->type, &dataset->strdata, req->key_len,
-                            &dataset->head, true, db, owner) < 0)
-               /* Ensure the data can be recovered.  */
-               dataset->head.usable = false;
+             (void) cache_add (req->type, &dataset->strdata, req->key_len,
+                               &dataset->head, true, db, owner);
 
              pthread_rwlock_unlock (&db->lock);
 
@@ -356,12 +354,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
            {
              if (cache_add (GETGRBYGID, cp, key_offset, &dataset->head, true,
                             db, owner) < 0)
-               {
-                 /* Could not allocate memory.  Make sure the data gets
-                    discarded.  */
-                 dataset->head.usable = false;
-                 goto out;
-               }
+               goto out;
 
              first = false;
            }
@@ -370,12 +363,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
            {
              if (cache_add (GETGRBYNAME, key_copy, key_len + 1,
                             &dataset->head, true, db, owner) < 0)
-               {
-                 /* Could not allocate memory.  Make sure the data gets
-                    discarded.  */
-                 dataset->head.usable = false;
-                 goto out;
-               }
+               goto out;
 
              first = false;
            }
@@ -389,12 +377,8 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
            {
              if (req->type == GETGRBYNAME && db->propagate)
                (void) cache_add (GETGRBYGID, cp, key_offset, &dataset->head,
-                                 req->type != GETGRBYNAME, db, owner);
+                                 false, db, owner);
            }
-         else if (first)
-           /* Could not allocate memory.  Make sure the data gets
-              discarded.  */
-           dataset->head.usable = false;
 
        out:
          pthread_rwlock_unlock (&db->lock);
index b93d4188783594cb2ada5b0ef92c955ad240fb01..3ceb6715cee19c6236751413d9fbded4c77439e1 100644 (file)
@@ -155,10 +155,8 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
              /* Now get the lock to safely insert the records.  */
              pthread_rwlock_rdlock (&db->lock);
 
-             if (cache_add (req->type, &dataset->strdata, req->key_len,
-                            &dataset->head, true, db, owner) < 0)
-               /* Ensure the data can be recovered.  */
-               dataset->head.usable = false;
+             (void) cache_add (req->type, &dataset->strdata, req->key_len,
+                               &dataset->head, true, db, owner);
 
              pthread_rwlock_unlock (&db->lock);
 
@@ -409,11 +407,8 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
                  || req->type == GETHOSTBYADDR
                  || req->type == GETHOSTBYADDRv6);
 
-         if (cache_add (req->type, key_copy, req->key_len,
-                        &dataset->head, true, db, owner) < 0)
-           /* Could not allocate memory.  Make sure the
-              data gets discarded.  */
-           dataset->head.usable = false;
+         (void) cache_add (req->type, key_copy, req->key_len,
+                           &dataset->head, true, db, owner);
 
          pthread_rwlock_unlock (&db->lock);
        }
index 4d6513b5d726473c2484c8ef45bd24df58a7e755..94e909d4aebbf8478a83cb291cc4efe4629ed545 100644 (file)
@@ -230,10 +230,8 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
              /* Now get the lock to safely insert the records.  */
              pthread_rwlock_rdlock (&db->lock);
 
-             if (cache_add (req->type, key_copy, req->key_len,
-                            &dataset->head, true, db, uid) < 0)
-               /* Ensure the data can be recovered.  */
-               dataset->head.usable = false;
+             (void) cache_add (req->type, key_copy, req->key_len,
+                               &dataset->head, true, db, uid);
 
              pthread_rwlock_unlock (&db->lock);
 
@@ -399,11 +397,8 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
          /* Now get the lock to safely insert the records.  */
          pthread_rwlock_rdlock (&db->lock);
 
-         if (cache_add (INITGROUPS, cp, req->key_len, &dataset->head, true,
-                        db, uid) < 0)
-           /* Could not allocate memory.  Make sure the data gets
-              discarded.  */
-           dataset->head.usable = false;
+         (void) cache_add (INITGROUPS, cp, req->key_len, &dataset->head, true,
+                           db, uid);
 
          pthread_rwlock_unlock (&db->lock);
        }
index e1bf6e951828c2cec071d397923c5d6d594dce50..2d0a26592c806ead9f98c94c0c9195f7f8ac4270 100644 (file)
@@ -153,11 +153,8 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
              /* Now get the lock to safely insert the records.  */
              pthread_rwlock_rdlock (&db->lock);
 
-             if (cache_add (req->type, key_copy, req->key_len,
-                            &dataset->head, true, db, owner) < 0)
-               /* Ensure the data can be recovered.  */
-               dataset->head.usable = false;
-
+             (void) cache_add (req->type, key_copy, req->key_len,
+                               &dataset->head, true, db, owner);
 
              pthread_rwlock_unlock (&db->lock);
 
@@ -352,12 +349,7 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
            {
              if (cache_add (GETPWBYUID, cp, key_offset, &dataset->head, true,
                             db, owner) < 0)
-               {
-                 /* Could not allocate memory.  Make sure the data gets
-                    discarded.  */
-                 dataset->head.usable = false;
-                 goto out;
-               }
+               goto out;
 
              first = false;
            }
@@ -366,12 +358,7 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
            {
              if (cache_add (GETPWBYNAME, key_copy, key_len + 1,
                             &dataset->head, true, db, owner) < 0)
-               {
-                 /* Could not allocate memory.  Make sure the data gets
-                    discarded.  */
-                 dataset->head.usable = false;
-                 goto out;
-               }
+               goto out;
 
              first = false;
            }
@@ -384,12 +371,8 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
            {
              if (req->type == GETPWBYNAME && db->propagate)
                (void) cache_add (GETPWBYUID, cp, key_offset, &dataset->head,
-                                 req->type != GETPWBYNAME, db, owner);
+                                 false, db, owner);
            }
-         else if (first)
-           /* Could not allocate memory.  Make sure the data gets
-              discarded.  */
-           dataset->head.usable = false;
 
        out:
          pthread_rwlock_unlock (&db->lock);
index 164b6e298d4c89ba7aa44c754cf794ae1d041f6b..c6f0b47e35762c76fc7a5b9d71c1ff30e8724b0c 100644 (file)
@@ -136,10 +136,8 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req,
              /* Now get the lock to safely insert the records.  */
              pthread_rwlock_rdlock (&db->lock);
 
-             if (cache_add (req->type, &dataset->strdata, req->key_len,
-                            &dataset->head, true, db, owner) < 0)
-               /* Ensure the data can be recovered.  */
-               dataset->head.usable = false;
+             (void) cache_add (req->type, &dataset->strdata, req->key_len,
+                               &dataset->head, true, db, owner);
 
              pthread_rwlock_unlock (&db->lock);
 
@@ -332,11 +330,8 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req,
          /* Now get the lock to safely insert the records.  */
          pthread_rwlock_rdlock (&db->lock);
 
-         if (cache_add (req->type, key_copy, req->key_len,
-                        &dataset->head, true, db, owner) < 0)
-           /* Could not allocate memory.  Make sure the
-              data gets discarded.  */
-           dataset->head.usable = false;
+         (void) cache_add (req->type, key_copy, req->key_len,
+                           &dataset->head, true, db, owner);
 
          pthread_rwlock_unlock (&db->lock);
        }