Browse Source

[trac589] close the socket on errors too

Jelte Jansen 14 years ago
parent
commit
41ef6df597
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/lib/asiolink/tcp_server.cc

+ 3 - 0
src/lib/asiolink/tcp_server.cc

@@ -104,6 +104,7 @@ TCPServer::operator()(error_code ec, size_t length) {
         CORO_YIELD async_read(*socket_, asio::buffer(data_.get(),
         CORO_YIELD async_read(*socket_, asio::buffer(data_.get(),
                               TCP_MESSAGE_LENGTHSIZE), *this);
                               TCP_MESSAGE_LENGTHSIZE), *this);
         if (ec) {
         if (ec) {
+            socket_->close();
             CORO_YIELD return;
             CORO_YIELD return;
         }
         }
 
 
@@ -116,6 +117,7 @@ TCPServer::operator()(error_code ec, size_t length) {
         }
         }
 
 
         if (ec) {
         if (ec) {
+            socket_->close();
             CORO_YIELD return;
             CORO_YIELD return;
         }
         }
 
 
@@ -149,6 +151,7 @@ TCPServer::operator()(error_code ec, size_t length) {
         // If we don't have a DNS Lookup provider, there's no point in
         // If we don't have a DNS Lookup provider, there's no point in
         // continuing; we exit the coroutine permanently.
         // continuing; we exit the coroutine permanently.
         if (lookup_callback_ == NULL) {
         if (lookup_callback_ == NULL) {
+            socket_->close();
             CORO_YIELD return;
             CORO_YIELD return;
         }
         }