p2p/discover: track active topic searches so they stop on shutdown#91
p2p/discover: track active topic searches so they stop on shutdown#91srene wants to merge 1 commit into
Conversation
topicSystem tracked registrations but not searches, so searches created via newSearchIterator kept their goroutines running past UDPv5.Close. Track live searches in the system and stop them in stop(); make topicSearch.stop idempotent so the iterator Close and shutdown paths can both call it safely.
|
Closing for now — deprioritized, not rejected. The only consumer of TopicSearch is the devp2p discAPI RPC (cmd/devp2p/discv5cmd.go), which already closes the iterator (defer it.Close() plus a searchTimeout goroutine); topic search is not wired into p2p.Server's dialer. So searches don't leak in normal operation. The real exposure is only the window where UDPv5.Close races an in-flight search RPC, and even then the leak is bounded by the consumer's searchTimeout, not permanent. The fix itself is correct — track searches in topicSystem, stop them from sys.stop(), with stopOnce + removeSearch for idempotent shutdown. Given the bounded exposure it's just not worth carrying right now. Keeping #28 open to track making Close self-contained (and as a prerequisite for the iterator/Close refactor). |
Closes #28