This commit is contained in:
esrrhs 2019-10-27 12:52:02 +08:00
parent d0897dd522
commit 37005c8ae8
2 changed files with 4 additions and 16 deletions

View File

@ -223,7 +223,6 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
for {
now := time.Now()
sleep := true
left := common.MinOfInt(clientConn.fm.GetSendBufferLeft(), len(bytes))
if left > 0 {
@ -238,9 +237,10 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
}
}
if n > 0 {
sleep = false
clientConn.fm.WriteSendBuffer(bytes[:n])
tcpActiveRecvTime = now
} else {
time.Sleep(time.Millisecond * 10)
}
}
@ -248,7 +248,6 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
sendlist := clientConn.fm.getSendList()
if sendlist.Len() > 0 {
sleep = false
clientConn.activeSendTime = now
for e := sendlist.Front(); e != nil; e = e.Next() {
f := e.Value.(*Frame)
@ -268,7 +267,6 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
}
if clientConn.fm.GetRecvBufferSize() > 0 {
sleep = false
rr := clientConn.fm.GetRecvReadLineBuffer()
conn.SetWriteDeadline(time.Now().Add(time.Millisecond * 1))
n, err := conn.Write(rr)
@ -286,10 +284,6 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
}
}
if sleep {
time.Sleep(time.Millisecond * 1)
}
diffrecv := now.Sub(clientConn.activeRecvTime)
diffsend := now.Sub(clientConn.activeSendTime)
tcpdiffrecv := now.Sub(tcpActiveRecvTime)

View File

@ -189,7 +189,6 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
for {
now := time.Now()
sleep := true
left := common.MinOfInt(conn.fm.GetSendBufferLeft(), len(bytes))
if left > 0 {
@ -204,9 +203,10 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
}
}
if n > 0 {
sleep = false
conn.fm.WriteSendBuffer(bytes[:n])
tcpActiveRecvTime = now
} else {
time.Sleep(time.Millisecond * 10)
}
}
@ -214,7 +214,6 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
sendlist := conn.fm.getSendList()
if sendlist.Len() > 0 {
sleep = false
conn.activeSendTime = now
for e := sendlist.Front(); e != nil; e = e.Next() {
f := e.Value.(*Frame)
@ -233,7 +232,6 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
}
if conn.fm.GetRecvBufferSize() > 0 {
sleep = false
rr := conn.fm.GetRecvReadLineBuffer()
conn.tcpconn.SetWriteDeadline(time.Now().Add(time.Millisecond * 1))
n, err := conn.tcpconn.Write(rr)
@ -251,10 +249,6 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
}
}
if sleep {
time.Sleep(time.Millisecond * 1)
}
diffrecv := now.Sub(conn.activeRecvTime)
diffsend := now.Sub(conn.activeSendTime)
tcpdiffrecv := now.Sub(tcpActiveRecvTime)