diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-10-15 18:52:04 -0700 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-10-15 18:52:04 -0700 |
commit | 93f061f78a8b914a731838058a38354a62d002de (patch) | |
tree | a2444956ccadaad1ef5dcda1a98364bbc987d3a9 /include/network.php | |
parent | 7517c76ae48ddad741fe61c41dd6dcc09421d160 (diff) | |
download | volse-hubzilla-93f061f78a8b914a731838058a38354a62d002de.tar.gz volse-hubzilla-93f061f78a8b914a731838058a38354a62d002de.tar.bz2 volse-hubzilla-93f061f78a8b914a731838058a38354a62d002de.zip |
mail sync/migrate continued; also abstract delivery loop to make it re-usable, change refresh_all to use delivery loop.
Diffstat (limited to 'include/network.php')
-rw-r--r-- | include/network.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/network.php b/include/network.php index e1793b405..c67c019ef 100644 --- a/include/network.php +++ b/include/network.php @@ -1677,13 +1677,40 @@ function format_and_send_email($sender,$xchan,$item) { 'additionalMailHeader' => '', )); +} + +function do_delivery($deliveries) { + if(! (is_array($deliveries) && count($deliveries))) + return; + $interval = ((get_config('system','delivery_interval') !== false) + ? intval(get_config('system','delivery_interval')) : 2 ); + $deliveries_per_process = intval(get_config('system','delivery_batch_count')); + if($deliveries_per_process <= 0) + $deliveries_per_process = 1; + $deliver = array(); + foreach($deliveries as $d) { + $deliver[] = $d; + + if(count($deliver) >= $deliveries_per_process) { + proc_run('php','include/deliver.php',$deliver); + $deliver = array(); + if($interval) + @time_sleep_until(microtime(true) + (float) $interval); + } + } + + // catch any stragglers + + if($deliver) + proc_run('php','include/deliver.php',$deliver); + } |