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

Side by Side Diff: ipc/mojo/ipc_channel_mojo.cc

Issue 1937733002: Fix lock-order-inversion in ChannelMojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ipc/mojo/ipc_channel_mojo.h" 5 #include "ipc/mojo/ipc_channel_mojo.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // ChannelMojo from a different thread. 233 // ChannelMojo from a different thread.
234 bootstrap_ = MojoBootstrap::Create(std::move(handle), mode, this); 234 bootstrap_ = MojoBootstrap::Create(std::move(handle), mode, this);
235 } 235 }
236 236
237 ChannelMojo::~ChannelMojo() { 237 ChannelMojo::~ChannelMojo() {
238 Close(); 238 Close();
239 } 239 }
240 240
241 bool ChannelMojo::Connect() { 241 bool ChannelMojo::Connect() {
242 WillConnect(); 242 WillConnect();
243 base::AutoLock lock(lock_); 243 {
244 DCHECK(!task_runner_); 244 base::AutoLock lock(lock_);
245 task_runner_ = base::ThreadTaskRunnerHandle::Get(); 245 DCHECK(!task_runner_);
246 DCHECK(!message_reader_); 246 task_runner_ = base::ThreadTaskRunnerHandle::Get();
247 DCHECK(!message_reader_);
248 }
247 bootstrap_->Connect(); 249 bootstrap_->Connect();
248 return true; 250 return true;
249 } 251 }
250 252
251 void ChannelMojo::Close() { 253 void ChannelMojo::Close() {
252 std::unique_ptr<internal::MessagePipeReader, ReaderDeleter> reader; 254 std::unique_ptr<internal::MessagePipeReader, ReaderDeleter> reader;
253 { 255 {
254 base::AutoLock lock(lock_); 256 base::AutoLock lock(lock_);
255 if (!message_reader_) 257 if (!message_reader_)
256 return; 258 return;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 DCHECK(ok); 431 DCHECK(ok);
430 if (!ok) { 432 if (!ok) {
431 LOG(ERROR) << "Failed to add new Mojo handle."; 433 LOG(ERROR) << "Failed to add new Mojo handle.";
432 return MOJO_RESULT_UNKNOWN; 434 return MOJO_RESULT_UNKNOWN;
433 } 435 }
434 } 436 }
435 return MOJO_RESULT_OK; 437 return MOJO_RESULT_OK;
436 } 438 }
437 439
438 } // namespace IPC 440 } // namespace IPC
OLDNEW
« 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