currentCheckFailures++;
- if (upStatus) {
+ if (upStatus.load()) {
/* we were previously marked as "up" and failed a health-check,
let's see if this is enough to move to the "down" state or if
need more failed checks for that */
}
}
- if (newState != upStatus) {
+ if (newState != upStatus.load()) {
/* we are actually moving to a new state */
if (!IsAnyAddress(d_config.remote)) {
infolog("Marking downstream %s as '%s'", getNameWithAddr(), newState ? "up" : "down");
});
luaCtx.registerFunction<std::string (DownstreamState::*)() const>("getName", [](const DownstreamState& state) -> const std::string& { return state.getName(); });
luaCtx.registerFunction<std::string (DownstreamState::*)() const>("getNameWithAddr", [](const DownstreamState& state) -> const std::string& { return state.getNameWithAddr(); });
- luaCtx.registerMember("upStatus", &DownstreamState::upStatus);
+ luaCtx.registerMember<bool(DownstreamState::*)>(
+ "upStatus",
+ [](const DownstreamState& state) -> bool { return state.upStatus.load(std::memory_order_relaxed); },
+ [](DownstreamState& state, bool newStatus) { state.upStatus.store(newStatus); });
luaCtx.registerMember<int(DownstreamState::*)>(
"weight",
[](const DownstreamState& state) -> int { return state.d_config.d_weight; },
status = "DOWN";
}
else {
- status = (backend->upStatus ? "up" : "down");
+ status = (backend->upStatus.load(std::memory_order_relaxed) ? "up" : "down");
}
Json::array pools;
uint16_t currentCheckFailures{0};
std::atomic<bool> hashesComputed{false};
std::atomic<bool> connected{false};
- bool upStatus{false};
+ std::atomic<bool> upStatus{false};
private:
void handleUDPTimeout(IDState& ids);
else if (d_config.availability == Availability::Up) {
return true;
}
- return upStatus;
+ return upStatus.load(std::memory_order_relaxed);
}
void setUp()
void setUpStatus(bool newStatus)
{
- upStatus = newStatus;
- if (!upStatus) {
+ upStatus.store(newStatus);
+ if (!newStatus) {
latencyUsec = 0.0;
latencyUsecTCP = 0.0;
}
status = "DOWN";
}
else {
- status = (upStatus ? "up" : "down");
+ status = (upStatus.load(std::memory_order_relaxed) ? "up" : "down");
}
return status;
}