I have Lua embedded in a C host. And I have several C functions registered with Lua.
Is there any way that when I call Lua and then Lua calls my C function, a value can be passed along from the "outer" C code to the "inner" C code?
The specific problem is that I have an HTTP request pointer that I need to access from the callback function, and I'd rather not store it in a global variable due to this potentially being multithreaded code.
When your "outer" C code calls Lua, pass the HTTP request pointer as a light userdata argument. Inside Lua, treat it as an opaque value that you pass to the "inner" C callback as an argument again. Then have your "inner" C code just read it and cast it back to the right type.
By the way, Lua itself isn't thread-safe, so be careful of that if your application is multithreaded.