erigon-pulse/miner
lzhfromustc 4ef76f9a58 miner, test: fix potential goroutine leak (#21989)
In miner/worker.go, there are two goroutine using channel w.newWorkCh: newWorkerLoop() sends to this channel, and mainLoop() receives from this channel. Only the receive operation is in a select.

However, w.exitCh may be closed by another goroutine. This is fine for the receive since receive is in select, but if the send operation is blocking, then it will block forever. This commit puts the send in a select, so it won't block even if w.exitCh is closed.

Similarly, there are two goroutines using channel errc: the parent that runs the test receives from it, and the child created at line 573 sends to it. If the parent goroutine exits too early by calling t.Fatalf() at line 614, then the child goroutine will be blocked at line 574 forever. This commit adds 1 buffer to errc. Now send will not block, and receive is not influenced because receive still needs to wait for the send.
# Conflicts:
#	miner/worker.go
2021-03-08 14:30:49 +01:00
..
stresstest geth-1.9.23: post-rebase fixups 2020-10-26 17:16:00 +01:00
environment.go Mining data races (#361) 2020-02-10 21:28:30 +07:00
miner_test.go Revert "Extract validating interface (#1120)" (#1543) 2021-03-05 20:34:23 +00:00
miner.go Revert "Extract validating interface (#1120)" (#1543) 2021-03-05 20:34:23 +00:00
uncles.go Refactor mining. Remove a few mining goroutines (#338) 2020-02-03 15:02:26 +03:00
worker_test.go Revert "Extract validating interface (#1120)" (#1543) 2021-03-05 20:34:23 +00:00
worker.go miner, test: fix potential goroutine leak (#21989) 2021-03-08 14:30:49 +01:00