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
22
pool.go
22
pool.go
|
|
@ -17,25 +17,23 @@ import (
|
||||||
"github.com/mmatczuk/go-http-tunnel/id"
|
"github.com/mmatczuk/go-http-tunnel/id"
|
||||||
)
|
)
|
||||||
|
|
||||||
type onDisconnectListener func(identifier id.ID)
|
|
||||||
|
|
||||||
type connPair struct {
|
type connPair struct {
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
clientConn *http2.ClientConn
|
clientConn *http2.ClientConn
|
||||||
}
|
}
|
||||||
|
|
||||||
type connPool struct {
|
type connPool struct {
|
||||||
t *http2.Transport
|
t *http2.Transport
|
||||||
conns map[string]connPair // key is host:port
|
conns map[string]connPair // key is host:port
|
||||||
listener onDisconnectListener
|
free func(identifier id.ID)
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConnPool(t *http2.Transport, l onDisconnectListener) *connPool {
|
func newConnPool(t *http2.Transport, f func(identifier id.ID)) *connPool {
|
||||||
return &connPool{
|
return &connPool{
|
||||||
t: t,
|
t: t,
|
||||||
listener: l,
|
free: f,
|
||||||
conns: make(map[string]connPair),
|
conns: make(map[string]connPair),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,8 +126,8 @@ func (p *connPool) ping(cp connPair) error {
|
||||||
func (p *connPool) close(cp connPair, addr string) {
|
func (p *connPool) close(cp connPair, addr string) {
|
||||||
cp.conn.Close()
|
cp.conn.Close()
|
||||||
delete(p.conns, addr)
|
delete(p.conns, addr)
|
||||||
if p.listener != nil {
|
if p.free != nil {
|
||||||
p.listener(p.identifier(addr))
|
p.free(p.identifier(addr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue