summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/include/ut0wqueue.h15
-rw-r--r--storage/innobase/ut/ut0wqueue.cc19
-rw-r--r--storage/xtradb/include/ut0wqueue.h15
-rw-r--r--storage/xtradb/ut/ut0wqueue.cc19
4 files changed, 28 insertions, 40 deletions
diff --git a/storage/innobase/include/ut0wqueue.h b/storage/innobase/include/ut0wqueue.h
index 47930145426..dcd3feabe72 100644
--- a/storage/innobase/include/ut0wqueue.h
+++ b/storage/innobase/include/ut0wqueue.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2006, 2009, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -67,15 +67,10 @@ ib_wqueue_add(
mem_heap_t* heap); /*!< in: memory heap to use for allocating the
list node */
-/********************************************************************
-Check if queue is empty. */
-
-ibool
-ib_wqueue_is_empty(
-/*===============*/
- /* out: TRUE if queue empty
- else FALSE */
- const ib_wqueue_t* wq); /* in: work queue */
+/** Check if queue is empty.
+@param wq wait queue
+@return whether the queue is empty */
+bool ib_wqueue_is_empty(ib_wqueue_t* wq);
/****************************************************************//**
Wait for a work item to appear in the queue.
diff --git a/storage/innobase/ut/ut0wqueue.cc b/storage/innobase/ut/ut0wqueue.cc
index 1607e535a94..fce39bd817e 100644
--- a/storage/innobase/ut/ut0wqueue.cc
+++ b/storage/innobase/ut/ut0wqueue.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -193,17 +194,15 @@ ib_wqueue_nowait(
return (node ? node->data : NULL);
}
-/********************************************************************
-Check if queue is empty. */
-
-ibool
-ib_wqueue_is_empty(
-/*===============*/
- /* out: TRUE if queue empty
- else FALSE */
- const ib_wqueue_t* wq) /* in: work queue */
+/** Check if queue is empty.
+@param wq wait queue
+@return whether the queue is empty */
+bool ib_wqueue_is_empty(ib_wqueue_t* wq)
{
- return(ib_list_is_empty(wq->items));
+ mutex_enter(&wq->mutex);
+ bool is_empty = ib_list_is_empty(wq->items);
+ mutex_exit(&wq->mutex);
+ return is_empty;
}
/********************************************************************
diff --git a/storage/xtradb/include/ut0wqueue.h b/storage/xtradb/include/ut0wqueue.h
index d69363afe7b..e0f8f76d5f1 100644
--- a/storage/xtradb/include/ut0wqueue.h
+++ b/storage/xtradb/include/ut0wqueue.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2006, 2009, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -67,15 +67,10 @@ ib_wqueue_add(
mem_heap_t* heap); /*!< in: memory heap to use for allocating the
list node */
-/********************************************************************
-Check if queue is empty. */
-
-ibool
-ib_wqueue_is_empty(
-/*===============*/
- /* out: TRUE if queue empty
- else FALSE */
- const ib_wqueue_t* wq); /* in: work queue */
+/** Check if queue is empty.
+@param wq wait queue
+@return whether the queue is empty */
+bool ib_wqueue_is_empty(ib_wqueue_t* wq);
/****************************************************************//**
Wait for a work item to appear in the queue.
diff --git a/storage/xtradb/ut/ut0wqueue.cc b/storage/xtradb/ut/ut0wqueue.cc
index 1607e535a94..fce39bd817e 100644
--- a/storage/xtradb/ut/ut0wqueue.cc
+++ b/storage/xtradb/ut/ut0wqueue.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -193,17 +194,15 @@ ib_wqueue_nowait(
return (node ? node->data : NULL);
}
-/********************************************************************
-Check if queue is empty. */
-
-ibool
-ib_wqueue_is_empty(
-/*===============*/
- /* out: TRUE if queue empty
- else FALSE */
- const ib_wqueue_t* wq) /* in: work queue */
+/** Check if queue is empty.
+@param wq wait queue
+@return whether the queue is empty */
+bool ib_wqueue_is_empty(ib_wqueue_t* wq)
{
- return(ib_list_is_empty(wq->items));
+ mutex_enter(&wq->mutex);
+ bool is_empty = ib_list_is_empty(wq->items);
+ mutex_exit(&wq->mutex);
+ return is_empty;
}
/********************************************************************