Heartbeats need to happen while waiting for sandbox

We can only know if sandbox is up by waiting for the http request to
succeed or fail.  In the common case (fail since it isn't up yet), we
have to wait until a connect timeout in http.  Seems that is a couple
seconds, and in that time we really upset the deadlock watchdog thread
since it keeps a moving average of heartbeat times.

Simple solution, updateHeartbeat while waiting, and right before we
start.
This commit is contained in:
David Kelly 2016-10-21 14:43:39 -07:00
parent ba9d9f6ab7
commit aa31d3d8cc

View file

@ -585,6 +585,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
static bool determinedSandboxState = false;
static bool sandboxIsRunning = false;
SandboxUtils sandboxUtils;
// updateHeartbeat() because we are going to poll shortly...
updateHeartbeat();
sandboxUtils.ifLocalSandboxRunningElse([&]() {
qCDebug(interfaceapp) << "Home sandbox appears to be running.....";
determinedSandboxState = true;
@ -605,6 +607,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
auto startWaiting = usecTimestampNow();
while (!determinedSandboxState && (usecTimestampNow() - startWaiting <= MAX_WAIT_TIME)) {
QCoreApplication::processEvents();
// updateHeartbeat() while polling so we don't scare the deadlock watchdog
updateHeartbeat();
usleep(USECS_PER_MSEC * 50); // 20hz
}