lfq baseline: check for empty list
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 5 Sep 2011 00:10:41 +0000 (20:10 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 5 Sep 2011 00:10:41 +0000 (20:10 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/test_lfq_baseline.c

index 4f0eba21a8651a1ba0bd92a4c76b620373c8a2f6..c35d8941bb6980c8933f518db12413e544ee70c6 100644 (file)
@@ -242,9 +242,12 @@ void *thr_dequeuer(void *_count)
                struct test *node;
 
                test_mutex_lock();
-               node = cds_list_first_entry(&q, struct test, node);
-               if (node)
+               if (!cds_list_empty(&q)) {
+                       node = cds_list_first_entry(&q, struct test, node);
                        cds_list_del(&node->node);
+               } else {
+                       node = NULL;
+               }
                test_mutex_unlock();
 
                if (node) {
@@ -273,7 +276,11 @@ void test_end(unsigned long long *nr_dequeues)
        struct test *node;
 
        do {
-               node = cds_list_first_entry(&q, struct test, node);
+               if (!cds_list_empty(&q)) {
+                       node = cds_list_first_entry(&q, struct test, node);
+               } else {
+                       node = NULL;
+               }
                if (node) {
                        cds_list_del(&node->node);
                        free(node);     /* no more concurrent access */
This page took 0.026224 seconds and 4 git commands to generate.