summaryrefslogtreecommitdiff
path: root/proxy_await.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-01-20 16:02:53 -0800
committerdormando <dormando@rydia.net>2023-01-20 16:02:53 -0800
commit3b9f7300b012805beaa6e0f01fcfde2ddcfe6b01 (patch)
tree12a2ba6e4a58a0a77d306da4a1bb1b522c936c92 /proxy_await.c
parent6537cfe41ead9c81dd3e9c9f5d3929a050692cbd (diff)
downloadmemcached-3b9f7300b012805beaa6e0f01fcfde2ddcfe6b01.tar.gz
proxy: fix stats deadlock caused by await code
- specifically the WSTAT_DECR in proxy_await.c's return code could potentially use the wrong thread's lock This is why I've been swapping c with thread as lock/function arguments all over the code lately; it's very accident prone. Am reasonably sure this causes the deadlock but need to attempt to verify more.
Diffstat (limited to 'proxy_await.c')
-rw-r--r--proxy_await.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/proxy_await.c b/proxy_await.c
index 3dfd16b..4192900 100644
--- a/proxy_await.c
+++ b/proxy_await.c
@@ -132,7 +132,7 @@ static void mcp_queue_await_io(conn *c, lua_State *Lc, mcp_request_t *rq, int aw
io_pending_proxy_t *p = do_cache_alloc(c->thread->io_cache);
if (p == NULL) {
- WSTAT_INCR(c, proxy_conn_oom, 1);
+ WSTAT_INCR(c->thread, proxy_conn_oom, 1);
proxy_lua_error(Lc, "out of memory allocating from IO cache");
return;
}
@@ -186,7 +186,7 @@ static void mcp_queue_await_dummy_io(conn *c, lua_State *Lc, int await_ref) {
io_pending_proxy_t *p = do_cache_alloc(c->thread->io_cache);
if (p == NULL) {
- WSTAT_INCR(c, proxy_conn_oom, 1);
+ WSTAT_INCR(c->thread, proxy_conn_oom, 1);
proxy_lua_error(Lc, "out of memory allocating from IO cache");
return;
}
@@ -223,7 +223,7 @@ static void mcp_queue_await_dummy_io(conn *c, lua_State *Lc, int await_ref) {
// places. Else these errors currently crash the daemon.
int mcplib_await_run(conn *c, mc_resp *resp, lua_State *L, int coro_ref) {
P_DEBUG("%s: start\n", __func__);
- WSTAT_INCR(c, proxy_await_active, 1);
+ WSTAT_INCR(c->thread, proxy_await_active, 1);
mcp_await_t *aw = lua_touserdata(L, -1);
int await_ref = luaL_ref(L, LUA_REGISTRYINDEX); // await is popped.
assert(aw != NULL);
@@ -430,7 +430,7 @@ int mcplib_await_return(io_pending_proxy_t *p) {
luaL_unref(L, LUA_REGISTRYINDEX, aw->argtable_ref);
luaL_unref(L, LUA_REGISTRYINDEX, aw->req_ref);
luaL_unref(L, LUA_REGISTRYINDEX, p->await_ref);
- WSTAT_DECR(p->c, proxy_await_active, 1);
+ WSTAT_DECR(p->thread, proxy_await_active, 1);
}
// Just remove anything we could have left on the primary VM stack