Commit 65bbffe7 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2903] same change as the previous commit for SyncUDPServer.

also made some other small cleanups.
parent abd65c5b
......@@ -75,7 +75,7 @@ If you see a single occurrence of this message, it probably does not
indicate any significant problem, but if it is logged often, it is probably
a good idea to inspect your network traffic.
% ASIODNS_UDP_RECEIVE_FAIL failed to accept UDP DNS packet: %1
% ASIODNS_UDP_RECEIVE_FAIL failed to receive UDP DNS packet: %1
Receiving a UDP packet from a DNS client failed due to an error that
could happen but should be very rare. The server still keeps
receiving UDP packets on this socket. The reason for the error is
......@@ -83,6 +83,11 @@ included in the log message. This log message is basically not
expected to appear at all in practice; if it does, there may be some
system level failure and other system logs may have to be checked.
% ASIODNS_UDP_SYNC_RECEIVE_FAIL failed to receive UDP DNS packet: %1
This is the same to ASIODNS_UDP_RECEIVE_FAIL but happens on the
"synchronous UDP server", mainly used for the authoritative DNS server
% ASIODNS_UDP_SYNC_SEND_FAIL Error sending UDP packet to %1: %2
The low-level ASIO library reported an error when trying to send a UDP
packet in synchronous UDP mode. See ASIODNS_UDP_ASYNC_SEND_FAIL for
......@@ -72,16 +72,19 @@ SyncUDPServer::scheduleRead() {
SyncUDPServer::handleRead(const asio::error_code& ec, const size_t length) {
// Abort on fatal errors
if (ec) {
using namespace asio::error;
if (ec.value() != would_block && ec.value() != try_again &&
ec.value() != interrupted) {
const asio::error_code::value_type err_val = ec.value();
// See TCPServer::operator() for details on error handling.
if (err_val == operation_aborted || err_val == bad_descriptor) {
if (err_val != would_block && err_val != try_again &&
err_val != interrupted) {
LOG_ERROR(logger, ASIODNS_UDP_SYNC_RECEIVE_FAIL).arg(ec.message());
// Some kind of interrupt, spurious wakeup, or like that. Just try reading
// again.
if (ec || length == 0) {
......@@ -173,6 +176,10 @@ SyncUDPServer::operator()(asio::error_code, size_t) {
/// Stop the UDPServer
SyncUDPServer::stop() {
// passing error_code to avoid getting exception; we simply ignore any
// error on close().
asio::error_code ec;
/// Using close instead of cancel, because cancel
/// will only cancel the asynchronized event already submitted
/// to io service, the events post to io service after
......@@ -181,13 +188,10 @@ SyncUDPServer::stop() {
/// for it won't be scheduled by io service not matter it is
/// submit to io service before or after close call. And we will
/// get bad_descriptor error.
stopped_ = true;
/// Post this coroutine on the ASIO service queue so that it will
/// resume processing where it left off. The 'done' parameter indicates
/// whether there is an answer to return to the client.
SyncUDPServer::resume(const bool done) {
resume_called_ = true;
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