remove backend Start/Stop funcs

This commit is contained in:
Leo Balduf 2016-08-07 17:20:31 -04:00 committed by Jimmy Zelinskie
parent 98a7c42ab3
commit 88567d5b2e
2 changed files with 7 additions and 31 deletions

View file

@ -44,23 +44,4 @@ func New(config BackendConfig, peerStore PeerStore) (*Backend, error) {
type Backend struct {
TrackerFuncs frontends.TrackerFuncs
peerStore PeerStore
closing chan struct{}
}
// Stop provides a thread-safe way to shutdown a currently running
// Backend.
func (t *Backend) Stop() {
close(t.closing)
}
// Start starts the Backend.
// It blocks until t.Stop() is called or an error is returned.
func (t *Backend) Start() error {
t.closing = make(chan struct{})
select {
case <-t.closing:
return nil
}
return nil
}

View file

@ -103,12 +103,6 @@ func main() {
errChan := make(chan error)
closedChan := make(chan struct{})
go func() {
if err := trackerBackend.Start(); err != nil {
errChan <- errors.New("failed to cleanly shutdown: " + err.Error())
}
}()
var hFrontend *httpfrontend.Frontend
var uFrontend *udpfrontend.Frontend
@ -149,17 +143,18 @@ func main() {
hFrontend.Stop()
}
trackerBackend.Stop()
// TODO: stop PeerStore
close(errChan)
close(closedChan)
}()
err = <-errChan
if err != nil {
close(shutdown)
<-closedChan
return err
for err := range errChan {
if err != nil {
close(shutdown)
<-closedChan
return err
}
}
return nil