Fix formatting

This commit is contained in:
2026-02-22 21:44:37 +01:00
parent 34af6063b6
commit aef44ce5f3
3 changed files with 23 additions and 11 deletions
+8 -5
View File
@@ -219,7 +219,8 @@ static void send_message_to_server(ToastyFS *tfs, int server_idx, MessageHeader
byte_queue_write(output, msg, msg->length); byte_queue_write(output, msg, msg->length);
} }
static void send_message_to_server_ex(ToastyFS *tfs, int server_idx, static void
send_message_to_server_ex(ToastyFS *tfs, int server_idx,
MessageHeader *msg, void *extra, int extra_len) MessageHeader *msg, void *extra, int extra_len)
{ {
ByteQueue *output; ByteQueue *output;
@@ -381,8 +382,8 @@ static void replay_request(ToastyFS *tfs)
} }
} }
static int process_message(ToastyFS *tfs, static int process_message(ToastyFS *tfs, int conn_idx,
int conn_idx, uint8_t type, ByteView msg) uint8_t type, ByteView msg)
{ {
(void) conn_idx; (void) conn_idx;
@@ -673,7 +674,8 @@ static int process_message(ToastyFS *tfs,
return 0; return 0;
} }
void toastyfs_process_events(ToastyFS *tfs, void **ctxs, struct pollfd *pdata, int pnum) void toastyfs_process_events(ToastyFS *tfs, void **ctxs,
struct pollfd *pdata, int pnum)
{ {
Event events[TCP_EVENT_CAPACITY]; Event events[TCP_EVENT_CAPACITY];
int num_events = tcp_translate_events(&tfs->tcp, events, ctxs, pdata, pnum); int num_events = tcp_translate_events(&tfs->tcp, events, ctxs, pdata, pnum);
@@ -748,7 +750,8 @@ void toastyfs_process_events(ToastyFS *tfs, void **ctxs, struct pollfd *pdata, i
// TODO: The toastyfs client needs to determine a timeout based on the // TODO: The toastyfs client needs to determine a timeout based on the
// pending operation status, not just use PRIMARY_DEATH_TIMEOUT_SEC // pending operation status, not just use PRIMARY_DEATH_TIMEOUT_SEC
// for everything. // for everything.
int toastyfs_register_events(ToastyFS *tfs, void **ctxs, struct pollfd *pdata, int pcap, int *timeout) int toastyfs_register_events(ToastyFS *tfs, void **ctxs,
struct pollfd *pdata, int pcap, int *timeout)
{ {
Time now = get_current_time(); // TODO: Handle INVALID_TIME error Time now = get_current_time(); // TODO: Handle INVALID_TIME error
Time deadline = INVALID_TIME; Time deadline = INVALID_TIME;
+2 -1
View File
@@ -1358,7 +1358,8 @@ process_new_state(ServerState *state, int conn_idx, ByteView msg)
memcpy(&new_state_message, msg.ptr, sizeof(new_state_message)); memcpy(&new_state_message, msg.ptr, sizeof(new_state_message));
node_log(state, "RECV NEW_STATE", "entries=%d commit=%d view=%lu", node_log(state, "RECV NEW_STATE", "entries=%d commit=%d view=%lu",
new_state_message.op_number, new_state_message.commit_index, new_state_message.view_number); new_state_message.op_number, new_state_message.commit_index,
new_state_message.view_number);
// Ignore if we're in a different view // Ignore if we're in a different view
if (new_state_message.view_number != state->view_number) if (new_state_message.view_number != state->view_number)
+12 -4
View File
@@ -319,7 +319,8 @@ typedef struct {
uint32_t checksum; uint32_t checksum;
} ViewAndCommitDisk; } ViewAndCommitDisk;
static uint32_t vc_checksum(uint64_t view_number, uint64_t last_normal_view, int commit_index) static uint32_t vc_checksum(uint64_t view_number,
uint64_t last_normal_view, int commit_index)
{ {
uint32_t h = 2166136261u; uint32_t h = 2166136261u;
@@ -362,21 +363,28 @@ int view_and_commit_init(ViewAndCommit *vc, string file)
} }
if (size >= sizeof(ViewAndCommitDisk)) { if (size >= sizeof(ViewAndCommitDisk)) {
ViewAndCommitDisk disk;
if (file_set_offset(handle, 0) < 0) { if (file_set_offset(handle, 0) < 0) {
file_close(handle); file_close(handle);
return -1; return -1;
} }
ViewAndCommitDisk disk;
if (file_read_exact(handle, (char *)&disk, sizeof(disk)) < 0) { if (file_read_exact(handle, (char *)&disk, sizeof(disk)) < 0) {
file_close(handle); file_close(handle);
return -1; return -1;
} }
if (disk.checksum == vc_checksum(disk.view_number, disk.last_normal_view, disk.commit_index)) {
uint32_t expected_checksum = vc_checksum(disk.view_number,
disk.last_normal_view, disk.commit_index);
if (disk.checksum == expected_checksum) {
vc->view_number = disk.view_number; vc->view_number = disk.view_number;
vc->last_normal_view = disk.last_normal_view; vc->last_normal_view = disk.last_normal_view;
vc->commit_index = disk.commit_index; vc->commit_index = disk.commit_index;
} }
// If checksum doesn't match, start from defaults (0, 0, 0).
// If checksum doesn't match, start from defaults (0, 0, 0)
} }
return 0; return 0;