Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,14 @@ func Connect(connStr string, logLevel LogLevel) (conn *Conn, err error) {
tcpConn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", params.Host, params.Port))
panicIfErr(err)

panicIfErr(tcpConn.SetDeadline(time.Unix(int64(params.TimeoutSeconds*1000*1000*1000), 0)))
// Handling the timeout using SetDeadline and an absolute date
// 0 if no timeout
noDeadline := time.Time{}
if params.TimeoutSeconds <= 0 {
panicIfErr(tcpConn.SetDeadline(noDeadline))
} else {
panicIfErr(tcpConn.SetDeadline(time.Now().Add(time.Duration(params.TimeoutSeconds)*time.Second)))
}

newConn.tcpConn = tcpConn

Expand Down