Accepting request 723404 from home:JonathanKang:branches:GNOME:Factory
OBS-URL: https://build.opensuse.org/request/show/723404 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/PackageKit?expand=0&rev=354
This commit is contained in:
parent
f79414d722
commit
e326744659
@ -0,0 +1,93 @@
|
||||
From 1b028d0598224fbb1510355c4a7dee7d25873872 Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Kang <jonathankang@gnome.org>
|
||||
Date: Fri, 8 Mar 2019 21:44:08 +0800
|
||||
Subject: [PATCH] Add mutex lock to protect backend->priv->eulas (#303)
|
||||
|
||||
pk_is_thread_default() check was introduced in commit 44bd3ab6 to
|
||||
detect possible threading problems.
|
||||
|
||||
Some backends need call pk_backend_is_eula_valid() in a thread which is
|
||||
not the default one to perform EULA related actions. This way
|
||||
pk_is_thread_default() check fails.
|
||||
|
||||
Fix that by removing the pk_is_thread_default() checks in related
|
||||
functions and add mutex lock to avoid eulas to be accessed in multiple
|
||||
threads at the same time.
|
||||
|
||||
Fixes #300
|
||||
---
|
||||
src/pk-backend.c | 15 ++++++++++++---
|
||||
1 file changed, 12 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/pk-backend.c b/src/pk-backend.c
|
||||
index 38f32a04c..c05f6c0cd 100644
|
||||
--- a/src/pk-backend.c
|
||||
+++ b/src/pk-backend.c
|
||||
@@ -189,6 +189,7 @@ struct PkBackendPrivate
|
||||
gchar *name;
|
||||
gpointer file_changed_data;
|
||||
GHashTable *eulas;
|
||||
+ GMutex eulas_mutex;
|
||||
GModule *handle;
|
||||
PkBackendDesc *desc;
|
||||
PkBackendFileChanged file_changed_func;
|
||||
@@ -935,10 +936,12 @@ void
|
||||
pk_backend_accept_eula (PkBackend *backend, const gchar *eula_id)
|
||||
{
|
||||
gpointer present;
|
||||
+ g_autoptr(GMutexLocker) locker = NULL;
|
||||
+
|
||||
+ locker = g_mutex_locker_new (&backend->priv->eulas_mutex);
|
||||
|
||||
g_return_if_fail (PK_IS_BACKEND (backend));
|
||||
g_return_if_fail (eula_id != NULL);
|
||||
- g_return_if_fail (pk_is_thread_default ());
|
||||
|
||||
present = g_hash_table_lookup (backend->priv->eulas, eula_id);
|
||||
if (present != NULL) {
|
||||
@@ -952,10 +955,12 @@ gboolean
|
||||
pk_backend_is_eula_valid (PkBackend *backend, const gchar *eula_id)
|
||||
{
|
||||
gpointer present;
|
||||
+ g_autoptr(GMutexLocker) locker = NULL;
|
||||
+
|
||||
+ locker = g_mutex_locker_new (&backend->priv->eulas_mutex);
|
||||
|
||||
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
|
||||
g_return_val_if_fail (eula_id != NULL, FALSE);
|
||||
- g_return_val_if_fail (pk_is_thread_default (), FALSE);
|
||||
|
||||
present = g_hash_table_lookup (backend->priv->eulas, eula_id);
|
||||
if (present != NULL)
|
||||
@@ -969,9 +974,11 @@ pk_backend_get_accepted_eula_string (PkBackend *backend)
|
||||
GString *string;
|
||||
GList *l;
|
||||
g_autoptr(GList) keys = NULL;
|
||||
+ g_autoptr(GMutexLocker) locker = NULL;
|
||||
+
|
||||
+ locker = g_mutex_locker_new (&backend->priv->eulas_mutex);
|
||||
|
||||
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
|
||||
- g_return_val_if_fail (pk_is_thread_default (), FALSE);
|
||||
|
||||
/* optimise for the common case */
|
||||
if (g_hash_table_size (backend->priv->eulas) == 0)
|
||||
@@ -1065,6 +1072,7 @@ pk_backend_finalize (GObject *object)
|
||||
g_key_file_unref (backend->priv->conf);
|
||||
g_hash_table_destroy (backend->priv->eulas);
|
||||
|
||||
+ g_mutex_clear (&backend->priv->eulas_mutex);
|
||||
g_mutex_clear (&backend->priv->thread_hash_mutex);
|
||||
g_hash_table_unref (backend->priv->thread_hash);
|
||||
g_free (backend->priv->desc);
|
||||
@@ -1708,6 +1716,7 @@ pk_backend_init (PkBackend *backend)
|
||||
g_direct_equal,
|
||||
NULL,
|
||||
g_free);
|
||||
+ g_mutex_init (&backend->priv->eulas_mutex);
|
||||
g_mutex_init (&backend->priv->thread_hash_mutex);
|
||||
}
|
||||
|
||||
--
|
||||
2.21.0
|
||||
|
@ -1,35 +0,0 @@
|
||||
From 8060817fcc4fa31c5fc66da988027c4ea5810be9 Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Kang <jonathankang@gnome.org>
|
||||
Date: Wed, 26 Dec 2018 11:18:42 +0800
|
||||
Subject: [PATCH] Remove pk_is_thread_default check in pk_backend_is_eula_valid
|
||||
|
||||
pk_is_thread_default() check was introduced in commit 44bd3ab6 to
|
||||
detect possible threading problems.
|
||||
|
||||
Some backends need call pk_backend_is_eula_valid() in a thread which is
|
||||
not the default one to perform EULA related actions. This way
|
||||
pk_is_thread_default() check fails.
|
||||
|
||||
Fix that by removing the pk_is_thread_default() check in
|
||||
pk_backend_is_eula_valid().
|
||||
|
||||
Fixes #300
|
||||
---
|
||||
src/pk-backend.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/src/pk-backend.c b/src/pk-backend.c
|
||||
index 38f32a04c..2dc464938 100644
|
||||
--- a/src/pk-backend.c
|
||||
+++ b/src/pk-backend.c
|
||||
@@ -955,7 +955,6 @@ pk_backend_is_eula_valid (PkBackend *backend, const gchar *eula_id)
|
||||
|
||||
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
|
||||
g_return_val_if_fail (eula_id != NULL, FALSE);
|
||||
- g_return_val_if_fail (pk_is_thread_default (), FALSE);
|
||||
|
||||
present = g_hash_table_lookup (backend->priv->eulas, eula_id);
|
||||
if (present != NULL)
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Aug 14 01:32:01 UTC 2019 - Jonathan Kang <sckang@suse.com>
|
||||
|
||||
- Rename PackageKit-remove-default-thread-check.patch to
|
||||
PackageKit-add-mutex-lock-to-protect-backend-priv-eulas.patch,
|
||||
and update it with the one accepted upstream.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 19 08:17:22 UTC 2019 - Jonathan Kang <sckang@suse.com>
|
||||
|
||||
|
@ -43,8 +43,8 @@ Source99: PackageKit.keyring
|
||||
Patch0: PackageKit-cron-without-sleep.patch
|
||||
# PATCH-FIX-UPSTREAM PackageKit-return-on-transactions-going-backwards.patch gh#hughsie/PackageKit#301, bsc#1038425 sckang@suse.com -- transaction: Return directly when its state is going backwards
|
||||
Patch1: PackageKit-return-on-transactions-going-backwards.patch
|
||||
# PATCH-FIX-UPSTREAM PackageKit-remove-default-thread-check.patch gh#hughsie/PackageKit#303, bsc#1038425 sckang@suse.com -- Remove pk_is_thread_default() check in pk_backend_is_eula_valid
|
||||
Patch2: PackageKit-remove-default-thread-check.patch
|
||||
# PATCH-FIX-UPSTREAM PackageKit-add-mutex-lock-to-protect-backend-priv-eulas.patch gh#hughsie/PackageKit#303, bsc#1038425 sckang@suse.com -- Remove pk_is_thread_default() check in pk_backend_is_eula_valid
|
||||
Patch2: PackageKit-add-mutex-lock-to-protect-backend-priv-eulas.patch
|
||||
# PATCH-FEATURE-OPENSUSE PackageKit-systemd-timers.patch bsc#1115410 sckang@suse.com -- Migrate from cron to systemd timers
|
||||
Patch3: PackageKit-systemd-timers.patch
|
||||
Patch4: zypp-Switch-to-doUpgrade-solver-when-required-by-distribution.patch
|
||||
|
Loading…
Reference in New Issue
Block a user