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

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

Issue 1975073002: [mojo-edk] Broadcast surprise port disruptions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reenable-clean-shutdown
Patch Set: . Created 4 years, 6 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 | « mojo/edk/system/node_channel.h ('k') | mojo/edk/system/node_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/node_channel.cc
diff --git a/mojo/edk/system/node_channel.cc b/mojo/edk/system/node_channel.cc
index e84c5a21e5e14bbfb4eb16589ed75178a5351f50..45e933bccf10876d63ba36603ab5681047a101af 100644
--- a/mojo/edk/system/node_channel.cc
+++ b/mojo/edk/system/node_channel.cc
@@ -359,6 +359,15 @@ void NodeChannel::Introduce(const ports::NodeName& name,
WriteChannelMessage(std::move(message));
}
+void NodeChannel::Broadcast(Channel::MessagePtr message) {
+ DCHECK(!message->has_handles());
+ void* data;
+ Channel::MessagePtr broadcast_message = CreateMessage(
+ MessageType::BROADCAST, message->data_num_bytes(), 0, &data);
+ memcpy(data, message->data(), message->data_num_bytes());
+ WriteChannelMessage(std::move(broadcast_message));
+}
+
#if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS))
void NodeChannel::RelayPortsMessage(const ports::NodeName& destination,
Channel::MessagePtr message) {
@@ -675,12 +684,20 @@ void NodeChannel::OnChannelMessage(const void* payload,
}
#endif
- case MessageType::BROADCAST:
- // This is here as a placeholder for now because nothing sends a BROADCAST
- // message yet. This avoids breakage on version skew (namely for ARC) when
- // we actually begin using the message.
- DVLOG(1) << "Ignoring unhandled BROADCAST message.";
+ case MessageType::BROADCAST: {
+ if (payload_size <= sizeof(Header))
+ break;
+ const void* data = static_cast<const void*>(
+ reinterpret_cast<const Header*>(payload) + 1);
+ Channel::MessagePtr message =
+ Channel::Message::Deserialize(data, payload_size - sizeof(Header));
+ if (!message || message->has_handles()) {
+ DLOG(ERROR) << "Dropping invalid broadcast message.";
+ break;
+ }
+ delegate_->OnBroadcast(remote_node_name_, std::move(message));
return;
+ }
#if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS))
case MessageType::PORTS_MESSAGE_FROM_RELAY:
« no previous file with comments | « mojo/edk/system/node_channel.h ('k') | mojo/edk/system/node_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698