Fix portability bug in websocket server sync example

fixes #2032
closes #2034
This commit is contained in:
Richard Hodges
2020-07-23 11:10:52 +02:00
parent b168f6242d
commit 4f913cab63
3 changed files with 9 additions and 6 deletions

View File

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
Version 299: Version 299:
* Fix race in http-crawl example. * Fix race in http-crawl example.

View File

@ -38,7 +38,7 @@ using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
// Echoes back all received WebSocket messages // Echoes back all received WebSocket messages
void void
do_session(tcp::socket& socket, ssl::context& ctx) do_session(tcp::socket socket, ssl::context& ctx)
{ {
try try
{ {
@ -123,10 +123,10 @@ int main(int argc, char* argv[])
acceptor.accept(socket); acceptor.accept(socket);
// Launch the session, transferring ownership of the socket // Launch the session, transferring ownership of the socket
std::thread{std::bind( std::thread(
&do_session, &do_session,
std::move(socket), std::move(socket),
std::ref(ctx))}.detach(); std::ref(ctx)).detach();
} }
} }
catch (const std::exception& e) catch (const std::exception& e)

View File

@ -32,7 +32,7 @@ using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
// Echoes back all received WebSocket messages // Echoes back all received WebSocket messages
void void
do_session(tcp::socket& socket) do_session(tcp::socket socket)
{ {
try try
{ {
@ -108,9 +108,9 @@ int main(int argc, char* argv[])
acceptor.accept(socket); acceptor.accept(socket);
// Launch the session, transferring ownership of the socket // Launch the session, transferring ownership of the socket
std::thread{std::bind( std::thread(
&do_session, &do_session,
std::move(socket))}.detach(); std::move(socket)).detach();
} }
} }
catch (const std::exception& e) catch (const std::exception& e)