You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2013/06/18 16:25:49 UTC

svn commit: r1494155 - /spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/Redis.pm

Author: mmartinec
Date: Tue Jun 18 14:25:49 2013
New Revision: 1494155

URL: http://svn.apache.org/r1494155
Log:
Bug 6942: Redis bayes storage - fix a non-Lua compatibility case

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/Redis.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/Redis.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/Redis.pm?rev=1494155&r1=1494154&r2=1494155&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/Redis.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/Redis.pm Tue Jun 18 14:25:49 2013
@@ -595,6 +595,7 @@ sub tok_get_all {
       $r->hmget('w:'.$token, 's', 'h', sub {
         my($values, $error) = @_;
         return if !$values || @$values != 2;
+        return if !$values->[0] && !$values->[1];
         push(@values, [$token, $values->[0]||0, $values->[1]||0, 0]);
         1;
       });
@@ -703,20 +704,21 @@ sub multi_tok_count_change {
         if ($dspam < 0) {
           my $result = $self->_hincrby('w:'.$token, 's', int $dspam);
           if (!$result || $result <= 0) {
-            $self->hdel('w:'.$token, 's');
+            $self->_hdel_p('w:'.$token, 's');
           } elsif ($ttl) {
-            $self->expire('w:'.$token, $ttl);
+            $self->_expire_p('w:'.$token, $ttl);
           }
         }
         if ($dham < 0) {
           my $result = $self->_hincrby('w:'.$token, 'h', int $dham);
           if (!$result || $result <= 0) {
-            $self->hdel('w:'.$token, 'h');
+            $self->_hdel_p('w:'.$token, 'h');
           } elsif ($ttl) {
-            $self->expire('w:'.$token, $ttl);
+            $self->_expire_p('w:'.$token, $ttl);
           }
         }
       }
+      $self->_wait_all_responses;
     }
   }
 
@@ -1366,6 +1368,15 @@ sub _del_p {
   return 1;
 }
 
+# Pipelined hdel, must call _wait_all_responses after
+sub _hdel_p {
+  my ($self, $key, $field) = @_;
+
+  $self->{redis}->hdel($key, $field, sub {});
+
+  return 1;
+}
+
 # Pipelined expire, must call _wait_all_responses after
 sub _expire_p {
   my ($self, $key, $expire) = @_;