mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Scripting: use mstime() and mstime_t for lua_time_start.
server.lua_time_start is expressed in milliseconds. Use mstime_t instead of long long, and populate it with mstime() instead of ustime()/1000. Functionally identical but more natural.
This commit is contained in:
parent
b0335287ac
commit
89884e8f6e
@ -799,8 +799,8 @@ struct redisServer {
|
|||||||
redisClient *lua_client; /* The "fake client" to query Redis from Lua */
|
redisClient *lua_client; /* The "fake client" to query Redis from Lua */
|
||||||
redisClient *lua_caller; /* The client running EVAL right now, or NULL */
|
redisClient *lua_caller; /* The client running EVAL right now, or NULL */
|
||||||
dict *lua_scripts; /* A dictionary of SHA1 -> Lua scripts */
|
dict *lua_scripts; /* A dictionary of SHA1 -> Lua scripts */
|
||||||
long long lua_time_limit; /* Script timeout in seconds */
|
mstime_t lua_time_limit; /* Script timeout in milliseconds */
|
||||||
long long lua_time_start; /* Start time of script */
|
mstime_t lua_time_start; /* Start time of script, milliseconds time */
|
||||||
int lua_write_dirty; /* True if a write command was called during the
|
int lua_write_dirty; /* True if a write command was called during the
|
||||||
execution of the current script. */
|
execution of the current script. */
|
||||||
int lua_random_dirty; /* True if a random command was called during the
|
int lua_random_dirty; /* True if a random command was called during the
|
||||||
|
@ -441,7 +441,7 @@ void luaMaskCountHook(lua_State *lua, lua_Debug *ar) {
|
|||||||
REDIS_NOTUSED(ar);
|
REDIS_NOTUSED(ar);
|
||||||
REDIS_NOTUSED(lua);
|
REDIS_NOTUSED(lua);
|
||||||
|
|
||||||
elapsed = (ustime()/1000) - server.lua_time_start;
|
elapsed = mstime() - server.lua_time_start;
|
||||||
if (elapsed >= server.lua_time_limit && server.lua_timedout == 0) {
|
if (elapsed >= server.lua_time_limit && server.lua_timedout == 0) {
|
||||||
redisLog(REDIS_WARNING,"Lua slow script detected: still in execution after %lld milliseconds. You can try killing the script using the SCRIPT KILL command.",elapsed);
|
redisLog(REDIS_WARNING,"Lua slow script detected: still in execution after %lld milliseconds. You can try killing the script using the SCRIPT KILL command.",elapsed);
|
||||||
server.lua_timedout = 1;
|
server.lua_timedout = 1;
|
||||||
@ -900,7 +900,7 @@ void evalGenericCommand(redisClient *c, int evalsha) {
|
|||||||
* We set the hook only if the time limit is enabled as the hook will
|
* We set the hook only if the time limit is enabled as the hook will
|
||||||
* make the Lua script execution slower. */
|
* make the Lua script execution slower. */
|
||||||
server.lua_caller = c;
|
server.lua_caller = c;
|
||||||
server.lua_time_start = ustime()/1000;
|
server.lua_time_start = mstime();
|
||||||
server.lua_kill = 0;
|
server.lua_kill = 0;
|
||||||
if (server.lua_time_limit > 0 && server.masterhost == NULL) {
|
if (server.lua_time_limit > 0 && server.masterhost == NULL) {
|
||||||
lua_sethook(lua,luaMaskCountHook,LUA_MASKCOUNT,100000);
|
lua_sethook(lua,luaMaskCountHook,LUA_MASKCOUNT,100000);
|
||||||
|
Loading…
Reference in New Issue
Block a user