Skip to content

Commit

Permalink
Remove SCRIPT KILL as it does not make sense in Thredis
Browse files Browse the repository at this point in the history
  • Loading branch information
grisha committed Nov 16, 2012
1 parent 8c52790 commit b107cf6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
1 change: 0 additions & 1 deletion src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ redisClient *createClient(int fd) {
c->lua_client = NULL;
}
c->lua_time_start = 0;
c->lua_kill = 0;

return c;
}
Expand Down
1 change: 0 additions & 1 deletion src/redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ typedef struct redisClient {
struct redisClient *lua_client; /* The "fake client" to query Redis from Lua */
lua_State *lua; /* The Lua interpreter for this client */
long long lua_time_start; /* Start time of script */
int lua_kill; /* Kill the script if true. */
} redisClient;

struct saveparam {
Expand Down
17 changes: 1 addition & 16 deletions src/scripting.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,6 @@ void luaMaskCountHook(lua_State *lua, lua_Debug *ar) {
lua_pushstring(lua, buf);
lua_error(lua);
}

if (lua_caller->lua_kill) {
/* THREDIS TODO - currently this is impossible */
redisLog(REDIS_WARNING,"Lua script killed by user with SCRIPT KILL.");
lua_pushstring(lua,"Script killed by user with SCRIPT KILL...");
lua_error(lua);
}
}

void luaLoadLib(lua_State *lua, const char *libname, lua_CFunction luafunc) {
Expand Down Expand Up @@ -870,7 +863,7 @@ void evalGenericCommand(redisClient *c, int evalsha) {
* We set the hook only if the time limit is enabled as the hook will
* make the Lua script execution slower. */
c->lua_time_start = ustime()/1000;
c->lua_kill = 0;

if (server.lua_time_limit > 0 && server.masterhost == NULL) {
lua_sethook(lua,luaMaskCountHook,LUA_MASKCOUNT,100000);
delhook = 1;
Expand Down Expand Up @@ -1011,14 +1004,6 @@ void scriptCommand(redisClient *c) {
}
addReplyBulkCBuffer(c,funcname+2,40);
sdsfree(sha);
} else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"kill")) {
// THREDIS TODO - this is broken
if (c->lua_time_start == 0) {
addReplyError(c,"No scripts in execution right now.");
} else {
c->lua_kill = 1;
addReply(c,shared.ok);
}
} else {
addReplyError(c, "Unknown SCRIPT subcommand or wrong # of args.");
}
Expand Down

0 comments on commit b107cf6

Please sign in to comment.