From badb709a8ff694f2ed5a495cf0064846be81e209 Mon Sep 17 00:00:00 2001 From: John Sully Date: Fri, 27 Dec 2019 17:45:56 -0500 Subject: [PATCH 1/2] Ignore dependency files Former-commit-id: 6e06e0dfc7cd572d93cce99c4b8b8b0b59e95e60 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c5cba54dd..f6e6abb12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .*.swp core *.o +*.d *.log dump.rdb redis-benchmark From da17594170d444d944698e5be71c616296900a41 Mon Sep 17 00:00:00 2001 From: John Sully Date: Fri, 27 Dec 2019 18:17:22 -0500 Subject: [PATCH 2/2] Fix some static analysis warnings Former-commit-id: 42a8f22c21706f9ddcaa63ceafc5ad817c1fe876 --- src/ae.cpp | 15 +++++++++------ src/rdb.cpp | 2 +- src/replication.cpp | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ae.cpp b/src/ae.cpp index 87212f704..90c148510 100644 --- a/src/ae.cpp +++ b/src/ae.cpp @@ -84,7 +84,7 @@ fastlock g_lock("AE (global)"); #endif thread_local aeEventLoop *g_eventLoopThisThread = NULL; -#define AE_ASSERT(x) if (!(x)) do { fprintf(stderr, "AE_ASSERT FAILURE %s: %d\n", __FILE__, __LINE__); *((volatile int*)0) = 1; } while(0) +#define AE_ASSERT(x) if (!(x)) do { fprintf(stderr, "AE_ASSERT FAILURE %s: %d\n", __FILE__, __LINE__); *((volatile int*)1) = 1; } while(0) /* Include the best multiplexing layer supported by this system. * The following should be ordered by performances, descending. */ @@ -237,11 +237,11 @@ int aeCreateRemoteFileEvent(aeEventLoop *eventLoop, int fd, int mask, cmd.clientData = clientData; cmd.pctl = nullptr; if (fSynchronous) + { cmd.pctl = new (MALLOC_LOCAL) aeCommandControl(); - - std::unique_lock ulock(cmd.pctl->mutexcv, std::defer_lock); - if (fSynchronous) cmd.pctl->mutexcv.lock(); + } + auto size = safe_write(eventLoop->fdCmdWrite, &cmd, sizeof(cmd)); if (size != sizeof(cmd)) { @@ -252,6 +252,7 @@ int aeCreateRemoteFileEvent(aeEventLoop *eventLoop, int fd, int mask, if (fSynchronous) { + std::unique_lock ulock(cmd.pctl->mutexcv, std::defer_lock); cmd.pctl->cv.wait(ulock); ret = cmd.pctl->rval; delete cmd.pctl; @@ -289,15 +290,17 @@ int aePostFunction(aeEventLoop *eventLoop, std::function fn, bool fSynch cmd.pfn = new (MALLOC_LOCAL) std::function(fn); cmd.pctl = nullptr; if (fSynchronous) + { cmd.pctl = new (MALLOC_LOCAL) aeCommandControl(); - std::unique_lock ulock(cmd.pctl->mutexcv, std::defer_lock); - if (fSynchronous) cmd.pctl->mutexcv.lock(); + } + auto size = write(eventLoop->fdCmdWrite, &cmd, sizeof(cmd)); AE_ASSERT(size == sizeof(cmd)); int ret = AE_OK; if (fSynchronous) { + std::unique_lock ulock(cmd.pctl->mutexcv, std::defer_lock); cmd.pctl->cv.wait(ulock); ret = cmd.pctl->rval; delete cmd.pctl; diff --git a/src/rdb.cpp b/src/rdb.cpp index 1c5b25d16..b76afdfd7 100644 --- a/src/rdb.cpp +++ b/src/rdb.cpp @@ -1919,7 +1919,7 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof) { redisDb *db = g_pserver->db+0; char buf[1024]; /* Key-specific attributes, set by opcodes before the key type. */ - long long lru_idle = -1, lfu_freq = -1, expiretime = -1, now = mstime(); + long long lru_idle = -1, lfu_freq = -1, expiretime = -1, now; long long lru_clock = 0; uint64_t mvcc_tstamp = OBJ_MVCC_INVALID; robj *subexpireKey = nullptr; diff --git a/src/replication.cpp b/src/replication.cpp index b7eb13aeb..ec2bbea63 100644 --- a/src/replication.cpp +++ b/src/replication.cpp @@ -3061,7 +3061,7 @@ void replicationCron(void) { } /* Timed out master when we are an already connected replica? */ - if (mi->masterhost && mi->repl_state == REPL_STATE_CONNECTED && + if (mi->masterhost && mi->master && mi->repl_state == REPL_STATE_CONNECTED && (time(NULL)-mi->master->lastinteraction) > g_pserver->repl_timeout) { serverLog(LL_WARNING,"MASTER timeout: no data nor PING received...");