Actually wait for things to finish terminating before reaping next one

Fixes #27. This is all kind of clunky right now, it would be much
better to just standardize the `run()` function pattern.
This commit is contained in:
Francesco Mazzoli
2023-07-26 22:22:27 +00:00
parent 15e59b8e67
commit bf447408a6
5 changed files with 102 additions and 47 deletions

View File

@@ -19,11 +19,9 @@ static std::string generateErrString(const std::string& what, int err) {
Xmon::Xmon(
Logger& logger,
std::shared_ptr<XmonAgent>& agent,
const XmonConfig& config,
std::atomic<bool>& stop
const XmonConfig& config
) :
_env(logger, agent, "xmon"),
_stop(stop),
_agent(agent),
_appType("restech.info"),
_xmonHost(config.prod ? "REDACTED" : "REDACTED"),
@@ -196,7 +194,7 @@ reconnect:
// Start recv loop
bool gotHeartbeat = false;
for (;;) {
bool shutDown = _stop.load();
bool shutDown = _stopper.shouldStop();
// send all requests
if (gotHeartbeat) {
@@ -230,6 +228,7 @@ reconnect:
if (shutDown) {
LOG_DEBUG(_env, "got told to stop, stopping");
close(sock);
_stopper.stopDone();
return;
}