Merge branch 'unstable' into redis_6_merge

Former-commit-id: 30a603ce05956195aa027a3400eafd48d2750ea7
This commit is contained in:
John Sully 2020-02-16 18:18:24 -05:00
commit 04d174ba1a
4 changed files with 24 additions and 5 deletions

View File

@ -399,10 +399,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

@ -1367,6 +1367,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)
{ {
dictEntry *kde; dictEntry *kde;

View File

@ -3786,7 +3786,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()
{ {
@ -3799,7 +3799,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

@ -1085,10 +1085,13 @@ typedef struct clientReplyBlock {
/* 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 { struct redisDb {
redisDb() redisDb()
: expireitr(nullptr) : expireitr(nullptr)
{}; {};
~redisDb();
dict *pdict; /* The keyspace for this DB */ dict *pdict; /* The keyspace for this DB */
expireset *setexpire; expireset *setexpire;
expireset::setiter expireitr; expireset::setiter expireitr;
@ -1100,7 +1103,7 @@ typedef struct redisDb {
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 {