$mailerJobsMax = Civi::settings()->get('mailerJobsMax');
if (is_numeric($mailerJobsMax) && $mailerJobsMax > 0) {
$lockArray = range(1, $mailerJobsMax);
+
+ // Shuffle the array to improve chances of quickly finding an open thread
shuffle($lockArray);
- // check if we are using global locks
+ // Check if we are using global locks
foreach ($lockArray as $lockID) {
$cronLock = Civi::lockManager()->acquire("worker.mailing.send.{$lockID}");
if ($cronLock->isAcquired()) {
}
}
- // exit here since we have enuf cronjobs running
+ // Exit here since we have enough mailing processes running
if (!$gotCronLock) {
- CRM_Core_Error::debug_log_message('Returning early, since max number of cronjobs running');
+ CRM_Core_Error::debug_log_message('Returning early, since the maximum number of mailing processes are running');
return TRUE;
}
}
}
- // load bootstrap to call hooks
-
// Split up the parent jobs into multiple child jobs
$mailerJobSize = Civi::settings()->get('mailerJobSize');
CRM_Mailing_BAO_MailingJob::runJobs_pre($mailerJobSize, $mode);
CRM_Mailing_BAO_MailingJob::runJobs(NULL, $mode);
CRM_Mailing_BAO_MailingJob::runJobs_post($mode);
- // lets release the global cron lock if we do have one
+ // Release the global lock if we do have one
if ($gotCronLock) {
$cronLock->release();
}