[gnome-software/wip/hughsie/duplicate-reviews: 2/4] trivial: Make adding and removing reviews thread safe



commit dc03c803f6eba2758aae66b0b0f41569b3ed96fa
Author: Richard Hughes <richard hughsie com>
Date:   Tue Apr 23 11:28:58 2019 +0100

    trivial: Make adding and removing reviews thread safe

 lib/gs-app.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index ef65988a..17a54673 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -2957,8 +2957,10 @@ void
 gs_app_add_review (GsApp *app, AsReview *review)
 {
        GsAppPrivate *priv = gs_app_get_instance_private (app);
+       g_autoptr(GMutexLocker) locker = NULL;
        g_return_if_fail (GS_IS_APP (app));
        g_return_if_fail (AS_IS_REVIEW (review));
+       locker = g_mutex_locker_new (&priv->mutex);
        g_ptr_array_add (priv->reviews, g_object_ref (review));
 }
 
@@ -2975,7 +2977,9 @@ void
 gs_app_remove_review (GsApp *app, AsReview *review)
 {
        GsAppPrivate *priv = gs_app_get_instance_private (app);
+       g_autoptr(GMutexLocker) locker = NULL;
        g_return_if_fail (GS_IS_APP (app));
+       locker = g_mutex_locker_new (&priv->mutex);
        g_ptr_array_remove (priv->reviews, review);
 }
 
@@ -3010,8 +3014,10 @@ void
 gs_app_add_provide (GsApp *app, AsProvide *provide)
 {
        GsAppPrivate *priv = gs_app_get_instance_private (app);
+       g_autoptr(GMutexLocker) locker = NULL;
        g_return_if_fail (GS_IS_APP (app));
        g_return_if_fail (AS_IS_PROVIDE (provide));
+       locker = g_mutex_locker_new (&priv->mutex);
        g_ptr_array_add (priv->provides, g_object_ref (provide));
 }
 


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