diff --git a/stream.go b/stream.go index 4bf326797..ecfc5de8d 100644 --- a/stream.go +++ b/stream.go @@ -138,7 +138,7 @@ func (s *stream) Write(p []byte) (int, error) { s.doneWritingOrErrCond.Wait() } - s.mutex.Unlock() + defer s.mutex.Unlock() if s.err != nil { return 0, s.err }