summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-10-26 13:43:07 +0200
committerVolker Lendecke <vlendec@samba.org>2011-10-27 20:28:31 +0200
commit4a96b629a69d06abe73490f03bf6d62cdda08cd6 (patch)
treedf96e924d0a9f04eaea170c11e925b3df4b55028 /source3/locking
parent37d7d523589cfa69220b60a37abbb5aefb11f338 (diff)
downloadsamba-4a96b629a69d06abe73490f03bf6d62cdda08cd6.tar.gz
samba-4a96b629a69d06abe73490f03bf6d62cdda08cd6.tar.bz2
samba-4a96b629a69d06abe73490f03bf6d62cdda08cd6.zip
s3: Use serverids_exist in parse_share_modes
This is the main reason for the preceding commits. We need to reduce the number of round-trips to ctdb when checking the locking record entries for existence. Using the plural version of process_exists gets the number of round-trips to ctdb for process_exists down to 1.
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/locking.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 3177fc109f..1947b185e6 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -645,6 +645,8 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
struct locking_data data;
int delete_tokens_size;
int i;
+ struct server_id *pids;
+ bool *pid_exists;
if (dbuf.dsize < sizeof(struct locking_data)) {
smb_panic("parse_share_modes: buffer too short");
@@ -719,6 +721,24 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
* Ensure that each entry has a real process attached.
*/
+ pids = talloc_array(talloc_tos(), struct server_id,
+ lck->num_share_modes);
+ if (pids == NULL) {
+ smb_panic("parse_share_modes: talloc_array failed");
+ }
+ pid_exists = talloc_array(talloc_tos(), bool, lck->num_share_modes);
+ if (pid_exists == NULL) {
+ smb_panic("parse_share_modes: talloc_array failed");
+ }
+
+ for (i=0; i<lck->num_share_modes; i++) {
+ pids[i] = lck->share_modes[i].pid;
+ }
+
+ if (!serverids_exist(pids, lck->num_share_modes, pid_exists)) {
+ smb_panic("parse_share_modes: serverids_exist failed");
+ }
+
for (i = 0; i < lck->num_share_modes; i++) {
struct share_mode_entry *entry_p = &lck->share_modes[i];
char *str = NULL;
@@ -727,7 +747,7 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
}
DEBUG(10,("parse_share_modes: %s\n",
str ? str : ""));
- if (!serverid_exists(&entry_p->pid)) {
+ if (!pid_exists[i]) {
DEBUG(10,("parse_share_modes: deleted %s\n",
str ? str : ""));
entry_p->op_type = UNUSED_SHARE_MODE_ENTRY;
@@ -735,6 +755,8 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
}
TALLOC_FREE(str);
}
+ TALLOC_FREE(pid_exists);
+ TALLOC_FREE(pids);
return True;
}