| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/data_pipe_producer_dispatcher.h" | 5 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 UpdateSignalsStateNoLock(); | 489 UpdateSignalsStateNoLock(); |
| 490 } | 490 } |
| 491 | 491 |
| 492 void DataPipeProducerDispatcher::UpdateSignalsStateNoLock() { | 492 void DataPipeProducerDispatcher::UpdateSignalsStateNoLock() { |
| 493 lock_.AssertAcquired(); | 493 lock_.AssertAcquired(); |
| 494 | 494 |
| 495 bool was_peer_closed = peer_closed_; | 495 bool was_peer_closed = peer_closed_; |
| 496 size_t previous_capacity = available_capacity_; | 496 size_t previous_capacity = available_capacity_; |
| 497 | 497 |
| 498 ports::PortStatus port_status; | 498 ports::PortStatus port_status; |
| 499 if (node_controller_->node()->GetStatus(control_port_, &port_status) != | 499 int rv = node_controller_->node()->GetStatus(control_port_, &port_status); |
| 500 ports::OK || | 500 if (rv != ports::OK || !port_status.receiving_messages) { |
| 501 !port_status.receiving_messages) { | |
| 502 DVLOG(1) << "Data pipe producer " << pipe_id_ << " is aware of peer closure" | 501 DVLOG(1) << "Data pipe producer " << pipe_id_ << " is aware of peer closure" |
| 503 << " [control_port=" << control_port_.name() << "]"; | 502 << " [control_port=" << control_port_.name() << "]"; |
| 504 | |
| 505 peer_closed_ = true; | 503 peer_closed_ = true; |
| 506 } | 504 } else if (rv == ports::OK && port_status.has_messages && !in_transit_) { |
| 507 | |
| 508 if (port_status.has_messages && !in_transit_) { | |
| 509 ports::ScopedMessage message; | 505 ports::ScopedMessage message; |
| 510 do { | 506 do { |
| 511 int rv = node_controller_->node()->GetMessageIf(control_port_, nullptr, | 507 int rv = node_controller_->node()->GetMessageIf(control_port_, nullptr, |
| 512 &message); | 508 &message); |
| 513 if (rv != ports::OK) | 509 if (rv != ports::OK) |
| 514 peer_closed_ = true; | 510 peer_closed_ = true; |
| 515 if (message) { | 511 if (message) { |
| 516 PortsMessage* ports_message = static_cast<PortsMessage*>(message.get()); | 512 PortsMessage* ports_message = static_cast<PortsMessage*>(message.get()); |
| 517 const DataPipeControlMessage* m = | 513 const DataPipeControlMessage* m = |
| 518 static_cast<const DataPipeControlMessage*>( | 514 static_cast<const DataPipeControlMessage*>( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 540 } | 536 } |
| 541 | 537 |
| 542 if (peer_closed_ != was_peer_closed || | 538 if (peer_closed_ != was_peer_closed || |
| 543 available_capacity_ != previous_capacity) { | 539 available_capacity_ != previous_capacity) { |
| 544 awakable_list_.AwakeForStateChange(GetHandleSignalsStateNoLock()); | 540 awakable_list_.AwakeForStateChange(GetHandleSignalsStateNoLock()); |
| 545 } | 541 } |
| 546 } | 542 } |
| 547 | 543 |
| 548 } // namespace edk | 544 } // namespace edk |
| 549 } // namespace mojo | 545 } // namespace mojo |
| OLD | NEW |