Skip to content

Commit

Permalink
transport: fixed zero lastReadTime
Browse files Browse the repository at this point in the history
  • Loading branch information
IrineSistiana committed Jul 16, 2022
1 parent 5fe570c commit 0a421e5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/upstream/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,13 @@ func (t *Transport) getPipelineConn() (conn *dnsConn, isNewConn bool, allocatedQ
// connTooOld returns true if c's last read time is close to
// its idle deadline.
func (t *Transport) connTooOld(c *dnsConn) bool {
if ddl := t.idleTimeout() - connTooOldThreshold; ddl > 0 {
return c.getLastReadTime().Add(ddl).Before(time.Now())
lrt := c.getLastReadTime()
if lrt.IsZero() {
return false
}
if tooOldTimeout := t.idleTimeout() - connTooOldThreshold; tooOldTimeout > 0 {
tooOldDdl := lrt.Add(tooOldTimeout)
return time.Now().After(tooOldDdl)
}
return false
}
Expand Down

0 comments on commit 0a421e5

Please sign in to comment.