[gnome-software/554-keeps-rpm-ostreed-alive-forever: 17/19] rpm-ostree: Correct detection of a transaction name owner disappear




commit f47282c54a44e4966baf752f7e7b1537b132e5b0
Author: Milan Crha <mcrha redhat com>
Date:   Wed Apr 7 18:23:29 2021 +0200

    rpm-ostree: Correct detection of a transaction name owner disappear
    
    The GDBusProxy name owner can be NULL shortly after the proxy is created,
    due to delayed D-Bus property value synchronization to the client, thus
    count with it instead of claiming the other side disappeared (crashed)
    before the transaction even begun.

 plugins/rpm-ostree/gs-plugin-rpm-ostree.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
index 78933e012..39c8fe8f3 100644
--- a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
+++ b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c
@@ -240,6 +240,7 @@ typedef struct {
        GMainContext *context;
        GsApp *app;
        gboolean complete;
+       gboolean owner_changed;
 } TransactionProgress;
 
 static TransactionProgress *
@@ -332,6 +333,8 @@ on_owner_notify (GObject    *obj,
 {
        TransactionProgress *tp = user_data;
 
+       tp->owner_changed = TRUE;
+
        /* Wake up the context so it can notice the server has disappeared. */
        g_main_context_wakeup (tp->context);
 }
@@ -358,6 +361,7 @@ gs_rpmostree_transaction_get_response_sync (GsRPMOSTreeSysroot *sysroot_proxy,
        gulong notify_handler = 0;
        gboolean success = FALSE;
        gboolean just_started = FALSE;
+       gboolean saw_name_owner = FALSE;
        g_autofree gchar *name_owner = NULL;
 
        peer_connection = g_dbus_connection_new_for_address_sync (transaction_address,
@@ -401,9 +405,15 @@ gs_rpmostree_transaction_get_response_sync (GsRPMOSTreeSysroot *sysroot_proxy,
                goto out;
 
        /* Process all the signals until we receive the Finished signal or the
-        * daemon disappears (which can happen if it crashes). */
+        * daemon disappears (which can happen if it crashes).
+        *
+        * The property can be NULL right after connecting to it, before the D-Bus
+        * transfers the property value to the client. */
        while (!tp->complete &&
-              (name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (transaction))) != NULL) {
+              !g_cancellable_is_cancelled (cancellable) &&
+              ((name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (transaction))) != NULL ||
+               (!saw_name_owner && !tp->owner_changed))) {
+               saw_name_owner = saw_name_owner || name_owner != NULL;
                g_clear_pointer (&name_owner, g_free);
                g_main_context_iteration (tp->context, TRUE);
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]