@@ -662,8 +662,8 @@ const sd_bus_vtable bus_unit_vtable[] = {
662662 SD_BUS_PROPERTY ("AssertResult" , "b" , bus_property_get_bool , offsetof(Unit , assert_result ), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ),
663663 BUS_PROPERTY_DUAL_TIMESTAMP ("ConditionTimestamp" , offsetof(Unit , condition_timestamp ), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ),
664664 BUS_PROPERTY_DUAL_TIMESTAMP ("AssertTimestamp" , offsetof(Unit , assert_timestamp ), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ),
665- SD_BUS_PROPERTY ("Conditions" , "a(sbbsi)" , property_get_conditions , offsetof(Unit , conditions ), 0 ),
666- SD_BUS_PROPERTY ("Asserts" , "a(sbbsi)" , property_get_conditions , offsetof(Unit , asserts ), 0 ),
665+ SD_BUS_PROPERTY ("Conditions" , "a(sbbsi)" , property_get_conditions , offsetof(Unit , conditions ), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION ),
666+ SD_BUS_PROPERTY ("Asserts" , "a(sbbsi)" , property_get_conditions , offsetof(Unit , asserts ), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION ),
667667 SD_BUS_PROPERTY ("LoadError" , "(ss)" , property_get_load_error , 0 , SD_BUS_VTABLE_PROPERTY_CONST ),
668668 SD_BUS_PROPERTY ("Transient" , "b" , bus_property_get_bool , offsetof(Unit , transient ), SD_BUS_VTABLE_PROPERTY_CONST ),
669669 SD_BUS_PROPERTY ("Perpetual" , "b" , bus_property_get_bool , offsetof(Unit , perpetual ), SD_BUS_VTABLE_PROPERTY_CONST ),
@@ -675,8 +675,8 @@ const sd_bus_vtable bus_unit_vtable[] = {
675675 SD_BUS_PROPERTY ("SuccessAction" , "s" , property_get_emergency_action , offsetof(Unit , success_action ), SD_BUS_VTABLE_PROPERTY_CONST ),
676676 SD_BUS_PROPERTY ("SuccessActionExitStatus" , "i" , bus_property_get_int , offsetof(Unit , success_action_exit_status ), SD_BUS_VTABLE_PROPERTY_CONST ),
677677 SD_BUS_PROPERTY ("RebootArgument" , "s" , NULL , offsetof(Unit , reboot_arg ), SD_BUS_VTABLE_PROPERTY_CONST ),
678- SD_BUS_PROPERTY ("InvocationID" , "ay" , bus_property_get_id128 , offsetof(Unit , invocation_id ), 0 ),
679- SD_BUS_PROPERTY ("CollectMode" , "s" , property_get_collect_mode , offsetof(Unit , collect_mode ), 0 ),
678+ SD_BUS_PROPERTY ("InvocationID" , "ay" , bus_property_get_id128 , offsetof(Unit , invocation_id ), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ),
679+ SD_BUS_PROPERTY ("CollectMode" , "s" , property_get_collect_mode , offsetof(Unit , collect_mode ), SD_BUS_VTABLE_PROPERTY_CONST ),
680680 SD_BUS_PROPERTY ("Refs" , "as" , property_get_refs , 0 , 0 ),
681681
682682 SD_BUS_METHOD ("Start" , "s" , "o" , method_start , SD_BUS_VTABLE_UNPRIVILEGED ),
@@ -1202,6 +1202,27 @@ void bus_unit_send_change_signal(Unit *u) {
12021202 u -> sent_dbus_new_signal = true;
12031203}
12041204
1205+ void bus_unit_send_pending_change_signal (Unit * u , bool including_new ) {
1206+
1207+ /* Sends out any pending change signals, but only if they really are pending. This call is used when we are
1208+ * about to change state in order to force out a PropertiesChanged signal beforehand if there was one pending
1209+ * so that clients can follow the full state transition */
1210+
1211+ if (!u -> in_dbus_queue ) /* If not enqueued, don't bother */
1212+ return ;
1213+
1214+ if (!u -> sent_dbus_new_signal && !including_new ) /* If the unit was never announced, don't bother, it's fine if
1215+ * the unit appears in the new state right-away (except if the
1216+ * caller explicitly asked us to send it anyway) */
1217+ return ;
1218+
1219+ if (MANAGER_IS_RELOADING (u -> manager )) /* Don't generate unnecessary PropertiesChanged signals for the same unit
1220+ * when we are reloading. */
1221+ return ;
1222+
1223+ bus_unit_send_change_signal (u );
1224+ }
1225+
12051226static int send_removed_signal (sd_bus * bus , void * userdata ) {
12061227 _cleanup_ (sd_bus_message_unrefp ) sd_bus_message * m = NULL ;
12071228 _cleanup_free_ char * p = NULL ;
@@ -1300,6 +1321,9 @@ int bus_unit_queue_job(
13001321 if (!path )
13011322 return - ENOMEM ;
13021323
1324+ /* Before we send the method reply, force out the announcement JobNew for this job */
1325+ bus_job_send_pending_change_signal (j , true);
1326+
13031327 return sd_bus_reply_method_return (message , "o" , path );
13041328}
13051329
0 commit comments