1
0
Fork 0

fix race in _batchPingTimer shutdown (#8801)

This commit is contained in:
Jan 2019-04-26 18:31:24 +02:00 committed by GitHub
parent d3a152bfad
commit c054cddfe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -54,13 +54,19 @@ void InitialSyncer::startRecurringBatchExtension() {
if (secs < 30) { if (secs < 30) {
secs = 30; secs = 30;
} }
std::weak_ptr<Syncer> self(shared_from_this());
_batchPingTimer = SchedulerFeature::SCHEDULER->queueDelay( _batchPingTimer = SchedulerFeature::SCHEDULER->queueDelay(
RequestLane::SERVER_REPLICATION, std::chrono::seconds(secs), [this](bool cancelled) { RequestLane::SERVER_REPLICATION, std::chrono::seconds(secs), [self](bool cancelled) {
if (!cancelled && _batch.id != 0 && !isAborted()) { if (!cancelled) {
_batch.extend(_state.connection, _progress); auto syncer = self.lock();
startRecurringBatchExtension(); if (syncer) {
} else { InitialSyncer* s = static_cast<InitialSyncer*>(syncer.get());
_batchPingTimer.reset(); if (s->_batch.id != 0 && !s->isAborted()) {
s->_batch.extend(s->_state.connection, s->_progress);
s->startRecurringBatchExtension();
}
}
} }
}); });
} }

View File

@ -94,6 +94,7 @@ class InitialSyncer : public Syncer {
protected: protected:
replutils::BatchInfo _batch; replutils::BatchInfo _batch;
replutils::ProgressInfo _progress; replutils::ProgressInfo _progress;
/// recurring task to keep the batch alive /// recurring task to keep the batch alive
Scheduler::WorkHandle _batchPingTimer; Scheduler::WorkHandle _batchPingTimer;
}; };