diff options
author | Francisco Redondo Marchena <francisco.marchena@codethink.co.uk> | 2012-08-09 15:40:47 +0100 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2012-08-09 17:13:47 +0100 |
commit | b1483f842beded2611d6fbff0ff040caa717f28c (patch) | |
tree | 293923e205f3f5364b2ffdf923199a93f394033d | |
parent | 9ce8952b117226ddda6b60e676dc9c6c7f9072b1 (diff) | |
download | node-startup-controller-b1483f842beded2611d6fbff0ff040caa717f28c.tar.gz |
Remove the list of units and create D-Bus proxy only for wanted targets
Remove the list of units which is not longer used.
When the TargetStarterMonitor receives a "job-removed" signal it
creates a D-Bus proxy to monitor the unit and check if the state
changes to "active". If it does the TargetStartupMonitor sets the node
state.
The TargetStarterMonitor is only interested in monitoring
"focussed.target", "unfocussed.target" and "lazy.target" units. To
avoid creating the D-Bus proxy for unneeded units, it should check in
target_startup_monitor_job_removed if the unit is a unit which has to be
monitored.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | node-startup-controller/target-startup-monitor.c | 37 |
2 files changed, 14 insertions, 25 deletions
@@ -19,6 +19,8 @@ x.y.z Universal (CC0 1.0) * Fixed NodeStartupControllerApplication's SIGINT handler redundantly quitting the application and not cancelling the LUCStarter. +* The TargetStartupMonitor now only monitors its targets, not every + unit whose state changes. 0.9.1 ===== diff --git a/node-startup-controller/target-startup-monitor.c b/node-startup-controller/target-startup-monitor.c index 33cf463..1b5db78 100644 --- a/node-startup-controller/target-startup-monitor.c +++ b/node-startup-controller/target-startup-monitor.c @@ -110,9 +110,6 @@ struct _TargetStartupMonitor NSMLifecycleControl *nsm_lifecycle_control; - /* list of systemd units for the targets we are interested in */ - GList *units; - /* map of systemd target names to corresponding node states */ GHashTable *targets_to_states; }; @@ -206,18 +203,6 @@ static void target_startup_monitor_finalize (GObject *object) { TargetStartupMonitor *monitor = TARGET_STARTUP_MONITOR (object); - GList *lp; - - /* disconnect from all the unit proxies and release them */ - for (lp = monitor->units; lp != NULL; lp = lp->next) - { - g_signal_handlers_disconnect_matched (lp->data, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, monitor); - g_object_unref (lp->data); - } - - /* release the list of systemd units */ - g_list_free (monitor->units); /* release the mapping of systemd targets to node states */ g_hash_table_destroy (monitor->targets_to_states); @@ -294,16 +279,18 @@ target_startup_monitor_job_removed (SystemdManager *manager, g_return_if_fail (result != NULL && *result != '\0'); g_return_if_fail (IS_TARGET_STARTUP_MONITOR (monitor)); - /* create a temporary struct to bundle information about the unit */ - data = g_slice_new0 (GetUnitData); - data->monitor = g_object_ref (monitor); - data->unit_name = g_strdup (unit); - - /* ask systemd to return the object path for this unit */ - systemd_manager_call_get_unit (monitor->systemd_manager, unit, NULL, - target_startup_monitor_get_unit_finish, data); - - + /* check if the unit corresponds to one which has to be monitored */ + if (g_hash_table_lookup_extended (monitor->targets_to_states, unit, NULL, NULL)) + { + /* create a temporary struct to bundle information about the unit */ + data = g_slice_new0 (GetUnitData); + data->monitor = g_object_ref (monitor); + data->unit_name = g_strdup (unit); + + /* ask systemd to return the object path for this unit */ + systemd_manager_call_get_unit (monitor->systemd_manager, unit, NULL, + target_startup_monitor_get_unit_finish, data); + } } |