mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Avoid dispatching multiple fetch pack threads
This commit is contained in:
@@ -1790,13 +1790,16 @@ LedgerMaster::gotFetchPack (
|
||||
bool progress,
|
||||
std::uint32_t seq)
|
||||
{
|
||||
// FIXME: Calling this function more than once will result in
|
||||
// InboundLedgers::gotFetchPack being called more than once
|
||||
// which is expensive. A flag should track whether we've already dispatched
|
||||
|
||||
app_.getJobQueue().addJob (
|
||||
jtLEDGER_DATA, "gotFetchPack",
|
||||
[&] (Job&) { app_.getInboundLedgers().gotFetchPack(); });
|
||||
if (!mGotFetchPackThread.test_and_set(std::memory_order_acquire))
|
||||
{
|
||||
app_.getJobQueue().addJob (
|
||||
jtLEDGER_DATA, "gotFetchPack",
|
||||
[&] (Job&)
|
||||
{
|
||||
app_.getInboundLedgers().gotFetchPack();
|
||||
mGotFetchPackThread.clear(std::memory_order_release);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user