asiolink::SimpleCallback* checkin,
DNSLookup* lookup, DNSAnswer* answer) :
io_(io_service), checkin_callback_(checkin), lookup_callback_(lookup),
- answer_callback_(answer)
+ answer_callback_(answer), stopped_(false)
{
// We must use different instantiations for v4 and v6;
// otherwise ASIO will bind to both
const int af, asiolink::SimpleCallback* checkin,
DNSLookup* lookup, DNSAnswer* answer) :
io_(io_service), checkin_callback_(checkin), lookup_callback_(lookup),
- answer_callback_(answer)
+ answer_callback_(answer), stopped_(false)
{
if (af != AF_INET && af != AF_INET6) {
isc_throw(InvalidParameter, "Address family must be either AF_INET "
IOMessage message(data_, length, socket, endpoint);
if (checkin_callback_ != NULL) {
(*checkin_callback_)(message);
+ if (stopped_) {
+ return;
+ }
}
// If we don't have a DNS Lookup provider, there's no point in
"No resume called from the lookup callback");
}
+ if (stopped_) {
+ return;
+ }
+
if (done_) {
// Good, there's an answer.
// Call the answer callback to render it.
(*answer_callback_)(message, query, answer, output);
+ if (stopped_) {
+ return;
+ }
+
socket_->send_to(asio::buffer(output->getData(), output->getLength()),
sender_);
}
/// submit to io serice before or after close call. And we will
//. get bad_descriptor error
socket_->close();
+ stopped_ = true;
}
/// Post this coroutine on the ASIO service queue so that it will
const asiolink::SimpleCallback* checkin_callback_;
const DNSLookup* lookup_callback_;
const DNSAnswer* answer_callback_;
- bool resume_called_, done_;
+ bool resume_called_, done_, stopped_;
void scheduleRead();
void handleRead(const asio::error_code& ec, const size_t length);