Closed stanhu closed 2 years ago
@michael-grunder Would you be able to trigger CI, merge this, and release a new hiredis-rb version?
I'm also happy to help maintain these releases.
Merged, thanks.
I'll put together a release, and I'll see about getting you added as a maintainer if that works for you.
This updates #59 with the latest
master
.Hiredis::Ext::Connection#sock
creates aSocket
object usingSocket.for_fd
, wrapping the socket managed in C by hiredis and returns it to the caller. TheSocket
does not have autoclose set to false, so this has the unwanted side-effect that once the object becomes stale and is GC'd, the underlying file descriptor will be closed. This can causeErrno::EBADF
errors, as outlined in Ruby Bug #1174, especially when the Redis driver performs a reconnect and creates a new instance ofHiredis::Ext::Connection
, forgetting the old one completely.Note that
Errno::EBADF
errors might affect other parts of the program, as the FD is closed at GC time and it may refer to something else. The following script reproduces the issue:Fix this by setting autoclose to false in the created Socket object.