Turn on exclusive senders in LogReader
This makes it so that we now automatically detect situations where a
user attempts to send messages during replay that are simultaneously
*being* replayed.
Change-Id: I40f30693fe93c94018b6ddbc9f748e655cdf1fe3
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/network/message_bridge_client_status.cc b/aos/network/message_bridge_client_status.cc
index aa2484d..f3511a0 100644
--- a/aos/network/message_bridge_client_status.cc
+++ b/aos/network/message_bridge_client_status.cc
@@ -219,12 +219,16 @@
filter->Sample(monotonic_delivered_time, offset);
}
-void MessageBridgeClientStatus::DisableStatistics() {
+void MessageBridgeClientStatus::DisableStatistics(bool destroy_sender) {
statistics_timer_->Disable();
send_ = false;
+ if (destroy_sender) {
+ sender_ = aos::Sender<ClientStatistics>();
+ }
}
void MessageBridgeClientStatus::EnableStatistics() {
+ CHECK(sender_.valid());
send_ = true;
statistics_timer_->Setup(event_loop_->monotonic_now() + kStatisticsPeriod,
kStatisticsPeriod);
diff --git a/aos/network/message_bridge_client_status.h b/aos/network/message_bridge_client_status.h
index 9c21169..033af95 100644
--- a/aos/network/message_bridge_client_status.h
+++ b/aos/network/message_bridge_client_status.h
@@ -54,7 +54,10 @@
void Connect(int client_index);
// Disables sending out any statistics messages.
- void DisableStatistics();
+ // If destroy_sender is set, will clear the ClientStatistics Sender.
+ // EnableStatistics cannot be called again if destroy_sender is set. This is
+ // used by the LogReader to enforce one-sender-per-channel checks.
+ void DisableStatistics(bool destroy_sender);
// Enables sending out any statistics messages.
void EnableStatistics();
diff --git a/aos/network/message_bridge_server_status.cc b/aos/network/message_bridge_server_status.cc
index c82158b..4f6abff 100644
--- a/aos/network/message_bridge_server_status.cc
+++ b/aos/network/message_bridge_server_status.cc
@@ -411,13 +411,19 @@
}
}
-void MessageBridgeServerStatus::DisableStatistics() {
+void MessageBridgeServerStatus::DisableStatistics(bool destroy_senders) {
send_ = false;
statistics_timer_->Disable();
+ if (destroy_senders) {
+ sender_ = aos::Sender<ServerStatistics>();
+ timestamp_sender_ = aos::Sender<Timestamp>();
+ }
}
void MessageBridgeServerStatus::EnableStatistics() {
send_ = true;
+ CHECK(sender_.valid());
+ CHECK(timestamp_sender_.valid());
statistics_timer_->Setup(event_loop_->monotonic_now() + kPingPeriod,
kPingPeriod);
}
diff --git a/aos/network/message_bridge_server_status.h b/aos/network/message_bridge_server_status.h
index feb1b05..327930c 100644
--- a/aos/network/message_bridge_server_status.h
+++ b/aos/network/message_bridge_server_status.h
@@ -73,7 +73,7 @@
}
// Disables sending out any statistics messages.
- void DisableStatistics();
+ void DisableStatistics(bool destroy_senders);
// Enables sending out any statistics messages.
void EnableStatistics();
diff --git a/aos/network/timestamp_channel.h b/aos/network/timestamp_channel.h
index e35a170..d95edda 100644
--- a/aos/network/timestamp_channel.h
+++ b/aos/network/timestamp_channel.h
@@ -59,6 +59,8 @@
aos::Sender<RemoteMessage> *SenderForChannel(const Channel *channel,
const Connection *connection);
+ void ClearSenderForChannel(const Channel *channel,
+ const Connection *connection);
private:
aos::EventLoop *event_loop_;