The poller is now the worker
This commit is contained in:
parent
cabfcfc904
commit
920160cb28
14 changed files with 41 additions and 41 deletions
|
@ -108,7 +108,7 @@ class Worker {
|
|||
}
|
||||
}
|
||||
|
||||
// To avoid the quitting of multiple pollers only one poller at a time will execute the check
|
||||
// To avoid the quitting of multiple workers only one worker at a time will execute the check
|
||||
if (Lock::set('poller_worker', 0)) {
|
||||
$stamp = (float)microtime(true);
|
||||
// Count active workers and compare them with a maximum value that depends on the load
|
||||
|
@ -126,7 +126,7 @@ class Worker {
|
|||
self::$db_duration += (microtime(true) - $stamp);
|
||||
}
|
||||
|
||||
// Quit the poller once every 5 minutes
|
||||
// Quit the worker once every 5 minutes
|
||||
if (time() > ($starttime + 300)) {
|
||||
logger('Process lifetime reached, quitting.', LOGGER_DEBUG);
|
||||
return;
|
||||
|
@ -152,7 +152,7 @@ class Worker {
|
|||
/**
|
||||
* @brief Returns the highest priority in the worker queue that isn't executed
|
||||
*
|
||||
* @return integer Number of active poller processes
|
||||
* @return integer Number of active worker processes
|
||||
*/
|
||||
private static function highestPriority() {
|
||||
$condition = array("`executed` <= ? AND NOT `done`", NULL_DATE);
|
||||
|
@ -431,7 +431,7 @@ class Worker {
|
|||
// Fetch the max value from the config. This is needed when the system cannot detect the correct value by itself.
|
||||
$max = Config::get("system", "max_connections");
|
||||
|
||||
// Fetch the percentage level where the poller will get active
|
||||
// Fetch the percentage level where the worker will get active
|
||||
$maxlevel = Config::get("system", "max_connections_level", 75);
|
||||
|
||||
if ($max == 0) {
|
||||
|
@ -636,9 +636,9 @@ class Worker {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the number of active poller processes
|
||||
* @brief Returns the number of active worker processes
|
||||
*
|
||||
* @return integer Number of active poller processes
|
||||
* @return integer Number of active worker processes
|
||||
*/
|
||||
private static function activeWorkers() {
|
||||
$workers = dba::fetch_first("SELECT COUNT(*) AS `processes` FROM `process` WHERE `command` = 'Worker.php'");
|
||||
|
@ -840,7 +840,7 @@ class Worker {
|
|||
return;
|
||||
}
|
||||
|
||||
// Do we have "proc_open"? Then we can fork the poller
|
||||
// Do we have "proc_open"? Then we can fork the worker
|
||||
if (function_exists("proc_open")) {
|
||||
// When was the last time that we called the worker?
|
||||
// Less than one minute? Then we quit
|
||||
|
@ -861,7 +861,7 @@ class Worker {
|
|||
|
||||
self::runCron();
|
||||
|
||||
logger('Call poller', LOGGER_DEBUG);
|
||||
logger('Call worker', LOGGER_DEBUG);
|
||||
self::spawnWorker();
|
||||
return;
|
||||
}
|
||||
|
@ -999,7 +999,7 @@ class Worker {
|
|||
dba::insert('workerqueue', array('parameter' => $parameters, 'created' => $created, 'priority' => $priority));
|
||||
}
|
||||
|
||||
// Should we quit and wait for the poller to be called as a cronjob?
|
||||
// Should we quit and wait for the worker to be called as a cronjob?
|
||||
if ($dont_fork) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1017,7 +1017,7 @@ class Worker {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Now call the poller to execute the jobs that we just added to the queue
|
||||
// Now call the worker to execute the jobs that we just added to the queue
|
||||
self::spawnWorker();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -190,7 +190,7 @@ Class OnePoll
|
|||
|
||||
|
||||
if (!strlen($handshake_xml) || ($html_code >= 400) || !$html_code) {
|
||||
logger("poller: $url appears to be dead - marking for death ");
|
||||
logger("$url appears to be dead - marking for death ");
|
||||
|
||||
// dead connection - might be a transient event, or this might
|
||||
// mean the software was uninstalled or the domain expired.
|
||||
|
@ -206,7 +206,7 @@ Class OnePoll
|
|||
}
|
||||
|
||||
if (!strstr($handshake_xml, '<')) {
|
||||
logger('poller: response from ' . $url . ' did not contain XML.');
|
||||
logger('response from ' . $url . ' did not contain XML.');
|
||||
|
||||
mark_for_death($contact);
|
||||
|
||||
|
@ -220,7 +220,7 @@ Class OnePoll
|
|||
$res = parse_xml_string($handshake_xml);
|
||||
|
||||
if (intval($res->status) == 1) {
|
||||
logger("poller: $url replied status 1 - marking for death ");
|
||||
logger("$url replied status 1 - marking for death ");
|
||||
|
||||
// we may not be friends anymore. Will keep trying for one month.
|
||||
// set the last-update so we don't keep polling
|
||||
|
@ -229,7 +229,7 @@ Class OnePoll
|
|||
|
||||
mark_for_death($contact);
|
||||
} elseif ($contact['term-date'] > NULL_DATE) {
|
||||
logger("poller: $url back from the dead - removing mark for death");
|
||||
logger("$url back from the dead - removing mark for death");
|
||||
unmark_for_death($contact);
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ Class OnePoll
|
|||
}
|
||||
|
||||
if ($final_dfrn_id != $orig_id) {
|
||||
logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
|
||||
logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
|
||||
// did not decode properly - cannot trust this site
|
||||
return;
|
||||
}
|
||||
|
@ -555,9 +555,9 @@ Class OnePoll
|
|||
}
|
||||
|
||||
if ($xml) {
|
||||
logger('poller: received xml : ' . $xml, LOGGER_DATA);
|
||||
logger('received xml : ' . $xml, LOGGER_DATA);
|
||||
if (!strstr($xml, '<')) {
|
||||
logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
|
||||
logger('post_handshake: response from ' . $url . ' did not contain XML.');
|
||||
|
||||
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
||||
dba::update('contact', $fields, array('id' => $contact['id']));
|
||||
|
@ -590,7 +590,7 @@ Class OnePoll
|
|||
logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
|
||||
|
||||
if (strlen($hub) && $hub_update && (($contact['rel'] != CONTACT_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED)) {
|
||||
logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
|
||||
logger('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
|
||||
$hubs = explode(',', $hub);
|
||||
if (count($hubs)) {
|
||||
foreach ($hubs as $h) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue