Skip to content

Commit

Permalink
Do not set write deadline to prevent partial data write
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <[email protected]>
  • Loading branch information
yilunzhang committed Aug 5, 2020
1 parent 19fa2b4 commit 539cb8c
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 539cb8c

Please sign in to comment.