| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 "to transfer handle " | 162 "to transfer handle " |
| 163 << handle_values[i] | 163 << handle_values[i] |
| 164 << " while it is in use on a different thread"; | 164 << " while it is in use on a different thread"; |
| 165 | 165 |
| 166 // Unset the busy flag (since it won't be unset below). | 166 // Unset the busy flag (since it won't be unset below). |
| 167 entries[i]->busy = false; | 167 entries[i]->busy = false; |
| 168 error_result = MOJO_RESULT_BUSY; | 168 error_result = MOJO_RESULT_BUSY; |
| 169 break; | 169 break; |
| 170 } | 170 } |
| 171 | 171 |
| 172 // Check if the dispatcher is busy (e.g., in a two-phase read/write). | |
| 173 // (Note that this must be done after the dispatcher's lock is acquired.) | |
| 174 if (transport.IsBusy()) { | |
| 175 // Unset the busy flag and end the transport (since it won't be done | |
| 176 // below). | |
| 177 entries[i]->busy = false; | |
| 178 transport.End(); | |
| 179 error_result = MOJO_RESULT_BUSY; | |
| 180 break; | |
| 181 } | |
| 182 | |
| 183 // Hang on to the transport (which we'll need to end the transport). | 172 // Hang on to the transport (which we'll need to end the transport). |
| 184 (*transports)[i] = transport; | 173 (*transports)[i] = transport; |
| 185 } | 174 } |
| 186 if (i < num_handles) { | 175 if (i < num_handles) { |
| 187 DCHECK_NE(error_result, MOJO_RESULT_INTERNAL); | 176 DCHECK_NE(error_result, MOJO_RESULT_INTERNAL); |
| 188 | 177 |
| 189 // Unset the busy flags and release the locks. | 178 // Unset the busy flags and release the locks. |
| 190 for (uint32_t j = 0; j < i; j++) { | 179 for (uint32_t j = 0; j < i; j++) { |
| 191 DCHECK(entries[j]->busy); | 180 DCHECK(entries[j]->busy); |
| 192 entries[j]->busy = false; | 181 entries[j]->busy = false; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 for (uint32_t i = 0; i < num_handles; i++) { | 233 for (uint32_t i = 0; i < num_handles; i++) { |
| 245 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); | 234 HandleToEntryMap::iterator it = handle_to_entry_map_.find(handle_values[i]); |
| 246 DCHECK(it != handle_to_entry_map_.end()); | 235 DCHECK(it != handle_to_entry_map_.end()); |
| 247 DCHECK(it->second.busy); | 236 DCHECK(it->second.busy); |
| 248 it->second.busy = false; | 237 it->second.busy = false; |
| 249 } | 238 } |
| 250 } | 239 } |
| 251 | 240 |
| 252 } // namespace system | 241 } // namespace system |
| 253 } // namespace mojo | 242 } // namespace mojo |
| OLD | NEW |