Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #16 from vania-pooh/master
Browse files Browse the repository at this point in the history
Completely replacing hosts on quota reload (fixes #15)
  • Loading branch information
aandryashin authored May 24, 2018
2 parents 3da8fa6 + 0da6b15 commit e3d7c60
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func configure() error {
if len(files) == 0 {
return fmt.Errorf("no quota XML files found in %s", quotaDir)
}
newHosts := make(map[string]string)
for _, fn := range files {
file, err := ioutil.ReadFile(fn)
if err != nil {
Expand All @@ -62,14 +63,15 @@ func configure() error {
for _, r := range v.Regions {
for _, h := range r.Hosts {
url := fmt.Sprintf("http://%s", net.JoinHostPort(h.Name, strconv.Itoa(h.Port)))
lock.Lock()
hosts[h.Sum()] = url
lock.Unlock()
newHosts[h.Sum()] = url
}
}
}
}
}
lock.Lock()
defer lock.Unlock()
hosts = newHosts
return nil
}

Expand Down

0 comments on commit e3d7c60

Please # to comment.