diff options
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/src/eval.c b/src/eval.c index 41dc3b611..1a9437a09 100644 --- a/src/eval.c +++ b/src/eval.c @@ -47,11 +47,6 @@ void ldbEnable(client *c); void evalGenericCommandWithDebugging(client *c, int evalsha); sds ldbCatStackValue(sds s, lua_State *lua, int idx); -typedef struct luaScript { - uint64_t flags; - robj *body; -} luaScript; - static void dictLuaScriptDestructor(dict *d, void *val) { UNUSED(d); if (val == NULL) return; /* Lazy freeing will set value to NULL. */ @@ -63,7 +58,7 @@ static uint64_t dictStrCaseHash(const void *key) { return dictGenCaseHashFunction((unsigned char*)key, strlen((char*)key)); } -/* server.lua_scripts sha (as sds string) -> scripts (as robj) cache. */ +/* server.lua_scripts sha (as sds string) -> scripts (as luaScript) cache. */ dictType shaScriptObjectDictType = { dictStrCaseHash, /* hash function */ NULL, /* key dup */ @@ -246,11 +241,14 @@ void scriptingInit(int setup) { " if i and i.what == 'C' then\n" " i = dbg.getinfo(3,'nSl')\n" " end\n" + " if type(err) ~= 'table' then\n" + " err = {err='ERR' .. tostring(err)}" + " end" " if i then\n" - " return i.source .. ':' .. i.currentline .. ': ' .. err\n" - " else\n" - " return err\n" - " end\n" + " err['source'] = i.source\n" + " err['line'] = i.currentline\n" + " end" + " return err\n" "end\n"; luaL_loadbuffer(lua,errh_func,strlen(errh_func),"@err_handler_def"); lua_pcall(lua,0,0,0); @@ -392,7 +390,7 @@ sds luaCreateFunction(client *c, robj *body) { if (luaL_loadbuffer(lctx.lua,funcdef,sdslen(funcdef),"@user_script")) { if (c != NULL) { addReplyErrorFormat(c, - "Error compiling script (new function): %s\n", + "Error compiling script (new function): %s", lua_tostring(lctx.lua,-1)); } lua_pop(lctx.lua,1); @@ -403,7 +401,7 @@ sds luaCreateFunction(client *c, robj *body) { if (lua_pcall(lctx.lua,0,0,0)) { if (c != NULL) { - addReplyErrorFormat(c,"Error running script (new function): %s\n", + addReplyErrorFormat(c,"Error running script (new function): %s", lua_tostring(lctx.lua,-1)); } lua_pop(lctx.lua,1); @@ -1479,8 +1477,8 @@ int ldbRepl(lua_State *lua) { while((argv = ldbReplParseCommand(&argc, &err)) == NULL) { char buf[1024]; if (err) { - lua_pushstring(lua, err); - lua_error(lua); + luaPushError(lua, err); + luaError(lua); } int nread = connRead(ldb.conn,buf,sizeof(buf)); if (nread <= 0) { @@ -1497,8 +1495,8 @@ int ldbRepl(lua_State *lua) { if (sdslen(ldb.cbuf) > 1<<20) { sdsfree(ldb.cbuf); ldb.cbuf = sdsempty(); - lua_pushstring(lua, "max client buffer reached"); - lua_error(lua); + luaPushError(lua, "max client buffer reached"); + luaError(lua); } } @@ -1558,8 +1556,8 @@ ldbLog(sdsnew(" next line of code.")); ldbEval(lua,argv,argc); ldbSendLogs(); } else if (!strcasecmp(argv[0],"a") || !strcasecmp(argv[0],"abort")) { - lua_pushstring(lua, "script aborted for user request"); - lua_error(lua); + luaPushError(lua, "script aborted for user request"); + luaError(lua); } else if (argc > 1 && (!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],"redis"))) { ldbRedis(lua,argv,argc); @@ -1640,8 +1638,8 @@ void luaLdbLineHook(lua_State *lua, lua_Debug *ar) { /* If the client closed the connection and we have a timeout * connection, let's kill the script otherwise the process * will remain blocked indefinitely. */ - lua_pushstring(lua, "timeout during Lua debugging with client closing connection"); - lua_error(lua); + luaPushError(lua, "timeout during Lua debugging with client closing connection"); + luaError(lua); } rctx->start_time = getMonotonicUs(); rctx->snapshot_time = mstime(); |