Commit db9ded28 authored by Michal Vaner's avatar Michal Vaner
Browse files

Fix problem with stopped IOService

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/vorner-recursor-config@3351 e5f2f494-b856-4b98-b285-d166d9295462
parent a57c6c2a
...@@ -171,7 +171,7 @@ SessionImpl::readData(void* data, size_t datalen) { ...@@ -171,7 +171,7 @@ SessionImpl::readData(void* data, size_t datalen) {
asio::async_read(socket_, asio::buffer(data, datalen), asio::async_read(socket_, asio::buffer(data, datalen),
boost::bind(&setResult, &read_result, _1)); boost::bind(&setResult, &read_result, _1));
asio::deadline_timer timer(socket_.io_service()); asio::deadline_timer timer(socket_.io_service());
if (getTimeout() != 0) { if (getTimeout() != 0) {
timer.expires_from_now(boost::posix_time::milliseconds(getTimeout())); timer.expires_from_now(boost::posix_time::milliseconds(getTimeout()));
timer.async_wait(boost::bind(&setResult, &timer_result, _1)); timer.async_wait(boost::bind(&setResult, &timer_result, _1));
...@@ -182,7 +182,12 @@ SessionImpl::readData(void* data, size_t datalen) { ...@@ -182,7 +182,12 @@ SessionImpl::readData(void* data, size_t datalen) {
// When one of them has a result, cancel the other, and wait // When one of them has a result, cancel the other, and wait
// until the cancel is processed before we continue // until the cancel is processed before we continue
while (!read_result && !timer_result) { while (!read_result && !timer_result) {
socket_.io_service().run_one(); if (!socket_.io_service().run_one()) {
// We run out of work last time we did readData
// and there seems to be no way to test if it is running.
// We know when it returns 0, it is stopped.
socket_.io_service().reset();
}
// Don't cancel the timer if we haven't set it // Don't cancel the timer if we haven't set it
if (read_result && getTimeout() != 0) { if (read_result && getTimeout() != 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment