This fixes race errors caused by incorrect usage of sync.WaitGroup. sync.WaitGroup has a restriction when first used on an empty value: calls to Add() and Wait() must be synchronized, such that the initial Wait() is not called concurrently to any other Add(). However, the background template generator breaks this premise by allowing invocations of both Wait() and Add() from different goroutines. For example, Wait() can be called from an rpcserver handler method while an Add() is called from an internal goroutine. This causes a potential race condition. This can be verified by installing dcrd with `-race`, then running the TestTreasury test of the internal/rpcserver package. We fix this issue by switching to a local implementation of the wait group that retains the same semantics as the one from the stdlib but lifts the aforementioned restriction. This is accomplished by using a global lock on the wait group instead of the semaphore-based implementation currently used in the stdlib. |
||
|---|---|---|
| .. | ||
| cpuminer | ||
| bgblktmplgenerator_test.go | ||
| bgblktmplgenerator.go | ||
| doc.go | ||
| error.go | ||
| interface.go | ||
| log.go | ||
| mining_view.go | ||
| mining.go | ||
| policy_test.go | ||
| policy.go | ||
| README.md | ||
| tx_desc_graph.go | ||
| txpriorityqueue_test.go | ||
| txpriorityqueue.go | ||