mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
* reset deadline, fix #1562. reset deadline before we put it back to pool. * make errcheck happy
This commit is contained in:
parent
304661c547
commit
42e07cfaea
1 changed files with 7 additions and 0 deletions
|
@ -3,6 +3,7 @@ package netutil
|
|||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/handshake"
|
||||
)
|
||||
|
@ -70,6 +71,12 @@ func (cp *ConnPool) Get() (*handshake.BufferedConn, error) {
|
|||
//
|
||||
// Do not put broken and closed connections to the pool!
|
||||
func (cp *ConnPool) Put(bc *handshake.BufferedConn) {
|
||||
if err := bc.SetDeadline(time.Time{}); err != nil {
|
||||
// Close the connection instead of returning it to the pool,
|
||||
// since it may be broken.
|
||||
_ = bc.Close()
|
||||
return
|
||||
}
|
||||
cp.mu.Lock()
|
||||
cp.conns = append(cp.conns, bc)
|
||||
cp.mu.Unlock()
|
||||
|
|
Loading…
Reference in a new issue