summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2013-03-05 14:02:10 +0100
committerMichael Adam <obnox@samba.org>2013-04-18 13:15:12 +0200
commit02cc5a5c6a6b6b2b796abe573a671853d945b22f (patch)
treee4a2d9fc4094bb5c9b5187b32f67259b1b0a880a /source3
parent941e84dcfe985559e5e75318e7b5dd9d50fcc47b (diff)
downloadsamba-02cc5a5c6a6b6b2b796abe573a671853d945b22f.tar.gz
samba-02cc5a5c6a6b6b2b796abe573a671853d945b22f.tar.bz2
samba-02cc5a5c6a6b6b2b796abe573a671853d945b22f.zip
s3:locking:brlock: use serverids_exist to validate_lock_entries
...instead of checking each server-id separately which can be expensive in a cluster. Signed-off-by: Gregor Beck <gbeck@sernet.de> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/locking/brlock.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index c5bbcd181c..3f23961ec2 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -1655,17 +1655,48 @@ static bool validate_lock_entries(unsigned int *pnum_entries, struct lock_struct
unsigned int i;
unsigned int num_valid_entries = 0;
struct lock_struct *locks = *pplocks;
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct server_id *ids;
+ bool *exists;
+
+ ids = talloc_array(frame, struct server_id, *pnum_entries);
+ if (ids == NULL) {
+ DEBUG(0, ("validate_lock_entries: "
+ "talloc_array(struct server_id, %u) failed\n",
+ *pnum_entries));
+ talloc_free(frame);
+ return false;
+ }
+
+ exists = talloc_array(frame, bool, *pnum_entries);
+ if (exists == NULL) {
+ DEBUG(0, ("validate_lock_entries: "
+ "talloc_array(bool, %u) failed\n",
+ *pnum_entries));
+ talloc_free(frame);
+ return false;
+ }
+
+ for (i = 0; i < *pnum_entries; i++) {
+ ids[i] = locks[i].context.pid;
+ }
+
+ if (!serverids_exist(ids, *pnum_entries, exists)) {
+ DEBUG(3, ("validate_lock_entries: serverids_exists failed\n"));
+ talloc_free(frame);
+ return false;
+ }
for (i = 0; i < *pnum_entries; i++) {
- struct lock_struct *lock_data = &locks[i];
- if (!serverid_exists(&lock_data->context.pid)) {
+ if (!exists[i]) {
/* This process no longer exists - mark this
entry as invalid by zeroing it. */
- ZERO_STRUCTP(lock_data);
+ ZERO_STRUCTP(&locks[i]);
} else {
num_valid_entries++;
}
}
+ TALLOC_FREE(frame);
if (num_valid_entries != *pnum_entries) {
struct lock_struct *new_lock_data = NULL;