fixed tcp collector

This commit is contained in:
Timo Volkmann 2021-01-15 14:51:51 +01:00
parent 0fbc6e2758
commit b0e18cb212

View File

@ -1,7 +1,6 @@
package core
import (
"bufio"
"fmt"
"git.timovolkmann.de/gyrogpsc/ublox"
"github.com/sirupsen/logrus"
@ -212,18 +211,18 @@ func (t *tcpCollector) connectionHandler(conn net.Conn) {
conn.Close()
}()
sc := bufio.NewScanner(conn)
buf := make([]byte, 2048)
skipped := 0
//loop:
for sc.Scan() {
for {
// Read the incoming connection into the buffer.
res := append([]byte{}, sc.Bytes()...)
if err2 := sc.Err(); err2 != nil {
logrus.Warn("lost tcp link:", err2)
n, err := conn.Read(buf)
if err != nil {
fmt.Println("TCP error - reading from connection:", n, err.Error())
break
}
select {
case t.out <- res:
case t.out <- buf:
skipped = 0
default:
logrus.Traceln("skip collecting tcp messages")