mirror of
https://github.com/xtaci/smux.git
synced 2024-04-21 10:51:48 +00:00
fix a potential logic race
This commit is contained in:
+8
-3
@@ -113,9 +113,14 @@ func (s *Session) OpenStream() (*Stream, error) {
|
||||
}
|
||||
|
||||
s.streamLock.Lock()
|
||||
s.streams[sid] = stream
|
||||
s.streamLock.Unlock()
|
||||
return stream, nil
|
||||
defer s.streamLock.Unlock()
|
||||
select {
|
||||
case <-s.die:
|
||||
return nil, errors.New(errBrokenPipe)
|
||||
default:
|
||||
s.streams[sid] = stream
|
||||
return stream, nil
|
||||
}
|
||||
}
|
||||
|
||||
// AcceptStream is used to block until the next available stream
|
||||
|
||||
Reference in New Issue
Block a user