Skip to content
This repository has been archived by the owner on Nov 13, 2018. It is now read-only.

close old connections explicitly to prevent tcp conn leak #1995

Merged
merged 1 commit into from
Oct 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions traffic_stats/traffic_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ func loadStartupConfig(configFile string, oldConfig StartupConfig) (StartupConfi
config.InfluxDBs = append(config.InfluxDBs, &influxDBProps)
}

//Close old connections explicitly
for _, host := range oldConfig.InfluxDBs {
if host.InfluxClient != nil {
host.InfluxClient.Close()
}
}

return config, nil
}

Expand Down Expand Up @@ -741,6 +748,11 @@ func influxConnect(config StartupConfig) (influx.Client, error) {
errHndlr(fmt.Errorf("An error occurred creating HTTP client. %v\n", err), ERROR)
continue
}
//Close old connections explicitly
if host.InfluxClient != nil {
host.InfluxClient.Close()
}
host.InfluxClient = con
_, _, err = con.Ping(10)
if err != nil {
errHndlr(err, WARN)
Expand Down