Fix bug in web proxy when not buffering messages
Change-Id: Icf9ae4d81031fcc0ebeede60ad9a2d548eb01174
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/aos/network/web_proxy.cc b/aos/network/web_proxy.cc
index 972b1d7..a486b94 100644
--- a/aos/network/web_proxy.cc
+++ b/aos/network/web_proxy.cc
@@ -223,6 +223,13 @@
std::shared_ptr<struct mbuf>(mbuffer, mem_deref));
}
message_buffer_.push_back(std::move(message));
+ // If we aren't keeping a buffer, then we should only do one iteration of
+ // the while loop--otherwise, if additional messages arrive between the
+ // first FetchNext() and the second iteration then we can end up behaving
+ // poorly (since we do a Fetch() when buffer_size_ == 0).
+ if (buffer_size_ == 0) {
+ break;
+ }
}
for (auto &conn : channels_) {
std::shared_ptr<ScopedDataChannel> rtc_channel = conn.first;