* Processes events for registered sockets and timers and calls whatever * handlers have been set up for these events. */
| 306 | * handlers have been set up for these events. |
| 307 | */ |
| 308 | void Application::RunEventLoop() |
| 309 | { |
| 310 | double lastLoop = Utility::GetTime(); |
| 311 | |
| 312 | while (!m_ShuttingDown) { |
| 313 | if (m_RequestRestart) { |
| 314 | m_RequestRestart = false; // we are now handling the request, once is enough |
| 315 | |
| 316 | #ifdef _WIN32 |
| 317 | // are we already restarting? ignore request if we already are |
| 318 | if (!l_Restarting) { |
| 319 | l_Restarting = true; |
| 320 | m_ReloadProcess = StartReloadProcess(); |
| 321 | } |
| 322 | #else /* _WIN32 */ |
| 323 | Log(LogNotice, "Application") |
| 324 | << "Got reload command, forwarding to umbrella process (PID " << m_UmbrellaProcess << ")"; |
| 325 | |
| 326 | (void)kill(m_UmbrellaProcess, SIGHUP); |
| 327 | #endif /* _WIN32 */ |
| 328 | } else { |
| 329 | /* Watches for changes to the system time. Adjusts timers if necessary. */ |
| 330 | Utility::Sleep(2.5); |
| 331 | |
| 332 | if (m_RequestReopenLogs) { |
| 333 | Log(LogNotice, "Application", "Reopening log files"); |
| 334 | m_RequestReopenLogs = false; |
| 335 | OnReopenLogs(); |
| 336 | } |
| 337 | |
| 338 | double now = Utility::GetTime(); |
| 339 | double timeDiff = lastLoop - now; |
| 340 | |
| 341 | if (std::fabs(timeDiff) > 15) { |
| 342 | /* We made a significant jump in time. */ |
| 343 | Log(LogInformation, "Application") |
| 344 | << "We jumped " |
| 345 | << (timeDiff < 0 ? "forward" : "backward") |
| 346 | << " in time: " << std::fabs(timeDiff) << " seconds"; |
| 347 | |
| 348 | Timer::AdjustTimers(-timeDiff); |
| 349 | } |
| 350 | |
| 351 | lastLoop = now; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | Log(LogInformation, "Application", "Shutting down..."); |
| 356 | |
| 357 | ConfigObject::StopObjects(); |
| 358 | Application::GetInstance()->OnShutdown(); |
| 359 | |
| 360 | #ifdef I2_DEBUG |
| 361 | UninitializeBase(); // Inspired from Exit() |
| 362 | #endif /* I2_DEBUG */ |
| 363 | } |
| 364 | |
| 365 | bool Application::IsShuttingDown() |
nothing calls this directly
no test coverage detected