Skip to content

Conversation

@inouekazu
Copy link

The second argument of copy_ticket_from_msg() needs to be checked, since it may be NULL.

235                 become_follower(tk, NULL);
130 static void become_follower(struct ticket_config *tk,
131                 struct boothc_ticket_msg *msg)
132 {
133         copy_ticket_from_msg(tk, msg);
122 static void copy_ticket_from_msg(struct ticket_config *tk,
123                 struct boothc_ticket_msg *msg)
124 {
125         tk->term_expires = time(NULL) + ntohl(msg->ticket.term_valid_for);

I set the time(NULL) + tk->term_duration to tk->term_expires if msg is NULL, referring to the update_ticket_from_msg().

@dmuhamedagic
Copy link

On Fri, May 30, 2014 at 03:17:59AM -0700, Kazunori INOUE wrote:

The second argument of copy_ticket_from_msg() needs to be checked, since it may be NULL.

Right.

It'd probably be better to:

if (msg)
    copy_ticket_from_msg(tk, msg);

Or in copy_ticket_from_msg():

if (!msg)
    return;

Otherwise, the function's name wouldn't really fit.

Further, the elections_end() should really be invoked with the
msg too so that followers do have up to date tickets in most
normal cases:

elections_end(tk, msg);

Could you please incorporate those changes and rebase.

I wonder if invoking elections_end() from the CANDIDATE state
in case the candidate didn't win the elections is good. I feel
that a server should get into the follower state when instructed
to do so by the leader.

Thanks!

@dmuhamedagic
Copy link

The offending call got removed here dcd6e98. This pull request is obsolete. Many thanks for reporting the issue and proposed solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants