mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-04 18:55:49 +00:00
Avoid dispatching multiple fetch pack threads
This commit is contained in:
@@ -337,6 +337,8 @@ private:
|
||||
int mPathFindThread {0}; // Pathfinder jobs dispatched
|
||||
bool mPathFindNewRequest {false};
|
||||
|
||||
std::atomic_flag mGotFetchPackThread = ATOMIC_FLAG_INIT; // GotFetchPack jobs dispatched
|
||||
|
||||
std::atomic <std::uint32_t> mPubLedgerClose {0};
|
||||
std::atomic <LedgerIndex> mPubLedgerSeq {0};
|
||||
std::atomic <std::uint32_t> mValidLedgerSign {0};
|
||||
|
||||
@@ -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