luainstance: add possibility to skip timeout ([basicsocket] receive timed out.) with luaclient <plugin> <...> DisableAbort

This commit is contained in:
Jacek Jendrzej
2021-09-03 09:19:22 +02:00
parent 743b3b2d6e
commit 772dae5e24
2 changed files with 12 additions and 2 deletions

View File

@@ -473,6 +473,7 @@ const char CLuaInstance::className[] = LUA_CLASSNAME;
CLuaInstance::CLuaInstance()
{
DisableAbort = true;
/* Create the intepreter object. */
lua = luaL_newstate();
@@ -523,7 +524,12 @@ void CLuaInstance::runScript(const char *fileName, std::vector<std::string> *arg
lua_rawseti(lua, -2, n++);
if (argv && (!argv->empty())) {
std::string abort = "DisableAbort";
for(std::vector<std::string>::iterator it = argv->begin(); it != argv->end(); ++it) {
if (!it->compare(abort)) {
DisableAbort = false;
continue;
}
lua_pushstring(lua, it->c_str());
lua_rawseti(lua, -2, n++);
}
@@ -592,7 +598,11 @@ static void abortHook(lua_State *lua, lua_Debug *)
void CLuaInstance::abortScript()
{
lua_sethook(lua, &abortHook, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
if(DisableAbort)
lua_sethook(lua, &abortHook, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
else
fprintf(stderr, "DisableAbort Script is aktiv\n");
}
#ifdef STATIC_LUAPOSIX

View File

@@ -42,7 +42,7 @@ public:
~CLuaInstance();
void runScript(const char *fileName, std::vector<std::string> *argv = NULL, std::string *result_code = NULL, std::string *result_string = NULL, std::string *error_string = NULL);
void abortScript();
bool DisableAbort;
enum {
DYNFONT_NO_ERROR = 0,
DYNFONT_MAXIMUM_FONTS = 1,