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

Side by Side Diff: remoting/host/ipc_util_posix.cc

Issue 1903663004: IPC: Fix attachment brokering race condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (scoped_ptr->std::unique_ptr) Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « remoting/host/ipc_util.h ('k') | remoting/host/ipc_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/ipc_util.h" 5 #include "remoting/host/ipc_util.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/socket.h> 8 #include <sys/socket.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/posix/eintr_wrapper.h" 14 #include "base/posix/eintr_wrapper.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "ipc/attachment_broker.h"
16 #include "ipc/ipc_channel.h" 17 #include "ipc/ipc_channel.h"
17 #include "ipc/ipc_channel_proxy.h" 18 #include "ipc/ipc_channel_proxy.h"
18 19
19 namespace remoting { 20 namespace remoting {
20 21
21 bool CreateConnectedIpcChannel( 22 bool CreateConnectedIpcChannel(
22 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 23 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
23 IPC::Listener* listener, 24 IPC::Listener* listener,
24 base::File* client_out, 25 base::File* client_out,
25 std::unique_ptr<IPC::ChannelProxy>* server_out) { 26 std::unique_ptr<IPC::ChannelProxy>* server_out) {
(...skipping 12 matching lines...) Expand all
38 PLOG(ERROR) << "close()"; 39 PLOG(ERROR) << "close()";
39 if (IGNORE_EINTR(close(pipe_fds[1])) < 0) 40 if (IGNORE_EINTR(close(pipe_fds[1])) < 0)
40 PLOG(ERROR) << "close()"; 41 PLOG(ERROR) << "close()";
41 return false; 42 return false;
42 } 43 }
43 44
44 std::string socket_name = "Chromoting socket"; 45 std::string socket_name = "Chromoting socket";
45 46
46 // Wrap the pipe into an IPC channel. 47 // Wrap the pipe into an IPC channel.
47 base::FileDescriptor fd(pipe_fds[0], false); 48 base::FileDescriptor fd(pipe_fds[0], false);
48 IPC::ChannelHandle handle(socket_name, fd); 49 server_out->reset(new IPC::ChannelProxy(listener, io_task_runner));
49 *server_out = IPC::ChannelProxy::Create(IPC::ChannelHandle(socket_name, fd), 50 if (IPC::AttachmentBroker::GetGlobal()) {
50 IPC::Channel::MODE_SERVER, listener, 51 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel(
51 io_task_runner.get()); 52 server_out->get(), io_task_runner);
53 }
54 (*server_out)
55 ->Init(IPC::ChannelHandle(socket_name, fd), IPC::Channel::MODE_SERVER,
56 true);
52 57
53 *client_out = base::File(pipe_fds[1]); 58 *client_out = base::File(pipe_fds[1]);
54 return true; 59 return true;
55 } 60 }
56 61
57 } // namespace remoting 62 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/ipc_util.h ('k') | remoting/host/ipc_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698