[Xfce4-commits] <tumbler:master> Wrap request unqueued check with the mutex to make the check atomic.

Jannis Pohlmann noreply at xfce.org
Thu Oct 8 13:52:01 CEST 2009


Updating branch refs/heads/master
         to f583df4a3bf353ad577723c5fce538b872fd9e47 (commit)
       from f2be883615ab5e226cd0b377ac8a83b3701cb768 (commit)

commit f583df4a3bf353ad577723c5fce538b872fd9e47
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Thu Oct 8 13:38:39 2009 +0200

    Wrap request unqueued check with the mutex to make the check atomic.

 tumblerd/tumbler-group-scheduler.c |   12 ++++++------
 tumblerd/tumbler-lifo-scheduler.c  |    8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tumblerd/tumbler-group-scheduler.c b/tumblerd/tumbler-group-scheduler.c
index c97f97f..8429cfa 100644
--- a/tumblerd/tumbler-group-scheduler.c
+++ b/tumblerd/tumbler-group-scheduler.c
@@ -370,25 +370,25 @@ tumbler_group_scheduler_thread (gpointer data,
   g_signal_emit_by_name (request->scheduler, "started", request->handle);
 
   /* finish the request if it was unqueued */
+  g_mutex_lock (scheduler->mutex);
   if (request->unqueued)
     {
-      g_mutex_lock (scheduler->mutex);
       tumbler_group_scheduler_finish_request (scheduler, request);
-      g_mutex_unlock (scheduler->mutex);
       return;
     }
+  g_mutex_unlock (scheduler->mutex);
 
   /* process URI by URI */
   for (n = 0; request->uris[n] != NULL; ++n)
     {
       /* finish the request if it was unqueued */
+      g_mutex_lock (scheduler->mutex);
       if (request->unqueued)
         {
-          g_mutex_lock (scheduler->mutex);
           tumbler_group_scheduler_finish_request (scheduler, request);
-          g_mutex_unlock (scheduler->mutex);
           return;
         }
+      g_mutex_unlock (scheduler->mutex);
 
       /* create a file infor for the current URI */
       info = tumbler_file_info_new (request->uris[n]);
@@ -485,13 +485,13 @@ tumbler_group_scheduler_thread (gpointer data,
       n = GPOINTER_TO_INT (lp->data);
 
       /* finish the request if it was unqueued */
+      g_mutex_lock (scheduler->mutex);
       if (request->unqueued)
         {
-          g_mutex_lock (scheduler->mutex);
           tumbler_group_scheduler_finish_request (scheduler, request);
-          g_mutex_unlock (scheduler->mutex);
           return;
         }
+      g_mutex_unlock (scheduler->mutex);
 
       /* connect to the error signal of the thumbnailer */
       g_signal_connect (request->thumbnailers[n], "error", 
diff --git a/tumblerd/tumbler-lifo-scheduler.c b/tumblerd/tumbler-lifo-scheduler.c
index 3335eb5..d314c51 100644
--- a/tumblerd/tumbler-lifo-scheduler.c
+++ b/tumblerd/tumbler-lifo-scheduler.c
@@ -317,25 +317,25 @@ tumbler_lifo_scheduler_thread (gpointer data,
   g_signal_emit_by_name (request->scheduler, "started", request->handle);
 
   /* finish the request if it was already unqueued */
+  g_mutex_lock (scheduler->mutex);
   if (request->unqueued)
     {
-      g_mutex_lock (scheduler->mutex);
       tumbler_lifo_scheduler_finish_request (scheduler, request);
-      g_mutex_unlock (scheduler->mutex);
       return;
     }
+  g_mutex_unlock (scheduler->mutex);
 
   /* process URI by URI */
   for (n = 0; request->uris[n] != NULL; ++n)
     {
       /* finish the request if it was unqueued */
+      g_mutex_lock (scheduler->mutex);
       if (request->unqueued)
         {
-          g_mutex_lock (scheduler->mutex);
           tumbler_lifo_scheduler_finish_request (scheduler, request);
-          g_mutex_unlock (scheduler->mutex);
           return;
         }
+      g_mutex_unlock (scheduler->mutex);
 
       /* create a file info for the current URI */
       info = tumbler_file_info_new (request->uris[n]);



More information about the Xfce4-commits mailing list