@@ -50,10 +50,8 @@ func NetConn(ctx context.Context, c *Conn, msgType MessageType) net.Conn {
50
50
writeMu :newMu (c ),
51
51
}
52
52
53
- var writeCancel context.CancelFunc
54
- nc .writeCtx ,writeCancel = context .WithCancel (ctx )
55
- var readCancel context.CancelFunc
56
- nc .readCtx ,readCancel = context .WithCancel (ctx )
53
+ nc .writeCtx ,nc .writeCancel = context .WithCancel (ctx )
54
+ nc .readCtx ,nc .readCancel = context .WithCancel (ctx )
57
55
58
56
nc .writeTimer = time .AfterFunc (math .MaxInt64 ,func () {
59
57
if ! nc .writeMu .tryLock () {
@@ -98,11 +96,13 @@ type netConn struct {
98
96
writeMu * mu
99
97
writeExpired int64
100
98
writeCtx context.Context
99
+ writeCancel context.CancelFunc
101
100
102
101
readTimer * time.Timer
103
102
readMu * mu
104
103
readExpired int64
105
104
readCtx context.Context
105
+ readCancel context.CancelFunc
106
106
readEOFed bool
107
107
reader io.Reader
108
108
}
@@ -111,7 +111,9 @@ var _ net.Conn = &netConn{}
111
111
112
112
func (nc * netConn )Close ()error {
113
113
nc .writeTimer .Stop ()
114
+ nc .writeCancel ()
114
115
nc .readTimer .Stop ()
116
+ nc .readCancel ()
115
117
return nc .c .Close (StatusNormalClosure ,"" )
116
118
}
117
119