From b1483f842beded2611d6fbff0ff040caa717f28c Mon Sep 17 00:00:00 2001 From: Francisco Redondo Marchena Date: Thu, 9 Aug 2012 15:40:47 +0100 Subject: 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. --- NEWS | 2 ++ node-startup-controller/target-startup-monitor.c | 37 ++++++++---------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/NEWS b/NEWS index f564bf5..34f355b 100644 --- a/NEWS +++ b/NEWS @@ -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); + } } -- cgit v1.2.1