31f1ce360a
With faster starting spare kits we can end up waiting for a state where there are no live or spare kits, but the spare kit has already beaten us to the punch: [testCrashKit] (+1124ms): Killing coolkit instances.| httpcrashtest.cpp:151 [killPid] (+1124ms): Killing 1650047| httpcrashtest.cpp:257 [killPid] (+1124ms): Killing 1650071| httpcrashtest.cpp:257 [waitForKitProcessCount] (+1124ms): Waiting for kit process count: Doc Kits: 0 Spare Kits: 0 | KitPidHelpers.cpp:70 [waitForKitProcessCount] (+1124ms): Current kit processes: Doc Kits: [1650047, ] Spare Kits: [1650071, ]| KitPidHelpers.cpp:80 ... Forking a coolkit process with jailId: 09X67pOy1HAgSk9G as spare coolkit #5.| kit/ForKit.cpp:406 ... [waitForKitProcessCount] (+1558ms): Current kit processes: Doc Kits: [] Spare Kits: [1650083, ]| KitPidHelpers.cpp:94 ... fail ... Avoid this by intersecting before & after to ensure are all before are dead. Cleanup exposing the more problematic wait-for-zero-spare method. Signed-off-by: Michael Meeks <michael.meeks@collabora.com> Change-Id: I6f0ba87139b58f9bf1770ebbc5cac95b5063679e
75 lines
1.9 KiB
C++
75 lines
1.9 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
/*
|
|
* Copyright the Collabora Online contributors.
|
|
*
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <config.h>
|
|
|
|
#include <chrono>
|
|
#include <set>
|
|
|
|
#include <Common.hpp>
|
|
|
|
namespace helpers
|
|
{
|
|
|
|
constexpr int KIT_PID_TIMEOUT_MS = 10000 * TRACE_MULTIPLIER;
|
|
constexpr int KIT_PID_RETRY_MS = 20;
|
|
|
|
/*
|
|
* Get the list of all kit pids
|
|
*/
|
|
std::set<pid_t> getKitPids();
|
|
|
|
/*
|
|
* Get the list of spare (unused) kit pids
|
|
*/
|
|
std::set<pid_t> getSpareKitPids();
|
|
|
|
/*
|
|
* Get the list of doc (loaded) kit pids
|
|
*/
|
|
std::set<pid_t> getDocKitPids();
|
|
|
|
/*
|
|
* Get the pid of the coolforkit process
|
|
*/
|
|
pid_t getForKitPid();
|
|
|
|
/*
|
|
* Log the current doc and spare kit pids
|
|
* Useful for debugging
|
|
*/
|
|
void logKitProcesses(const std::string& testname);
|
|
|
|
/*
|
|
* SIGKILL relevant pid
|
|
*/
|
|
void killPid(const std::string& testname, const pid_t pid);
|
|
|
|
/*
|
|
* Wait until ready with 0 doc kits and 1 spare kit
|
|
* Used to wait for spare kit to start up before use
|
|
* or to wait for doc kits to shut down after
|
|
*/
|
|
void waitForKitPidsReady(
|
|
const std::string& testname,
|
|
const std::chrono::milliseconds timeoutMs = std::chrono::milliseconds(KIT_PID_TIMEOUT_MS),
|
|
const std::chrono::milliseconds retryMs = std::chrono::milliseconds(KIT_PID_RETRY_MS));
|
|
|
|
/*
|
|
* Kill all and wait for previous processes to die
|
|
*/
|
|
void killAllKitProcesses(const std::string& testname,
|
|
const std::chrono::milliseconds timeoutMs = std::chrono::milliseconds(KIT_PID_TIMEOUT_MS),
|
|
const std::chrono::milliseconds retryMs = std::chrono::milliseconds(KIT_PID_RETRY_MS));
|
|
|
|
} // namespace helpers
|