mirror of
https://github.com/xtaci/smux.git
synced 2026-10-21 11:25:03 +00:00
fix nil pointer exception
This commit is contained in:
+6
-3
@@ -348,9 +348,12 @@ func (s *Session) RemoteAddr() net.Addr {
|
||||
// notify the session that a stream has closed
|
||||
func (s *Session) streamClosed(sid uint32) {
|
||||
s.streamLock.Lock()
|
||||
if n := s.streams[sid].recycleTokens(); n > 0 { // return remaining tokens to the bucket
|
||||
if atomic.AddInt32(&s.bucket, int32(n)) > 0 {
|
||||
s.notifyBucket()
|
||||
if stream, ok := s.streams[sid]; ok {
|
||||
n := stream.recycleTokens()
|
||||
if n > 0 { // return remaining tokens to the bucket
|
||||
if atomic.AddInt32(&s.bucket, int32(n)) > 0 {
|
||||
s.notifyBucket()
|
||||
}
|
||||
}
|
||||
}
|
||||
delete(s.streams, sid)
|
||||
|
||||
Reference in New Issue
Block a user