summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
cf498c4)
Make sure we get rid of the IO::Socket::INET object on QUIT.
Signed-off-by: Pedro Melo <melo@simplicidade.org>
# we don't want DESTROY to fallback into AUTOLOAD
sub DESTROY {}
# we don't want DESTROY to fallback into AUTOLOAD
sub DESTROY {}
+
+### Deal with common, general case, Redis commands
our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
$self->__send_command($command, @_);
$self->__send_command($command, @_);
- if ( $command eq 'quit' ) {
- close( $sock ) || confess("Can't close socket: $!");
- return 1;
- }
-
my $result = <$sock> || confess("Can't read socket: $!");
my $type = substr($result,0,1);
$result = substr($result,1,-2);
my $result = <$sock> || confess("Can't read socket: $!");
my $type = substr($result,0,1);
$result = substr($result,1,-2);
+### Commands with extra logic
+
+sub quit {
+ my ($self) = @_;
+
+ $self->__send_command('QUIT');
+
+ close(delete $self->{sock}) || confess("Can't close socket: $!");
+ return 1;
+}
+
+
### Socket operations
sub __send_command {
### Socket operations
sub __send_command {