Open AnWuPP opened 4 years ago
Are you saying your program freezes when disconnect
is called?
Are you saying your program freezes when
disconnect
is called?
call in destructor dll
Are you saying your program freezes when
disconnect
is called?
yea. problem with shared_ptr. thread m_thread alive after unloading my dll. maybe
I do not use the libraries' thread, but a boost::thread
instead:
boost::thread run_thread;
INFO << "start the ASIO io_service run loop";
run_thread = boost::thread([this] {
try
{
m_server.run();
}
catch (const std::exception &e)
{
ERROR << "run_thread >> error = " << e.what();
callback_error = true;
}
INFO << "run_thread stopping";
});
Then, in my deconstructor, I stop listening, close all connections, and join run_thread
:
websocketpp::lib::error_code ec;
m_server.stop_listening();
// close all connections
con_list::iterator it;
for (it = m_connections.begin(); it != m_connections.end(); ++it)
{
m_server.close(*it, websocketpp::close::status::service_restart, "class destructor", ec);
if (ec)
{
ERROR << "close error; error = " << ec.message();
}
}
// stop running thread
if (run_thread.joinable())
{
INFO << "end run_thread";
run_thread.join();
}
Hey. I make a WebSocket connection in a dynamic library. The problem occurs when you try to unload this very library. The main application freezes.
websocket.h
websocket.cpp
init in main.cpp
what am i doing wrong?