return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
r = call(m->runtime_scope, flags, NULL, l, &changes, &n_changes);
+ m->unit_file_state_outdated = m->unit_file_state_outdated || n_changes > 0; /* See comments for this variable in manager.h */
if (r < 0)
return install_error(error, r, changes, n_changes);
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
r = unit_file_preset(m->runtime_scope, flags, NULL, l, preset_mode, &changes, &n_changes);
+ m->unit_file_state_outdated = m->unit_file_state_outdated || n_changes > 0; /* See comments for this variable in manager.h */
if (r < 0)
return install_error(error, r, changes, n_changes);
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
r = call(m->runtime_scope, flags, NULL, l, &changes, &n_changes);
+ m->unit_file_state_outdated = m->unit_file_state_outdated || n_changes > 0; /* See comments for this variable in manager.h */
if (r < 0)
return install_error(error, r, changes, n_changes);
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
r = unit_file_revert(m->runtime_scope, NULL, l, &changes, &n_changes);
+ m->unit_file_state_outdated = m->unit_file_state_outdated || n_changes > 0; /* See comments for this variable in manager.h */
if (r < 0)
return install_error(error, r, changes, n_changes);
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
r = unit_file_preset_all(m->runtime_scope, flags, NULL, preset_mode, &changes, &n_changes);
+ m->unit_file_state_outdated = m->unit_file_state_outdated || n_changes > 0; /* See comments for this variable in manager.h */
if (r < 0)
return install_error(error, r, changes, n_changes);
return -EINVAL;
r = unit_file_add_dependency(m->runtime_scope, flags, NULL, l, target, dep, &changes, &n_changes);
+ m->unit_file_state_outdated = m->unit_file_state_outdated || n_changes > 0; /* See comments for this variable in manager.h */
if (r < 0)
return install_error(error, r, changes, n_changes);
Set *unit_path_cache;
uint64_t unit_cache_timestamp_hash;
+ /* We don't have support for atomically enabling/disabling units, and unit_file_state might become
+ * outdated if such operations failed half-way. Therefore, we set this flag if changes to unit files
+ * are made, and reset it after daemon-reload. If set, we report that daemon-reload is needed through
+ * unit's NeedDaemonReload property. */
+ bool unit_file_state_outdated;
+
char **transient_environment; /* The environment, as determined from config files, kernel cmdline and environment generators */
char **client_environment; /* Environment variables created by clients through the bus API */
}
bool unit_need_daemon_reload(Unit *u) {
- _cleanup_strv_free_ char **t = NULL;
+ _cleanup_strv_free_ char **dropins = NULL;
assert(u);
+ assert(u->manager);
+
+ if (u->manager->unit_file_state_outdated)
+ return true;
/* For unit files, we allow masking… */
if (fragment_mtime_newer(u->fragment_path, u->fragment_mtime,
return true;
if (u->load_state == UNIT_LOADED)
- (void) unit_find_dropin_paths(u, &t);
- if (!strv_equal(u->dropin_paths, t))
+ (void) unit_find_dropin_paths(u, &dropins);
+ if (!strv_equal(u->dropin_paths, dropins))
return true;
/* … any drop-ins that are masked are simply omitted from the list. */