We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 921cc71 commit 0136857Copy full SHA for 0136857
p2p/transport/tcp/metrics.go
@@ -208,7 +208,9 @@ type tracingConn struct {
208
isClient bool
209
210
manet.Conn
211
- tcpConn *tcp.Conn
+ tcpConn *tcp.Conn
212
+ closeOnce sync.Once
213
+ closeErr error
214
}
215
216
func newTracingConn(c manet.Conn, isClient bool) (*tracingConn, error) {
@@ -236,8 +238,11 @@ func (c *tracingConn) getDirection() string {
236
238
237
239
240
func (c *tracingConn) Close() error {
- collector.ClosedConn(c, c.getDirection())
- return c.Conn.Close()
241
+ c.closeOnce.Do(func() {
242
+ collector.ClosedConn(c, c.getDirection())
243
+ c.closeErr = c.Conn.Close()
244
+ })
245
+ return c.closeErr
246
247
248
func (c *tracingConn) getTCPInfo() (*tcpinfo.Info, error) {
0 commit comments