diff --git a/addrmanager.go b/addrmanager.go index 394fd914..8eb76400 100644 --- a/addrmanager.go +++ b/addrmanager.go @@ -103,8 +103,8 @@ func (a *AddrManager) Start() { log.Trace("[AMGR] Starting address manager") - go a.addressHandler() a.wg.Add(1) + go a.addressHandler() a.started = true } diff --git a/blockmanager.go b/blockmanager.go index b793698c..0bfba57c 100644 --- a/blockmanager.go +++ b/blockmanager.go @@ -350,10 +350,10 @@ func (b *blockManager) Start() { } log.Trace("[BMGR] Starting block manager") + b.wg.Add(3) go b.syncHandler() go b.blockHandler() go b.chainNotificationHandler() - b.wg.Add(3) b.started = true } diff --git a/rpcserver.go b/rpcserver.go index 201e47ab..d4552730 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -44,13 +44,13 @@ func (s *rpcServer) Start() { }) httpServer := &http.Server{} for _, listener := range s.listeners { + s.wg.Add(1) go func(listener net.Listener) { log.Infof("[RPCS] RPC server listening on %s", listener.Addr()) httpServer.Serve(listener) log.Tracef("[RPCS] RPC listener done for %s", listener.Addr()) s.wg.Done() }(listener) - s.wg.Add(1) } s.started = true } diff --git a/server.go b/server.go index 12cfbdad..389a5276 100644 --- a/server.go +++ b/server.go @@ -337,14 +337,14 @@ func (s *server) Start() { // Start all the listeners. There will not be any if listening is // disabled. for _, listener := range s.listeners { - go s.listenHandler(listener) s.wg.Add(1) + go s.listenHandler(listener) } // Start the peer handler which in turn starts the address and block // managers. - go s.peerHandler() s.wg.Add(1) + go s.peerHandler() // Start the RPC server if it's not disabled. if !cfg.DisableRpc {