diff options
author | Colin Walters <walters@verbum.org> | 2021-08-25 17:45:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 17:45:28 -0400 |
commit | 28a079291910d9772fc3b19820d0cb0d946c095f (patch) | |
tree | 6ce5664e12456085b8160fed5607f14d76ffcb8b | |
parent | 30909a28f2aff54b615837a184f53509cbccc381 (diff) | |
parent | c64b4bcebafd06a0cbfc4b8e67fb3e20e99488bb (diff) | |
download | ostree-28a079291910d9772fc3b19820d0cb0d946c095f.tar.gz |
Merge pull request #2421 from lucab/ups/auto-txn-fixes
lib: improve transactions auto-cleanup logic
-rw-r--r-- | src/libostree/ostree-repo-private.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libostree/ostree-repo-private.h b/src/libostree/ostree-repo-private.h index 0cd9d8bb..67f755bd 100644 --- a/src/libostree/ostree-repo-private.h +++ b/src/libostree/ostree-repo-private.h @@ -234,9 +234,17 @@ typedef OstreeRepo _OstreeRepoAutoTransaction; static inline void _ostree_repo_auto_transaction_cleanup (void *p) { + if (p == NULL) + return; + g_return_if_fail (OSTREE_IS_REPO (p)); + OstreeRepo *repo = p; - if (repo) - (void) ostree_repo_abort_transaction (repo, NULL, NULL); + g_autoptr(GError) error = NULL; + + if (!ostree_repo_abort_transaction (repo, NULL, &error)) + g_warning("Failed to auto-cleanup OSTree transaction: %s", error->message); + + g_object_unref (repo); } static inline _OstreeRepoAutoTransaction * @@ -246,7 +254,8 @@ _ostree_repo_auto_transaction_start (OstreeRepo *repo, { if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error)) return NULL; - return (_OstreeRepoAutoTransaction *)repo; + + return (_OstreeRepoAutoTransaction *) g_object_ref (repo); } G_DEFINE_AUTOPTR_CLEANUP_FUNC (_OstreeRepoAutoTransaction, _ostree_repo_auto_transaction_cleanup) |