Skip to content

Commit

Permalink
fix: never call response body Close()
Browse files Browse the repository at this point in the history
  • Loading branch information
Suzuki Kyosuke committed Jun 22, 2018
1 parent f9f24b0 commit 09f61c6
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 09f61c6

Please sign in to comment.