fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-01-31 11:18 am

[dw-free] allow checkforupdates to hit db if timeupdate not in memcache

[commit: http://hg.dwscoalition.org/dw-free/rev/744f97686e08]

http://bugs.dwscoalition.org/show_bug.cgi?id=3415

Allow checkforupdates to check db if there's nothing in memcached.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/ljprotocol.pl
--------------------------------------------------------------------------------
diff -r 3d40feeedb63 -r 744f97686e08 cgi-bin/ljprotocol.pl
--- a/cgi-bin/ljprotocol.pl	Mon Jan 31 14:37:24 2011 +0800
+++ b/cgi-bin/ljprotocol.pl	Mon Jan 31 19:17:57 2011 +0800
@@ -875,11 +875,12 @@ sub checkforupdates
         if (@LJ::MEMCACHE_SERVERS) {
             my $tu = LJ::get_timeupdate_multi({ memcache_only => 1 }, @fr);
             my $max = 0;
-            while ($_ = each %$tu) {
-                $max = $tu->{$_} if $tu->{$_} > $max;
+            foreach ( values %$tu ) {
+                $max = $_ if $_ > $max;
             }
             $update = LJ::mysql_time($max) if $max;
-        } else {
+        }
+        unless ( $update ) {
             my $dbr = LJ::get_db_reader();
             unless ($dbr) {
                 # rather than return a 502 no-db error, just say no updates,
--------------------------------------------------------------------------------