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...");