Skip to content

Commit

Permalink
Merge pull request #4 from dozen/fix/close-response-body
Browse files Browse the repository at this point in the history
fix: never call response body Close()
  • Loading branch information
fujiwara authored Jun 22, 2018
2 parents f9f24b0 + 09f61c6 commit e6a204c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ func watchForTrigger(command string) {
continue
}
index = newIndex
defer resp.Body.Close()
var kvps []*KVPair
dec := json.NewDecoder(resp.Body)
dec.Decode(&kvps)
resp.Body.Close()

// find each current item of category
currentItem := make(map[string]Item)
Expand Down Expand Up @@ -350,13 +350,13 @@ func updateNodes() {
continue
}
index = newIndex
defer resp.Body.Close()
dec := json.NewDecoder(resp.Body)
mutex.Lock()
dec.Decode(&Nodes)
log.Println("[info]", Nodes)
mutex.Unlock()
time.Sleep(1 * time.Second)
resp.Body.Close()
}
}

Expand All @@ -372,12 +372,12 @@ func updateServices() {
continue
}
index = newIndex
defer resp.Body.Close()
dec := json.NewDecoder(resp.Body)
mutex.Lock()
dec.Decode(&Services)
mutex.Unlock()
time.Sleep(1 * time.Second)
resp.Body.Close()
}
}

Expand Down

0 comments on commit e6a204c

Please sign in to comment.