mirror of https://github.com/v2ray/v2ray-core
rework multibuf copy
parent
9ee9af9e02
commit
a3fd81dfff
|
@ -392,7 +392,11 @@ func (c *Connection) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
mbPtr := &mb
|
f := func(x *buf.MultiBuffer) buf.Supplier {
|
||||||
|
return func(bb []byte) (int, error) {
|
||||||
|
return x.Read(bb[:c.mss])
|
||||||
|
}
|
||||||
|
}(&mb)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
for {
|
for {
|
||||||
|
@ -400,13 +404,11 @@ func (c *Connection) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
||||||
return io.ErrClosedPipe
|
return io.ErrClosedPipe
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.sendingWorker.Push(func(bb []byte) (int, error) {
|
if !c.sendingWorker.Push(f) {
|
||||||
return mbPtr.Read(bb[:c.mss])
|
|
||||||
}) {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
updatePending = true
|
updatePending = true
|
||||||
if mbPtr.IsEmpty() {
|
if mb.IsEmpty() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue