Fix formatting
This commit is contained in:
+8
-5
@@ -219,7 +219,8 @@ static void send_message_to_server(ToastyFS *tfs, int server_idx, MessageHeader
|
||||
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)
|
||||
{
|
||||
ByteQueue *output;
|
||||
@@ -381,8 +382,8 @@ static void replay_request(ToastyFS *tfs)
|
||||
}
|
||||
}
|
||||
|
||||
static int process_message(ToastyFS *tfs,
|
||||
int conn_idx, uint8_t type, ByteView msg)
|
||||
static int process_message(ToastyFS *tfs, int conn_idx,
|
||||
uint8_t type, ByteView msg)
|
||||
{
|
||||
(void) conn_idx;
|
||||
|
||||
@@ -673,7 +674,8 @@ static int process_message(ToastyFS *tfs,
|
||||
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];
|
||||
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
|
||||
// pending operation status, not just use PRIMARY_DEATH_TIMEOUT_SEC
|
||||
// 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 deadline = INVALID_TIME;
|
||||
|
||||
+2
-1
@@ -1358,7 +1358,8 @@ process_new_state(ServerState *state, int conn_idx, ByteView msg)
|
||||
memcpy(&new_state_message, msg.ptr, sizeof(new_state_message));
|
||||
|
||||
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
|
||||
if (new_state_message.view_number != state->view_number)
|
||||
|
||||
@@ -319,7 +319,8 @@ typedef struct {
|
||||
uint32_t checksum;
|
||||
} 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;
|
||||
|
||||
@@ -362,21 +363,28 @@ int view_and_commit_init(ViewAndCommit *vc, string file)
|
||||
}
|
||||
|
||||
if (size >= sizeof(ViewAndCommitDisk)) {
|
||||
ViewAndCommitDisk disk;
|
||||
|
||||
if (file_set_offset(handle, 0) < 0) {
|
||||
file_close(handle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ViewAndCommitDisk disk;
|
||||
if (file_read_exact(handle, (char *)&disk, sizeof(disk)) < 0) {
|
||||
file_close(handle);
|
||||
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->last_normal_view = disk.last_normal_view;
|
||||
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;
|
||||
@@ -389,7 +397,7 @@ void view_and_commit_free(ViewAndCommit *vc)
|
||||
}
|
||||
|
||||
int set_view_and_commit(ViewAndCommit *vc, uint64_t view_number,
|
||||
uint64_t last_normal_view, int commit_index)
|
||||
uint64_t last_normal_view, int commit_index)
|
||||
{
|
||||
ViewAndCommitDisk disk = {
|
||||
.view_number = view_number,
|
||||
|
||||
Reference in New Issue
Block a user