Skip to content

Commit

Permalink
Fix: append entries array index
Browse files Browse the repository at this point in the history
Regression caused by 6f318d0
  • Loading branch information
willemt committed Apr 11, 2016
1 parent 6f318d0 commit 5ea572f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/raft_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int log_append_entry(log_t* me_, raft_entry_t* c)
if (me->cb && me->cb->log_offer)
{
void* ud = raft_get_udata(me->raft);
e = me->cb->log_offer(me->raft, ud, c, me->back - 1);
e = me->cb->log_offer(me->raft, ud, c, me->back);
if (e == RAFT_ERR_SHUTDOWN)
return e;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ static int __raft_logentry_offer(
int ety_idx
)
{
CuAssertIntEquals(udata, ety_idx, 0);
ety->data.buf = udata;
return 0;
}
Expand All @@ -202,10 +203,9 @@ void TestRaft_server_append_entry_user_can_set_data_buf(CuTest * tc)
.log_offer = __raft_logentry_offer,
};

char *data = "xxx";
void *r = raft_new();
raft_set_state(r, RAFT_STATE_CANDIDATE);
raft_set_callbacks(r, &funcs, data);
raft_set_callbacks(r, &funcs, tc);
raft_set_current_term(r, 5);
raft_entry_t ety = {};
ety.term = 1;
Expand Down

0 comments on commit 5ea572f

Please sign in to comment.