• Meir Shpilraien (Spielrein)'s avatar
    Fix script kill to work also on scripts that use pcall (#8661) · 9ae4f5c7
    Meir Shpilraien (Spielrein) authored
    pcall function runs another LUA function in protected mode, this means
    that any error will be caught by this function and will not stop the LUA
    execution. The script kill mechanism uses error to stop the running script.
    Scripts that uses pcall can catch the error raise by the script kill mechanism,
    this will cause a script like this to be unkillable:
    
    local f = function()
            while 1 do
                    redis.call('ping')
            end
    end
    while 1 do
            pcall(f)
    end
    
    The fix is, when we want to kill the script, we set the hook function to be invoked 
    after each line. This will promise that the execution will get another
    error before it is able to enter the pcall function again.
    9ae4f5c7
scripting.tcl 30.7 KB