summaryrefslogtreecommitdiff
path: root/proxy.h
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-03-04 21:44:24 -0800
committerdormando <dormando@rydia.net>2023-03-26 16:48:37 -0700
commite0fa1fe46aeb9e405cb58234f6016b2c48a10777 (patch)
treedecf57c8e0a321c6e4094391b32e2d7bfbbfddc4 /proxy.h
parent923df263b5e34449acee2ce24906653c7d8808e1 (diff)
downloadmemcached-e0fa1fe46aeb9e405cb58234f6016b2c48a10777.tar.gz
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.
Diffstat (limited to 'proxy.h')
-rw-r--r--proxy.h10
1 files changed, 6 insertions, 4 deletions
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;