summary refs log tree commit diff stats
path: root/thread-pool.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2015-04-02 17:39:22 +0100
committerKevin Wolf <kwolf@redhat.com>2015-04-28 15:36:09 +0200
commit1faa5bb73247339bf3d797433a9ade990ef0fb32 (patch)
treea90709ca58f1e5bb1616a6dc0b9a7843ab9cbb87 /thread-pool.c
parentd1a126c53ddc563b7b731cee013e0362f7a5f22f (diff)
downloadfocaccia-qemu-1faa5bb73247339bf3d797433a9ade990ef0fb32.tar.gz
focaccia-qemu-1faa5bb73247339bf3d797433a9ade990ef0fb32.zip
thread-pool: clean up thread_pool_completion_bh()
This patch simplifies thread_pool_completion_bh().

The function first checks elem->state:

  if (elem->state != THREAD_DONE) {
      continue;
  }

It then goes on to check elem->state == THREAD_DONE although we already
know this must be the case.

The QLIST_REMOVE() is duplicated down both branches of an if-else
statement so that can be lifted out as well.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1427992762-10126-1-git-send-email-stefanha@redhat.com
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'thread-pool.c')
-rw-r--r--thread-pool.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/thread-pool.c b/thread-pool.c
index e2cac8e4ff..ac909f4986 100644
--- a/thread-pool.c
+++ b/thread-pool.c
@@ -170,12 +170,12 @@ restart:
         if (elem->state != THREAD_DONE) {
             continue;
         }
-        if (elem->state == THREAD_DONE) {
-            trace_thread_pool_complete(pool, elem, elem->common.opaque,
-                                       elem->ret);
-        }
-        if (elem->state == THREAD_DONE && elem->common.cb) {
-            QLIST_REMOVE(elem, all);
+
+        trace_thread_pool_complete(pool, elem, elem->common.opaque,
+                                   elem->ret);
+        QLIST_REMOVE(elem, all);
+
+        if (elem->common.cb) {
             /* Read state before ret.  */
             smp_rmb();
 
@@ -188,8 +188,6 @@ restart:
             qemu_aio_unref(elem);
             goto restart;
         } else {
-            /* remove the request */
-            QLIST_REMOVE(elem, all);
             qemu_aio_unref(elem);
         }
     }