This commit is contained in:
esrrhs 2019-10-27 12:19:16 +08:00
parent 2b37b02276
commit 63e557b566
2 changed files with 4 additions and 12 deletions

View File

@ -226,7 +226,7 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
left := common.MinOfInt(clientConn.fm.GetSendBufferLeft(), len(bytes))
if left > 0 {
conn.SetReadDeadline(time.Now().Add(time.Millisecond * 100))
conn.SetReadDeadline(time.Now().Add(time.Millisecond * 10))
n, err := conn.Read(bytes[0:left])
if err != nil {
nerr, ok := err.(net.Error)
@ -262,13 +262,11 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
p.sendPacket++
p.sendPacketSize += (uint64)(len(mb))
}
} else {
time.Sleep(time.Millisecond * 10)
}
if clientConn.fm.GetRecvBufferSize() > 0 {
rr := clientConn.fm.GetRecvReadLineBuffer()
conn.SetWriteDeadline(time.Now().Add(time.Millisecond * 100))
conn.SetWriteDeadline(time.Now().Add(time.Millisecond * 10))
n, err := conn.Write(rr)
if err != nil {
nerr, ok := err.(net.Error)
@ -282,8 +280,6 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
clientConn.fm.SkipRecvBuffer(n)
tcpActiveSendTime = now
}
} else {
time.Sleep(time.Millisecond * 10)
}
diffrecv := now.Sub(clientConn.activeRecvTime)

View File

@ -192,7 +192,7 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
left := common.MinOfInt(conn.fm.GetSendBufferLeft(), len(bytes))
if left > 0 {
conn.tcpconn.SetReadDeadline(time.Now().Add(time.Millisecond * 100))
conn.tcpconn.SetReadDeadline(time.Now().Add(time.Millisecond * 10))
n, err := conn.tcpconn.Read(bytes[0:left])
if err != nil {
nerr, ok := err.(net.Error)
@ -227,13 +227,11 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
p.sendPacket++
p.sendPacketSize += (uint64)(len(mb))
}
} else {
time.Sleep(time.Millisecond * 10)
}
if conn.fm.GetRecvBufferSize() > 0 {
rr := conn.fm.GetRecvReadLineBuffer()
conn.tcpconn.SetWriteDeadline(time.Now().Add(time.Millisecond * 100))
conn.tcpconn.SetWriteDeadline(time.Now().Add(time.Millisecond * 10))
n, err := conn.tcpconn.Write(rr)
if err != nil {
nerr, ok := err.(net.Error)
@ -247,8 +245,6 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
conn.fm.SkipRecvBuffer(n)
tcpActiveSendTime = now
}
} else {
time.Sleep(time.Millisecond * 10)
}
diffrecv := now.Sub(conn.activeRecvTime)