diff options
author | antirez <antirez@gmail.com> | 2017-11-29 11:39:19 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2017-11-29 11:39:19 +0100 |
commit | 8ad1eedbf9f180634b31d104bbea114671fc5a87 (patch) | |
tree | 831fe65e9e038fb03e664a5adf4eceb30206f9e0 /src/scripting.c | |
parent | 565e139a5631a777254e222d1c50ea6d696e1a8e (diff) | |
download | redis-rdb9.tar.gz |
RDB v9: Save Lua scripts state into RDB file.rdb9
This is currently needed in order to fix #4483, but this can be useful
in other contexts, so maybe later we may want to remove the conditionals
and always save/load scripts.
Diffstat (limited to 'src/scripting.c')
-rw-r--r-- | src/scripting.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/scripting.c b/src/scripting.c index d9f954068..64de1edcd 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -1160,16 +1160,21 @@ int luaCreateFunction(client *c, lua_State *lua, char *funcname, robj *body) { funcdef = sdscatlen(funcdef,"\nend",4); if (luaL_loadbuffer(lua,funcdef,sdslen(funcdef),"@user_script")) { - addReplyErrorFormat(c,"Error compiling script (new function): %s\n", - lua_tostring(lua,-1)); + if (c != NULL) { + addReplyErrorFormat(c, + "Error compiling script (new function): %s\n", + lua_tostring(lua,-1)); + } lua_pop(lua,1); sdsfree(funcdef); return C_ERR; } sdsfree(funcdef); if (lua_pcall(lua,0,0,0)) { - addReplyErrorFormat(c,"Error running script (new function): %s\n", - lua_tostring(lua,-1)); + if (c != NULL) { + addReplyErrorFormat(c,"Error running script (new function): %s\n", + lua_tostring(lua,-1)); + } lua_pop(lua,1); return C_ERR; } @@ -1180,7 +1185,7 @@ int luaCreateFunction(client *c, lua_State *lua, char *funcname, robj *body) { { int retval = dictAdd(server.lua_scripts, sdsnewlen(funcname+2,40),body); - serverAssertWithInfo(c,NULL,retval == DICT_OK); + serverAssertWithInfo(c ? c : server.lua_client,NULL,retval == DICT_OK); incrRefCount(body); } return C_OK; |