File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -143,14 +143,17 @@ WAIT:
143143 timeout = timer .C
144144 }
145145 select {
146+ case <- s .session .shutdownCh :
146147 case <- s .recvNotifyCh :
147- if timer != nil {
148- timer .Stop ()
149- }
150- goto START
151148 case <- timeout :
152149 return 0 , ErrTimeout
153150 }
151+ if timer != nil {
152+ if ! timer .Stop () {
153+ <- timeout
154+ }
155+ }
156+ goto START
154157}
155158
156159// Write is used to write to the stream
@@ -219,17 +222,25 @@ START:
219222
220223WAIT:
221224 var timeout <- chan time.Time
225+ var timer * time.Timer
222226 writeDeadline := s .writeDeadline .Load ().(time.Time )
223227 if ! writeDeadline .IsZero () {
224228 delay := time .Until (writeDeadline )
225- timeout = time .After (delay )
229+ timer = time .NewTimer (delay )
230+ timeout = timer .C
226231 }
227232 select {
233+ case <- s .session .shutdownCh :
228234 case <- s .sendNotifyCh :
229- goto START
230235 case <- timeout :
231236 return 0 , ErrTimeout
232237 }
238+ if timer != nil {
239+ if ! timer .Stop () {
240+ <- timeout
241+ }
242+ }
243+ goto START
233244}
234245
235246// sendFlags determines any flags that are appropriate
You can’t perform that action at this time.
0 commit comments