aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/servers/httpsys.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenhttp/servers/httpsys.cpp')
-rw-r--r--src/zenhttp/servers/httpsys.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/zenhttp/servers/httpsys.cpp b/src/zenhttp/servers/httpsys.cpp
index 0be53ffee..9dbdd7167 100644
--- a/src/zenhttp/servers/httpsys.cpp
+++ b/src/zenhttp/servers/httpsys.cpp
@@ -939,7 +939,7 @@ HttpSysServer::HttpSysServer(const HttpSysConfig& InConfig)
MaxThreadCount = MinThreadCount * 2;
- if (m_InitialConfig.IsDedicatedServer)
+ if (m_InitialConfig.IsDedicatedServer && m_InitialConfig.ThreadCount == 0)
{
// In order to limit the potential impact of threads stuck
// in locks we allow the thread pool to be oversubscribed
@@ -1042,16 +1042,35 @@ HttpSysServer::InitializeServer(int BasePort)
{
Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
- if ((Result == ERROR_SHARING_VIOLATION) && AllowPortProbing)
+ if ((Result == ERROR_SHARING_VIOLATION))
{
- // Sharing violation implies the port is being used by another process
- for (int PortOffset = 1; (Result == ERROR_SHARING_VIOLATION) && (PortOffset < 10); ++PortOffset)
+ ZEN_INFO("Desired port {} is in use (error: '{}'), retrying", EffectivePort, Result);
+ Sleep(500);
+ Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
+
+ if (Result == ERROR_SHARING_VIOLATION)
{
- EffectivePort = BasePort + (PortOffset * 100);
- WildcardUrlPath.Reset();
- WildcardUrlPath << u8"http://*:"sv << int64_t(EffectivePort) << u8"/"sv;
+ if (AllowPortProbing)
+ {
+ // Sharing violation implies the port is being used by another process
+ for (int PortOffset = 1; (Result == ERROR_SHARING_VIOLATION) && (PortOffset < 10); ++PortOffset)
+ {
+ EffectivePort = BasePort + (PortOffset * 100);
+ WildcardUrlPath.Reset();
+ WildcardUrlPath << u8"http://*:"sv << int64_t(EffectivePort) << u8"/"sv;
- Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
+ Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
+ }
+ }
+ else
+ {
+ for (uint32_t Retries = 0; (Result == ERROR_SHARING_VIOLATION) && (Retries < 3); Retries++)
+ {
+ ZEN_INFO("Desired port {} is in use (error: '{}'), retrying", EffectivePort, Result);
+ Sleep(500);
+ Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
+ }
+ }
}
}
}