Skip to content

Commit b89a463

Browse files
authored
Set conn deadline to both reads and writes (#281)
1 parent 56816e6 commit b89a463

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

utils/conn.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ type IdleTimeoutConn struct {
184184

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

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

0 commit comments

Comments
 (0)