diff options
author | dormando <dormando@rydia.net> | 2022-10-20 23:17:50 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2022-10-20 23:17:50 -0700 |
commit | 5d2da18808d50705f5038f304974d99f75c30f25 (patch) | |
tree | 51df23b3b060c2ce94ec5add0fbc8c8340121239 /proxy_lua.c | |
parent | ebc91d71a583adf84e59f57a009dd1a2bcaf2465 (diff) | |
download | memcached-5d2da18808d50705f5038f304974d99f75c30f25.tar.gz |
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.
Diffstat (limited to 'proxy_lua.c')
-rw-r--r-- | proxy_lua.c | 6 |
1 files changed, 4 insertions, 2 deletions
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; } |