| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/message_pipe_dispatcher.h" | 5 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 DVLOG(4) << "Sent message on pipe " << pipe_id_ << " endpoint " << endpoint_ | 242 DVLOG(4) << "Sent message on pipe " << pipe_id_ << " endpoint " << endpoint_ |
| 243 << " [port=" << port_.name() << "; rv=" << rv | 243 << " [port=" << port_.name() << "; rv=" << rv |
| 244 << "; num_bytes=" << num_bytes << "]"; | 244 << "; num_bytes=" << num_bytes << "]"; |
| 245 | 245 |
| 246 if (rv != ports::OK) { | 246 if (rv != ports::OK) { |
| 247 if (rv == ports::ERROR_PORT_UNKNOWN || | 247 if (rv == ports::ERROR_PORT_UNKNOWN || |
| 248 rv == ports::ERROR_PORT_STATE_UNEXPECTED || | 248 rv == ports::ERROR_PORT_STATE_UNEXPECTED || |
| 249 rv == ports::ERROR_PORT_CANNOT_SEND_PEER) { | 249 rv == ports::ERROR_PORT_CANNOT_SEND_PEER) { |
| 250 return MOJO_RESULT_INVALID_ARGUMENT; | 250 return MOJO_RESULT_INVALID_ARGUMENT; |
| 251 } else if (rv == ports::ERROR_PORT_PEER_CLOSED) { | 251 } else if (rv == ports::ERROR_PORT_PEER_CLOSED) { |
| 252 base::AutoLock lock(signal_lock_); | |
| 253 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock()); | |
| 254 return MOJO_RESULT_FAILED_PRECONDITION; | 252 return MOJO_RESULT_FAILED_PRECONDITION; |
| 255 } | 253 } |
| 256 | 254 |
| 257 NOTREACHED(); | 255 NOTREACHED(); |
| 258 return MOJO_RESULT_UNKNOWN; | 256 return MOJO_RESULT_UNKNOWN; |
| 259 } | 257 } |
| 260 | 258 |
| 261 return MOJO_RESULT_OK; | 259 return MOJO_RESULT_OK; |
| 262 } | 260 } |
| 263 | 261 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 306 } |
| 309 | 307 |
| 310 if (!ports_message) { | 308 if (!ports_message) { |
| 311 // No message was available in queue. | 309 // No message was available in queue. |
| 312 | 310 |
| 313 if (rv == ports::OK) | 311 if (rv == ports::OK) |
| 314 return MOJO_RESULT_SHOULD_WAIT; | 312 return MOJO_RESULT_SHOULD_WAIT; |
| 315 | 313 |
| 316 // Peer is closed and there are no more messages to read. | 314 // Peer is closed and there are no more messages to read. |
| 317 DCHECK_EQ(rv, ports::ERROR_PORT_PEER_CLOSED); | 315 DCHECK_EQ(rv, ports::ERROR_PORT_PEER_CLOSED); |
| 318 base::AutoLock lock(signal_lock_); | |
| 319 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock()); | |
| 320 return MOJO_RESULT_FAILED_PRECONDITION; | 316 return MOJO_RESULT_FAILED_PRECONDITION; |
| 321 } | 317 } |
| 322 | 318 |
| 323 // Alright! We have a message and the caller has provided sufficient storage | 319 // Alright! We have a message and the caller has provided sufficient storage |
| 324 // in which to receive it. | 320 // in which to receive it. |
| 325 | 321 |
| 326 std::unique_ptr<PortsMessage> msg( | 322 std::unique_ptr<PortsMessage> msg( |
| 327 static_cast<PortsMessage*>(ports_message.release())); | 323 static_cast<PortsMessage*>(ports_message.release())); |
| 328 | 324 |
| 329 const MessageHeader* header = | 325 const MessageHeader* header = |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]"; | 594 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]"; |
| 599 } | 595 } |
| 600 } | 596 } |
| 601 #endif | 597 #endif |
| 602 | 598 |
| 603 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock()); | 599 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock()); |
| 604 } | 600 } |
| 605 | 601 |
| 606 } // namespace edk | 602 } // namespace edk |
| 607 } // namespace mojo | 603 } // namespace mojo |
| OLD | NEW |