Updates #15 Prevent a potential file handle leak in sending update notifications via POST to mtwebmapper.

This commit is contained in:
Sascha L. Teichmann 2016-01-24 14:31:15 +01:00
parent 5730da652b
commit 4522708ddf

View File

@ -64,8 +64,13 @@ func (ct *ChangeTracker) FlushChanges(url string) {
log.Printf("WARN: encode changes to JSON failed: %s\n", err)
return
}
if _, err = http.Post(
url, "application/json", bytes.NewBuffer(buf.Bytes())); err != nil {
var resp *http.Response
resp, err = http.Post(
url, "application/json", bytes.NewBuffer(buf.Bytes()))
if resp != nil {
defer resp.Body.Close()
}
if err != nil {
log.Printf("WARN: posting changes to %s failed: %s\n", url, err)
}
}()