Skip to content

Commit

Permalink
close the socket when the connection is disconnected.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtm committed Dec 12, 2021
1 parent 95160b3 commit 68c0710
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/mysql/protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ def read
raise EOFError unless ret && ret.length == len
data.concat ret
rescue EOFError
@socket.close rescue nil
raise ClientError::ServerGoneError, 'MySQL server has gone away'
rescue Errno::ETIMEDOUT
raise ClientError, "read timeout"
Expand Down Expand Up @@ -524,6 +525,7 @@ def write(data)
@socket.sync = true
@socket.flush
rescue Errno::EPIPE
@socket.close rescue nil
raise ClientError::ServerGoneError, 'MySQL server has gone away'
rescue Errno::ETIMEDOUT
raise ClientError, "write timeout"
Expand Down

0 comments on commit 68c0710

Please sign in to comment.