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

Side by Side Diff: mojo/system/handle_table.cc

Issue 407643002: Mojo: In Debug builds, log when a race condition in user code is likely observed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« 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 "mojo/system/handle_table.h" 5 #include "mojo/system/handle_table.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "mojo/system/constants.h" 9 #include "mojo/system/constants.h"
10 #include "mojo/system/dispatcher.h" 10 #include "mojo/system/dispatcher.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 // Note: By marking the handle as busy here, we're also preventing the 140 // Note: By marking the handle as busy here, we're also preventing the
141 // same handle from being sent multiple times in the same message. 141 // same handle from being sent multiple times in the same message.
142 entries[i]->busy = true; 142 entries[i]->busy = true;
143 143
144 // Try to start the transport. 144 // Try to start the transport.
145 DispatcherTransport transport = 145 DispatcherTransport transport =
146 Dispatcher::HandleTableAccess::TryStartTransport( 146 Dispatcher::HandleTableAccess::TryStartTransport(
147 entries[i]->dispatcher.get()); 147 entries[i]->dispatcher.get());
148 if (!transport.is_valid()) { 148 if (!transport.is_valid()) {
149 // Only log for Debug builds, since this is not a problem with the system
150 // code, but with user code.
151 DLOG(WARNING) << "Likely race condition in user code detected: attempt "
152 "to transfer handle "
153 << handles[i]
154 << " while it is in use on a different thread";
155
149 // Unset the busy flag (since it won't be unset below). 156 // Unset the busy flag (since it won't be unset below).
150 entries[i]->busy = false; 157 entries[i]->busy = false;
151 error_result = MOJO_RESULT_BUSY; 158 error_result = MOJO_RESULT_BUSY;
152 break; 159 break;
153 } 160 }
154 161
155 // Check if the dispatcher is busy (e.g., in a two-phase read/write). 162 // Check if the dispatcher is busy (e.g., in a two-phase read/write).
156 // (Note that this must be done after the dispatcher's lock is acquired.) 163 // (Note that this must be done after the dispatcher's lock is acquired.)
157 if (transport.IsBusy()) { 164 if (transport.IsBusy()) {
158 // Unset the busy flag and end the transport (since it won't be done 165 // Unset the busy flag and end the transport (since it won't be done
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 for (uint32_t i = 0; i < num_handles; i++) { 235 for (uint32_t i = 0; i < num_handles; i++) {
229 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handles[i]); 236 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handles[i]);
230 DCHECK(it != handle_to_entry_map_.end()); 237 DCHECK(it != handle_to_entry_map_.end());
231 DCHECK(it->second.busy); 238 DCHECK(it->second.busy);
232 it->second.busy = false; 239 it->second.busy = false;
233 } 240 }
234 } 241 }
235 242
236 } // namespace system 243 } // namespace system
237 } // namespace mojo 244 } // 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