Add the channel name into the sender creation failure message
It used to just fail saying "Too Many Senders". This isn't actionable.
We want the chanel name in there.
The fix is to propegate the failure up to the event loop where it can
make a more educated decision. Also, add a test (and make sure
simulation matches).
Change-Id: If70397ee319ad25ce5ab7ed146e8f5057d8af100
diff --git a/aos/events/shm_event_loop.cc b/aos/events/shm_event_loop.cc
index ce34ad1..b53be2f 100644
--- a/aos/events/shm_event_loop.cc
+++ b/aos/events/shm_event_loop.cc
@@ -374,10 +374,22 @@
event_loop->configuration()->channel_storage_duration()))),
lockless_queue_(lockless_queue_memory_.memory(),
lockless_queue_memory_.config()),
- lockless_queue_sender_(lockless_queue_.MakeSender()) {}
+ lockless_queue_sender_(
+ VerifySender(lockless_queue_.MakeSender(), channel)) {}
~ShmSender() override {}
+ static ipc_lib::LocklessQueue::Sender VerifySender(
+ std::optional<ipc_lib::LocklessQueue::Sender> &&sender,
+ const Channel *channel) {
+ if (sender) {
+ return std::move(sender.value());
+ }
+ LOG(FATAL) << "Failed to create sender on "
+ << configuration::CleanedChannelToString(channel)
+ << ", too many senders.";
+ }
+
void *data() override { return lockless_queue_sender_.Data(); }
size_t size() override { return lockless_queue_sender_.size(); }
bool DoSend(size_t length,