Added kadm5_lock() and unlock.
This commit is contained in:

committed by
Nicolas Williams

parent
109607a355
commit
58d72035f1
22
lib/hdb/db.c
22
lib/hdb/db.c
@@ -65,12 +65,24 @@ DB_lock(krb5_context context, HDB *db, int operation)
|
||||
{
|
||||
DB *d = (DB*)db->hdb_db;
|
||||
int fd = (*d->fd)(d);
|
||||
krb5_error_code ret;
|
||||
|
||||
if (db->lock_count > 0) {
|
||||
assert( db->lock_type == HDB_WLOCK );
|
||||
db->lock_count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(fd < 0) {
|
||||
krb5_set_error_message(context, HDB_ERR_CANT_LOCK_DB,
|
||||
"Can't lock database: %s", db->hdb_name);
|
||||
return HDB_ERR_CANT_LOCK_DB;
|
||||
}
|
||||
return hdb_lock(fd, operation);
|
||||
ret = hdb_lock(fd, operation);
|
||||
if (ret)
|
||||
return ret;
|
||||
db->lock_count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static krb5_error_code
|
||||
@@ -78,6 +90,14 @@ DB_unlock(krb5_context context, HDB *db)
|
||||
{
|
||||
DB *d = (DB*)db->hdb_db;
|
||||
int fd = (*d->fd)(d);
|
||||
|
||||
if (db->lock_count > 1) {
|
||||
db->lock_count--;
|
||||
return 0;
|
||||
}
|
||||
assert( db->lock_count == 1 );
|
||||
db->lock_count--;
|
||||
|
||||
if(fd < 0) {
|
||||
krb5_set_error_message(context, HDB_ERR_CANT_LOCK_DB,
|
||||
"Can't unlock database: %s", db->hdb_name);
|
||||
|
Reference in New Issue
Block a user