Skip to content

Commit

Permalink
Remove goroutine from sending alert function
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Luis Lucas authored and iknite committed Dec 18, 2018
1 parent b50864f commit 6e4f989
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions gossip/auditor/auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func (t *MembershipTask) getSnapshot(version uint64) (*protocol.SignedSnapshot,
return nil, fmt.Errorf("Error getting snapshot from the store. Status: %d", resp.StatusCode)
}
buf, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Infof("Error reading request body: %v", err)
}
var s protocol.SignedSnapshot
err = s.Decode(buf)
if err != nil {
Expand Down Expand Up @@ -125,18 +128,15 @@ func (t *MembershipTask) Do() {
}

func (t *MembershipTask) sendAlert(msg string) {

go func() {
resp, err := http.Post(fmt.Sprintf("%s/alert", t.pubUrl), "application/json", bytes.NewBufferString(msg))
if err != nil {
log.Infof("Error saving batch in alertStore: %v", err)
}
defer resp.Body.Close()
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
log.Infof("Error getting response from alertStore saving a batch: %v", err)
}
}()
resp, err := http.Post(fmt.Sprintf("%s/alert", t.pubUrl), "application/json", bytes.NewBufferString(msg))
if err != nil {
log.Infof("Error saving batch in alertStore: %v", err)
}
defer resp.Body.Close()
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
log.Infof("Error reading request body: %v", err)
}
}

func (a Auditor) Process(b *protocol.BatchSnapshots) {
Expand Down

0 comments on commit 6e4f989

Please sign in to comment.