summaryrefslogtreecommitdiff
path: root/proto_proxy.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2022-02-14 10:08:56 -0800
committerdormando <dormando@rydia.net>2022-02-14 10:08:56 -0800
commit7e58c6dd333b03e2cd7f1b1ef286da39f1a67fc3 (patch)
tree53edb3a1cc23258151ceb587a51fe9072b3ededd /proto_proxy.c
parente03751b2c411dd69325cbb634ef6fc996a9518b2 (diff)
downloadmemcached-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.c6
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);
}