Skip to content

Commit

Permalink
Remove dead code in luaCreateFunction about the client being NULL
Browse files Browse the repository at this point in the history
It was first added to load lua from RDB, see 28dfdca. After redis#9812,
we no longer save lua in RDB. luaCreateFunction will only be called
in script load and eval*, both of which are available in the client.

Remove the dead code and comments to avoid misunderstandings.
  • Loading branch information
enjoy-binbin committed Dec 4, 2023
1 parent 8a4ccb0 commit d5aa7f1
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,7 @@ uint64_t evalGetCommandFlags(client *c, uint64_t cmd_flags) {
* to scriptingReset() function), otherwise NULL is returned.
*
* The function handles the fact of being called with a script that already
* exists, and in such a case, it behaves like in the success case.
*
* If 'c' is not NULL, on error the client is informed with an appropriate
* error describing the nature of the problem and the Lua interpreter error. */
* exists, and in such a case, it behaves like in the success case. */
sds luaCreateFunction(client *c, robj *body) {
char funcname[43];
dictEntry *de;
Expand All @@ -442,11 +439,9 @@ sds luaCreateFunction(client *c, robj *body) {

/* Note that in case of a shebang line we skip it but keep the line feed to conserve the user's line numbers */
if (luaL_loadbuffer(lctx.lua,(char*)body->ptr + shebang_len,sdslen(body->ptr) - shebang_len,"@user_script")) {
if (c != NULL) {
addReplyErrorFormat(c,
"Error compiling script (new function): %s",
lua_tostring(lctx.lua,-1));
}
addReplyErrorFormat(c,
"Error compiling script (new function): %s",
lua_tostring(lctx.lua,-1));
lua_pop(lctx.lua,1);
return NULL;
}
Expand All @@ -463,7 +458,7 @@ sds luaCreateFunction(client *c, robj *body) {
l->flags = script_flags;
sds sha = sdsnewlen(funcname+2,40);
int retval = dictAdd(lctx.lua_scripts,sha,l);
serverAssertWithInfo(c ? c : lctx.lua_client,NULL,retval == DICT_OK);
serverAssertWithInfo(c, NULL, retval == DICT_OK);
lctx.lua_scripts_mem += sdsZmallocSize(sha) + getStringObjectSdsUsedMemory(body);
incrRefCount(body);
return sha;
Expand Down

0 comments on commit d5aa7f1

Please sign in to comment.