fixed: set the timeout of the libmicrohttp webserver to 24 hours, the default timeout...
authorbobo1on1 <bobo1on1@svn>
Thu, 2 Sep 2010 23:10:29 +0000 (23:10 +0000)
committerbobo1on1 <bobo1on1@svn>
Thu, 2 Sep 2010 23:10:29 +0000 (23:10 +0000)
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@33460 568bbfeb-2a22-0410-94d2-cc84cf5bfa90

xbmc/utils/WebServer.cpp

index 37a05a9..35d30cf 100644 (file)
@@ -344,10 +344,15 @@ bool CWebServer::Start(const char *ip, int port)
 {
   if (!m_running)
   {
+    // set MHD_OPTION_CONNECTION_TIMEOUT to 24 hours, connection gets closed when it has been idle for that long
+    // timeout is 0 by default, which in libmicrohttpd 0.4.2 means let select wait forever
+    // and in 0.4.4 means let select return immediately, so that's very useful
+    unsigned int timeout = 60 * 60 * 24;
+
     // To stream perfectly we should probably have MHD_USE_THREAD_PER_CONNECTION instead of MHD_USE_SELECT_INTERNALLY as it provides multiple clients concurrently
-    m_daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY | MHD_USE_IPv6, port, NULL, NULL, &CWebServer::AnswerToConnection, this, MHD_OPTION_END);
+    m_daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY | MHD_USE_IPv6, port, NULL, NULL, &CWebServer::AnswerToConnection, this, MHD_OPTION_CONNECTION_TIMEOUT, timeout, MHD_OPTION_END);
     if (!m_daemon) //try IPv4
-      m_daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, port, NULL, this, &CWebServer::AnswerToConnection, this, MHD_OPTION_END);
+      m_daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, port, NULL, this, &CWebServer::AnswerToConnection, this, MHD_OPTION_CONNECTION_TIMEOUT, timeout, MHD_OPTION_END);
     m_running = m_daemon != NULL;
     if (m_running)
       CLog::Log(LOGNOTICE, "WebServer: Started the webserver");