From abd94953e2973381e85a9837aa7b9112bc325607 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Thu, 14 Jul 2011 23:34:20 -0500 Subject: [PATCH] Fixes to lock nesting code. --- lib/hdb/db.c | 4 ++-- lib/hdb/db3.c | 6 +++--- lib/hdb/hdb-mitdb.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/hdb/db.c b/lib/hdb/db.c index 40479cdaf..4b80a74fb 100644 --- a/lib/hdb/db.c +++ b/lib/hdb/db.c @@ -68,9 +68,9 @@ DB_lock(krb5_context context, HDB *db, int operation) krb5_error_code ret; if (db->lock_count > 0) { - assert( db->lock_type == HDB_WLOCK ); db->lock_count++; - return 0; + if (db->lock_type == HDB_WLOCK || db->lock_type == operation) + return 0; } if(fd < 0) { diff --git a/lib/hdb/db3.c b/lib/hdb/db3.c index be2f80c09..20ac64c89 100644 --- a/lib/hdb/db3.c +++ b/lib/hdb/db3.c @@ -77,10 +77,10 @@ DB_lock(krb5_context context, HDB *db, int operation) int fd; krb5_error_code ret; - if (db->lock_count > 0) { - assert( db->lock_type == HDB_WLOCK ); + if (db->lock_count > 1) { db->lock_count++; - return 0; + if (db->lock_count == HDB_WLOCK || db->lock_count == operation) + return 0; } if ((*d->fd)(d, &fd)) diff --git a/lib/hdb/hdb-mitdb.c b/lib/hdb/hdb-mitdb.c index 12fbda640..90c6aec99 100644 --- a/lib/hdb/hdb-mitdb.c +++ b/lib/hdb/hdb-mitdb.c @@ -650,10 +650,10 @@ mdb_lock(krb5_context context, HDB *db, int operation) int fd = (*d->fd)(d); krb5_error_code ret; - if (db->lock_count > 0) { - assert( db->lock_type == HDB_WLOCK ); + if (db->lock_count > 1) { db->lock_count++; - return 0; + if (db->lock_type == HDB_WLOCK || db->lock_count == operation) + return 0; } if(fd < 0) {