We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 23ffe45 commit 7f1225bCopy full SHA for 7f1225b
transport/gun/transport_close.go
@@ -0,0 +1,35 @@
1
+package gun
2
+
3
+import (
4
+ "sync"
5
+ "unsafe"
6
7
+ "golang.org/x/net/http2"
8
+)
9
10
+type clientConnPool struct {
11
+ t *http2.Transport
12
+ mu sync.Mutex
13
+ conns map[string][]*http2.ClientConn // key is host:port
14
+}
15
16
+type efaceWords struct {
17
+ typ unsafe.Pointer
18
+ data unsafe.Pointer
19
20
21
+func (tw *TransportWrap) Close() error {
22
+ connPool := transportConnPool(tw.Transport)
23
+ p := (*clientConnPool)((*efaceWords)(unsafe.Pointer(&connPool)).data)
24
+ p.mu.Lock()
25
+ defer p.mu.Unlock()
26
+ for _, vv := range p.conns {
27
+ for _, cc := range vv {
28
+ cc.Close()
29
+ }
30
31
+ return nil
32
33
34
+//go:linkname transportConnPool golang.org/x/net/http2.(*Transport).connPool
35
+func transportConnPool(t *http2.Transport) http2.ClientConnPool
0 commit comments