summaryrefslogtreecommitdiff
path: root/nscd/mem.c
diff options
context:
space:
mode:
authorPetr Baudis <pasky@suse.cz>2009-07-16 10:10:10 -0700
committerUlrich Drepper <drepper@redhat.com>2009-07-16 10:10:10 -0700
commit137028b4d7e50f71906c1656c27079eac5a1d085 (patch)
tree61b121088c68e50ff2483cd15675729cf3c337e7 /nscd/mem.c
parent50158f95525ca59459a90f2a7bc65ceb892a0807 (diff)
downloadglibc-137028b4d7e50f71906c1656c27079eac5a1d085.tar.gz
Fix lock handling in memory hander of nscd.
The commit 20e498bd removes the pthread_mutex_rdlock() calls, but not the corresponding pthread_mutex_unlock() calls. Also, the database lock is never unlocked in one branch of the mempool_alloc() if. I think unreproducible random assert(dh->usable) crashes in prune_cache() were caused by this. But an easy way to make nscd threads hang with the broken locking was.
Diffstat (limited to 'nscd/mem.c')
-rw-r--r--nscd/mem.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/nscd/mem.c b/nscd/mem.c
index fcea6dbd03..80ea951146 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -566,9 +566,6 @@ mempool_alloc (struct database_dyn *db, size_t len, int data_alloc)
}
}
- if (data_alloc)
- pthread_rwlock_unlock (&db->lock);
-
if (! db->last_alloc_failed)
{
dbg_log (_("no more memory for database '%s'"), dbnames[db - dbs]);
@@ -591,5 +588,8 @@ mempool_alloc (struct database_dyn *db, size_t len, int data_alloc)
pthread_mutex_unlock (&db->memlock);
+ if (data_alloc)
+ pthread_rwlock_unlock (&db->lock);
+
return res;
}