Browse Source

[trac589] close the socket when tcp_server is done with a query

this is not RFC-compliant; it *should* keep the connection open for a while, which would involve another timeout etc. If we want that i suggest we create another task :) (it should fix the problem of running out of file descriptors)
Jelte Jansen 14 years ago
parent
commit
bf57a576ff
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/lib/asiolink/tcp_server.cc

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

@@ -166,6 +166,9 @@ TCPServer::operator()(error_code ec, size_t length) {
         // The 'done_' flag indicates whether we have an answer
         // to send back.  If not, exit the coroutine permanently.
         if (!done_) {
+            // TODO: should we keep the connection open for a short time
+            // to see if new requests come in?
+            socket_->close();
             CORO_YIELD return;
         }
 
@@ -184,6 +187,10 @@ TCPServer::operator()(error_code ec, size_t length) {
         // (though we have nothing further to do, so the coroutine
         // will simply exit at that time).
         CORO_YIELD async_write(*socket_, bufs, *this);
+        
+        // TODO: should we keep the connection open for a short time
+        // to see if new requests come in?
+        socket_->close();
     }
 }