Commit dda97d1
committed
create_share_fn: unique_lock(try_to_lock) — fix race + freeze risk
Two bugs in the same call site, fixed together:
1. tracker_shared_lock() was a BLOCKING acquire. Same freeze class as
the SHAREREQ paths fixed in 2f9d3e1 — when the compute thread
held the exclusive write lock for a long think+clean cycle, this
would block the io_context until the watchdog fired.
2. create_local_share() called below mutates the tracker via
tracker.add() (sharechain.hpp:267 — writes m_shares, m_reverse,
heads/tails). ShareChain::add is NOT internally synchronised.
Holding only a shared_lock here was a real data race against the
compute thread's writes (drop-tails, prune, attempt_verify).
Fix: unique_lock with try_to_lock. On busy, log+return (drop the
share creation request). The miner will submit again; dropping one
request is strictly better than 30 s freeze + SIGABRT + losing all
state.
The blocking helper tracker_shared_lock() is now caller-less. Left
in place with its existing anti-pattern warning so the next session
can decide whether to remove it outright.1 parent 2f9d3e1 commit dda97d1
1 file changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4598 | 4598 | | |
4599 | 4599 | | |
4600 | 4600 | | |
4601 | | - | |
| 4601 | + | |
| 4602 | + | |
| 4603 | + | |
| 4604 | + | |
| 4605 | + | |
| 4606 | + | |
| 4607 | + | |
| 4608 | + | |
| 4609 | + | |
| 4610 | + | |
| 4611 | + | |
| 4612 | + | |
| 4613 | + | |
| 4614 | + | |
| 4615 | + | |
| 4616 | + | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
| 4624 | + | |
| 4625 | + | |
| 4626 | + | |
| 4627 | + | |
4602 | 4628 | | |
4603 | 4629 | | |
4604 | 4630 | | |
| |||
0 commit comments