
Hello List, Attached is a piece of sample code in which I'm trying to use Boost.Asio to dispatch a call that will cause the program to shutdown, however for some reason the io_service is not ever calling the handle_stop method, so the program does not shutdown. Any help would be greatly appreciated.

Attached is a piece of sample code in which I'm trying to use Boost.Asio to dispatch a call that will cause the program to shutdown, however for some reason the io_service is not ever calling the handle_stop method, so the program does not shutdown.
bool run = m_io.poll_one() >= 0;
the return value of poll_one() is always >=0 (it's size_t), so run is always true and the condition if(!run && m_stop) is always false.

On Fri, Jul 30, 2010 at 02:50, Igor R
Attached is a piece of sample code in which I'm trying to use Boost.Asio to dispatch a call that will cause the program to shutdown, however for some reason the io_service is not ever calling the handle_stop method, so the program does not shutdown.
bool run = m_io.poll_one() >= 0;
the return value of poll_one() is always >=0 (it's size_t), so run is always true and the condition if(!run && m_stop) is always false.
sorry that's a typo but actually irrelevant as the handle_stop is still never called. here is a simpler version with output that shows the same behavior http://ix.io/16b and here is a fixed version of what was previously attached with output http://ix.io/16c

On Fri, Jul 30, 2010 at 04:14, Malinka Rellikwodahs
On Fri, Jul 30, 2010 at 02:50, Igor R
wrote: Attached is a piece of sample code in which I'm trying to use Boost.Asio to dispatch a call that will cause the program to shutdown, however for some reason the io_service is not ever calling the handle_stop method, so the program does not shutdown.
bool run = m_io.poll_one() >= 0;
the return value of poll_one() is always >=0 (it's size_t), so run is always true and the condition if(!run && m_stop) is always false.
sorry that's a typo but actually irrelevant as the handle_stop is still never called.
here is a simpler version with output that shows the same behavior http://ix.io/16b
and here is a fixed version of what was previously attached with output http://ix.io/16c
After some help in the irc channel I've found the problem to be related to the calls to poll_one having no work to do, so subsequent calls to poll_one are invalid, as per http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/reference/io_servic... thank you for your help. As an interesting side note windows has the unfortunately incorrect behavior of working, which ends up making it look like a bug >.<;;;
participants (2)
-
Igor R
-
Malinka Rellikwodahs