summaryrefslogtreecommitdiff
path: root/ctdb/client
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2016-04-20 11:30:21 +1000
committerMartin Schwenke <martins@samba.org>2016-07-05 10:53:14 +0200
commit8b8e73a3105762828a1ae7ed0bde9f81829f40ef (patch)
tree235c402564b60cc74a1bcbaf8487aa2a645dd874 /ctdb/client
parent3ed3d460b7aeb12ed44455d9a77452c74e38517b (diff)
downloadsamba-8b8e73a3105762828a1ae7ed0bde9f81829f40ef.tar.gz
ctdb-client: Fix g_lock implementation
If a conflicting g_lock entry is found, check if the process exists. This matches Samba implementation. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/client')
-rw-r--r--ctdb/client/client_db.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c
index 6a21e0b2dca..b7c0e47df76 100644
--- a/ctdb/client/client_db.c
+++ b/ctdb/client/client_db.c
@@ -1287,15 +1287,11 @@ static void ctdb_g_lock_lock_process_locks(struct tevent_req *req)
if (check_server) {
struct ctdb_req_control request;
- struct ctdb_uint64_array u64_array;
- u64_array.num = 1;
- u64_array.val = &lock->sid.unique_id;
-
- ctdb_req_control_check_srvids(&request, &u64_array);
+ ctdb_req_control_process_exists(&request, lock->sid.pid);
subreq = ctdb_client_control_send(state, state->ev,
state->client,
- state->client->pnn,
+ lock->sid.vnn,
tevent_timeval_zero(),
&request);
if (tevent_req_nomem(subreq, req)) {
@@ -1336,10 +1332,8 @@ static void ctdb_g_lock_lock_checked(struct tevent_req *subreq)
struct ctdb_g_lock_lock_state *state = tevent_req_data(
req, struct ctdb_g_lock_lock_state);
struct ctdb_reply_control *reply;
- struct ctdb_uint8_array *u8_array;
- int ret;
+ int ret, value;
bool status;
- int8_t val;
status = ctdb_client_control_recv(subreq, &ret, state, &reply);
TALLOC_FREE(subreq);
@@ -1348,22 +1342,14 @@ static void ctdb_g_lock_lock_checked(struct tevent_req *subreq)
return;
}
- ret = ctdb_reply_control_check_srvids(reply, state, &u8_array);
+ ret = ctdb_reply_control_process_exists(reply, &value);
if (ret != 0) {
- tevent_req_error(req, ENOMEM);
- return;
- }
-
- if (u8_array->num != 1) {
- talloc_free(u8_array);
- tevent_req_error(req, EIO);
+ tevent_req_error(req, ret);
return;
}
+ talloc_free(reply);
- val = u8_array->val[0];
- talloc_free(u8_array);
-
- if (val == 1) {
+ if (value == 0) {
/* server process exists, need to retry */
subreq = tevent_wakeup_send(state, state->ev,
tevent_timeval_current_ofs(0,1000));