Mercurial > hg > orthanc
comparison Core/HttpServer/MongooseServer.cpp @ 2903:1153b1a128fe
MongooseServer::SetThreadsCount()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 23 Oct 2018 17:32:56 +0200 |
parents | da43ef7ff32a |
children | d924f9bb61cc |
comparison
equal
deleted
inserted
replaced
2902:e80b38fb22c6 | 2903:1153b1a128fe |
---|---|
917 filter_ = NULL; | 917 filter_ = NULL; |
918 keepAlive_ = false; | 918 keepAlive_ = false; |
919 httpCompression_ = true; | 919 httpCompression_ = true; |
920 exceptionFormatter_ = NULL; | 920 exceptionFormatter_ = NULL; |
921 realm_ = ORTHANC_REALM; | 921 realm_ = ORTHANC_REALM; |
922 threadsCount_ = 50; // Default value in mongoose | |
922 | 923 |
923 #if ORTHANC_ENABLE_SSL == 1 | 924 #if ORTHANC_ENABLE_SSL == 1 |
924 // Check for the Heartbleed exploit | 925 // Check for the Heartbleed exploit |
925 // https://en.wikipedia.org/wiki/OpenSSL#Heartbleed_bug | 926 // https://en.wikipedia.org/wiki/OpenSSL#Heartbleed_bug |
926 if (OPENSSL_VERSION_NUMBER < 0x1000107fL /* openssl-1.0.1g */ && | 927 if (OPENSSL_VERSION_NUMBER < 0x1000107fL /* openssl-1.0.1g */ && |
955 #endif | 956 #endif |
956 | 957 |
957 if (!IsRunning()) | 958 if (!IsRunning()) |
958 { | 959 { |
959 std::string port = boost::lexical_cast<std::string>(port_); | 960 std::string port = boost::lexical_cast<std::string>(port_); |
961 std::string numThreads = boost::lexical_cast<std::string>(threadsCount_); | |
960 | 962 |
961 if (ssl_) | 963 if (ssl_) |
962 { | 964 { |
963 port += "s"; | 965 port += "s"; |
964 } | 966 } |
973 | 975 |
974 #if ORTHANC_ENABLE_CIVETWEB == 1 | 976 #if ORTHANC_ENABLE_CIVETWEB == 1 |
975 // https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md#enable_keep_alive-no | 977 // https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md#enable_keep_alive-no |
976 "keep_alive_timeout_ms", (keepAlive_ ? "500" : "0"), | 978 "keep_alive_timeout_ms", (keepAlive_ ? "500" : "0"), |
977 #endif | 979 #endif |
980 | |
981 // Set the number of threads | |
982 "num_threads", numThreads.c_str(), | |
978 | 983 |
979 // Set the SSL certificate, if any. This must be the last option. | 984 // Set the SSL certificate, if any. This must be the last option. |
980 ssl_ ? "ssl_certificate" : NULL, | 985 ssl_ ? "ssl_certificate" : NULL, |
981 certificate_.c_str(), | 986 certificate_.c_str(), |
982 NULL | 987 NULL |
1123 throw OrthancException(ErrorCode_InternalError); | 1128 throw OrthancException(ErrorCode_InternalError); |
1124 } | 1129 } |
1125 | 1130 |
1126 return *handler_; | 1131 return *handler_; |
1127 } | 1132 } |
1133 | |
1134 | |
1135 void MongooseServer::SetThreadsCount(unsigned int threads) | |
1136 { | |
1137 if (threads <= 0) | |
1138 { | |
1139 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1140 } | |
1141 | |
1142 Stop(); | |
1143 threadsCount_ = threads; | |
1144 } | |
1128 } | 1145 } |