This commit is contained in:
parent
18d3b23658
commit
1e0bda09f4
@ -1,6 +1,7 @@
|
|||||||
package tcp
|
package tcp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -208,10 +209,12 @@ func (f *Flow) consumeMarshalled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Flow) produceMarshalled() {
|
func (f *Flow) produceMarshalled() {
|
||||||
|
buf := bufio.NewReader(f.conn)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
lengthBytes := make([]byte, 4)
|
lengthBytes := make([]byte, 4)
|
||||||
if n, err := io.LimitReader(f.conn, 4).Read(lengthBytes); err != nil {
|
if n, err := io.LimitReader(buf, 4).Read(lengthBytes); err != nil {
|
||||||
f.produceErrors <- err
|
f.produceErrors <- err
|
||||||
return
|
return
|
||||||
} else if n != 4 {
|
} else if n != 4 {
|
||||||
@ -224,7 +227,7 @@ func (f *Flow) produceMarshalled() {
|
|||||||
|
|
||||||
var read uint32
|
var read uint32
|
||||||
for read < length {
|
for read < length {
|
||||||
if n, err := io.LimitReader(f.conn, int64(length-read)).Read(dataBytes[read:]); err != nil {
|
if n, err := io.LimitReader(buf, int64(length-read)).Read(dataBytes[read:]); err != nil {
|
||||||
f.produceErrors <- err
|
f.produceErrors <- err
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user