From 539cb8cebbdd9be8468e8a5c2b6e1e6aa6c05bfd Mon Sep 17 00:00:00 2001 From: Yilun Date: Wed, 5 Aug 2020 01:31:41 -0700 Subject: [PATCH] Do not set write deadline to prevent partial data write Signed-off-by: Yilun --- client.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/client.go b/client.go index fd5b9ca..9fc1aa1 100644 --- a/client.go +++ b/client.go @@ -597,25 +597,14 @@ func (c *TunaSessionClient) newSession(remoteAddr string, sessionID []byte, conn if conn == nil { return fmt.Errorf("conn %s is nil", connID) } - if writeTimeout > 0 { - err := conn.SetWriteDeadline(time.Now().Add(writeTimeout)) - if err != nil { - return ncp.ErrConnClosed - } - } buf, err := c.encode(buf, remoteAddr) if err != nil { return err } err = writeMessage(conn, buf) if err != nil { - return err - } - if writeTimeout > 0 { - err = conn.SetWriteDeadline(zeroTime) - if err != nil { - return ncp.ErrConnClosed - } + log.Println(err) + return ncp.ErrConnClosed } return nil }), config)