Subject: | Quit does not clear socket internally |
Date: | Tue, 4 Jan 2011 15:58:05 -0500 |
To: | bug-redis [...] rt.cpan.org |
From: | Brian Dunavant <brian [...] omniti.com> |
$r->quit closes the socket but does not track that it has done so internally.
Example (assume I have a key named "blah" with value "0").
; perl -MRedis -e '$r = Redis->new(); print "".$r->get("blah")."\n";
$r->quit; $r->quit; '
0
print() on closed filehandle GEN0 at
/opt/OMNIperl/lib/site_perl/5.8.8/Redis.pm line 113.
can't close socket: Bad file number at
/opt/OMNIperl/lib/site_perl/5.8.8/Redis.pm line 116.
This can be addressed with a one line change inside of the AUTOLOAD
function. Change the following code at line 115:
if ( $command eq 'quit' ) {
close( $sock ) || die "can't close socket: $!";
return 1;
}
to:
if ( $command eq 'quit' ) {
close( $sock ) || die "can't close socket: $!";
undef $self->{sock};
return 1;
}
This causes it to fail with the more correct error (using my
BrianRedis.pm which has the change):
; perl -MBrianRedis -e '$r = BrianRedis->new(); print
"".$r->get("blah")."\n"; $r->quit; $r->quit; '
0
no server connected at /home/brian/BrianRedis.pm line 80.
Thanks,
Brian Dunavant