From 382ad59822ebbc7b3ca30058bb5bb450a6ff91be Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 5 Nov 2019 10:05:45 -0800 Subject: [PATCH 1/2] Bump version in symbols file There were no new symbols in 2019.5 and this version didn't get bumped when 2019.5 was released. --- src/libostree/libostree-devel.sym | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libostree/libostree-devel.sym b/src/libostree/libostree-devel.sym index 0b876f3b..d9d02056 100644 --- a/src/libostree/libostree-devel.sym +++ b/src/libostree/libostree-devel.sym @@ -18,7 +18,7 @@ ***/ /* Add new symbols here. Release commits should copy this section into -released.sym. */ -LIBOSTREE_2019.5 { +LIBOSTREE_2019.6 { } LIBOSTREE_2019.4; /* Stub section for the stable release *after* this development one; don't From 54639c03ca7713d71088f1ac9d323063d4c116d7 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 4 Nov 2019 13:21:36 -0800 Subject: [PATCH 2/2] libostree: Add ostree_async_progress_copy_state() This allows copying the state from one OstreeAsyncProgress object to another, atomically, without invoking the callback. This is needed in libflatpak, in order to chain OstreeAsyncProgress objects so that you can still receive progress updates when iterating a different GMainContext than the one that the OstreeAsyncProgress object was created under. See https://github.com/flatpak/flatpak/pull/3211 for the application of this API. --- apidoc/ostree-sections.txt | 1 + src/libostree/libostree-devel.sym | 1 + src/libostree/ostree-async-progress.c | 34 +++++++++++++++++++++++++++ src/libostree/ostree-async-progress.h | 4 ++++ 4 files changed, 40 insertions(+) diff --git a/apidoc/ostree-sections.txt b/apidoc/ostree-sections.txt index 252a563a..f99c4df5 100644 --- a/apidoc/ostree-sections.txt +++ b/apidoc/ostree-sections.txt @@ -3,6 +3,7 @@ OstreeAsyncProgress ostree_async_progress_new ostree_async_progress_new_and_connect +ostree_async_progress_copy_state ostree_async_progress_get_status ostree_async_progress_get ostree_async_progress_get_variant diff --git a/src/libostree/libostree-devel.sym b/src/libostree/libostree-devel.sym index d9d02056..646a4a21 100644 --- a/src/libostree/libostree-devel.sym +++ b/src/libostree/libostree-devel.sym @@ -19,6 +19,7 @@ /* Add new symbols here. Release commits should copy this section into -released.sym. */ LIBOSTREE_2019.6 { + ostree_async_progress_copy_state; } LIBOSTREE_2019.4; /* Stub section for the stable release *after* this development one; don't diff --git a/src/libostree/ostree-async-progress.c b/src/libostree/ostree-async-progress.c index 64372c27..8d6fdfe5 100644 --- a/src/libostree/ostree-async-progress.c +++ b/src/libostree/ostree-async-progress.c @@ -424,6 +424,40 @@ ostree_async_progress_set_uint64 (OstreeAsyncProgress *self, ostree_async_progress_set_variant (self, key, g_variant_new_uint64 (value)); } +/** + * ostree_async_progress_copy_state: + * @self: An #OstreeAsyncProgress to copy from + * @dest: An #OstreeAsyncProgress to copy to + * + * Atomically copies all the state from @self to @dest, without invoking the + * callback. + * This is used for proxying progress objects across different #GMainContexts. + * + * Since: 2019.6 + */ +void +ostree_async_progress_copy_state (OstreeAsyncProgress *self, + OstreeAsyncProgress *dest) +{ + g_return_if_fail (OSTREE_IS_ASYNC_PROGRESS (self)); + g_return_if_fail (OSTREE_IS_ASYNC_PROGRESS (dest)); + + g_mutex_lock (&self->lock); + + if (self->dead) + goto out; + + GLNX_HASH_TABLE_FOREACH_KV (self->values, void *, key, GVariant *, value) + { + if (value) + g_variant_ref (value); + g_hash_table_replace (dest->values, key, value); + } + + out: + g_mutex_unlock (&self->lock); +} + /** * ostree_async_progress_new: * diff --git a/src/libostree/ostree-async-progress.h b/src/libostree/ostree-async-progress.h index 45a80cfb..475d7f62 100644 --- a/src/libostree/ostree-async-progress.h +++ b/src/libostree/ostree-async-progress.h @@ -92,4 +92,8 @@ void ostree_async_progress_set_variant (OstreeAsyncProgress *self, _OSTREE_PUBLIC void ostree_async_progress_finish (OstreeAsyncProgress *self); +_OSTREE_PUBLIC +void ostree_async_progress_copy_state (OstreeAsyncProgress *self, + OstreeAsyncProgress *dest); + G_END_DECLS