From 137028b4d7e50f71906c1656c27079eac5a1d085 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 16 Jul 2009 10:10:10 -0700 Subject: 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. --- nscd/mem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nscd/mem.c') 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; } -- cgit 1.4.1