From e0fa1fe46aeb9e405cb58234f6016b2c48a10777 Mon Sep 17 00:00:00 2001 From: dormando Date: Sat, 4 Mar 2023 21:44:24 -0800 Subject: proxy: restrict functions for lua config vs route Also changes the way the global context and thread contexts are fetched from lua; via the VM extra space instead of upvalues, which is a little faster and more universal. It was always erroneous to run a lot of the config functions from routes and vice versa, but there was no consistent strictness so users could get into trouble. --- proxy.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'proxy.h') diff --git a/proxy.h b/proxy.h index f8ceec3..0ab3b91 100644 --- a/proxy.h +++ b/proxy.h @@ -76,10 +76,7 @@ #define ENDSTR "END\r\n" #define ENDLEN sizeof(ENDSTR)-1 -#define MCP_THREAD_UPVALUE 1 -#define MCP_ATTACH_UPVALUE 2 -#define MCP_BACKEND_UPVALUE 3 -#define MCP_CONTEXT_UPVALUE 4 +#define MCP_BACKEND_UPVALUE 1 #define MCP_YIELD_POOL 1 #define MCP_YIELD_AWAIT 2 @@ -217,6 +214,11 @@ typedef struct { pthread_mutex_t stats_lock; // used for rare global counters } proxy_ctx_t; +#define PROXY_GET_THR_CTX(L) ((*(LIBEVENT_THREAD **)lua_getextraspace(L))->proxy_ctx) +#define PROXY_GET_THR(L) (*(LIBEVENT_THREAD **)lua_getextraspace(L)) +// Operations from the config VM don't have a libevent thread. +#define PROXY_GET_CTX(L) (*(proxy_ctx_t **)lua_getextraspace(L)) + struct proxy_hook_tagged { uint64_t tag; int lua_ref; -- cgit v1.2.1