From 011ccd57f62335c915b5ac75e20c45a36a64a888 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Mar 2015 17:56:07 -0800 Subject: add queue priority --- include/deliver.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/deliver.php') diff --git a/include/deliver.php b/include/deliver.php index 47d8562df..459c0f94b 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -20,6 +20,24 @@ function deliver_run($argv, $argc) { dbesc($argv[$x]) ); if($r) { + $h = parse_url($r[0]['outq_posturl']); + if($h) { + $base = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : ''); + if($base !== z_root()) { + $x = q("select site_update from site where site_url = '%s' ", + dbesc($base) + ); + if($x && $x[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) { + q("update outq set outq_priority = %d where outq_hash = '%s'", + intval($r[0]['outq_priority'] + 10) + dbesc($r[0]['outq_hash']) + ); + logger('immediate delivery deferred for site ' . $base); + continue; + } + } + } + if($r[0]['outq_driver'] === 'post') { $result = z_post_url($r[0]['outq_posturl'],$r[0]['outq_msg']); if($result['success'] && $result['return_code'] < 300) { -- cgit v1.2.3 From 1d5d80808ca1463e67f7586f8c804347f3dfb5f4 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Mar 2015 18:11:47 -0800 Subject: don't re-use $x --- include/deliver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/deliver.php') diff --git a/include/deliver.php b/include/deliver.php index 459c0f94b..95fb19a79 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -24,10 +24,10 @@ function deliver_run($argv, $argc) { if($h) { $base = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : ''); if($base !== z_root()) { - $x = q("select site_update from site where site_url = '%s' ", + $y = q("select site_update from site where site_url = '%s' ", dbesc($base) ); - if($x && $x[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) { + if($y && $y[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) { q("update outq set outq_priority = %d where outq_hash = '%s'", intval($r[0]['outq_priority'] + 10) dbesc($r[0]['outq_hash']) -- cgit v1.2.3 From ad3b4da3ff5751a5e0da6ba7e46a4fc8731d4d28 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Mar 2015 18:23:54 -0800 Subject: missing comma --- include/deliver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/deliver.php') diff --git a/include/deliver.php b/include/deliver.php index 95fb19a79..498440271 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -29,7 +29,7 @@ function deliver_run($argv, $argc) { ); if($y && $y[0]['site_update'] < datetime_convert('UTC','UTC','now - 1 month')) { q("update outq set outq_priority = %d where outq_hash = '%s'", - intval($r[0]['outq_priority'] + 10) + intval($r[0]['outq_priority'] + 10), dbesc($r[0]['outq_hash']) ); logger('immediate delivery deferred for site ' . $base); -- cgit v1.2.3 From 0134a41015dd79092cb6a42ad0f7122d0af9bc6d Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Mar 2015 19:57:35 -0700 Subject: more work on queue optimisations --- include/deliver.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/deliver.php') diff --git a/include/deliver.php b/include/deliver.php index 498440271..0fb7a4aeb 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -20,6 +20,12 @@ function deliver_run($argv, $argc) { dbesc($argv[$x]) ); if($r) { + + /** + * Check to see if we have any recent communications with this hub (in the last month). + * If not, reduce the outq_priority. + */ + $h = parse_url($r[0]['outq_posturl']); if($h) { $base = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : ''); @@ -38,6 +44,8 @@ function deliver_run($argv, $argc) { } } + // "post" queue driver - used for diaspora and friendica-over-diaspora communications. + if($r[0]['outq_driver'] === 'post') { $result = z_post_url($r[0]['outq_posturl'],$r[0]['outq_msg']); if($result['success'] && $result['return_code'] < 300) { @@ -92,9 +100,11 @@ function deliver_run($argv, $argc) { logger('deliver: dest: ' . $r[0]['outq_posturl'], LOGGER_DEBUG); $result = zot_zot($r[0]['outq_posturl'],$r[0]['outq_notify']); if($result['success']) { + logger('deliver: remote zot delivery succeeded to ' . $r[0]['outq_posturl']); zot_process_response($r[0]['outq_posturl'],$result, $r[0]); } else { + logger('deliver: remote zot delivery failed to ' . $r[0]['outq_posturl']); $y = q("update outq set outq_updated = '%s' where outq_hash = '%s'", dbesc(datetime_convert()), dbesc($argv[$x]) -- cgit v1.2.3