Skip to content

Commit 87022cb

Browse files
committed
Fix review issues
1 parent 4599a70 commit 87022cb

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

src/etl/ETLService.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,18 +380,16 @@ ETLService::startMonitor(uint32_t seq)
380380
auto const backendRange = backend_->fetchLedgerRange();
381381
auto const backendNeedsUpdate = backendRange.has_value() and backendRange->maxSequence < seq;
382382

383-
if (cacheNeedsUpdate or backendNeedsUpdate) {
383+
if (cacheNeedsUpdate) {
384384
auto const diff = data::synchronousAndRetryOnTimeout([this, seq](auto yield) {
385385
return backend_->fetchLedgerDiff(seq, yield);
386386
});
387-
388-
if (cacheNeedsUpdate)
389-
cacheUpdater_->update(seq, diff);
390-
391-
if (backendNeedsUpdate)
392-
backend_->updateRange(seq);
387+
cacheUpdater_->update(seq, diff);
393388
}
394389

390+
if (backendNeedsUpdate)
391+
backend_->updateRange(seq);
392+
395393
publisher_->publish(seq, {});
396394
});
397395

src/util/Channel.hpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,15 @@ class Channel {
151151
* @brief Constructs a Sender from a shared control block.
152152
* @param shared The shared control block managing the channel state
153153
*/
154-
Sender(std::shared_ptr<ControlBlock> shared) : shared_(shared)
154+
Sender(std::shared_ptr<ControlBlock> shared)
155+
: shared_(shared), guard_([shared = std::move(shared)]() {
156+
if constexpr (kIS_MULTI_PRODUCER) {
157+
return std::make_shared<Guard>(std::move(shared));
158+
} else {
159+
return Guard{std::move(shared)};
160+
}
161+
}())
155162
{
156-
if constexpr (kIS_MULTI_PRODUCER) {
157-
guard_ = std::make_shared<Guard>(shared);
158-
} else {
159-
guard_ = Guard{std::move(shared)};
160-
}
161163
}
162164

163165
public:
@@ -269,13 +271,15 @@ class Channel {
269271
* @brief Constructs a Receiver from a shared control block.
270272
* @param shared The shared control block managing the channel state
271273
*/
272-
Receiver(std::shared_ptr<ControlBlock> shared) : shared_(shared)
274+
Receiver(std::shared_ptr<ControlBlock> shared)
275+
: shared_(shared), guard_([shared = std::move(shared)]() {
276+
if constexpr (kIS_MULTI_CONSUMER) {
277+
return std::make_shared<Guard>(std::move(shared));
278+
} else {
279+
return Guard{std::move(shared)};
280+
}
281+
}())
273282
{
274-
if constexpr (kIS_MULTI_CONSUMER) {
275-
guard_ = std::make_shared<Guard>(shared);
276-
} else {
277-
guard_ = Guard{std::move(shared)};
278-
}
279283
}
280284

281285
public:

tests/unit/etl/ETLServiceTests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,7 @@ TEST_F(ETLServiceTests, StopWaitsForWriteCommandHandlersToComplete)
757757
// Stop should wait for the handler to complete and disconnect the subscription
758758
service_.stop();
759759

760-
// Verify stop() returned, meaning all handlers completed
761-
SUCCEED();
760+
// The test will hang on stop() or in service_ destructor if there is a problem.
762761
}
763762

764763
TEST_F(ETLServiceTests, WriteConflictIsHandledImmediately_NotDelayed)

0 commit comments

Comments
 (0)