add
This commit is contained in:
parent
37005c8ae8
commit
b67d5d372d
10
client.go
10
client.go
@ -223,6 +223,7 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
|
||||
|
||||
for {
|
||||
now := time.Now()
|
||||
sleep := true
|
||||
|
||||
left := common.MinOfInt(clientConn.fm.GetSendBufferLeft(), len(bytes))
|
||||
if left > 0 {
|
||||
@ -237,10 +238,9 @@ 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,6 +248,7 @@ 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)
|
||||
@ -267,6 +268,7 @@ 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)
|
||||
@ -284,6 +286,10 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
|
||||
}
|
||||
}
|
||||
|
||||
if sleep {
|
||||
time.Sleep(time.Millisecond * 10)
|
||||
}
|
||||
|
||||
diffrecv := now.Sub(clientConn.activeRecvTime)
|
||||
diffsend := now.Sub(clientConn.activeSendTime)
|
||||
tcpdiffrecv := now.Sub(tcpActiveRecvTime)
|
||||
|
10
server.go
10
server.go
@ -189,6 +189,7 @@ 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 {
|
||||
@ -203,10 +204,9 @@ 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,6 +214,7 @@ 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)
|
||||
@ -232,6 +233,7 @@ 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)
|
||||
@ -249,6 +251,10 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
|
||||
}
|
||||
}
|
||||
|
||||
if sleep {
|
||||
time.Sleep(time.Millisecond * 10)
|
||||
}
|
||||
|
||||
diffrecv := now.Sub(conn.activeRecvTime)
|
||||
diffsend := now.Sub(conn.activeSendTime)
|
||||
tcpdiffrecv := now.Sub(tcpActiveRecvTime)
|
||||
|
Loading…
Reference in New Issue
Block a user