MCPcopy Create free account
hub / github.com/MITK/MITK / ServerThreadFunc

Method ServerThreadFunc

Modules/RESTAPI/src/mitkRestServer.cpp:1203–1227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201}
1202
1203void RestServer::ServerThreadFunc()
1204{
1205 // The port is already bound via bind_to_port() in Start(). This call blocks
1206 // until the server is stopped (via Stop()) or an unexpected error occurs.
1207 const bool result = m_Server->listen_after_bind();
1208
1209 {
1210 std::lock_guard<std::mutex> lock(m_Mutex);
1211
1212 // Check if this was an unexpected failure (not triggered by Stop()).
1213 // m_Running being true here means Stop() has not been called yet.
1214 if (!result && m_Running)
1215 {
1216 const std::string host = m_RunningConfig ? m_RunningConfig->host : "?";
1217 const int port = m_RunningConfig ? m_RunningConfig->port : 0;
1218 m_LastError = "Server stopped unexpectedly on " + SanitizeForLog(host) + ":" + std::to_string(port);
1219 MITK_ERROR << *m_LastError;
1220 }
1221
1222 // Server is no longer running regardless of how listen_after_bind() returned.
1223 // This ensures IsRunning() returns the correct state.
1224 m_Running = false;
1225 m_RunningConfig = std::nullopt;
1226 }
1227}
1228
1229bool RestServer::SetupTempDirectory()
1230{

Callers

nothing calls this directly

Calls 1

SanitizeForLogFunction · 0.85

Tested by

no test coverage detected