madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r21030: LJSUP-11064: Error with lock state is fi...

Committer: sbelyaev
LJSUP-11064: Error with lock state is fixed
U   trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm
Modified: trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2012-01-27 14:09:23 UTC (rev 21029)
+++ trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2012-01-27 14:46:59 UTC (rev 21030)
@@ -7,7 +7,7 @@
 sub new {
     my ($class, $dbh) = @_;
 
-    if (try_lock($dbh)) {
+    if (!try_lock($dbh)) {
         return undef;
     }
 
@@ -60,13 +60,13 @@
     my $list = $dbh->selectall_arrayref("SELECT journalid, delayedid, posterid " .
                                         "FROM delayedlog2 ".
                                         "WHERE posttime <= NOW() LIMIT 1000");
-
     foreach my $tuple (@$list) {
         push @entries, LJ::DelayedEntry->load_data($dbh,
                                                    { journalid  => $tuple->[0],
                                                      delayed_id => $tuple->[1],
                                                      posterid   => $tuple->[2]} );
     }
+    return undef if !scalar @entries;
     return \@entries;
 }
 
@@ -81,10 +81,10 @@
         'charset'   => 'utf-8',
         'subject'   => LJ::Lang::get_text($poster->prop('browselang'),
                                         'email.delayed_error.subject'),
-        'body'      =>  LJ::Lang::get_text($poster->prop('browselang'),
+        'body'      => LJ::Lang::get_text($poster->prop('browselang'),
                                         'email.delayed_error.body',
         {subject => $subject, reason=>$error}),
-    });    
+    });
 }
 
 
@@ -99,10 +99,8 @@
     }
 
     eval {
-        my $entries = __load_delayed_entries($dbh);
-
-        do {
-            foreach my $entry(@$entries) {
+        while ( my $entries = __load_delayed_entries($dbh) ) {
+            foreach my $entry (@$entries) {
                 my $post_status = $entry->convert();
         
                 # do we need to send error
@@ -115,7 +113,7 @@
                     $entry->delete();
                 }
             }
-        } while ($entries = __load_delayed_entries($dbh) && @$entries)
+        } 
     };
     if ($@) {
         warn 'worker has failed: ' . $@;

Tags: livejournal, madeon, pm, sbelyaev
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments