forked from quic-go/quic-go
don't schedule sending when stream.Write is called after the deadline
This commit is contained in:
@@ -81,6 +81,9 @@ func (s *sendStream) Write(p []byte) (int, error) {
|
|||||||
if s.closeForShutdownErr != nil {
|
if s.closeForShutdownErr != nil {
|
||||||
return 0, s.closeForShutdownErr
|
return 0, s.closeForShutdownErr
|
||||||
}
|
}
|
||||||
|
if !s.writeDeadline.IsZero() && !time.Now().Before(s.writeDeadline) {
|
||||||
|
return 0, errDeadline
|
||||||
|
}
|
||||||
if len(p) == 0 {
|
if len(p) == 0 {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ var _ = Describe("Send Stream", func() {
|
|||||||
n, err := strWithTimeout.Write([]byte("foobar"))
|
n, err := strWithTimeout.Write([]byte("foobar"))
|
||||||
Expect(err).To(MatchError(errDeadline))
|
Expect(err).To(MatchError(errDeadline))
|
||||||
Expect(n).To(BeZero())
|
Expect(n).To(BeZero())
|
||||||
|
Expect(onDataCalled).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("unblocks after the deadline", func() {
|
It("unblocks after the deadline", func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user