diff options
author | dormando <dormando@rydia.net> | 2023-04-10 13:07:10 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2023-04-10 13:07:10 -0700 |
commit | 8bcf3b45b7735b25d8d361b8342fab3b1dbb5755 (patch) | |
tree | 6d31c13e9cea9b7db8edceb1d04def56d7ba88a0 | |
parent | 41be027140ac4c42564e472178e88ed149570fbd (diff) | |
download | memcached-8bcf3b45b7735b25d8d361b8342fab3b1dbb5755.tar.gz |
proxy: fix backend leak with 2-arg mcp.pool()
When mcp.pool() is called in its two argument form, ie: mcp.pool({b1,
b2}, { foo = bar }), backend objects would not be properly cached
internally, causing objects to leak.
Further, it was settings the objects into the cache table indexed by the
object itself, so they would not be cleaned up by garbage collection.
Bug was introduced as part of 6442017c (allow workers to run IO
optionally)
-rw-r--r-- | proxy_lua.c | 2 | ||||
-rw-r--r-- | t/proxyconfig.t | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/proxy_lua.c b/proxy_lua.c index 85de700..7f969c5 100644 --- a/proxy_lua.c +++ b/proxy_lua.c @@ -378,7 +378,7 @@ static mcp_backend_wrap_t *_mcplib_make_backendconn(lua_State *L, mcp_backend_la } #endif - lua_pushvalue(L, 4); // push the label string back to the top. + lua_pushvalue(L, -2); // push the label string back to the top. // Add this new backend connection to the object cache. lua_pushvalue(L, -2); // copy the backend reference to the top. // set our new backend wrapper object into the reference table. diff --git a/t/proxyconfig.t b/t/proxyconfig.t index 73b0169..e839bd8 100644 --- a/t/proxyconfig.t +++ b/t/proxyconfig.t @@ -265,6 +265,12 @@ is(<$watcher>, "OK\r\n", "watcher enabled"); push(@cli, $p); } + @readable = $s->can_read(0.25); + is(scalar @readable, 0, "no listeners should be active pre-reload"); + $p_srv->reload(); + wait_reload($watcher); + @readable = $s->can_read(0.25); + is(scalar @readable, 0, "no listeners should be active post-reload"); } ### |