Commit 306a9bec by pupi1985

Apply some early returns in function qa_mailing_perform_step()

parent de02a7fc
...@@ -63,7 +63,10 @@ function qa_mailing_perform_step() ...@@ -63,7 +63,10 @@ function qa_mailing_perform_step()
$lastuserid = qa_opt('mailing_last_userid'); $lastuserid = qa_opt('mailing_last_userid');
if (strlen($lastuserid)) { if (strlen($lastuserid) == 0) {
return;
}
$thistime = time(); $thistime = time();
$lasttime = qa_opt('mailing_last_timestamp'); $lasttime = qa_opt('mailing_last_timestamp');
$perminute = qa_opt('mailing_per_minute'); $perminute = qa_opt('mailing_per_minute');
...@@ -75,7 +78,10 @@ function qa_mailing_perform_step() ...@@ -75,7 +78,10 @@ function qa_mailing_perform_step()
$count = min(floor(($thistime - $lasttime) * $perminute / 60), 100); // don't do more than 100 messages at a time $count = min(floor(($thistime - $lasttime) * $perminute / 60), 100); // don't do more than 100 messages at a time
if ($count > 0) { if ($count == 0) {
return;
}
qa_opt('mailing_last_timestamp', $thistime + 30); qa_opt('mailing_last_timestamp', $thistime + 30);
// prevents a parallel call to qa_mailing_perform_step() from sending messages, unless we're very unlucky with timing (poor man's mutex) // prevents a parallel call to qa_mailing_perform_step() from sending messages, unless we're very unlucky with timing (poor man's mutex)
...@@ -105,10 +111,9 @@ function qa_mailing_perform_step() ...@@ -105,10 +111,9 @@ function qa_mailing_perform_step()
qa_opt('mailing_last_timestamp', $lasttime + $sentusers * 60 / $perminute); // can be floating point result, based on number of mails actually sent qa_opt('mailing_last_timestamp', $lasttime + $sentusers * 60 / $perminute); // can be floating point result, based on number of mails actually sent
} else } else {
qa_mailing_stop(); qa_mailing_stop();
} }
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment