mirror of
https://github.com/coalaura/whiskr.git
synced 2025-12-02 20:22:52 +00:00
prevent stream corruption
This commit is contained in:
@@ -32,6 +32,7 @@ type Chunk struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Stream struct {
|
type Stream struct {
|
||||||
|
mx sync.Mutex
|
||||||
wr http.ResponseWriter
|
wr http.ResponseWriter
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
@@ -81,6 +82,9 @@ func GetErrorMessage(err error) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stream) WriteChunk(chunk *Chunk) error {
|
func (s *Stream) WriteChunk(chunk *Chunk) error {
|
||||||
|
s.mx.Lock()
|
||||||
|
defer s.mx.Unlock()
|
||||||
|
|
||||||
debugIf(chunk.Type == ChunkError, "error: %v", chunk.Data)
|
debugIf(chunk.Type == ChunkError, "error: %v", chunk.Data)
|
||||||
|
|
||||||
if err := s.ctx.Err(); err != nil {
|
if err := s.ctx.Err(); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user