Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1325)

Unified Diff: mojo/edk/system/node_controller.cc

Issue 2784463004: Mojo EDK: Avoid redundant queueing when sending to unknown peers (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/node_controller.cc
diff --git a/mojo/edk/system/node_controller.cc b/mojo/edk/system/node_controller.cc
index 982ca39d02b77a94bd94dbc0da307d473c0367dd..73b16b14ae2b49044338f49d62cb04c27be332ef 100644
--- a/mojo/edk/system/node_controller.cc
+++ b/mojo/edk/system/node_controller.cc
@@ -694,10 +694,17 @@ void NodeController::SendPeerMessage(const ports::NodeName& name,
return;
}
- // If we don't know who the peer is, queue the message for delivery. If this
- // is the first message queued for the peer, we also ask the broker to
- // introduce us to them.
+ // If we don't know who the peer is and we are the broker, we can only assume
+ // the peer is invalid, i.e., it's either a junk name or has already been
+ // disconnected.
+ scoped_refptr<NodeChannel> broker = GetBrokerChannel();
+ if (!broker) {
+ DVLOG(1) << "Dropping message for unknown peer: " << name;
+ return;
+ }
+ // If we aren't the broker, assume we just need to be introduced and queue
+ // until that can be either confirmed or denied by the broker.
bool needs_introduction = false;
{
base::AutoLock lock(peers_lock_);
@@ -705,18 +712,8 @@ void NodeController::SendPeerMessage(const ports::NodeName& name,
needs_introduction = queue.empty();
queue.emplace(std::move(channel_message));
}
-
- if (needs_introduction) {
- scoped_refptr<NodeChannel> broker = GetBrokerChannel();
- if (!broker) {
- DVLOG(1) << "Dropping message for unknown peer: " << name;
-
- base::AutoLock lock(peers_lock_);
- pending_peer_messages_.erase(name);
- return;
- }
+ if (needs_introduction)
broker->RequestIntroduction(name);
- }
}
void NodeController::AcceptIncomingMessages() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698