Skip to content

Commit

Permalink
Revert "make sure streamLock is non-blocking due to receiveBytes"
Browse files Browse the repository at this point in the history
This reverts commit 20e41dd.
  • Loading branch information
xtaci committed Apr 17, 2019
1 parent 20e41dd commit 5eb9306
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,20 @@ func (s *Session) recvLoop() {
}
s.streamLock.Unlock()
case cmdPSH:
var written int64
var err error
s.streamLock.Lock()
stream := s.streams[sid]
s.streamLock.Unlock()

if stream != nil {
written, err := stream.receiveBytes(s.conn, int64(hdr.Length()))
if stream, ok := s.streams[sid]; ok {
written, err = stream.receiveBytes(s.conn, int64(hdr.Length()))
atomic.AddInt32(&s.bucket, -int32(written))
stream.notifyReadEvent()
if err != nil {
s.Close()
return
}
}
s.streamLock.Unlock()

// read data error
if err != nil {
s.Close()
return
}
default:
s.Close()
Expand Down

0 comments on commit 5eb9306

Please sign in to comment.