Mojo: Clean up port closure behavior

This avoids constructing a deserialized MessagePipeDispatcher over a
port in an invalid state. This could happen previously since EDK message
impl destructors first deserialize and then close any attached handles.

Messages may however be destroyed if still in a port's receiving queue
when the port is destroyed. In this case we first manually scan the
message queue and close attached ports before the message destructors
can run. Said message destructors may then go on to deserialize invalid
MessagePipeDispatchers.

This has no interesting negative effects in production code but can
occasionally trigger DCHECKs in test environments.

BUG=None

Change-Id: I34a5259c70a59350cb0c4cabcfc15c903d89370b
Reviewed-on: https://chromium-review.googlesource.com/566298
Reviewed-by: Jay Civelli <jcivelli@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485634}

CrOS-Libchrome-Original-Commit: e01ad954bd943e60d5f9b45f9dfe54357811d7ca
4 files changed
tree: a4d9a6f86124e208fab2aab308e66b05815f775d
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/