Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2316 from Montellese/libmicrohttpd_threading_work…

…around

webserver: work around a potential crash bug in libmicrohttpd 0.9.x
  • Loading branch information...
commit 3a4d16fb54c4ca1eca9ba87448763084fd3a996e 2 parents aae7f2d + 9ddbb2e
@Montellese Montellese authored
Showing with 15 additions and 8 deletions.
  1. +15 −8 xbmc/network/WebServer.cpp
View
23 xbmc/network/WebServer.cpp
@@ -541,20 +541,27 @@ void CWebServer::ContentReaderFreeCallback(void *cls)
struct MHD_Daemon* CWebServer::StartMHD(unsigned int flags, int port)
{
- // WARNING: when using MHD_USE_THREAD_PER_CONNECTION, set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
- // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
-
unsigned int timeout = 60 * 60 * 24;
- // MHD_USE_THREAD_PER_CONNECTION = one thread per connection
- // MHD_USE_SELECT_INTERNALLY = use main thread for each connection, can only handle one request at a time [unless you set the thread pool size]
- return MHD_start_daemon(flags,
+ return MHD_start_daemon(flags |
+#if (MHD_VERSION >= 0x00040002) && (MHD_VERSION < 0x00090B01)
+ // use main thread for each connection, can only handle one request at a
+ // time [unless you set the thread pool size]
+ MHD_USE_SELECT_INTERNALLY
+#else
+ // one thread per connection
+ // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1
+ // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop
+ MHD_USE_THREAD_PER_CONNECTION
+#endif
+ ,
port,
NULL,
NULL,
&CWebServer::AnswerToConnection,
this,
-#if (MHD_VERSION >= 0x00040002)
+
+#if (MHD_VERSION >= 0x00040002) && (MHD_VERSION < 0x00090B01)
MHD_OPTION_THREAD_POOL_SIZE, 4,
#endif
MHD_OPTION_CONNECTION_LIMIT, 512,
@@ -568,7 +575,7 @@ bool CWebServer::Start(int port, const string &username, const string &password)
SetCredentials(username, password);
if (!m_running)
{
- m_daemon = StartMHD(MHD_USE_SELECT_INTERNALLY, port);
+ m_daemon = StartMHD(0 , port);
m_running = m_daemon != NULL;
if (m_running)
Please sign in to comment.
Something went wrong with that request. Please try again.