Skip to content

Commit eedcf95

Browse files
committed
Align Write timeout handling with Read timeout handling
In #31, the Read path was changed to move away from time.After. This change was not reflected in the Write path, and this commit rectifies that.
1 parent 877b999 commit eedcf95

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

stream.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,22 @@ START:
220220

221221
WAIT:
222222
var timeout <-chan time.Time
223+
var timer *time.Timer
223224
writeDeadline := s.writeDeadline.Load().(time.Time)
224225
if !writeDeadline.IsZero() {
225226
delay := time.Until(writeDeadline)
226-
timeout = time.After(delay)
227+
timer = time.NewTimer(delay)
228+
timeout = timer.C
227229
}
228230
select {
229231
case <-s.session.shutdownCh:
230232
case <-s.sendNotifyCh:
231233
case <-timeout:
232234
return 0, ErrTimeout
233235
}
236+
if timer != nil {
237+
timer.Stop()
238+
}
234239
goto START
235240
}
236241

0 commit comments

Comments
 (0)