File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -139,10 +139,14 @@ func (c *channel) Write(p []byte) (int, error) {
139139 return written , io .EOF
140140 }
141141 if c .write .size () > 0 {
142+ // Some window space is available
142143 toWrite := c .write .size ()
143144 if toWrite > len (p ) {
144145 toWrite = len (p )
145146 }
147+ // Advance the window before dropping the lock in case another Write() appears and sees the same available space
148+ c .write .current = c .write .current + uint64 (toWrite )
149+
146150 // Don't block holding the metadata mutex.
147151 // Note this would allow concurrent calls to Write on the same channel
148152 // to conflict, but we regard that as user error.
@@ -167,7 +171,6 @@ func (c *channel) Write(p []byte) (int, error) {
167171 if err3 != nil {
168172 return written , err3
169173 }
170- c .write .current = c .write .current + uint64 (toWrite )
171174 p = p [toWrite :]
172175 written = written + toWrite
173176 continue
You can’t perform that action at this time.
0 commit comments