From 88567d5b2e761d987345d0db4eaf3f81af975638 Mon Sep 17 00:00:00 2001 From: Leo Balduf Date: Sun, 7 Aug 2016 17:20:31 -0400 Subject: [PATCH] remove backend Start/Stop funcs --- backend/backend.go | 19 ------------------- cmd/trakr/main.go | 19 +++++++------------ 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/backend/backend.go b/backend/backend.go index 0bc4425..bea1d6c 100644 --- a/backend/backend.go +++ b/backend/backend.go @@ -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 } diff --git a/cmd/trakr/main.go b/cmd/trakr/main.go index 1478023..5f0590b 100644 --- a/cmd/trakr/main.go +++ b/cmd/trakr/main.go @@ -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