From bb6432a6158b97cd5b92ab316d9d8b52bca2044d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 24 Feb 2015 16:30:07 +0100 Subject: Various fixes --- apis/cb.inc.php | 5 ++++- config.php.example | 4 ++-- inc/configmodule/adauth.inc.php | 1 + inc/configtgz.inc.php | 1 + inc/event.inc.php | 1 + inc/property.inc.php | 10 ---------- inc/taskmanagercallback.inc.php | 4 ++-- inc/trigger.inc.php | 12 ++++++++---- index.php | 4 +--- modules/sysconfig/addconfig.inc.php | 2 +- templates/tm-callback-trigger.html | 16 +++++++++++++--- 11 files changed, 34 insertions(+), 26 deletions(-) diff --git a/apis/cb.inc.php b/apis/cb.inc.php index da5d8756..a94ac463 100644 --- a/apis/cb.inc.php +++ b/apis/cb.inc.php @@ -1,3 +1,6 @@ id(), $parent); $config = $this->moduleData; $config['parentTask'] = $parent; $config['failOnParentFail'] = false; diff --git a/inc/configtgz.inc.php b/inc/configtgz.inc.php index 231960bb..8ddd4523 100644 --- a/inc/configtgz.inc.php +++ b/inc/configtgz.inc.php @@ -285,6 +285,7 @@ class ConfigTgz { if ($this->configId === 0) Util::traceError('ConfigTgz::markUpdated called with invalid config id!'); + Event::activeConfigChanged(); if ($this->areAllModulesUpToDate()) return $this->mark('OK'); return $this->mark('OUTDATED'); diff --git a/inc/event.inc.php b/inc/event.inc.php index 6b303493..5dca20ef 100644 --- a/inc/event.inc.php +++ b/inc/event.inc.php @@ -84,6 +84,7 @@ class Event */ public static function activeConfigChanged() { + error_log('Active config changed'); $task = Trigger::ldadp(); TaskmanagerCallback::addCallback($task, 'ldadpStartup'); } diff --git a/inc/property.inc.php b/inc/property.inc.php index d5a91872..0cb57f81 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -183,15 +183,5 @@ class Property { return self::get('password-type', 'password'); } - - public static function setNeedsCallback($value) - { - return self::set('need-callback', $value, 5); - } - - public static function getNeedsCallback() - { - return self::get('need-callback', 0); - } } diff --git a/inc/taskmanagercallback.inc.php b/inc/taskmanagercallback.inc.php index 546fbbc9..ba589469 100644 --- a/inc/taskmanagercallback.inc.php +++ b/inc/taskmanagercallback.inc.php @@ -38,7 +38,6 @@ class TaskmanagerCallback } else { Database::exec("INSERT INTO callback (taskid, dateline, cbfunction) VALUES (:task, UNIX_TIMESTAMP(), :callback)", $data); } - Property::setNeedsCallback(1); } /** @@ -73,8 +72,9 @@ class TaskmanagerCallback return; if (Taskmanager::isFailed($status) || Taskmanager::isFinished($status)) { $del = Database::exec("DELETE FROM callback WHERE taskid = :task AND cbfunction = :cb LIMIT 1", array('task' => $callback['taskid'], 'cb' => $callback['cbfunction'])); - if ($del === 0) // No entry deleted, so someone else must have deleted it - race condition, do nothing + if ($del === 0) { // No entry deleted, so someone else must have deleted it - race condition, do nothing return; + } } if (Taskmanager::isFinished($status)) { $func = array('TaskmanagerCallback', preg_replace('/\W/', '', $callback['cbfunction'])); diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index 0410b2be..0b1f00c5 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -78,10 +78,11 @@ class Trigger /** * Launch all ldadp instances that need to be running. * + * @param int $exclude if not NULL, id of config module NOT to start * @param string $parent if not NULL, this will be the parent task of the launch-task * @return boolean|string false on error, id of task otherwise */ - public static function ldadp($parent = NULL) + public static function ldadp($exclude = NULL, $parent = NULL) { // TODO: Fetch list from ConfigModule_AdAuth (call loadDb first) $res = Database::simpleQuery("SELECT moduleid, configtgz.filepath FROM configtgz_module" @@ -92,7 +93,9 @@ class Trigger $id = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if (readlink('/srv/openslx/www/boot/default/config.tgz') === $row['filepath']) { - $id[] = (int) $row['moduleid']; + if (!is_null($exclude) && (int)$row['moduleid'] === (int)$exclude) + continue; + $id[] = (int)$row['moduleid']; break; } } @@ -133,6 +136,8 @@ class Trigger /** * Check and process all callbacks. + * + * @return boolean Whether there are still callbacks pending */ public static function checkCallbacks() { @@ -150,8 +155,7 @@ class Trigger else $tasksLeft = true; } - if (!$tasksLeft) - Property::setNeedsCallback(0); + return $tasksLeft; } private static function triggerDaemons($action, $parent, &$taskids) diff --git a/index.php b/index.php index 884a6190..021820b8 100644 --- a/index.php +++ b/index.php @@ -145,9 +145,7 @@ if (defined('CONFIG_FOOTER')) { Render::addTemplate('footer', array('text' => CONFIG_FOOTER)); } -if (Property::getNeedsCallback()) { - Render::addTemplate('tm-callback-trigger'); -} +Render::addTemplate('tm-callback-trigger'); // Send page to client. Render::output(); diff --git a/modules/sysconfig/addconfig.inc.php b/modules/sysconfig/addconfig.inc.php index 8acf5c32..023ec000 100644 --- a/modules/sysconfig/addconfig.inc.php +++ b/modules/sysconfig/addconfig.inc.php @@ -153,7 +153,7 @@ class AddConfig_Start extends AddConfig_Base 'step' => 'AddConfig_Finish', 'groups' => array_values($mods), 'title' => $title, - 'edit' => $this->edit->id() + 'edit' => ($this->edit !== false ? $this->edit->id() : false) )); } diff --git a/templates/tm-callback-trigger.html b/templates/tm-callback-trigger.html index 26b362ca..274a2246 100644 --- a/templates/tm-callback-trigger.html +++ b/templates/tm-callback-trigger.html @@ -1,5 +1,15 @@ \ No newline at end of file -- cgit v1.2.3-55-g7522