[epiphany] gsb-service: Use atomic set/get on boolean flag



commit 3d8c44c04d9fa501deae1b860f46ae677a13f2ac
Author: Gabriel Ivascu <gabrielivascu gnome org>
Date:   Thu Nov 16 18:24:18 2017 +0200

    gsb-service: Use atomic set/get on boolean flag
    
    This flag is written/read from different threads.

 lib/safe-browsing/ephy-gsb-service.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/lib/safe-browsing/ephy-gsb-service.c b/lib/safe-browsing/ephy-gsb-service.c
index 73f57a6..b36592a 100644
--- a/lib/safe-browsing/ephy-gsb-service.c
+++ b/lib/safe-browsing/ephy-gsb-service.c
@@ -373,7 +373,7 @@ ephy_gsb_service_update_finished_cb (EphyGSBService *self,
                                      GAsyncResult   *result,
                                      gpointer        user_data)
 {
-  self->is_updating = FALSE;
+  g_atomic_int_set (&self->is_updating, FALSE);
   g_signal_emit (self, signals[UPDATE_FINISHED], 0);
   ephy_gsb_service_schedule_update (self);
 }
@@ -386,7 +386,7 @@ ephy_gsb_service_update (EphyGSBService *self)
   g_assert (EPHY_IS_GSB_SERVICE (self));
   g_assert (ephy_gsb_storage_is_operable (self->storage));
 
-  self->is_updating = TRUE;
+  g_atomic_int_set (&self->is_updating, TRUE);
   task = g_task_new (self, NULL,
                      (GAsyncReadyCallback)ephy_gsb_service_update_finished_cb,
                      NULL);
@@ -700,8 +700,13 @@ ephy_gsb_service_verify_url_thread (GTask          *task,
   /* If the local database is broken or an update is in course, we cannot
    * really verify the URL, so we have no choice other than to consider it safe.
    */
-  if (!ephy_gsb_storage_is_operable (self->storage) || self->is_updating) {
-    LOG ("Local GSB storage is not available at the moment, cannot verify URL");
+  if (g_atomic_int_get (&self->is_updating)) {
+    LOG ("Local GSB database is being updated, cannot verify URL");
+    goto out;
+  }
+
+  if (!ephy_gsb_storage_is_operable (self->storage)) {
+    LOG ("Local GSB database is broken, cannot verify URL");
     goto out;
   }
 


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