return a net.Error when opening streams

net.Error.Temporary() will be true if no stream can be opened when the
peer's stream limit is reached.
This commit is contained in:
Marten Seemann 2019-01-06 17:18:43 +07:00
parent 8ac77be934
commit a2e48e204b
7 changed files with 85 additions and 37 deletions

View file

@ -49,7 +49,11 @@ func (m *outgoingUniStreamsMap) OpenStream() (sendStreamI, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
return m.openStreamImpl()
str, err := m.openStreamImpl()
if err != nil {
return nil, streamOpenErr{err}
}
return str, nil
}
func (m *outgoingUniStreamsMap) OpenStreamSync() (sendStreamI, error) {
@ -59,10 +63,10 @@ func (m *outgoingUniStreamsMap) OpenStreamSync() (sendStreamI, error) {
for {
str, err := m.openStreamImpl()
if err == nil {
return str, err
return str, nil
}
if err != nil && err != qerr.TooManyOpenStreams {
return nil, err
if err != nil && err != errTooManyOpenStreams {
return nil, streamOpenErr{err}
}
m.cond.Wait()
}
@ -87,7 +91,7 @@ func (m *outgoingUniStreamsMap) openStreamImpl() (sendStreamI, error) {
}
m.blockedSent = true
}
return nil, qerr.TooManyOpenStreams
return nil, errTooManyOpenStreams
}
s := m.newStream(m.nextStream)
m.streams[m.nextStream] = s