Handles the timeout error in case it happened, by canceling the stream write.
(err error)
| 54 | |
| 55 | // Handles the timeout error in case it happened, by canceling the stream write. |
| 56 | func (s *SafeStreamCloser) handleWriteError(err error) { |
| 57 | // If we are closing the stream we just ignore any write error. |
| 58 | if s.closing.Load() { |
| 59 | return |
| 60 | } |
| 61 | var netErr net.Error |
| 62 | if errors.As(err, &netErr) { |
| 63 | if netErr.Timeout() { |
| 64 | // We don't need to log if what cause the timeout was no network activity. |
| 65 | if !errors.Is(netErr, &idleTimeoutError) { |
| 66 | s.log.Error().Err(netErr).Msg("Closing quic stream due to timeout while writing") |
| 67 | } |
| 68 | // We need to explicitly cancel the write so that it frees all buffers. |
| 69 | s.stream.CancelWrite(0) |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | func (s *SafeStreamCloser) Close() error { |
| 75 | // Set this stream to a closing state. |