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/ipc_lib/lockless_queue.cc b/aos/ipc_lib/lockless_queue.cc
index f31d80d..728d2d1 100644
--- a/aos/ipc_lib/lockless_queue.cc
+++ b/aos/ipc_lib/lockless_queue.cc
@@ -518,7 +518,8 @@
}
if (sender_index_ == -1) {
- LOG(FATAL) << "Too many senders";
+ VLOG(1) << "Too many senders, starting to bail.";
+ return;
}
::aos::ipc_lib::Sender *s = memory_->GetSender(sender_index_);
@@ -529,13 +530,18 @@
}
LocklessQueue::Sender::~Sender() {
- if (memory_ != nullptr) {
+ if (valid()) {
death_notification_release(&(memory_->GetSender(sender_index_)->tid));
}
}
-LocklessQueue::Sender LocklessQueue::MakeSender() {
- return LocklessQueue::Sender(memory_);
+std::optional<LocklessQueue::Sender> LocklessQueue::MakeSender() {
+ LocklessQueue::Sender result = LocklessQueue::Sender(memory_);
+ if (result.valid()) {
+ return std::move(result);
+ } else {
+ return std::nullopt;
+ }
}
QueueIndex ZeroOrValid(QueueIndex index) {