Skip to content

Commit

Permalink
transport: fixed Test_ReuseConnTransport may fail
Browse files Browse the repository at this point in the history
  • Loading branch information
IrineSistiana committed Nov 1, 2023
1 parent 0e4d6e2 commit 4f149c2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/upstream/transport/reuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,17 @@ func (c *reusableConn) readLoop() {
return
}

// This connection is idled again.
c.c.SetReadDeadline(time.Now().Add(c.t.idleTimeout))
// Note: calling setIdle before sending resp back to make sure this connection is idle
// before Exchange call returning. Otherwise, Test_ReuseConnTransport may fail.
c.t.setIdle(c)

select {
case respChan <- resp:
default:
panic("bug: respChan has buffer, we shouldn't reach here")
}

// this connection is idled again
c.c.SetReadDeadline(time.Now().Add(c.t.idleTimeout))
c.t.setIdle(c)

}
}

Expand Down

0 comments on commit 4f149c2

Please sign in to comment.