]> git.sesse.net Git - casparcg/commitdiff
Enabled TCP keep alive on TCP connections to clients. This might help in discovering...
authorHelge Norberg <helge.norberg@svt.se>
Wed, 13 Jul 2016 11:03:39 +0000 (13:03 +0200)
committerHelge Norberg <helge.norberg@svt.se>
Wed, 13 Jul 2016 11:03:39 +0000 (13:03 +0200)
protocol/util/AsyncEventServer.cpp

index 8348c56b97f4754d7bbaf3ddd992643e6b7b77c9..d404becdbb9c5711f5d6f2203a8a14864ef49441 100644 (file)
@@ -329,6 +329,12 @@ struct AsyncEventServer::implementation : public spl::enable_shared_from_this<im
                
         if (!error)
                {
+                       boost::system::error_code ec;
+                       socket->set_option(boost::asio::socket_base::keep_alive(true), ec);
+
+                       if (ec)
+                               CASPAR_LOG(warning) << print() << L" Failed to enable TCP keep-alive on socket";
+                       
                        auto conn = connection::create(service_, socket, protocol_factory_, connection_set_);
                        connection_set_->insert(conn);
 
@@ -341,6 +347,11 @@ struct AsyncEventServer::implementation : public spl::enable_shared_from_this<im
                start_accept();
     }
 
+       std::wstring print() const
+       {
+               return L"async_event_server[:" + boost::lexical_cast<std::wstring>(acceptor_.local_endpoint().port()) + L"]";
+       }
+
        void add_client_lifecycle_object_factory(const lifecycle_factory_t& factory)
        {
                auto self = shared_from_this();