Commit a32e0822 authored by hanfeng's avatar hanfeng

[trac678] merge code from ticket 657

parent d48aaf1a
......@@ -81,10 +81,18 @@ TCPServer::operator()(error_code ec, size_t length) {
/// try again
do {
CORO_YIELD acceptor_->async_accept(*socket_, *this);
/// If user stop the server which will close the acceptor
/// we just return
if (ec == asio::error::bad_descriptor)
CORO_YIELD return;
// return if we meet fatal error
// Todo add log
if (ec) {
using namespace asio::error;
if (ec.value() != would_block && ec.value() != try_again &&
ec.value() != connection_aborted &&
ec.value() != interrupted) {
return;
}
}
} while (ec);
......
......@@ -188,10 +188,15 @@ UDPServer::operator()(error_code ec, size_t length) {
buffer(data_->data_.get(), MAX_LENGTH), *data_->sender_,
*this);
// If the server is stopped which will close the socket,
// we just return
if (ec == asio::error::bad_descriptor)
CORO_YIELD return;
//return if we met fatal error
//Todo add log
if (ec) {
using namespace asio::error;
if (ec.value() != would_block && ec.value() != try_again &&
ec.value() != interrupted) {
return;
}
}
} while (ec || length == 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