fix early garbage collection of streams

ref #83
This commit is contained in:
Lucas Clemente
2016-07-08 13:56:30 +02:00
parent 5cc88f60dc
commit f8130288a3
3 changed files with 12 additions and 6 deletions

View File

@@ -202,6 +202,7 @@ func (s *stream) getDataForWriting(maxBytes protocol.ByteCount) []byte {
// Close implements io.Closer
func (s *stream) Close() error {
atomic.StoreInt32(&s.closed, 1)
s.session.scheduleSending()
return nil
}
@@ -286,8 +287,9 @@ func (s *stream) finishedReading() bool {
}
func (s *stream) finishedWriting() bool {
// TODO: sentFIN
return atomic.LoadInt32(&s.closed) != 0
s.mutex.Lock()
defer s.mutex.Unlock()
return s.err != nil || (atomic.LoadInt32(&s.closed) != 0 && s.finSent)
}
func (s *stream) finished() bool {