Skip to content

Commit

Permalink
Merge pull request #205 from bitshares/fix-websocket-close
Browse files Browse the repository at this point in the history
Fix race condition in websocket server close
  • Loading branch information
abitmore authored Jun 24, 2020
2 parents a876678 + 8b94976 commit a2b380d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/network/http/websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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 );
}

Expand Down

0 comments on commit a2b380d

Please sign in to comment.