Skip to content
Browse files

Bug fix: forbid PING and SHUTDOWN in SUBSCRIBE mode

  • Loading branch information...
1 parent 4054b4d commit 2c3b57aa28c9b142429313697ad7df71efb87976 @arc committed
Showing with 9 additions and 3 deletions.
  1. +4 −0 lib/Redis.pm
  2. +5 −3 t/03-pubsub.t
View
4 lib/Redis.pm
@@ -290,6 +290,8 @@ sub quit {
sub shutdown {
my ($self) = @_;
+ $self->__is_valid_command('SHUTDOWN');
+
return unless $self->{sock};
$self->__send_command('SHUTDOWN');
@@ -300,6 +302,8 @@ sub shutdown {
sub ping {
my ($self) = @_;
+ $self->__is_valid_command('PING');
+
return unless exists $self->{sock};
my $reply;
View
8 t/03-pubsub.t 100644 → 100755
@@ -116,9 +116,11 @@ is($sub->wait_for_messages(1), 0, '... yep, no messages delivered');
cmp_deeply(\%got, {}, '... and an empty messages recorded set');
is($sub->is_subscriber, 1, 'Still some pending subcriptions active');
-throws_ok sub { $sub->info },
- qr/Cannot use command 'INFO' while in SUBSCRIBE mode/,
- '... still an error to try commands in subscribe mode';
+for my $cmd (qw<ping info keys dbsize shutdown>) {
+ throws_ok sub { $sub->$cmd },
+ qr/Cannot use command '(?i:$cmd)' while in SUBSCRIBE mode/,
+ ".. still an error to try \U$cmd\E while in SUBSCRIBE mode";
+}
$sub->punsubscribe('c*', $psub_cb);
is($sub->is_subscriber, 0, '... but none anymore');

0 comments on commit 2c3b57a

Please sign in to comment.
Something went wrong with that request. Please try again.