Fix memory leaks
This commit is contained in:
parent
8b755aee1b
commit
f435218ed9
@ -2703,11 +2703,6 @@ void redisDbPersistentData::prepOverwriteForSnapshot(char *key)
|
|||||||
auto itr = m_pdbSnapshot->find_cached_threadsafe(key);
|
auto itr = m_pdbSnapshot->find_cached_threadsafe(key);
|
||||||
if (itr.key() != nullptr)
|
if (itr.key() != nullptr)
|
||||||
{
|
{
|
||||||
if (itr.val()->FExpires()) {
|
|
||||||
// Note: I'm sure we could handle this, but its too risky at the moment.
|
|
||||||
// There are known bugs doing this with expires
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sds keyNew = sdsdupshared(itr.key());
|
sds keyNew = sdsdupshared(itr.key());
|
||||||
if (dictAdd(m_pdictTombstone, keyNew, (void*)dictHashKey(m_pdict, key)) != DICT_OK)
|
if (dictAdd(m_pdictTombstone, keyNew, (void*)dictHashKey(m_pdict, key)) != DICT_OK)
|
||||||
sdsfree(keyNew);
|
sdsfree(keyNew);
|
||||||
|
@ -160,6 +160,8 @@ public:
|
|||||||
|
|
||||||
expireEntry &operator=(expireEntry &&e)
|
expireEntry &operator=(expireEntry &&e)
|
||||||
{
|
{
|
||||||
|
if (FFat())
|
||||||
|
delete pfatentry();
|
||||||
s = e.s;
|
s = e.s;
|
||||||
e.s.m_whenAndPtrUnion = 0;
|
e.s.m_whenAndPtrUnion = 0;
|
||||||
e.s.fFat = false;
|
e.s.fFat = false;
|
||||||
@ -167,6 +169,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
expireEntry &operator=(expireEntry &e) {
|
expireEntry &operator=(expireEntry &e) {
|
||||||
|
if (FFat())
|
||||||
|
delete pfatentry();
|
||||||
if (e.FFat()) {
|
if (e.FFat()) {
|
||||||
s.m_whenAndPtrUnion = reinterpret_cast<long long>(new expireEntryFat(*e.pfatentry()));
|
s.m_whenAndPtrUnion = reinterpret_cast<long long>(new expireEntryFat(*e.pfatentry()));
|
||||||
s.fFat = true;
|
s.fFat = true;
|
||||||
|
@ -4,7 +4,7 @@ OBJECT_FILES := modmain.o
|
|||||||
MODSNAP_CXX_FLAGS := -std=gnu++14
|
MODSNAP_CXX_FLAGS := -std=gnu++14
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CXX) -o $@ -c $< $(MODULE_FLAGS) -I../../../deps/cpp-statsd-client/include $(MODSNAP_CXX_FLAGS)
|
$(CXX) -o $@ -c $< $(MODULE_FLAGS) -I../../../deps/cpp-statsd-client/include $(MODSNAP_CXX_FLAGS) -g
|
||||||
|
|
||||||
modstatsd.so: $(OBJECT_FILES)
|
modstatsd.so: $(OBJECT_FILES)
|
||||||
$(CXX) -shared $(OBJECT_FILES) -o modstatsd.so
|
$(CXX) -shared $(OBJECT_FILES) -o modstatsd.so
|
||||||
|
@ -46,6 +46,7 @@ robj *createObject(int type, void *ptr) {
|
|||||||
char *oB = (char*)zcalloc(sizeof(robj)+mvccExtraBytes, MALLOC_SHARED);
|
char *oB = (char*)zcalloc(sizeof(robj)+mvccExtraBytes, MALLOC_SHARED);
|
||||||
robj *o = reinterpret_cast<robj*>(oB + mvccExtraBytes);
|
robj *o = reinterpret_cast<robj*>(oB + mvccExtraBytes);
|
||||||
|
|
||||||
|
new (o) redisObject;
|
||||||
o->type = type;
|
o->type = type;
|
||||||
o->encoding = OBJ_ENCODING_RAW;
|
o->encoding = OBJ_ENCODING_RAW;
|
||||||
o->m_ptr = ptr;
|
o->m_ptr = ptr;
|
||||||
@ -418,6 +419,7 @@ void decrRefCount(robj_roptr o) {
|
|||||||
case OBJ_NESTEDHASH: freeNestedHashObject(o); break;
|
case OBJ_NESTEDHASH: freeNestedHashObject(o); break;
|
||||||
default: serverPanic("Unknown object type"); break;
|
default: serverPanic("Unknown object type"); break;
|
||||||
}
|
}
|
||||||
|
o->~redisObject();
|
||||||
if (g_pserver->fActiveReplica) {
|
if (g_pserver->fActiveReplica) {
|
||||||
zfree(reinterpret_cast<redisObjectExtended*>(o.unsafe_robjcast())-1);
|
zfree(reinterpret_cast<redisObjectExtended*>(o.unsafe_robjcast())-1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,6 +188,8 @@ int bg_unlink(const char *filename) {
|
|||||||
/* ---------------------------------- MASTER -------------------------------- */
|
/* ---------------------------------- MASTER -------------------------------- */
|
||||||
|
|
||||||
bool createDiskBacklog() {
|
bool createDiskBacklog() {
|
||||||
|
if (g_pserver->repl_backlog_disk != nullptr)
|
||||||
|
return true; // already exists
|
||||||
// Lets create some disk backed pages and add them here
|
// Lets create some disk backed pages and add them here
|
||||||
std::string path = "./repl-backlog-temp" + std::to_string(gettid());
|
std::string path = "./repl-backlog-temp" + std::to_string(gettid());
|
||||||
#if (defined __APPLE__ || defined __FreeBSD__)
|
#if (defined __APPLE__ || defined __FreeBSD__)
|
||||||
|
@ -966,6 +966,7 @@ struct redisObjectExtended {
|
|||||||
|
|
||||||
typedef struct redisObject {
|
typedef struct redisObject {
|
||||||
friend redisObject *createEmbeddedStringObject(const char *ptr, size_t len);
|
friend redisObject *createEmbeddedStringObject(const char *ptr, size_t len);
|
||||||
|
friend redisObject *createObject(int type, void *ptr);
|
||||||
protected:
|
protected:
|
||||||
redisObject() {}
|
redisObject() {}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user