Permalink
Browse files

Add lease ownership checking when releasing the lease

Signed-off-by: Guangliang Zhao <gzhao@suse.com>
  • Loading branch information...
1 parent 15e533a commit 7b351bb381cc69b17f02c6f9ae506a78a6750319 @glzhao glzhao committed with May 3, 2012
Showing with 8 additions and 2 deletions.
  1. +6 −0 src/paxos_lease.c
  2. +2 −2 src/ticket.c
View
@@ -240,6 +240,12 @@ int paxos_lease_release(pl_handle_t handle,
int round;
log_debug("enter paxos_lease_release");
+ if (pl->owner != myid) {
+ log_error("can not release the lease "
+ "because I'm not the lease owner");
+ return -1;
+ }
+
memset(&value, 0, sizeof(struct paxos_lease_value));
strncpy(value.name, pl->name, PAXOS_NAME_LEN + 1);
pl->end_lease = end_release;
View
@@ -462,8 +462,8 @@ int revoke_ticket(char *ticket)
if (tk->owner == -1)
return BOOTHC_RLT_SYNC_SUCC;
else {
- paxos_lease_release(tk->handle, end_release);
- return BOOTHC_RLT_ASYNC;
+ int ret = paxos_lease_release(tk->handle, end_release);
+ return (ret < 0)? BOOTHC_RLT_SYNC_FAIL: BOOTHC_RLT_ASYNC;
}
}

3 comments on commit 7b351bb

Contributor

seinocluster2 replied May 7, 2012

This fix can output "revoke failed!" when we mistake a specified site. Then the value of "echo $?" is 0.
I think that the value of "echo $?" is 1 better than 0. What do you think about that?

Contributor

glzhao replied May 7, 2012

Thank you for the reminder :), I'll submit a patch Immediately.

Owner

jjzhang replied May 7, 2012

Applied, thanks.

Please sign in to comment.