Skip to content

Commit bd2c73e

Browse files
committed
Switched from using SetDeadline to SetRead/WriteDeadline
1 parent b1a2248 commit bd2c73e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

connection.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ func (c *Connection) sendQuery(q Query) error {
143143

144144
// Set timeout
145145
if c.opts.Timeout == 0 {
146-
c.conn.SetDeadline(time.Time{})
146+
c.conn.SetWriteDeadline(time.Time{})
147147
} else {
148-
c.conn.SetDeadline(time.Now().Add(c.opts.Timeout))
148+
c.conn.SetWriteDeadline(time.Now().Add(c.opts.Timeout))
149149
}
150150

151151
// Send the JSON encoding of the query itself.
@@ -165,6 +165,13 @@ func (c *Connection) nextToken() int64 {
165165
}
166166

167167
func (c *Connection) readResponse() (*Response, error) {
168+
// Set timeout
169+
if c.opts.Timeout == 0 {
170+
c.conn.SetReadDeadline(time.Time{})
171+
} else {
172+
c.conn.SetReadDeadline(time.Now().Add(c.opts.Timeout))
173+
}
174+
168175
// Read response header (token+length)
169176
_, err := io.ReadFull(c.conn, c.headerBuf[:respHeaderLen])
170177
if err != nil {

0 commit comments

Comments
 (0)