diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 17:10:41 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 17:10:41 +0000 |
| commit | 738d5b411bab4e13e176a11f8ae6e6f70337381e (patch) | |
| tree | 0a3c9fabb998eead8068aeaecced61d3343e7f32 /src | |
| parent | e7b6bbffb1786eef842f1e446118a4daa9edf58f (diff) | |
worker: let a stop request interrupt the reconnect backoff
The retry sleep polled only fShutdown, while the loop around it polls
fShutdown, fGenerateBitcoins and nMineMode. That was survivable at a flat
10s. Raising the ceiling to 120s made it expensive: after an operator
cleared Generate or switched to Relay mode, the participant session --
and the vfThreadRunning[3] slot that gates restarting it -- stayed held
for up to two minutes.
Measured with the loop shape replicated and the stop condition flipped 1s
into a 120s sleep: 119.01s to notice before, 1.00s after, via either
fGenerateBitcoins or nMineMode. The fShutdown path is unchanged at 1.00s.
It also narrows the window on a pre-existing unsynchronised read of
vfThreadRunning[3] at gui.cpp:901, where a stop-then-start inside it
leaves mining silently not restarted.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 69b2c32..b0cdab2 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
| @@ -4418,7 +4418,16 @@ bool BitcoinMiner(int nThreadId) | |||
| 4418 | } | 4418 | } |
| 4419 | LogPrint("worker", "PoolParticipantMiner: reconnecting in %ds\n", | 4419 | LogPrint("worker", "PoolParticipantMiner: reconnecting in %ds\n", |
| 4420 | nRetrySecs); | 4420 | nRetrySecs); |
| 4421 | for (int i = 0; i < nRetrySecs && !fShutdown; i++) Sleep(1000); | 4421 | // Poll everything the enclosing while polls, not just |
| 4422 | // fShutdown. Raising the ceiling to 120s made a | ||
| 4423 | // shutdown-only predicate expensive: after the operator | ||
| 4424 | // clears Generate or switches to Relay, the session -- and | ||
| 4425 | // the vfThreadRunning[3] slot that gates restarting it -- | ||
| 4426 | // would stay held for up to two minutes. Measured 119s | ||
| 4427 | // before, 1s after. | ||
| 4428 | for (int i = 0; i < nRetrySecs && !fShutdown && fGenerateBitcoins | ||
| 4429 | && nMineMode == MINE_PARTICIPANT; i++) | ||
| 4430 | Sleep(1000); | ||
| 4422 | if (!fHadSession && nRetrySecs < 120) { | 4431 | if (!fHadSession && nRetrySecs < 120) { |
| 4423 | nRetrySecs *= 2; | 4432 | nRetrySecs *= 2; |
| 4424 | if (nRetrySecs > 120) | 4433 | if (nRetrySecs > 120) |