mirror of
https://github.com/sot-tech/mochi.git
synced 2026-04-28 08:29:59 -07:00
Return []error from Stop() channel, allow recursive stop groups
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/chihaya/chihaya/bittorrent"
|
||||
"github.com/chihaya/chihaya/pkg/log"
|
||||
"github.com/chihaya/chihaya/pkg/stop"
|
||||
"github.com/chihaya/chihaya/pkg/timecache"
|
||||
"github.com/chihaya/chihaya/storage"
|
||||
)
|
||||
@@ -707,8 +708,8 @@ func (ps *peerStore) collectGarbage(cutoff time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps *peerStore) Stop() <-chan error {
|
||||
c := make(chan error)
|
||||
func (ps *peerStore) Stop() stop.Result {
|
||||
c := make(stop.Channel)
|
||||
go func() {
|
||||
close(ps.closed)
|
||||
ps.wg.Wait()
|
||||
@@ -720,10 +721,10 @@ func (ps *peerStore) Stop() <-chan error {
|
||||
}
|
||||
ps.shards = shards
|
||||
|
||||
close(c)
|
||||
c.Done()
|
||||
}()
|
||||
|
||||
return c
|
||||
return c.Result()
|
||||
}
|
||||
|
||||
func (ps *peerStore) LogFields() log.Fields {
|
||||
|
||||
Reference in New Issue
Block a user