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

Side by Side Diff: mojo/edk/system/node_channel.cc

Issue 1985993002: [mojo-edk] Fix bootstrap NodeChannel Start/ShutDown race (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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "mojo/edk/system/node_channel.h" 5 #include "mojo/edk/system/node_channel.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 #include <limits> 8 #include <limits>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 166
167 void NodeChannel::Start() { 167 void NodeChannel::Start() {
168 #if defined(OS_MACOSX) && !defined(OS_IOS) 168 #if defined(OS_MACOSX) && !defined(OS_IOS)
169 MachPortRelay* relay = delegate_->GetMachPortRelay(); 169 MachPortRelay* relay = delegate_->GetMachPortRelay();
170 if (relay) 170 if (relay)
171 relay->AddObserver(this); 171 relay->AddObserver(this);
172 #endif 172 #endif
173 173
174 base::AutoLock lock(channel_lock_); 174 base::AutoLock lock(channel_lock_);
175 DCHECK(channel_); 175 // ShutDown() may have already been called, in which case |channel_| is null.
176 channel_->Start(); 176 if (channel_)
177 channel_->Start();
177 } 178 }
178 179
179 void NodeChannel::ShutDown() { 180 void NodeChannel::ShutDown() {
180 #if defined(OS_MACOSX) && !defined(OS_IOS) 181 #if defined(OS_MACOSX) && !defined(OS_IOS)
181 MachPortRelay* relay = delegate_->GetMachPortRelay(); 182 MachPortRelay* relay = delegate_->GetMachPortRelay();
182 if (relay) 183 if (relay)
183 relay->RemoveObserver(this); 184 relay->RemoveObserver(this);
184 #endif 185 #endif
185 186
186 base::AutoLock lock(channel_lock_); 187 base::AutoLock lock(channel_lock_);
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 755
755 base::AutoLock lock(channel_lock_); 756 base::AutoLock lock(channel_lock_);
756 if (!channel_) 757 if (!channel_)
757 DLOG(ERROR) << "Dropping message on closed channel."; 758 DLOG(ERROR) << "Dropping message on closed channel.";
758 else 759 else
759 channel_->Write(std::move(message)); 760 channel_->Write(std::move(message));
760 } 761 }
761 762
762 } // namespace edk 763 } // namespace edk
763 } // namespace mojo 764 } // namespace mojo
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