From 8257a3c1f61ae05b9545446c0ee0a29cdc080e1a Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 5 May 2020 10:20:48 +0200 Subject: [PATCH] Move CRC64 initialization in main(). --- src/crc64.c | 3 --- src/server.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/crc64.c b/src/crc64.c index 9c555e98b..4cbc019f6 100644 --- a/src/crc64.c +++ b/src/crc64.c @@ -29,7 +29,6 @@ #include "crc64.h" #include "crcspeed.h" static uint64_t crc64_table[8][256] = {{0}}; -static int crc64_table_initialized = 0; #define POLY UINT64_C(0xad93d23594c935a9) /******************** BEGIN GENERATED PYCRC FUNCTIONS ********************/ @@ -116,12 +115,10 @@ uint64_t _crc64(uint_fast64_t crc, const void *in_data, const uint64_t len) { /* Initializes the 16KB lookup tables. */ void crc64_init(void) { crcspeed64native_init(_crc64, crc64_table); - crc64_table_initialized = 1; } /* Compute crc64 */ uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l) { - if (!crc64_table_initialized) crc64_init(); return crcspeed64native(crc64_table, crc, (void *) s, l); } diff --git a/src/server.c b/src/server.c index f2f5c8b3f..416dcd747 100644 --- a/src/server.c +++ b/src/server.c @@ -2899,7 +2899,6 @@ void initServer(void) { scriptingInit(1); slowlogInit(); latencyMonitorInit(); - crc64_init(); } /* Some steps in server initialization need to be done last (after modules @@ -4963,6 +4962,7 @@ int main(int argc, char **argv) { zmalloc_set_oom_handler(redisOutOfMemoryHandler); srand(time(NULL)^getpid()); gettimeofday(&tv,NULL); + crc64_init(); uint8_t hashseed[16]; getRandomBytes(hashseed,sizeof(hashseed));