Merge branch 'redis_6_merge' into keydbpro

Former-commit-id: 8456e92d6e446f1cc20d9cea2328998da0a4d7d5
This commit is contained in:
John Sully 2020-02-16 18:28:45 -05:00
commit 74c7901a5e
4 changed files with 22 additions and 5 deletions

View File

@ -403,10 +403,18 @@ extern "C" void aeDeleteEventLoop(aeEventLoop *eventLoop) {
aeApiFree(eventLoop); aeApiFree(eventLoop);
zfree(eventLoop->events); zfree(eventLoop->events);
zfree(eventLoop->fired); zfree(eventLoop->fired);
zfree(eventLoop);
fastlock_free(&eventLoop->flock); fastlock_free(&eventLoop->flock);
close(eventLoop->fdCmdRead); close(eventLoop->fdCmdRead);
close(eventLoop->fdCmdWrite); close(eventLoop->fdCmdWrite);
auto *te = eventLoop->timeEventHead;
while (te)
{
auto *teNext = te->next;
zfree(te);
te = teNext;
}
zfree(eventLoop);
} }
extern "C" void aeStop(aeEventLoop *eventLoop) { extern "C" void aeStop(aeEventLoop *eventLoop) {

View File

@ -1495,6 +1495,14 @@ void setExpire(client *c, redisDb *db, robj *key, robj *subkey, long long when)
rememberSlaveKeyWithExpire(db,key); rememberSlaveKeyWithExpire(db,key);
} }
redisDb::~redisDb()
{
dictRelease(watched_keys);
dictRelease(ready_keys);
dictRelease(blocking_keys);
listRelease(defrag_later);
}
void setExpire(client *c, redisDb *db, robj *key, expireEntry &&e) void setExpire(client *c, redisDb *db, robj *key, expireEntry &&e)
{ {
serverAssert(GlobalLocksAcquired()); serverAssert(GlobalLocksAcquired());

View File

@ -3849,7 +3849,7 @@ private:
redisMaster *m_mi = nullptr; redisMaster *m_mi = nullptr;
}; };
static thread_local ReplicaNestState *s_pstate = nullptr; static thread_local std::unique_ptr<ReplicaNestState> s_pstate;
bool FInReplicaReplay() bool FInReplicaReplay()
{ {
@ -3862,7 +3862,7 @@ static std::unordered_map<std::string, uint64_t> g_mapmvcc;
void replicaReplayCommand(client *c) void replicaReplayCommand(client *c)
{ {
if (s_pstate == nullptr) if (s_pstate == nullptr)
s_pstate = new (MALLOC_LOCAL) ReplicaNestState; s_pstate = std::make_unique<ReplicaNestState>();
// the replay command contains two arguments: // the replay command contains two arguments:
// 1: The UUID of the source // 1: The UUID of the source

View File

@ -1400,7 +1400,7 @@ public:
/* Redis database representation. There are multiple databases identified /* Redis database representation. There are multiple databases identified
* by integers from 0 (the default database) up to the max configured * by integers from 0 (the default database) up to the max configured
* database. The database number is the 'id' field in the structure. */ * database. The database number is the 'id' field in the structure. */
typedef struct redisDb : public redisDbPersistentDataSnapshot struct redisDb : public redisDbPersistentDataSnapshot
{ {
// Legacy C API, Do not add more // Legacy C API, Do not add more
friend void tryResizeHashTables(int); friend void tryResizeHashTables(int);
@ -1425,6 +1425,7 @@ typedef struct redisDb : public redisDbPersistentDataSnapshot
: expireitr(nullptr) : expireitr(nullptr)
{} {}
void initialize(int id); void initialize(int id);
virtual ~redisDb();
void dbOverwriteCore(redisDb::iter itr, robj *key, robj *val, bool fUpdateMvcc, bool fRemoveExpire); void dbOverwriteCore(redisDb::iter itr, robj *key, robj *val, bool fUpdateMvcc, bool fRemoveExpire);
@ -1477,7 +1478,7 @@ public:
long long last_expire_set; /* when the last expire was set */ long long last_expire_set; /* when the last expire was set */
double avg_ttl; /* Average TTL, just for stats */ double avg_ttl; /* Average TTL, just for stats */
list *defrag_later; /* List of key names to attempt to defrag one by one, gradually. */ list *defrag_later; /* List of key names to attempt to defrag one by one, gradually. */
} redisDb; };
/* Client MULTI/EXEC state */ /* Client MULTI/EXEC state */
typedef struct multiCmd { typedef struct multiCmd {