diff options
author | dormando <dormando@rydia.net> | 2022-02-14 10:08:56 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2022-02-14 10:08:56 -0800 |
commit | 7e58c6dd333b03e2cd7f1b1ef286da39f1a67fc3 (patch) | |
tree | 53edb3a1cc23258151ceb587a51fe9072b3ededd /proto_proxy.c | |
parent | e03751b2c411dd69325cbb634ef6fc996a9518b2 (diff) | |
download | memcached-7e58c6dd333b03e2cd7f1b1ef286da39f1a67fc3.tar.gz |
proxy: fix crash on `stats proxy` sans user stats
Fix is a little subtle: there's a race condition when a user stat is
added to the global context but the worker threads aren't updated yet.
So we check that the context in the user thread has enough stats slots
to iterate, and that the user thread has stats at all.
Diffstat (limited to 'proto_proxy.c')
-rw-r--r-- | proto_proxy.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/proto_proxy.c b/proto_proxy.c index 24e6180..bd1e6e5 100644 --- a/proto_proxy.c +++ b/proto_proxy.c @@ -506,8 +506,10 @@ void process_proxy_stats(ADD_STAT add_stats, conn *c) { for (int i = 0; i < CMD_FINAL; i++) { istats.counters[i] += is->counters[i]; } - for (int i = 0; i < tus->num_stats; i++) { - counters[i] += tus->counters[i]; + if (tus && tus->num_stats >= us->num_stats) { + for (int i = 0; i < us->num_stats; i++) { + counters[i] += tus->counters[i]; + } } WSTAT_UL(t); } |