diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | nscd/grpcache.c | 13 | ||||
-rw-r--r-- | nscd/pwdcache.c | 13 |
3 files changed, 31 insertions, 2 deletions
@@ -1,3 +1,10 @@ +2016-06-09 Andreas Schwab <schwab@suse.de> + + [BZ #19755] + * nscd/pwdcache.c (cache_addpw): Lock prune_run_lock while adding + new entries in auto-propagate mode. + * nscd/grpcache.c (cache_addgr): Likewise. + 2016-06-09 Paul Pluzhnikov <ppluzhnikov@gmail.com> * test-skeleton.c (oom_error, xmalloc, xcalloc, xrealloc): diff --git a/nscd/grpcache.c b/nscd/grpcache.c index 38311701a7..8b9b13df16 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -205,10 +205,19 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, dataset = NULL; if (he == NULL) - dataset = (struct dataset *) mempool_alloc (db, total + n, 1); + { + /* Prevent an INVALIDATE request from pruning the data between + the two calls to cache_add. */ + if (db->propagate) + pthread_mutex_lock (&db->prune_run_lock); + dataset = (struct dataset *) mempool_alloc (db, total + n, 1); + } if (dataset == NULL) { + if (he == NULL && db->propagate) + pthread_mutex_unlock (&db->prune_run_lock); + /* We cannot permanently add the result in the moment. But we can provide the result as is. Store the data in some temporary memory. */ @@ -396,6 +405,8 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, out: pthread_rwlock_unlock (&db->lock); + if (he == NULL && db->propagate) + pthread_mutex_unlock (&db->prune_run_lock); } } diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c index 6dd6746f39..5ef8485c2a 100644 --- a/nscd/pwdcache.c +++ b/nscd/pwdcache.c @@ -198,10 +198,19 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req, dataset = NULL; if (he == NULL) - dataset = (struct dataset *) mempool_alloc (db, total + n, 1); + { + /* Prevent an INVALIDATE request from pruning the data between + the two calls to cache_add. */ + if (db->propagate) + pthread_mutex_lock (&db->prune_run_lock); + dataset = (struct dataset *) mempool_alloc (db, total + n, 1); + } if (dataset == NULL) { + if (he == NULL && db->propagate) + pthread_mutex_unlock (&db->prune_run_lock); + /* We cannot permanently add the result in the moment. But we can provide the result as is. Store the data in some temporary memory. */ @@ -374,6 +383,8 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req, out: pthread_rwlock_unlock (&db->lock); + if (he == NULL && db->propagate) + pthread_mutex_unlock (&db->prune_run_lock); } } |