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

max buffers in one read

This commit is contained in:
Darien Raymond 2018-11-30 14:48:44 +01:00
parent afba7a45c9
commit 7244dc928e
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -143,7 +143,8 @@ func (c *interConn) Read(b []byte) (int, error) {
} }
func (c *interConn) ReadMultiBuffer() (buf.MultiBuffer, error) { func (c *interConn) ReadMultiBuffer() (buf.MultiBuffer, error) {
mb := make(buf.MultiBuffer, 0, 8) const BufferCount = 16
mb := make(buf.MultiBuffer, 0, BufferCount)
{ {
b := buf.New() b := buf.New()
if _, err := b.ReadFrom(c.stream); err != nil { if _, err := b.ReadFrom(c.stream); err != nil {
@ -153,7 +154,7 @@ func (c *interConn) ReadMultiBuffer() (buf.MultiBuffer, error) {
mb = append(mb, b) mb = append(mb, b)
} }
for c.stream.HasMoreData() { for len(mb) < BufferCount && c.stream.HasMoreData() {
b := buf.New() b := buf.New()
if _, err := b.ReadFrom(c.stream); err != nil { if _, err := b.ReadFrom(c.stream); err != nil {
b.Release() b.Release()