@@ -2329,6 +2329,23 @@ static int send_unit_files_changed(sd_bus *bus, void *userdata) {
23292329 return sd_bus_send (bus , message , NULL );
23302330}
23312331
2332+ static void manager_unit_files_changed (Manager * m , const InstallChange * changes , size_t n_changes ) {
2333+ int r ;
2334+
2335+ assert (m );
2336+ assert (changes || n_changes == 0 );
2337+
2338+ if (!install_changes_have_modification (changes , n_changes ))
2339+ return ;
2340+
2341+ /* See comments for this variable in manager.h */
2342+ m -> unit_file_state_outdated = true;
2343+
2344+ r = bus_foreach_bus (m , NULL , send_unit_files_changed , NULL );
2345+ if (r < 0 )
2346+ log_debug_errno (r , "Failed to send UnitFilesChanged signal, ignoring: %m" );
2347+ }
2348+
23322349/* Create an error reply, using the error information from changes[]
23332350 * if possible, and fall back to generating an error from error code c.
23342351 * The error message only describes the first error.
@@ -2426,12 +2443,6 @@ static int reply_install_changes_and_free(
24262443
24272444 CLEANUP_ARRAY (changes , n_changes , install_changes_free );
24282445
2429- if (install_changes_have_modification (changes , n_changes )) {
2430- r = bus_foreach_bus (m , NULL , send_unit_files_changed , NULL );
2431- if (r < 0 )
2432- log_debug_errno (r , "Failed to send UnitFilesChanged signal: %m" );
2433- }
2434-
24352446 r = sd_bus_message_new_method_return (message , & reply );
24362447 if (r < 0 )
24372448 return r ;
@@ -2521,7 +2532,7 @@ static int method_enable_unit_files_generic(
25212532 return 1 ; /* No authorization for now, but the async polkit stuff will call us again when it has it */
25222533
25232534 r = call (m -> runtime_scope , flags , NULL , l , & changes , & n_changes );
2524- m -> unit_file_state_outdated = m -> unit_file_state_outdated || n_changes > 0 ; /* See comments for this variable in manager.h */
2535+ manager_unit_files_changed ( m , changes , n_changes );
25252536 if (r < 0 )
25262537 return install_error (error , r , changes , n_changes );
25272538
@@ -2594,7 +2605,7 @@ static int method_preset_unit_files_with_mode(sd_bus_message *message, void *use
25942605 return 1 ; /* No authorization for now, but the async polkit stuff will call us again when it has it */
25952606
25962607 r = unit_file_preset (m -> runtime_scope , flags , NULL , l , preset_mode , & changes , & n_changes );
2597- m -> unit_file_state_outdated = m -> unit_file_state_outdated || n_changes > 0 ; /* See comments for this variable in manager.h */
2608+ manager_unit_files_changed ( m , changes , n_changes );
25982609 if (r < 0 )
25992610 return install_error (error , r , changes , n_changes );
26002611
@@ -2648,7 +2659,7 @@ static int method_disable_unit_files_generic(
26482659 return 1 ; /* No authorization for now, but the async polkit stuff will call us again when it has it */
26492660
26502661 r = call (m -> runtime_scope , flags , NULL , l , & changes , & n_changes );
2651- m -> unit_file_state_outdated = m -> unit_file_state_outdated || n_changes > 0 ; /* See comments for this variable in manager.h */
2662+ manager_unit_files_changed ( m , changes , n_changes );
26522663 if (r < 0 )
26532664 return install_error (error , r , changes , n_changes );
26542665
@@ -2691,7 +2702,7 @@ static int method_revert_unit_files(sd_bus_message *message, void *userdata, sd_
26912702 return 1 ; /* No authorization for now, but the async polkit stuff will call us again when it has it */
26922703
26932704 r = unit_file_revert (m -> runtime_scope , NULL , l , & changes , & n_changes );
2694- m -> unit_file_state_outdated = m -> unit_file_state_outdated || n_changes > 0 ; /* See comments for this variable in manager.h */
2705+ manager_unit_files_changed ( m , changes , n_changes );
26952706 if (r < 0 )
26962707 return install_error (error , r , changes , n_changes );
26972708
@@ -2722,6 +2733,7 @@ static int method_set_default_target(sd_bus_message *message, void *userdata, sd
27222733 return 1 ; /* No authorization for now, but the async polkit stuff will call us again when it has it */
27232734
27242735 r = unit_file_set_default (m -> runtime_scope , force ? UNIT_FILE_FORCE : 0 , NULL , name , & changes , & n_changes );
2736+ manager_unit_files_changed (m , changes , n_changes );
27252737 if (r < 0 )
27262738 return install_error (error , r , changes , n_changes );
27272739
@@ -2764,7 +2776,7 @@ static int method_preset_all_unit_files(sd_bus_message *message, void *userdata,
27642776 return 1 ; /* No authorization for now, but the async polkit stuff will call us again when it has it */
27652777
27662778 r = unit_file_preset_all (m -> runtime_scope , flags , NULL , preset_mode , & changes , & n_changes );
2767- m -> unit_file_state_outdated = m -> unit_file_state_outdated || n_changes > 0 ; /* See comments for this variable in manager.h */
2779+ manager_unit_files_changed ( m , changes , n_changes );
27682780 if (r < 0 )
27692781 return install_error (error , r , changes , n_changes );
27702782
@@ -2804,7 +2816,7 @@ static int method_add_dependency_unit_files(sd_bus_message *message, void *userd
28042816 return - EINVAL ;
28052817
28062818 r = unit_file_add_dependency (m -> runtime_scope , flags , NULL , l , target , dep , & changes , & n_changes );
2807- m -> unit_file_state_outdated = m -> unit_file_state_outdated || n_changes > 0 ; /* See comments for this variable in manager.h */
2819+ manager_unit_files_changed ( m , changes , n_changes );
28082820 if (r < 0 )
28092821 return install_error (error , r , changes , n_changes );
28102822
0 commit comments