[Asio] when stopping io_service, I get a system_error : mutex: invalid argument
Hello,
I'm using asio for a udp receiver. I used the example code from http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/example/multicast/r... and created a class that in its contructor opens a socket, binds to it, calls async_receive_from, and in the receive handler again calls async_receive from.
Now i have manager class that takes care of the io service, the thread, and an instance of the receiver class.
Everything works fine until the moment I destroy the manager class.
Here is what the destructor looks like:
Manager::~Manager
{
// first, make sure that no further requests are handled that would prevent io_service from quitting
m_receiver->getSock()->shutdown(boost::asio::ip::udp::socket::shutdown_both);
m_receiver->getSock()->close();
// destroy the receiver by resetting its auto_ptr
m_receiver.reset();
// reset the work auto_ptr, destroying the work for io_service, so that it can quit
m_io_work.reset(0);
// join the thread in which io_service.run() was called.
m_receiver_thread.join();
// now stop the io
// this line is commented, it has no effect whether i remove the slashes
// m_io_service.stop();
}
When I destroy the manager, i get the following error:
"terminate called after throwing an instance of 'boost::exception_detail::clone_impl
participants (1)
-
philipp_muenzel@web.de