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:
parent
fc21f78231
commit
69fb0d3874
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user