Mercurial > hg > orthanc
diff Core/HttpServer/MongooseServer.cpp @ 2981:eff50153a7b3 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Dec 2018 15:58:08 +0100 |
parents | d924f9bb61cc |
children | 4e43e67f8ecf |
line wrap: on
line diff
--- a/Core/HttpServer/MongooseServer.cpp Thu Oct 18 10:48:11 2018 +0200 +++ b/Core/HttpServer/MongooseServer.cpp Thu Dec 06 15:58:08 2018 +0100 @@ -813,8 +813,8 @@ // Now convert native exceptions as OrthancException catch (boost::bad_lexical_cast&) { - LOG(ERROR) << "Syntax error in some user-supplied data"; - throw OrthancException(ErrorCode_BadParameterType); + throw OrthancException(ErrorCode_BadParameterType, + "Syntax error in some user-supplied data"); } catch (std::runtime_error&) { @@ -823,13 +823,13 @@ } catch (std::bad_alloc&) { - LOG(ERROR) << "The server hosting Orthanc is running out of memory"; - throw OrthancException(ErrorCode_NotEnoughMemory); + throw OrthancException(ErrorCode_NotEnoughMemory, + "The server hosting Orthanc is running out of memory"); } catch (...) { - LOG(ERROR) << "An unhandled exception was generated inside the HTTP server"; - throw OrthancException(ErrorCode_InternalError); + throw OrthancException(ErrorCode_InternalError, + "An unhandled exception was generated inside the HTTP server"); } } catch (OrthancException& e) @@ -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<std::string>(port_); + std::string numThreads = boost::lexical_cast<std::string>(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; + } }