mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 00:50:50 +00:00
PSYNC2: luaCreateFunction() should handle NULL client parameter.
See #4483. This is needed because luaCreateFunction() is now called from RDB loading code outside a client context.
This commit is contained in:
parent
f11a7585a8
commit
28dfdca733
@ -1160,16 +1160,21 @@ int luaCreateFunction(client *c, lua_State *lua, char *funcname, robj *body) {
|
|||||||
funcdef = sdscatlen(funcdef,"\nend",4);
|
funcdef = sdscatlen(funcdef,"\nend",4);
|
||||||
|
|
||||||
if (luaL_loadbuffer(lua,funcdef,sdslen(funcdef),"@user_script")) {
|
if (luaL_loadbuffer(lua,funcdef,sdslen(funcdef),"@user_script")) {
|
||||||
addReplyErrorFormat(c,"Error compiling script (new function): %s\n",
|
if (c != NULL) {
|
||||||
lua_tostring(lua,-1));
|
addReplyErrorFormat(c,
|
||||||
|
"Error compiling script (new function): %s\n",
|
||||||
|
lua_tostring(lua,-1));
|
||||||
|
}
|
||||||
lua_pop(lua,1);
|
lua_pop(lua,1);
|
||||||
sdsfree(funcdef);
|
sdsfree(funcdef);
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
}
|
}
|
||||||
sdsfree(funcdef);
|
sdsfree(funcdef);
|
||||||
if (lua_pcall(lua,0,0,0)) {
|
if (lua_pcall(lua,0,0,0)) {
|
||||||
addReplyErrorFormat(c,"Error running script (new function): %s\n",
|
if (c != NULL) {
|
||||||
lua_tostring(lua,-1));
|
addReplyErrorFormat(c,"Error running script (new function): %s\n",
|
||||||
|
lua_tostring(lua,-1));
|
||||||
|
}
|
||||||
lua_pop(lua,1);
|
lua_pop(lua,1);
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
}
|
}
|
||||||
@ -1180,7 +1185,7 @@ int luaCreateFunction(client *c, lua_State *lua, char *funcname, robj *body) {
|
|||||||
{
|
{
|
||||||
int retval = dictAdd(server.lua_scripts,
|
int retval = dictAdd(server.lua_scripts,
|
||||||
sdsnewlen(funcname+2,40),body);
|
sdsnewlen(funcname+2,40),body);
|
||||||
serverAssertWithInfo(c,NULL,retval == DICT_OK);
|
serverAssertWithInfo(c ? c : server.lua_client,NULL,retval == DICT_OK);
|
||||||
incrRefCount(body);
|
incrRefCount(body);
|
||||||
}
|
}
|
||||||
return C_OK;
|
return C_OK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user