diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/locking.h | 12 | ||||
-rw-r--r-- | source3/locking/brlock.c | 38 | ||||
-rw-r--r-- | source3/torture/locktest.c | 5 | ||||
-rw-r--r-- | source3/torture/locktest2.c | 9 | ||||
-rw-r--r-- | source3/utils/status.c | 5 |
5 files changed, 39 insertions, 30 deletions
diff --git a/source3/include/locking.h b/source3/include/locking.h index f02d817133..d61b5fe1e4 100644 --- a/source3/include/locking.h +++ b/source3/include/locking.h @@ -62,18 +62,6 @@ struct byte_range_lock { struct db_record *record; }; -#define BRLOCK_FN_CAST() \ - void (*)(struct file_id id, struct server_id pid, \ - enum brl_type lock_type, \ - enum brl_flavour lock_flav, \ - br_off start, br_off size) - -#define BRLOCK_FN(fn) \ - void (*fn)(struct file_id id, struct server_id pid, \ - enum brl_type lock_type, \ - enum brl_flavour lock_flav, \ - br_off start, br_off size) - /* Internal structure in brlock.tdb. The data in brlock records is an unsorted linear array of these records. It is unnecessary to store the count as tdb provides the diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c index a37afbddd5..b51076bf43 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -1447,6 +1447,15 @@ static BOOL validate_lock_entries(unsigned int *pnum_entries, struct lock_struct return True; } +struct brl_forall_cb { + void (*fn)(struct file_id id, struct server_id pid, + enum brl_type lock_type, + enum brl_flavour lock_flav, + br_off start, br_off size, + void *private_data); + void *private_data; +}; + /**************************************************************************** Traverse the whole database with this function, calling traverse_callback on each lock. @@ -1454,14 +1463,13 @@ static BOOL validate_lock_entries(unsigned int *pnum_entries, struct lock_struct static int traverse_fn(struct db_record *rec, void *state) { + struct brl_forall_cb *cb = (struct brl_forall_cb *)state; struct lock_struct *locks; struct file_id *key; unsigned int i; unsigned int num_locks = 0; unsigned int orig_num_locks = 0; - BRLOCK_FN(traverse_callback) = (BRLOCK_FN_CAST())state; - /* In a traverse function we must make a copy of dbuf before modifying it. */ @@ -1493,12 +1501,13 @@ static int traverse_fn(struct db_record *rec, void *state) } for ( i=0; i<num_locks; i++) { - traverse_callback(*key, - locks[i].context.pid, - locks[i].lock_type, - locks[i].lock_flav, - locks[i].start, - locks[i].size); + cb->fn(*key, + locks[i].context.pid, + locks[i].lock_type, + locks[i].lock_flav, + locks[i].start, + locks[i].size, + cb->private_data); } SAFE_FREE(locks); @@ -1509,12 +1518,21 @@ static int traverse_fn(struct db_record *rec, void *state) Call the specified function on each lock in the database. ********************************************************************/ -int brl_forall(BRLOCK_FN(fn)) +int brl_forall(void (*fn)(struct file_id id, struct server_id pid, + enum brl_type lock_type, + enum brl_flavour lock_flav, + br_off start, br_off size, + void *private_data), + void *private_data) { + struct brl_forall_cb cb; + if (!brlock_db) { return 0; } - return brlock_db->traverse(brlock_db, traverse_fn, (void *)fn); + cb.fn = fn; + cb.private_data = private_data; + return brlock_db->traverse(brlock_db, traverse_fn, &cb); } /******************************************************************* diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c index 92838f0ff2..7a970488b3 100644 --- a/source3/torture/locktest.c +++ b/source3/torture/locktest.c @@ -121,7 +121,8 @@ static void print_brl(struct file_id id, enum brl_type lock_type, enum brl_flavour lock_flav, br_off start, - br_off size) + br_off size, + void *private_data) { #if NASTY_POSIX_LOCK_HACK { @@ -147,7 +148,7 @@ static void print_brl(struct file_id id, static void show_locks(void) { - brl_forall(print_brl); + brl_forall(print_brl, NULL); /* system("cat /proc/locks"); */ } diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c index 184c84be43..0da7e9cf00 100644 --- a/source3/torture/locktest2.c +++ b/source3/torture/locktest2.c @@ -139,7 +139,8 @@ static BOOL try_unlock(struct cli_state *c, int fstype, static void print_brl(struct file_id id, struct server_id pid, enum brl_type lock_type, enum brl_flavour lock_flav, - br_off start, br_off size) + br_off start, br_off size, + void *private_data) { printf("%6d %s %s %.0f:%.0f(%.0f)\n", (int)procid_to_pid(&pid), file_id_static_string(&id), @@ -259,7 +260,7 @@ static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], op==READ_LOCK?"READ_LOCK":"WRITE_LOCK", ret[0], ret[1]); } - if (showall) brl_forall(print_brl); + if (showall) brl_forall(print_brl, NULL); if (ret[0] != ret[1]) return False; } else if (r2 < LOCK_PCT+UNLOCK_PCT) { /* unset a lock */ @@ -274,7 +275,7 @@ static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], start, start+len-1, len, ret[0], ret[1]); } - if (showall) brl_forall(print_brl); + if (showall) brl_forall(print_brl, NULL); if (!hide_unlock_fails && ret[0] != ret[1]) return False; } else { /* reopen the file */ @@ -290,7 +291,7 @@ static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], if (showall) { printf("reopen conn=%u fstype=%u f=%u\n", conn, fstype, f); - brl_forall(print_brl); + brl_forall(print_brl, NULL); } } return True; diff --git a/source3/utils/status.c b/source3/utils/status.c index 207be30912..5b769a036b 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -171,7 +171,8 @@ static void print_brl(struct file_id id, enum brl_type lock_type, enum brl_flavour lock_flav, br_off start, - br_off size) + br_off size, + void *private_data) { static int count; int i; @@ -389,7 +390,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo d_printf("\n"); if (show_brl) { - brl_forall(print_brl); + brl_forall(print_brl, NULL); } locking_end(); |