Skip to content

Commit

Permalink
Fix warnings from adding CHECKED annotations
Browse files Browse the repository at this point in the history
This centered on checking the result of sending IPC console heartbeats and a
few other one-offs.
  • Loading branch information
AgalmicVentures committed Mar 27, 2021
1 parent 53ddba4 commit d2f4b23
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/IpcConsoleClient/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ void heartbeat(std::atomic<bool> *running, werk::IpcConsoleClient *client)
delay.tv_sec = 1;
delay.tv_nsec = 0;

uint32_t failedHeartbeats = 0;
while (*running) {
nanosleep(&delay, nullptr);
client->heartbeat();
if (!client->heartbeat()) {
std::cout << "Failed to send heartbeat..." << std::endl;
failedHeartbeats += 1;
if (3 <= failedHeartbeats) {
break;
}
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/Werk/Config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,21 @@ void Config::execute()
}

//Run on whatever thread the configurables live on
void Config::reloadConfigurables()
bool Config::reloadConfigurables()
{
//Don't reload unless changed
if (!_changed.value()) {
return;
return true;
}
_changed.reset();

bool success = true;
for (Configurable *configurable : _configurables) {
configurable->reloadConfig(*this);
if (!configurable->reloadConfig(*this)) {
success = false;
}
}
return success;
}

//Basic types
Expand Down
2 changes: 1 addition & 1 deletion src/Werk/Config/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Config : public Action
void execute() override;

//Run on whatever thread the configurables live on
void reloadConfigurables();
CHECKED bool reloadConfigurables();

//Basic value-as-string accessor - this is the method that every inheriting class must override (return nullptr if the key is missing)
CHECKED const char *getStringRaw(const std::string &key) const {
Expand Down
3 changes: 2 additions & 1 deletion src/Werk/Console/IpcConsoleClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class IpcConsoleClient : public NamedObject
_queue(boost::interprocess::open_only, name.c_str()),
_pid(getpid()) {
//Send a heartbeat to let the server know about the connection
heartbeat();
//The return value of this one is ignored
(void) heartbeat();
}

CHECKED bool send(const std::string &message);
Expand Down

0 comments on commit d2f4b23

Please sign in to comment.