Skip to content

Commit

Permalink
Medium: ticket: drop expired tickets in elections too (gh#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuhamedagic committed Aug 7, 2014
1 parent 6683248 commit 17aef86
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
2 changes: 0 additions & 2 deletions src/raft.c
Expand Up @@ -730,7 +730,6 @@ int new_election(struct ticket_config *tk,
tk->current_term++;
}

tk->term_expires = 0;
tk->election_end = now + tk->timeout;
tk->in_election = 1;

Expand All @@ -745,7 +744,6 @@ int new_election(struct ticket_config *tk,
record_vote(tk, local, new_leader);
tk->voted_for = new_leader;

tk->leader = no_leader;
tk->state = ST_CANDIDATE;

/* some callers may want just to repeat on timeout */
Expand Down
3 changes: 1 addition & 2 deletions src/ticket.c
Expand Up @@ -818,9 +818,8 @@ static void ticket_cron(struct ticket_config *tk)
/* Has an owner, has an expiry date, and expiry date in the past?
* Losing the ticket must happen in _every_ state. */
now = get_secs(NULL);
if (!tk->in_election &&
if (is_owned(tk) &&
tk->term_expires &&
is_owned(tk) &&
now >= tk->term_expires) {
ticket_lost(tk);
goto out;
Expand Down

0 comments on commit 17aef86

Please sign in to comment.