Skip to content

Commit

Permalink
fix err on conn close
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Aug 28, 2024
1 parent f56b1c3 commit e17eaa8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion const.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const (
// It's not an implementation choice, the value defined in the specification.
initialStreamWindow = 256 * 1024
maxStreamWindow = 16 * 1024 * 1024
goAwayWaitTime = 5 * time.Second
goAwayWaitTime = 50 * time.Millisecond
)

const (
Expand Down
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (s *Session) close(shutdownErr error, sendGoAway bool, errCode uint32) erro
s.streamLock.Lock()
defer s.streamLock.Unlock()
for id, stream := range s.streams {
stream.forceClose()
stream.forceClose(fmt.Errorf("%w: connection closed: %w", ErrStreamReset, s.shutdownErr))
delete(s.streams, id)
stream.memorySpan.Done()
}
Expand Down
5 changes: 3 additions & 2 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Stream struct {
state streamState
writeState, readState halfStreamState
stateLock sync.Mutex
resetErr *StreamError
resetErr error

recvBuf segmentedBuffer

Expand Down Expand Up @@ -365,7 +365,7 @@ func (s *Stream) Close() error {
}

// forceClose is used for when the session is exiting
func (s *Stream) forceClose() {
func (s *Stream) forceClose(err error) {
s.stateLock.Lock()
if s.readState == halfOpen {
s.readState = halfReset
Expand All @@ -374,6 +374,7 @@ func (s *Stream) forceClose() {
s.writeState = halfReset
}
s.state = streamFinished
s.resetErr = err
s.notifyWaiting()
s.stateLock.Unlock()

Expand Down

0 comments on commit e17eaa8

Please sign in to comment.