Fix a race between Channel::Shutdown() and Channel::DetachEndpoint().
This is a roll of
https://github.com/domokit/mojo/commit/
457228e6bee9614d80ee04a98b296f96090304de
Original commit message:
The race is between shutdown and message pipe closing. Closing a message pipe
results in Channel::DetachEndpoint being called. The racing sequence is:
IO Thread Other Thread
Channel::DetachEndpoint (return from
DetachEndpointInternal)
Channel::local_id_to_endpoint_map_ no
longer contains the message pipe's
endpoint, preventing Channel::Shutdown from
blocking on ChannelEndpoint::mutex_ in
ChannelEndpoint::DetachFromChannel().
Channel::Shutdown()
delete Channel
Channel::SendControlMessage
use-after-free
Review URL: https://codereview.chromium.org/
1342073002
Cr-Commit-Position: refs/heads/master@{#349040}