Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

Commit

Permalink
fix race
Browse files Browse the repository at this point in the history
  • Loading branch information
melekes committed Apr 17, 2017
1 parent 32cef17 commit b489774
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions addrbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ func (a *AddrBook) OnStart() error {
return nil
}

func (a *AddrBook) Wait() {
a.wg.Wait()
}

// OnStop implements Service.
func (a *AddrBook) OnStop() {
a.BaseService.OnStop()
}

func (a *AddrBook) Wait() {
a.wg.Wait()
}

func (a *AddrBook) AddOurAddress(addr *NetAddress) {
a.mtx.Lock()
defer a.mtx.Unlock()
Expand Down Expand Up @@ -320,6 +320,8 @@ type addrBookJSON struct {
func (a *AddrBook) saveToFile(filePath string) {
log.Info("Saving AddrBook to file", "size", a.Size())

a.mtx.Lock()
defer a.mtx.Unlock()
// Compile Addrs
addrs := []*knownAddress{}
for _, ka := range a.addrLookup {
Expand Down

0 comments on commit b489774

Please sign in to comment.