Wait for all writes to complete before starting TLS in XmppSignalStrategy
commit84b1f469ac9e2fa711b44cab90a4d27e02a7b2ce
authorsergeyu <sergeyu@chromium.org>
Fri, 12 Jun 2015 21:42:15 +0000 (12 14:42 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 12 Jun 2015 21:42:58 +0000 (12 21:42 +0000)
tree2471b0e30c706fc8917d40f8343768d45dbb43bc
parent4cf702bcf9aaa31df4c3c7836b619306b463bb8a
Wait for all writes to complete before starting TLS in XmppSignalStrategy

When connecting XMPP socket the client sends <starttls> to the server,
waits for <proceed> response and starts TLS after that. In some cases
the first write for <starttls> may complete asynchronously, while the
<proceed> is received sychronously, which results in SSL initialization
on a socket with a pending write request. XmppSignalStrategy wasn't
handling that case correctly. Fixed it to keep track of pending write
requests and start TLS only after all write requests are finished.

BUG=499019

Review URL: https://codereview.chromium.org/1177323003

Cr-Commit-Position: refs/heads/master@{#334246}
remoting/base/buffered_socket_writer.cc
remoting/base/buffered_socket_writer.h
remoting/signaling/xmpp_signal_strategy.cc
remoting/signaling/xmpp_signal_strategy_unittest.cc