This commit is contained in:
esrrhs 2019-10-25 21:48:10 +08:00
parent b88c2320f3
commit b0c7bc5949
2 changed files with 8 additions and 6 deletions

View File

@ -182,7 +182,7 @@ func (p *Client) AcceptTcp() error {
loggo.Info("client waiting local accept tcp") loggo.Info("client waiting local accept tcp")
for { for {
p.tcplistenConn.SetDeadline(time.Now().Add(time.Millisecond * 100)) p.tcplistenConn.SetDeadline(time.Now().Add(time.Millisecond * 1000))
conn, err := p.tcplistenConn.AcceptTCP() conn, err := p.tcplistenConn.AcceptTCP()
if err != nil { if err != nil {
@ -193,7 +193,9 @@ func (p *Client) AcceptTcp() error {
} }
} }
go p.AcceptTcpConn(conn) if conn != nil {
go p.AcceptTcpConn(conn)
}
} }
} }
@ -240,8 +242,8 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
for e := sendlist.Front(); e != nil; e = e.Next() { for e := sendlist.Front(); e != nil; e = e.Next() {
f := e.Value.(Frame) f := e.Value.(*Frame)
mb, err := proto.Marshal(&f) mb, err := proto.Marshal(f)
if err != nil { if err != nil {
loggo.Error("Error tcp Marshal %s %s %s", uuid, tcpsrcaddr.String(), err) loggo.Error("Error tcp Marshal %s %s %s", uuid, tcpsrcaddr.String(), err)
continue continue

View File

@ -208,8 +208,8 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
for e := sendlist.Front(); e != nil; e = e.Next() { for e := sendlist.Front(); e != nil; e = e.Next() {
f := e.Value.(Frame) f := e.Value.(*Frame)
mb, err := proto.Marshal(&f) mb, err := proto.Marshal(f)
if err != nil { if err != nil {
loggo.Error("Error tcp Marshal %s %s %s", conn.id, conn.tcpaddrTarget.String(), err) loggo.Error("Error tcp Marshal %s %s %s", conn.id, conn.tcpaddrTarget.String(), err)
continue continue