1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

temp fix deadlock in quic lib

This commit is contained in:
Darien Raymond 2018-11-29 17:17:07 +01:00
parent 3b1aaa9a3d
commit fd060a0880
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 9 additions and 5 deletions

View File

@ -104,8 +104,8 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
ConnectionIDLength: 12,
HandshakeTimeout: time.Second * 8,
IdleTimeout: time.Second * 30,
MaxIncomingStreams: 32,
MaxIncomingUniStreams: -1,
MaxIncomingStreams: 128,
MaxIncomingUniStreams: 32,
}
conn, err := wrapSysConn(rawConn, config)

View File

@ -97,7 +97,7 @@ func (s *sendStream) Write(p []byte) (int, error) {
s.dataForWriting = make([]byte, len(p))
copy(s.dataForWriting, p)
s.sender.onHasStreamData(s.streamID)
go s.sender.onHasStreamData(s.streamID)
var bytesWritten int
var err error
@ -222,7 +222,7 @@ func (s *sendStream) Close() error {
return fmt.Errorf("Close called for canceled stream %d", s.streamID)
}
s.finishedWriting = true
s.sender.onHasStreamData(s.streamID) // need to send the FIN
go s.sender.onHasStreamData(s.streamID) // need to send the FIN
s.ctxCancel()
return nil
}
@ -268,10 +268,14 @@ func (s *sendStream) handleStopSendingFrame(frame *wire.StopSendingFrame) {
func (s *sendStream) handleMaxStreamDataFrame(frame *wire.MaxStreamDataFrame) {
s.flowController.UpdateSendWindow(frame.ByteOffset)
s.mutex.Lock()
hasData := false
if s.dataForWriting != nil {
s.sender.onHasStreamData(s.streamID)
hasData = true
}
s.mutex.Unlock()
if hasData {
s.sender.onHasStreamData(s.streamID)
}
}
// must be called after locking the mutex