Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,25 @@ void evalRelease(int async) {
}
}

/* Remove all cached eval scripts associated with the given scripting engine.
* Called when a scripting engine is unregistered to avoid dangling engine
* pointers in the eval script cache. */
void evalRemoveScriptsOfEngine(scriptingEngine *engine) {
dictIterator *iter = dictGetSafeIterator(evalCtx.scripts);
dictEntry *entry;
while ((entry = dictNext(iter))) {
evalScript *es = dictGetVal(entry);
if (es->engine == engine) {
sds sha = dictGetKey(entry);
evalCtx.scripts_mem -= sdsAllocSize(sha) + getStringObjectSdsUsedMemory(es->body);
if (es->node) {
listDelNode(evalCtx.scripts_lru_list, es->node);
}
dictDelete(evalCtx.scripts, sha);
}
}
dictReleaseIterator(iter);
}

void evalReset(int async) {
evalRelease(async);
Expand Down
3 changes: 3 additions & 0 deletions src/eval.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#ifndef _EVAL_H_
#define _EVAL_H_

typedef struct scriptingEngine scriptingEngine;

void evalInit(void);
void evalReset(int async);
void evalRemoveScriptsOfEngine(scriptingEngine *engine);
void *evalActiveDefragScript(void *ptr);

#endif /* _EVAL_H_ */
2 changes: 2 additions & 0 deletions src/scripting_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "scripting_engine.h"
#include "bio.h"
#include "dict.h"
#include "eval.h"
#include "functions.h"
#include "module.h"
#include "server.h"
Expand Down Expand Up @@ -178,6 +179,7 @@ int scriptingEngineManagerUnregister(const char *engine_name) {
scriptingEngine *e = dictGetVal(entry);

functionsRemoveLibFromEngine(e);
evalRemoveScriptsOfEngine(e);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one is named fromEngine, one is ofengine, can we do the same?


engineMemoryInfo mem_info = scriptingEngineCallGetMemoryInfo(e, VMSE_ALL);
engineMgr.total_memory_overhead -= zmalloc_size(e) +
Expand Down
Loading