| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 if (it == handle_to_entry_map_.end()) { | 136 if (it == handle_to_entry_map_.end()) { |
| 137 error_result = MOJO_RESULT_INVALID_ARGUMENT; | 137 error_result = MOJO_RESULT_INVALID_ARGUMENT; |
| 138 break; | 138 break; |
| 139 } | 139 } |
| 140 | 140 |
| 141 entries[i] = &it->second; | 141 entries[i] = &it->second; |
| 142 if (entries[i]->busy) { | 142 if (entries[i]->busy) { |
| 143 error_result = MOJO_RESULT_BUSY; | 143 error_result = MOJO_RESULT_BUSY; |
| 144 break; | 144 break; |
| 145 } | 145 } |
| 146 // Note: "Busy" is "preferred" over "permission denied". |
| 147 if (!entries[i]->handle.has_all_rights(MOJO_HANDLE_RIGHT_TRANSFER)) { |
| 148 error_result = MOJO_RESULT_PERMISSION_DENIED; |
| 149 break; |
| 150 } |
| 146 // Note: By marking the handle as busy here, we're also preventing the | 151 // Note: By marking the handle as busy here, we're also preventing the |
| 147 // same handle from being sent multiple times in the same message. | 152 // same handle from being sent multiple times in the same message. |
| 148 entries[i]->busy = true; | 153 entries[i]->busy = true; |
| 149 | 154 |
| 150 // Try to start the transport. | 155 // Try to start the transport. |
| 151 HandleTransport transport = | 156 HandleTransport transport = |
| 152 Dispatcher::HandleTableAccess::TryStartTransport(entries[i]->handle); | 157 Dispatcher::HandleTableAccess::TryStartTransport(entries[i]->handle); |
| 153 if (!transport.is_valid()) { | 158 if (!transport.is_valid()) { |
| 154 // Only log for Debug builds, since this is not a problem with the system | 159 // Only log for Debug builds, since this is not a problem with the system |
| 155 // code, but with user code. | 160 // code, but with user code. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 for (uint32_t i = 0; i < num_handles; i++) { | 244 for (uint32_t i = 0; i < num_handles; i++) { |
| 240 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); | 245 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); |
| 241 DCHECK(it != handle_to_entry_map_.end()); | 246 DCHECK(it != handle_to_entry_map_.end()); |
| 242 DCHECK(it->second.busy); | 247 DCHECK(it->second.busy); |
| 243 it->second.busy = false; | 248 it->second.busy = false; |
| 244 } | 249 } |
| 245 } | 250 } |
| 246 | 251 |
| 247 } // namespace system | 252 } // namespace system |
| 248 } // namespace mojo | 253 } // namespace mojo |
| OLD | NEW |