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();
}

View File

@@ -1058,8 +1058,7 @@ public:
BEAST_EXPECT(jrNextOffer[sfOwnerNode.fieldName] == "0000000000000000");
BEAST_EXPECT(jrNextOffer[sfSequence.fieldName] == 3);
BEAST_EXPECT(jrNextOffer[jss::TakerGets] == USD(5).value().getJson(0));
BEAST_EXPECT(jrNextOffer[jss::TakerPays] ==
XRP(2000).value().getJson(0));
BEAST_EXPECT(jrNextOffer[jss::TakerPays] == XRP(2000).value().getJson(0));
BEAST_EXPECT(jrNextOffer[jss::owner_funds] == "50");
BEAST_EXPECT(jrNextOffer[jss::quality] == "400000000");