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

Unified Diff: ipc/mojo/ipc_channel_mojo.cc

Issue 583473002: IPC: Get rid of FileDescriptor usage from FileDescriptorSet and Message (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « ipc/mojo/ipc_channel_mojo.h ('k') | ipc/mojo/ipc_channel_mojo_readers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/ipc_channel_mojo.cc
diff --git a/ipc/mojo/ipc_channel_mojo.cc b/ipc/mojo/ipc_channel_mojo.cc
index 71c373e01cf07a63708871ae3077c121fc0f3e31..b8dec293b8dfa2c68bd80e0b17a6056c82ea04fe 100644
--- a/ipc/mojo/ipc_channel_mojo.cc
+++ b/ipc/mojo/ipc_channel_mojo.cc
@@ -248,7 +248,8 @@ MojoResult ChannelMojo::WriteToFileDescriptorSet(
return unwrap_result;
}
- bool ok = message->file_descriptor_set()->Add(platform_handle.release().fd);
+ bool ok = message->file_descriptor_set()->AddToOwn(
+ base::ScopedFD(platform_handle.release().fd));
DCHECK(ok);
}
@@ -257,17 +258,20 @@ MojoResult ChannelMojo::WriteToFileDescriptorSet(
// static
MojoResult ChannelMojo::ReadFromFileDescriptorSet(
- const Message& message,
+ Message* message,
std::vector<MojoHandle>* handles) {
// We dup() the handles in IPC::Message to transmit.
// IPC::FileDescriptorSet has intricate lifecycle semantics
// of FDs, so just to dup()-and-own them is the safest option.
- if (message.HasFileDescriptors()) {
- const FileDescriptorSet* fdset = message.file_descriptor_set();
- for (size_t i = 0; i < fdset->size(); ++i) {
- int fd_to_send = dup(fdset->GetDescriptorAt(i));
+ if (message->HasFileDescriptors()) {
+ FileDescriptorSet* fdset = message->file_descriptor_set();
+ std::vector<base::PlatformFile> fds_to_send(fdset->size());
+ fdset->PeekDescriptors(&fds_to_send[0]);
+ for (size_t i = 0; i < fds_to_send.size(); ++i) {
+ int fd_to_send = dup(fds_to_send[i]);
if (-1 == fd_to_send) {
DPLOG(WARNING) << "Failed to dup FD to transmit.";
+ fdset->CommitAll();
return MOJO_RESULT_UNKNOWN;
}
@@ -279,11 +283,14 @@ MojoResult ChannelMojo::ReadFromFileDescriptorSet(
if (MOJO_RESULT_OK != wrap_result) {
DLOG(WARNING) << "Pipe failed to wrap handles. Closing: "
<< wrap_result;
+ fdset->CommitAll();
return wrap_result;
}
handles->push_back(wrapped_handle);
}
+
+ fdset->CommitAll();
}
return MOJO_RESULT_OK;
« no previous file with comments | « ipc/mojo/ipc_channel_mojo.h ('k') | ipc/mojo/ipc_channel_mojo_readers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698