From 746c04fb9d687b659830c73e847b00cb964a193a Mon Sep 17 00:00:00 2001 From: Ali-Akber Saifee Date: Tue, 7 Jun 2022 19:26:02 -0700 Subject: [PATCH] Use sum instead of individual counts for channels/patterns (#119) --- src/server/conn_context.cc | 4 ++-- src/server/conn_context.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/server/conn_context.cc b/src/server/conn_context.cc index c9d30ed..222567d 100644 --- a/src/server/conn_context.cc +++ b/src/server/conn_context.cc @@ -38,7 +38,7 @@ void ConnectionContext::ChangeSubscription(bool to_add, bool to_reply, CmdArgLis } if (to_reply) - result[i] = conn_state.subscribe_info->channels.size(); + result[i] = conn_state.subscribe_info->SubscriptionCount(); if (res) { ShardId sid = Shard(channel, shard_set->size()); @@ -132,7 +132,7 @@ void ConnectionContext::ChangePSub(bool to_add, bool to_reply, CmdArgList args) } if (to_reply) - result[i] = conn_state.subscribe_info->patterns.size(); + result[i] = conn_state.subscribe_info->SubscriptionCount(); if (res) { patterns.emplace_back(pattern); diff --git a/src/server/conn_context.h b/src/server/conn_context.h index daf0b96..57536b3 100644 --- a/src/server/conn_context.h +++ b/src/server/conn_context.h @@ -58,6 +58,10 @@ struct ConnectionState { return channels.empty() && patterns.empty(); } + unsigned SubscriptionCount() const { + return channels.size() + patterns.size(); + } + SubscribeInfo() : borrow_token(0) { } };