lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I have lua 5.3 embedded in a server application, basically responding to requests from other programs. There are multiple threads running lua vm's, and each thread handles one request until it is done. All requests run the same code. I have implemented this by loading the code when the per thread vm is created via lua_loadfile(), and execute it by lua_pushvalue()ing the function created by lua_loadfile() and then executing it using lua_pcall().

Now, the program being serviced by my server may have a request aborted on demand, and for that I need a way to abort a running vm in such a way that afterwards it is still functional, and the function created by lua_loadfile() is still on the stack for the next round of processing. My idea for this was to install a hook, probably a count hook, that checks for a flag to see whether the thread has been aborted, and if it has, just raises an error. This would abort the vm at the earliest convenient opportunity, and also offer the ability to handle te abort from within lua (to do some cleanup or whatever). But I was wondering, is there maybe a better solution for this kind of thing?

Regards,
Gunnar

Es ist keine Schande, vor Angst zu verblöden.