anacrolix / dht

dht is used by anacrolix/torrent, and is intended for use as a library in other projects both torrent related and otherwise
Mozilla Public License 2.0
309 stars 66 forks source link

stop traversal to plug a resource leak when returning an error #45

Closed stapelberg closed 3 years ago

stapelberg commented 3 years ago

When the torrent CLI program is started without network connectivity, it busy-loops with error message:

torrent.go:1700: "distri-qemu-serial.img.zst": error announcing \""distri-qemu-serial.img.zst\"" to DHT: getting starting nodes: nothing resolved

Before this commit, this busy-loop combined with the resource leak would quickly consume all available memory on the machine, making Linux invoke the OOM killer (in the best case) or run out of memory and just hang (in my case).

This commit plugs the resource leak, meaning the torrent CLI can now print errors all day long without consuming all the machine’s memory.

anacrolix commented 3 years ago

Thank you!