diff options
author | dormando <dormando@rydia.net> | 2023-01-20 16:02:53 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2023-01-20 16:02:53 -0800 |
commit | 3b9f7300b012805beaa6e0f01fcfde2ddcfe6b01 (patch) | |
tree | 12a2ba6e4a58a0a77d306da4a1bb1b522c936c92 /proxy.h | |
parent | 6537cfe41ead9c81dd3e9c9f5d3929a050692cbd (diff) | |
download | memcached-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.h')
-rw-r--r-- | proxy.h | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -42,15 +42,15 @@ #define WSTAT_L(t) pthread_mutex_lock(&t->stats.mutex); #define WSTAT_UL(t) pthread_mutex_unlock(&t->stats.mutex); -#define WSTAT_INCR(c, stat, amount) { \ - pthread_mutex_lock(&c->thread->stats.mutex); \ - c->thread->stats.stat += amount; \ - pthread_mutex_unlock(&c->thread->stats.mutex); \ +#define WSTAT_INCR(t, stat, amount) { \ + pthread_mutex_lock(&t->stats.mutex); \ + t->stats.stat += amount; \ + pthread_mutex_unlock(&t->stats.mutex); \ } -#define WSTAT_DECR(c, stat, amount) { \ - pthread_mutex_lock(&c->thread->stats.mutex); \ - c->thread->stats.stat -= amount; \ - pthread_mutex_unlock(&c->thread->stats.mutex); \ +#define WSTAT_DECR(t, stat, amount) { \ + pthread_mutex_lock(&t->stats.mutex); \ + t->stats.stat -= amount; \ + pthread_mutex_unlock(&t->stats.mutex); \ } #define STAT_L(ctx) pthread_mutex_lock(&ctx->stats_lock); #define STAT_UL(ctx) pthread_mutex_unlock(&ctx->stats_lock); |