Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7142ed

Browse files
committed
Fix 'is applied' check when asking about current node.
1 parent7c7795c commita7142ed

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

‎src/raft.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ static int raft_apply(raft_t raft) {
318318
raft_log_t*l=&raft->log;
319319
while (l->applied<l->acked) {
320320
raft_entry_t*e=&RAFT_LOG(raft,l->applied);
321+
assert(e->update.len==e->bytes);
321322
raft->config.applier(raft->config.userdata,e->update, false);
322323
raft->log.applied++;
323324
applied_now++;
@@ -661,6 +662,7 @@ int raft_emit(raft_t r, raft_update_t update) {
661662
assert(e->update.len==0);
662663
assert(e->update.data==NULL);
663664
e->update.len=update.len;
665+
e->bytes=update.len;
664666
e->update.data=malloc(update.len);
665667
memcpy(e->update.data,update.data,update.len);
666668
r->log.size++;
@@ -671,9 +673,16 @@ int raft_emit(raft_t r, raft_update_t update) {
671673
}
672674

673675
boolraft_applied(raft_tr,intid,intindex) {
674-
raft_peer_t*p=r->peers+id;
675-
if (!p->up)return false;
676-
returnp->applied >=index;
676+
if (r->me==id)
677+
{
678+
returnr->log.applied >=index;
679+
}
680+
else
681+
{
682+
raft_peer_t*p=r->peers+id;
683+
if (!p->up)return false;
684+
returnp->applied >=index;
685+
}
677686
}
678687

679688
staticboolraft_restore(raft_tr,intprevindex,raft_entry_t*e) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp