diff --git a/go.mod b/go.mod index 68932c9..2f446c9 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/prometheus/client_golang v1.2.1 // indirect github.com/sirupsen/logrus v1.4.2 github.com/spf13/cobra v0.0.5 // indirect - github.com/spiral/broadcast v0.0.0-20191205145228-118503a8d0e1 + github.com/spiral/broadcast v0.0.0-20191206140608-766959683e74 github.com/spiral/roadrunner v1.5.2 github.com/stretchr/testify v1.3.0 ) diff --git a/service.go b/service.go index e2994d9..74d38b1 100644 --- a/service.go +++ b/service.go @@ -47,6 +47,7 @@ func (s *Service) Init( s.cfg = cfg s.client = broadcast.NewClient() s.connPool = newPool(s.client, s.reportError) + s.stopped = 0 if err := rpc.Register(ID, &rpcService{svc: s}); err != nil { return false, err @@ -81,7 +82,7 @@ func (s *Service) Stop() { s.mu.Lock() defer s.mu.Unlock() - if !atomic.CompareAndSwapInt32(&s.stopped, 0, 1) { + if atomic.CompareAndSwapInt32(&s.stopped, 0, 1) { close(s.stop) } }