don't enqueue send stream for sending on duplicate Close calls (#4815)

This commit is contained in:
Marten Seemann
2024-12-28 16:43:16 +08:00
committed by GitHub
parent 810ef27db5
commit 72a934f375
2 changed files with 1 additions and 3 deletions

View File

@@ -398,7 +398,7 @@ func (s *sendStream) isNewlyCompleted() bool {
func (s *sendStream) Close() error {
s.mutex.Lock()
if s.closeForShutdownErr != nil {
if s.closeForShutdownErr != nil || s.finishedWriting {
s.mutex.Unlock()
return nil
}

View File

@@ -431,8 +431,6 @@ func TestSendStreamClose(t *testing.T) {
require.False(t, hasMore)
// further calls to Close don't do anything
// TODO(#4800): there shouldn't be any calls to mockSender
mockSender.EXPECT().onHasStreamData(streamID, str)
require.NoError(t, str.Close())
_, ok, hasMore = str.popStreamFrame(protocol.MaxByteCount, protocol.Version1)
require.False(t, ok)