diff --git a/src/basic.c b/src/basic.c index 3974344..b1f706f 100644 --- a/src/basic.c +++ b/src/basic.c @@ -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) diff --git a/src/basic.h b/src/basic.h index dfb641f..7ab2fa2 100644 --- a/src/basic.h +++ b/src/basic.h @@ -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(); diff --git a/src/config.h b/src/config.h index 2e2a80f..f997aee 100644 --- a/src/config.h +++ b/src/config.h @@ -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 \ No newline at end of file diff --git a/src/server.c b/src/server.c index 0091bdd..18de29f 100644 --- a/src/server.c +++ b/src/server.c @@ -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; }