Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add lease ownership checking when releasing the lease

Signed-off-by: Guangliang Zhao <gzhao@suse.com>
  • Loading branch information...
commit 7b351bb381cc69b17f02c6f9ae506a78a6750319 1 parent 15e533a
Guangliang Zhao glzhao authored committed

Showing 2 changed files with 8 additions and 2 deletions. Show diff stats Hide diff stats

  1. +6 0 src/paxos_lease.c
  2. +2 2 src/ticket.c
6 src/paxos_lease.c
@@ -240,6 +240,12 @@ int paxos_lease_release(pl_handle_t handle,
240 240 int round;
241 241
242 242 log_debug("enter paxos_lease_release");
  243 + if (pl->owner != myid) {
  244 + log_error("can not release the lease "
  245 + "because I'm not the lease owner");
  246 + return -1;
  247 + }
  248 +
243 249 memset(&value, 0, sizeof(struct paxos_lease_value));
244 250 strncpy(value.name, pl->name, PAXOS_NAME_LEN + 1);
245 251 pl->end_lease = end_release;
4 src/ticket.c
@@ -462,8 +462,8 @@ int revoke_ticket(char *ticket)
462 462 if (tk->owner == -1)
463 463 return BOOTHC_RLT_SYNC_SUCC;
464 464 else {
465   - paxos_lease_release(tk->handle, end_release);
466   - return BOOTHC_RLT_ASYNC;
  465 + int ret = paxos_lease_release(tk->handle, end_release);
  466 + return (ret < 0)? BOOTHC_RLT_SYNC_FAIL: BOOTHC_RLT_ASYNC;
467 467 }
468 468 }
469 469

3 comments on commit 7b351bb

Yuichi SEINO

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?

Guangliang Zhao
glzhao commented on 7b351bb

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

Jiaju Zhang
Owner

Applied, thanks.

Please sign in to comment.
Something went wrong with that request. Please try again.