mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-11 14:15: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
|
int mPathFindThread {0}; // Pathfinder jobs dispatched
|
||||||
bool mPathFindNewRequest {false};
|
bool mPathFindNewRequest {false};
|
||||||
|
|
||||||
|
std::atomic_flag mGotFetchPackThread = ATOMIC_FLAG_INIT; // GotFetchPack jobs dispatched
|
||||||
|
|
||||||
std::atomic <std::uint32_t> mPubLedgerClose {0};
|
std::atomic <std::uint32_t> mPubLedgerClose {0};
|
||||||
std::atomic <LedgerIndex> mPubLedgerSeq {0};
|
std::atomic <LedgerIndex> mPubLedgerSeq {0};
|
||||||
std::atomic <std::uint32_t> mValidLedgerSign {0};
|
std::atomic <std::uint32_t> mValidLedgerSign {0};
|
||||||
|
|||||||
@@ -1790,13 +1790,16 @@ LedgerMaster::gotFetchPack (
|
|||||||
bool progress,
|
bool progress,
|
||||||
std::uint32_t seq)
|
std::uint32_t seq)
|
||||||
{
|
{
|
||||||
// FIXME: Calling this function more than once will result in
|
if (!mGotFetchPackThread.test_and_set(std::memory_order_acquire))
|
||||||
// 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",
|
||||||
app_.getJobQueue().addJob (
|
[&] (Job&)
|
||||||
jtLEDGER_DATA, "gotFetchPack",
|
{
|
||||||
[&] (Job&) { app_.getInboundLedgers().gotFetchPack(); });
|
app_.getInboundLedgers().gotFetchPack();
|
||||||
|
mGotFetchPackThread.clear(std::memory_order_release);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user