Fix race condition in websocket server close

Note: the close() functions are not yet used in bitshares-core, but only in tests in FC.
The new code is not fully thread-safe either.
This commit is contained in:
Abit 2020-06-24 12:08:55 +02:00 committed by GitHub
parent a876678008
commit 8b94976b79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -665,8 +665,9 @@ namespace fc { namespace http {
void websocket_server::close()
{
auto cpy_con = my->_connections;
websocketpp::lib::error_code ec;
for( auto& connection : my->_connections )
for( auto& connection : cpy_con )
my->_server.close( connection.first, websocketpp::close::status::normal, "Goodbye", ec );
}
@ -709,8 +710,9 @@ namespace fc { namespace http {
void websocket_tls_server::close()
{
auto cpy_con = my->_connections;
websocketpp::lib::error_code ec;
for( auto& connection : my->_connections )
for( auto& connection : cpy_con )
my->_server.close( connection.first, websocketpp::close::status::normal, "Goodbye", ec );
}