1.1 --- a/libfsserver/lib/pages/page_queue.cc Sat May 11 23:53:40 2024 +0200
1.2 +++ b/libfsserver/lib/pages/page_queue.cc Tue Jun 25 13:53:18 2024 +0200
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * A page queue abstraction.
1.6 *
1.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2021, 2024 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -29,6 +29,8 @@
1.13
1.14
1.15
1.16 +/* Utility methods to be used within critical sections. */
1.17 +
1.18 void PageQueue::discard(Queue &queue, Memory *memory)
1.19 {
1.20 while (!queue.empty())
2.1 --- a/libfsserver/lib/pages/page_queue_partitioned.cc Sat May 11 23:53:40 2024 +0200
2.2 +++ b/libfsserver/lib/pages/page_queue_partitioned.cc Tue Jun 25 13:53:18 2024 +0200
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 * A page queue retaining two internal collections of memory pages.
2.6 *
2.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) 2021, 2024 Paul Boddie <paul@boddie.org.uk>
2.9 *
2.10 * This program is free software; you can redistribute it and/or
2.11 * modify it under the terms of the GNU General Public License as
2.12 @@ -27,6 +27,8 @@
2.13
2.14 void PageQueuePartitioned::close(Memory *memory)
2.15 {
2.16 + std::lock_guard<std::mutex> guard(_lock);
2.17 +
2.18 discard(_available, memory);
2.19 discard(_issued, memory);
2.20 }
2.21 @@ -127,6 +129,8 @@
2.22
2.23 bool PageQueuePartitioned::remove(PageOwner *owner, Flexpage *flexpage)
2.24 {
2.25 + std::lock_guard<std::mutex> guard(_lock);
2.26 +
2.27 return PageQueue::remove(_issued, _positions, owner, flexpage);
2.28 }
2.29
3.1 --- a/libfsserver/lib/pages/page_queue_shared.cc Sat May 11 23:53:40 2024 +0200
3.2 +++ b/libfsserver/lib/pages/page_queue_shared.cc Tue Jun 25 13:53:18 2024 +0200
3.3 @@ -1,7 +1,7 @@
3.4 /*
3.5 * A page queue whose users take turns to access pages.
3.6 *
3.7 - * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
3.8 + * Copyright (C) 2021, 2024 Paul Boddie <paul@boddie.org.uk>
3.9 *
3.10 * This program is free software; you can redistribute it and/or
3.11 * modify it under the terms of the GNU General Public License as
3.12 @@ -27,6 +27,8 @@
3.13
3.14 void PageQueueShared::close(Memory *memory)
3.15 {
3.16 + std::lock_guard<std::mutex> guard(_lock);
3.17 +
3.18 discard(_queue, memory);
3.19 }
3.20
3.21 @@ -106,6 +108,8 @@
3.22
3.23 bool PageQueueShared::remove(PageOwner *owner, Flexpage *flexpage)
3.24 {
3.25 + std::lock_guard<std::mutex> guard(_lock);
3.26 +
3.27 return PageQueue::remove(_queue, _positions, owner, flexpage);
3.28 }
3.29