svn commit: samba r23195 - in branches: SAMBA_3_0/source/include
SAMBA_3_0/source/locking SAMBA_3_0/source/torture
SAMBA_3_0/source/utils SAMBA_3_0_26/source/include
SAMBA_3_0_26/source/locking SAMBA_3_0_26/source/torture
SAMBA_3_0_26/source/utils
vlendec at samba.org
vlendec at samba.org
Tue May 29 13:26:44 GMT 2007
Author: vlendec
Date: 2007-05-29 13:26:44 +0000 (Tue, 29 May 2007)
New Revision: 23195
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23195
Log:
Add void *private_data to brl_forall
Modified:
branches/SAMBA_3_0/source/include/locking.h
branches/SAMBA_3_0/source/locking/brlock.c
branches/SAMBA_3_0/source/torture/locktest.c
branches/SAMBA_3_0/source/torture/locktest2.c
branches/SAMBA_3_0/source/utils/status.c
branches/SAMBA_3_0_26/source/include/locking.h
branches/SAMBA_3_0_26/source/locking/brlock.c
branches/SAMBA_3_0_26/source/torture/locktest.c
branches/SAMBA_3_0_26/source/torture/locktest2.c
branches/SAMBA_3_0_26/source/utils/status.c
Changeset:
Modified: branches/SAMBA_3_0/source/include/locking.h
===================================================================
--- branches/SAMBA_3_0/source/include/locking.h 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0/source/include/locking.h 2007-05-29 13:26:44 UTC (rev 23195)
@@ -62,18 +62,6 @@
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
Modified: branches/SAMBA_3_0/source/locking/brlock.c
===================================================================
--- branches/SAMBA_3_0/source/locking/brlock.c 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0/source/locking/brlock.c 2007-05-29 13:26:44 UTC (rev 23195)
@@ -1447,6 +1447,15 @@
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 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 @@
}
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 @@
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);
}
/*******************************************************************
Modified: branches/SAMBA_3_0/source/torture/locktest.c
===================================================================
--- branches/SAMBA_3_0/source/torture/locktest.c 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0/source/torture/locktest.c 2007-05-29 13:26:44 UTC (rev 23195)
@@ -121,7 +121,8 @@
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 show_locks(void)
{
- brl_forall(print_brl);
+ brl_forall(print_brl, NULL);
/* system("cat /proc/locks"); */
}
Modified: branches/SAMBA_3_0/source/torture/locktest2.c
===================================================================
--- branches/SAMBA_3_0/source/torture/locktest2.c 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0/source/torture/locktest2.c 2007-05-29 13:26:44 UTC (rev 23195)
@@ -139,7 +139,8 @@
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 @@
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 @@
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 @@
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;
Modified: branches/SAMBA_3_0/source/utils/status.c
===================================================================
--- branches/SAMBA_3_0/source/utils/status.c 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0/source/utils/status.c 2007-05-29 13:26:44 UTC (rev 23195)
@@ -171,7 +171,8 @@
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 @@
d_printf("\n");
if (show_brl) {
- brl_forall(print_brl);
+ brl_forall(print_brl, NULL);
}
locking_end();
Modified: branches/SAMBA_3_0_26/source/include/locking.h
===================================================================
--- branches/SAMBA_3_0_26/source/include/locking.h 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0_26/source/include/locking.h 2007-05-29 13:26:44 UTC (rev 23195)
@@ -62,18 +62,6 @@
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
Modified: branches/SAMBA_3_0_26/source/locking/brlock.c
===================================================================
--- branches/SAMBA_3_0_26/source/locking/brlock.c 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0_26/source/locking/brlock.c 2007-05-29 13:26:44 UTC (rev 23195)
@@ -1447,6 +1447,15 @@
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 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 @@
}
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 @@
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);
}
/*******************************************************************
Modified: branches/SAMBA_3_0_26/source/torture/locktest.c
===================================================================
--- branches/SAMBA_3_0_26/source/torture/locktest.c 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0_26/source/torture/locktest.c 2007-05-29 13:26:44 UTC (rev 23195)
@@ -121,7 +121,8 @@
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 show_locks(void)
{
- brl_forall(print_brl);
+ brl_forall(print_brl, NULL);
/* system("cat /proc/locks"); */
}
Modified: branches/SAMBA_3_0_26/source/torture/locktest2.c
===================================================================
--- branches/SAMBA_3_0_26/source/torture/locktest2.c 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0_26/source/torture/locktest2.c 2007-05-29 13:26:44 UTC (rev 23195)
@@ -139,7 +139,8 @@
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 @@
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 @@
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 @@
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;
Modified: branches/SAMBA_3_0_26/source/utils/status.c
===================================================================
--- branches/SAMBA_3_0_26/source/utils/status.c 2007-05-29 13:20:40 UTC (rev 23194)
+++ branches/SAMBA_3_0_26/source/utils/status.c 2007-05-29 13:26:44 UTC (rev 23195)
@@ -171,7 +171,8 @@
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 @@
d_printf("\n");
if (show_brl) {
- brl_forall(print_brl);
+ brl_forall(print_brl, NULL);
}
locking_end();
More information about the samba-cvs
mailing list