OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ports/node.h" | 5 #include "mojo/edk/system/ports/node.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // port to allow the peer to have the opportunity to consume all inbound | 206 // port to allow the peer to have the opportunity to consume all inbound |
207 // messages before notifying the embedder that this port is closed. | 207 // messages before notifying the embedder that this port is closed. |
208 data.last_sequence_num = port->next_sequence_num_to_send - 1; | 208 data.last_sequence_num = port->next_sequence_num_to_send - 1; |
209 | 209 |
210 peer_node_name = port->peer_node_name; | 210 peer_node_name = port->peer_node_name; |
211 peer_port_name = port->peer_port_name; | 211 peer_port_name = port->peer_port_name; |
212 | 212 |
213 // If the port being closed still has unread messages, then we need to take | 213 // If the port being closed still has unread messages, then we need to take |
214 // care to close those ports so as to avoid leaking memory. | 214 // care to close those ports so as to avoid leaking memory. |
215 port->message_queue.GetReferencedPorts(&referenced_port_names); | 215 port->message_queue.GetReferencedPorts(&referenced_port_names); |
| 216 |
| 217 ErasePort_Locked(port_ref.name()); |
216 } | 218 } |
217 | 219 |
218 DVLOG(2) << "Sending ObserveClosure from " << port_ref.name() << "@" << name_ | 220 DVLOG(2) << "Sending ObserveClosure from " << port_ref.name() << "@" << name_ |
219 << " to " << peer_port_name << "@" << peer_node_name; | 221 << " to " << peer_port_name << "@" << peer_node_name; |
220 | 222 |
221 ErasePort(port_ref.name()); | |
222 | |
223 delegate_->ForwardMessage( | 223 delegate_->ForwardMessage( |
224 peer_node_name, | 224 peer_node_name, |
225 NewInternalMessage(peer_port_name, EventType::kObserveClosure, data)); | 225 NewInternalMessage(peer_port_name, EventType::kObserveClosure, data)); |
226 | 226 |
227 for (const auto& name : referenced_port_names) { | 227 for (const auto& name : referenced_port_names) { |
228 PortRef ref; | 228 PortRef ref; |
229 if (GetPort(name, &ref) == OK) | 229 if (GetPort(name, &ref) == OK) |
230 ClosePort(ref); | 230 ClosePort(ref); |
231 } | 231 } |
232 return OK; | 232 return OK; |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 | 1240 |
1241 if (num_data_bytes) | 1241 if (num_data_bytes) |
1242 memcpy(header + 1, data, num_data_bytes); | 1242 memcpy(header + 1, data, num_data_bytes); |
1243 | 1243 |
1244 return message; | 1244 return message; |
1245 } | 1245 } |
1246 | 1246 |
1247 } // namespace ports | 1247 } // namespace ports |
1248 } // namespace edk | 1248 } // namespace edk |
1249 } // namespace mojo | 1249 } // namespace mojo |
OLD | NEW |