mirror of
https://github.com/mmatczuk/go-http-tunnel.git
synced 2026-05-15 06:06:03 -06:00
pool: rename connPool.listener to free
This commit is contained in:
parent
e7b3a5a6be
commit
1b22420dac
1 changed files with 10 additions and 12 deletions
12
pool.go
12
pool.go
|
|
@ -17,8 +17,6 @@ import (
|
|||
"github.com/mmatczuk/go-http-tunnel/id"
|
||||
)
|
||||
|
||||
type onDisconnectListener func(identifier id.ID)
|
||||
|
||||
type connPair struct {
|
||||
conn net.Conn
|
||||
clientConn *http2.ClientConn
|
||||
|
|
@ -27,14 +25,14 @@ type connPair struct {
|
|||
type connPool struct {
|
||||
t *http2.Transport
|
||||
conns map[string]connPair // key is host:port
|
||||
listener onDisconnectListener
|
||||
free func(identifier id.ID)
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func newConnPool(t *http2.Transport, l onDisconnectListener) *connPool {
|
||||
func newConnPool(t *http2.Transport, f func(identifier id.ID)) *connPool {
|
||||
return &connPool{
|
||||
t: t,
|
||||
listener: l,
|
||||
free: f,
|
||||
conns: make(map[string]connPair),
|
||||
}
|
||||
}
|
||||
|
|
@ -128,8 +126,8 @@ func (p *connPool) ping(cp connPair) error {
|
|||
func (p *connPool) close(cp connPair, addr string) {
|
||||
cp.conn.Close()
|
||||
delete(p.conns, addr)
|
||||
if p.listener != nil {
|
||||
p.listener(p.identifier(addr))
|
||||
if p.free != nil {
|
||||
p.free(p.identifier(addr))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue