Skip to content

Commit

Permalink
Make uses of raft_apply compatible with both DQLITE_NEXT and not
Browse files Browse the repository at this point in the history
Signed-off-by: Cole Miller <[email protected]>
  • Loading branch information
cole-miller committed Apr 25, 2024
1 parent 055a5ff commit 2df9c4c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/leader.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "utils.h"
#include "vfs.h"

/* Indicates that we plan to use this local buffer later */
#define PLACEHOLDER_LOCAL_BUF ((struct raft_buffer){})

/* Called when a leader exec request terminates and the associated callback can
Expand Down Expand Up @@ -226,8 +227,12 @@ static void leaderMaybeCheckpointLegacy(struct leader *l)
tracef("raft_malloc - no mem");
goto err_after_buf_alloc;
}
struct raft_buffer local_buf = PLACEHOLDER_LOCAL_BUF;
#ifdef USE_SYSTEM_RAFT
rv = raft_apply(l->raft, apply, &buf, 1, leaderCheckpointApplyCb);
#else
struct raft_buffer local_buf = {};
rv = raft_apply(l->raft, apply, &buf, &local_buf, 1, leaderCheckpointApplyCb);
#endif
if (rv != 0) {
tracef("raft_apply failed %d", rv);
raft_free(apply);
Expand Down Expand Up @@ -335,8 +340,12 @@ static int leaderApplyFrames(struct exec *req,
apply->type = COMMAND_FRAMES;
idSet(apply->req.req_id, req->id);

#ifdef USE_SYSTEM_RAFT
rv = raft_apply(l->raft, &apply->req, &buf, 1, leaderApplyFramesCb);
#else
struct raft_buffer local_buf = PLACEHOLDER_LOCAL_BUF;
rv = raft_apply(l->raft, &apply->req, &buf, &local_buf, 1, leaderApplyFramesCb);
#endif
if (rv != 0) {
tracef("raft apply failed %d", rv);
goto err_after_command_encode;
Expand Down

0 comments on commit 2df9c4c

Please sign in to comment.