Skip to content

Commit

Permalink
Set conn deadline to both reads and writes (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika authored Oct 9, 2023
1 parent 56816e6 commit b89a463
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ type IdleTimeoutConn struct {

// Read is needed to implement the reader part.
func (i IdleTimeoutConn) Read(buf []byte) (int, error) {
err := i.Conn.SetReadDeadline(time.Now().Add(viper.GetDuration("idle-connection-timeout")))
err := i.Conn.SetDeadline(time.Now().Add(viper.GetDuration("idle-connection-timeout")))
if err != nil {
return 0, err
}
Expand All @@ -194,7 +194,7 @@ func (i IdleTimeoutConn) Read(buf []byte) (int, error) {

// Write is needed to implement the writer part.
func (i IdleTimeoutConn) Write(buf []byte) (int, error) {
err := i.Conn.SetWriteDeadline(time.Now().Add(viper.GetDuration("idle-connection-timeout")))
err := i.Conn.SetDeadline(time.Now().Add(viper.GetDuration("idle-connection-timeout")))
if err != nil {
return 0, err
}
Expand Down

0 comments on commit b89a463

Please sign in to comment.