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,
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)