1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

avoid write locks during delete checks in traversals

(This used to be ctdb commit dde9f3f0061988a0cdf10ee9e4db982c1b79ad1a)
This commit is contained in:
Andrew Tridgell 2008-01-05 09:33:39 +11:00
parent fc21f78231
commit 69fb0d3874
3 changed files with 5 additions and 1 deletions

View File

@ -243,7 +243,8 @@ int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct
if (tdb->read_only || tdb->traverse_read) return -1;
if (tdb_write_lock_record(tdb, rec_ptr) == -1) {
if (tdb->traverse_write != 0 ||
tdb_write_lock_record(tdb, rec_ptr) == -1) {
/* Someone traversing here: mark it as dead */
rec->magic = TDB_DEAD_MAGIC;
return tdb_rec_write(tdb, rec_ptr, rec);

View File

@ -151,6 +151,7 @@ struct tdb_context {
tdb_len_t map_size; /* how much space has been mapped */
int read_only; /* opened read-only */
int traverse_read; /* read-only traversal */
int traverse_write; /* read-write traversal */
struct tdb_lock_type global_lock;
int num_lockrecs;
struct tdb_lock_type *lockrecs; /* only real locks, all with count>0 */

View File

@ -238,7 +238,9 @@ int tdb_traverse(struct tdb_context *tdb,
return -1;
}
tdb->traverse_write++;
ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
tdb->traverse_write--;
tdb_transaction_unlock(tdb);