1
0
Fork 0

fix some locking issues

This commit is contained in:
jsteemann 2016-10-21 12:57:59 +02:00
parent 75ecf79277
commit 8e58b8dfac
3 changed files with 16 additions and 7 deletions

View File

@ -299,12 +299,13 @@ void Agent::sendAppendEntriesRPC() {
term_t t(0);
index_t last_confirmed;
{
MUTEX_LOCKER(mutexLocker, _ioLock);
t = this->term();
last_confirmed = _confirmed[followerId];
}
index_t last_confirmed = _confirmed[followerId];
std::vector<log_t> unconfirmed = _state.get(last_confirmed);
if (unconfirmed.empty()) {

View File

@ -77,6 +77,9 @@ config_t::config_t(config_t&& other)
_supervisionGracePeriod(std::move(other._supervisionGracePeriod)) {}
config_t& config_t::operator=(config_t const& other) {
// must hold the lock of other to copy _pool, _minPing, _maxPing etc.
READ_LOCKER(readLocker, other._lock);
_id = other._id;
_agencySize = other._agencySize;
_poolSize = other._poolSize;

View File

@ -178,7 +178,10 @@ std::vector<bool> Store::apply(query_t const& query, bool verbose) {
}
// Wake up TTL processing
_cv.signal();
{
CONDITION_LOCKER(guard, _cv);
_cv.signal();
}
} catch (std::exception const& e) { // Catch any erorrs
LOG_TOPIC(ERR, Logger::AGENCY) << __FILE__ << ":" << __LINE__ << " "
@ -503,7 +506,6 @@ bool Store::start() {
/// Work ttls and callbacks
void Store::run() {
CONDITION_LOCKER(guard, _cv);
while (!this->isStopping()) { // Check timetable and remove overage entries
std::chrono::microseconds t{0};
@ -517,10 +519,13 @@ void Store::run() {
}
}
if (t != std::chrono::microseconds{0}) {
_cv.wait(t.count());
} else {
_cv.wait();
{
CONDITION_LOCKER(guard, _cv);
if (t != std::chrono::microseconds{0}) {
_cv.wait(t.count());
} else {
_cv.wait();
}
}
toClear = clearExpired();