Move CEIL macro to basic.h and remove unnecessary heartbeat reset
- Move the CEIL macro from config.h to basic.h alongside MIN/MAX, and use it in deadline_to_timeout for the rounding-up division - Remove the heartbeat reset in complete_view_change_and_become_primary since it was not needed — heartbeat is already set when the node enters STATUS_CHANGE_VIEW, which is close enough in time https://claude.ai/code/session_0184gHjra7fsmSPZ4kppaGhC
This commit is contained in:
+1
-1
@@ -74,7 +74,7 @@ int deadline_to_timeout(Time deadline, Time current_time)
|
||||
if (deadline <= current_time)
|
||||
return 0;
|
||||
// Round up so sub-millisecond deadlines become 1ms, not 0
|
||||
return (deadline - current_time + 999999) / 1000000;
|
||||
return CEIL(deadline - current_time, 1000000);
|
||||
}
|
||||
|
||||
bool getargb(int argc, char **argv, char *name)
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef uint64_t Time;
|
||||
|
||||
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
|
||||
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
|
||||
#define CEIL(X, Y) (((X) + (Y) - 1) / (Y))
|
||||
|
||||
#define UNREACHABLE __builtin_trap();
|
||||
|
||||
|
||||
@@ -12,6 +12,5 @@
|
||||
#define REPLICATION_FACTOR 2
|
||||
#define CHUNK_SIZE 32
|
||||
#define MAX_TRANSFERS (META_CHUNKS_MAX * REPLICATION_FACTOR)
|
||||
#define CEIL(X, Y) (((X) + (Y) - 1) / (Y))
|
||||
|
||||
#endif // CONFIG_INCLUDED
|
||||
@@ -517,7 +517,6 @@ complete_view_change_and_become_primary(ServerState *state)
|
||||
broadcast_to_peers_ex(state, &begin_view_message.base, state->log.entries, state->log.count * sizeof(LogEntry));
|
||||
|
||||
clear_view_change_fields(state);
|
||||
state->heartbeat = state->now;
|
||||
return HR_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user