From 5d2da18808d50705f5038f304974d99f75c30f25 Mon Sep 17 00:00:00 2001 From: dormando Date: Thu, 20 Oct 2022 23:17:50 -0700 Subject: proxy: fix crash when backensd are gc'd crept in on an earlier cleanup commit. for some reason pools get gc'ed pretty quickly but backends take several HUP's so I didn't see this until I sat here HUP'ing the proxy 10+ times in a row. --- proxy_lua.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'proxy_lua.c') diff --git a/proxy_lua.c b/proxy_lua.c index 8531f03..495c0de 100644 --- a/proxy_lua.c +++ b/proxy_lua.c @@ -96,10 +96,12 @@ static int mcplib_backend_gc(lua_State *L) { assert(STAILQ_EMPTY(&be->io_head)); mcmc_disconnect(be->client); - free(be->client); - proxy_ctx_t *ctx = lua_touserdata(L, lua_upvalueindex(MCP_CONTEXT_UPVALUE)); + // FIXME (v2): can we ensure a backend always has be->event_thread set, so + // we can use be->event_thread->ctx? + proxy_ctx_t *ctx = settings.proxy_ctx; STAT_DECR(ctx, backend_total, 1); + free(be->client); return 0; } -- cgit v1.2.1