Skip to content

Commit

Permalink
Fix possible file descriptor leak
Browse files Browse the repository at this point in the history
  • Loading branch information
sreis committed Aug 31, 2015
1 parent 59d8c3f commit 387b9d2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions keepalive.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ func SetKeepAlive(c net.Conn, idleTime time.Duration, count int, interval time.D
}

var f *os.File

if f, err = conn.File(); err != nil {
return err
}
defer f.Close()

fd := int(f.Fd())

Expand All @@ -100,8 +102,6 @@ func SetKeepAlive(c net.Conn, idleTime time.Duration, count int, interval time.D
return err
}

f.Close()

return nil
}

Expand Down

0 comments on commit 387b9d2

Please sign in to comment.