Skip to content

Commit 68c0710

Browse files
committed
close the socket when the connection is disconnected.
1 parent 95160b3 commit 68c0710

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/mysql/protocol.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ def read
460460
raise EOFError unless ret && ret.length == len
461461
data.concat ret
462462
rescue EOFError
463+
@socket.close rescue nil
463464
raise ClientError::ServerGoneError, 'MySQL server has gone away'
464465
rescue Errno::ETIMEDOUT
465466
raise ClientError, "read timeout"
@@ -524,6 +525,7 @@ def write(data)
524525
@socket.sync = true
525526
@socket.flush
526527
rescue Errno::EPIPE
528+
@socket.close rescue nil
527529
raise ClientError::ServerGoneError, 'MySQL server has gone away'
528530
rescue Errno::ETIMEDOUT
529531
raise ClientError, "write timeout"

0 commit comments

Comments
 (0)