diff options
author | Friendika <info@friendika.com> | 2011-08-28 21:41:42 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-08-28 21:41:42 -0700 |
commit | 846c4cea7c0e3868a63a187ee9a504a031b2a7e4 (patch) | |
tree | 034407e183dfb95ce9ef77cbe6a5af73377e2090 /include/notifier.php | |
parent | f29f228463d35f574d6d285be0cf337b7d39c541 (diff) | |
download | volse-hubzilla-846c4cea7c0e3868a63a187ee9a504a031b2a7e4.tar.gz volse-hubzilla-846c4cea7c0e3868a63a187ee9a504a031b2a7e4.tar.bz2 volse-hubzilla-846c4cea7c0e3868a63a187ee9a504a031b2a7e4.zip |
implement delivery queue in case notifier gets killed
Diffstat (limited to 'include/notifier.php')
-rw-r--r-- | include/notifier.php | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/include/notifier.php b/include/notifier.php index b87aa95b1..cde156cbd 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -379,11 +379,27 @@ function notifier_run($argv, $argc){ dbesc($recip_str) ); - // delivery loop require_once('include/salmon.php'); + $interval = intval(get_config('system','delivery_interval')); + if(! $interval) + $interval = 2; + + // delivery loop + if(count($r)) { + + foreach($r as $contact) { + if((! $mail) && (! $fsuggest) && (! $followup) && (! $contact['self'])) { + q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )", + dbesc($cmd), + intval($item_id), + intval($contact['id']) + ); + } + } + foreach($r as $contact) { if($contact['self']) continue; @@ -392,13 +408,8 @@ function notifier_run($argv, $argc){ // we will deliver single recipient types of message and email receipients here. if((! $mail) && (! $fsuggest) && (! $followup)) { - $interval = intval(get_config('system','delivery_interval')); - if(! $interval) - $interval = 2; - proc_run('php','include/delivery.php',$cmd,$item_id,$contact['id']); - sleep($interval); - continue; + @time_sleep_until(microtime(true) + (float) $interval); } $deliver_status = 0; @@ -624,6 +635,18 @@ function notifier_run($argv, $argc){ if(count($r)) { logger('pubdeliver: ' . print_r($r,true)); + // throw everything into the queue in case we get killed + + foreach($r as $rr) { + if((! $mail) && (! $fsuggest) && (! $followup)) { + q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )", + dbesc($cmd), + intval($item_id), + intval($rr['id']) + ); + } + } + foreach($r as $rr) { /* Don't deliver to folks who have already been delivered to */ @@ -634,13 +657,9 @@ function notifier_run($argv, $argc){ } if((! $mail) && (! $fsuggest) && (! $followup)) { - $interval = intval(get_config('system','delivery_interval')); - if(! $interval) - $interval = 2; - + logger('notifier: delivery agent: ' . $rr['name'] . ' ' . $rr['id']); proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']); - sleep($interval); - continue; + @time_sleep_until(microtime(true) + (float) $interval); } } } |