Skip to content

Commit

Permalink
app/dbus: Always call Reload() after transaction
Browse files Browse the repository at this point in the history
Specifically in this case, this allows us to close a race condition
during `upgrade --check` where the `CachedUpdate` property might not
have been updated yet when we read it after finishing the transaction.

Closes: #1311
Approved by: cgwalters
  • Loading branch information
jlebon authored and rh-atomic-bot committed Mar 23, 2018
1 parent 37306e3 commit 706506b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/app/rpmostree-dbus-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,16 @@ rpmostree_transaction_connect_active (RPMOSTreeSysroot *sysroot_proxy,
return FALSE;
}

static void
on_reload_done (GObject *src,
GAsyncResult *res,
gpointer user_data)
{
gboolean *donep = user_data;
*donep = TRUE;
(void) rpmostree_sysroot_call_reload_finish ((RPMOSTreeSysroot*)src, res, NULL);
}

/* Transactions need an explicit Start call so we can set up watches for signals
* beforehand and avoid losing information. We monitor the transaction,
* printing output it sends, and handle Ctrl-C, etc.
Expand Down Expand Up @@ -784,6 +794,16 @@ rpmostree_transaction_get_response_sync (RPMOSTreeSysroot *sysroot_proxy,
}
}

/* On success, call Reload() as a way to sync with the daemon. Do this in async mode so
* that gdbus handles signals for changed properties. */
if (success)
{
gboolean done = FALSE;
rpmostree_sysroot_call_reload (sysroot_proxy, NULL, on_reload_done, &done);
while (!done)
g_main_context_iteration (NULL, TRUE);
}

out:
if (sigintid)
g_source_remove (sigintid);
Expand Down
3 changes: 3 additions & 0 deletions tests/vmcheck/test-autoupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ assert_output
echo "ok check mode layered only with advisories"

# check we see the same output with --check/--preview
# clear out cache first to make sure they start from scratch
vm_rpmostree cleanup -m
vm_cmd systemctl stop rpm-ostreed
vm_rpmostree upgrade --check > out.txt
vm_rpmostree upgrade --preview > out-verbose.txt
assert_output
Expand Down

0 comments on commit 706506b

Please sign in to comment.