Increase TCP buffer size, fix truncation bug; it should truncate before
trying to read
This commit is contained in:
parent
af7627a15a
commit
0934e2df8d
|
@ -168,19 +168,20 @@ func InitTcpServer(db *sql.DB, state *ShroomState) {
|
|||
}()
|
||||
|
||||
// deal with the read side of the connection
|
||||
buf := make([]byte, 128)
|
||||
buf := make([]byte, 1024)
|
||||
left := buf
|
||||
|
||||
for {
|
||||
if len(left) == 0 {
|
||||
log.Println("overflow detected, truncating data")
|
||||
left = buf
|
||||
}
|
||||
|
||||
num_read, err := conn.Read(left)
|
||||
//log.Println("received: ", string(left[:num_read]))
|
||||
left = left[num_read:]
|
||||
//log.Println("buf ", buf)
|
||||
//log.Println("left ", left)
|
||||
if len(left) == 0 {
|
||||
log.Println("overflow detected, truncating data")
|
||||
left = buf
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Println("tcp read error: ", err)
|
||||
|
|
Loading…
Reference in New Issue