# HG changeset patch # User Sebastien Jodogne # Date 1540308776 -7200 # Node ID 1153b1a128fe6aeffa792c9f7769925836117242 # Parent e80b38fb22c6db1bd7f9cf5ca23492e728f73882 MongooseServer::SetThreadsCount() diff -r e80b38fb22c6 -r 1153b1a128fe Core/HttpServer/MongooseServer.cpp --- a/Core/HttpServer/MongooseServer.cpp Tue Oct 23 12:05:19 2018 +0200 +++ b/Core/HttpServer/MongooseServer.cpp Tue Oct 23 17:32:56 2018 +0200 @@ -919,6 +919,7 @@ httpCompression_ = true; exceptionFormatter_ = NULL; realm_ = ORTHANC_REALM; + threadsCount_ = 50; // Default value in mongoose #if ORTHANC_ENABLE_SSL == 1 // Check for the Heartbleed exploit @@ -957,6 +958,7 @@ if (!IsRunning()) { std::string port = boost::lexical_cast(port_); + std::string numThreads = boost::lexical_cast(threadsCount_); if (ssl_) { @@ -975,6 +977,9 @@ // https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md#enable_keep_alive-no "keep_alive_timeout_ms", (keepAlive_ ? "500" : "0"), #endif + + // Set the number of threads + "num_threads", numThreads.c_str(), // Set the SSL certificate, if any. This must be the last option. ssl_ ? "ssl_certificate" : NULL, @@ -1125,4 +1130,16 @@ return *handler_; } + + + void MongooseServer::SetThreadsCount(unsigned int threads) + { + if (threads <= 0) + { + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + + Stop(); + threadsCount_ = threads; + } } diff -r e80b38fb22c6 -r 1153b1a128fe Core/HttpServer/MongooseServer.h --- a/Core/HttpServer/MongooseServer.h Tue Oct 23 12:05:19 2018 +0200 +++ b/Core/HttpServer/MongooseServer.h Tue Oct 23 17:32:56 2018 +0200 @@ -96,6 +96,7 @@ bool httpCompression_; IHttpExceptionFormatter* exceptionFormatter_; std::string realm_; + unsigned int threadsCount_; bool IsRunning() const; @@ -198,5 +199,12 @@ { realm_ = realm; } + + void SetThreadsCount(unsigned int threads); + + unsigned int GetThreadsCount() const + { + return threadsCount_; + } }; } diff -r e80b38fb22c6 -r 1153b1a128fe OrthancServer/main.cpp --- a/OrthancServer/main.cpp Tue Oct 23 12:05:19 2018 +0200 +++ b/OrthancServer/main.cpp Tue Oct 23 17:32:56 2018 +0200 @@ -752,6 +752,7 @@ // HTTP server MyIncomingHttpRequestFilter httpFilter(context, plugins); MongooseServer httpServer; + //httpServer.SetThreadsCount(50); httpServer.SetPortNumber(Configuration::GetGlobalUnsignedIntegerParameter("HttpPort", 8042)); httpServer.SetRemoteAccessAllowed(Configuration::GetGlobalBoolParameter("RemoteAccessAllowed", false)); httpServer.SetKeepAliveEnabled(Configuration::GetGlobalBoolParameter("KeepAlive", false));