Skip to content

Commit

Permalink
Do not set deadline on connection with deadline already set
Browse files Browse the repository at this point in the history
closes #841
  • Loading branch information
sparrc committed Mar 22, 2016
1 parent 69606a4 commit 5ae7530
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- [#898](https://github.com/influxdata/telegraf/issues/898): Put database name in quotes, fixes special characters in the database name.
- [#656](https://github.com/influxdata/telegraf/issues/656): No longer run `lsof` on linux to get netstat data, fixes permissions issue.
- [#907](https://github.com/influxdata/telegraf/issues/907): Fix prometheus invalid label/measurement name key.
- [#841](https://github.com/influxdata/telegraf/issues/841): Fix memcached unix socket panic.

## v0.11.1 [2016-03-17]

Expand Down
9 changes: 7 additions & 2 deletions plugins/inputs/memcached/memcached.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ func (m *Memcached) gatherServer(
acc telegraf.Accumulator,
) error {
var conn net.Conn
var err error
if unix {
conn, err := net.DialTimeout("unix", address, defaultTimeout)
conn, err = net.DialTimeout("unix", address, defaultTimeout)
if err != nil {
return err
}
defer conn.Close()
} else {
_, _, err := net.SplitHostPort(address)
_, _, err = net.SplitHostPort(address)
if err != nil {
address = address + ":11211"
}
Expand All @@ -113,6 +114,10 @@ func (m *Memcached) gatherServer(
defer conn.Close()
}

if conn == nil {
return fmt.Errorf("Failed to create net connection")
}

// Extend connection
conn.SetDeadline(time.Now().Add(defaultTimeout))

Expand Down

0 comments on commit 5ae7530

Please sign in to comment.