cfg.DefaultStorage = mmapStorage
cl, err := NewClient(cfg)
c.Assert(err, qt.IsNil)
- defer logErr(cl.Close, "closing client")
+ defer cl.Close()
tor, new, err := cl.AddTorrentSpec(TorrentSpecFromMetaInfo(mi))
c.Assert(err, qt.IsNil)
c.Assert(new, qt.IsTrue)
}
// Stops the client. All connections to peers are closed and all activity will come to a halt.
-func (cl *Client) Close() error {
+func (cl *Client) Close() (errs []error) {
var closeGroup sync.WaitGroup // For concurrent cleanup to complete before returning
cl.lock()
- var errs []error
for _, t := range cl.torrents {
err := t.close(&closeGroup)
if err != nil {
cl.unlock()
cl.event.Broadcast()
closeGroup.Wait() // defer is LIFO. We want to Wait() after cl.unlock()
- return errors.Join(errs...)
+ return
}
func (cl *Client) ipBlockRange(ip net.IP) (r iplist.Range, blocked bool) {