OLD | NEW |
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/edk/system/handle_table.h" | 5 #include "mojo/edk/system/handle_table.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 handles[i] = MOJO_HANDLE_INVALID; | 106 handles[i] = MOJO_HANDLE_INVALID; |
107 } | 107 } |
108 } | 108 } |
109 return true; | 109 return true; |
110 } | 110 } |
111 | 111 |
112 MojoResult HandleTable::MarkBusyAndStartTransport( | 112 MojoResult HandleTable::MarkBusyAndStartTransport( |
113 MojoHandle disallowed_handle, | 113 MojoHandle disallowed_handle, |
114 const MojoHandle* handle_values, | 114 const MojoHandle* handle_values, |
115 uint32_t num_handles, | 115 uint32_t num_handles, |
116 std::vector<DispatcherTransport>* transports) { | 116 std::vector<HandleTransport>* transports) { |
117 DCHECK_NE(disallowed_handle, MOJO_HANDLE_INVALID); | 117 DCHECK_NE(disallowed_handle, MOJO_HANDLE_INVALID); |
118 DCHECK(handle_values); | 118 DCHECK(handle_values); |
119 DCHECK_LE(num_handles, GetConfiguration().max_message_num_handles); | 119 DCHECK_LE(num_handles, GetConfiguration().max_message_num_handles); |
120 DCHECK(transports); | 120 DCHECK(transports); |
121 DCHECK_EQ(transports->size(), num_handles); | 121 DCHECK_EQ(transports->size(), num_handles); |
122 | 122 |
123 std::vector<Entry*> entries(num_handles); | 123 std::vector<Entry*> entries(num_handles); |
124 | 124 |
125 // First verify all the handle values and get their dispatchers. | 125 // First verify all the handle values and get their dispatchers. |
126 uint32_t i; | 126 uint32_t i; |
(...skipping 15 matching lines...) Expand all Loading... |
142 entries[i] = &it->second; | 142 entries[i] = &it->second; |
143 if (entries[i]->busy) { | 143 if (entries[i]->busy) { |
144 error_result = MOJO_RESULT_BUSY; | 144 error_result = MOJO_RESULT_BUSY; |
145 break; | 145 break; |
146 } | 146 } |
147 // Note: By marking the handle as busy here, we're also preventing the | 147 // Note: By marking the handle as busy here, we're also preventing the |
148 // same handle from being sent multiple times in the same message. | 148 // same handle from being sent multiple times in the same message. |
149 entries[i]->busy = true; | 149 entries[i]->busy = true; |
150 | 150 |
151 // Try to start the transport. | 151 // Try to start the transport. |
152 DispatcherTransport transport = | 152 HandleTransport transport = |
153 Dispatcher::HandleTableAccess::TryStartTransport(entries[i]->handle); | 153 Dispatcher::HandleTableAccess::TryStartTransport(entries[i]->handle); |
154 if (!transport.is_valid()) { | 154 if (!transport.is_valid()) { |
155 // Only log for Debug builds, since this is not a problem with the system | 155 // Only log for Debug builds, since this is not a problem with the system |
156 // code, but with user code. | 156 // code, but with user code. |
157 DLOG(WARNING) << "Likely race condition in user code detected: attempt " | 157 DLOG(WARNING) << "Likely race condition in user code detected: attempt " |
158 "to transfer handle " | 158 "to transfer handle " |
159 << handle_values[i] | 159 << handle_values[i] |
160 << " while it is in use on a different thread"; | 160 << " while it is in use on a different thread"; |
161 | 161 |
162 // Unset the busy flag (since it won't be unset below). | 162 // Unset the busy flag (since it won't be unset below). |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 for (uint32_t i = 0; i < num_handles; i++) { | 240 for (uint32_t i = 0; i < num_handles; i++) { |
241 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); | 241 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); |
242 DCHECK(it != handle_to_entry_map_.end()); | 242 DCHECK(it != handle_to_entry_map_.end()); |
243 DCHECK(it->second.busy); | 243 DCHECK(it->second.busy); |
244 it->second.busy = false; | 244 it->second.busy = false; |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 } // namespace system | 248 } // namespace system |
249 } // namespace mojo | 249 } // namespace mojo |
OLD | NEW |