Do not close socket on a foreign thread:

* Closing a socket in WSClient's cleanup method was not thread safe. Force the
close to happen on the WSClient's strand.
This commit is contained in:
seelabs
2017-02-13 09:01:12 -05:00
parent 5cf38bf88a
commit 30b6e4e2e5
2 changed files with 7 additions and 6 deletions

View File

@@ -114,10 +114,12 @@ class WSClientImpl : public WSClient
void cleanup()
{
error_code ec;
if(!peerClosed_)
ws_.close({}, ec);
stream_.close(ec);
ios_.post(strand_.wrap([this] {
error_code ec;
if (!peerClosed_)
ws_.close({}, ec);
stream_.close(ec);
}));
work_ = boost::none;
thread_.join();
}