Skip to content

Commit 365b2e8

Browse files
committed
fix quota manager not exiting properly on stop
1 parent faf9e44 commit 365b2e8

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,23 @@ int main(int argc, char *argv[]) {
171171
fuse_loop_cfg_set_max_threads(loop_config, fs.num_threads);
172172
fuse_loop_cfg_set_clone_fd(loop_config, fs.clone_fd);
173173

174+
debug_print("Filesystem mounted at {}", mountpoint);
175+
174176
int ret =
175177
options.count("single") ? fuse_session_loop(se) : fuse_session_loop_mt(se, loop_config);
176178

179+
debug_print("Filesystem unmounting");
180+
177181
fuse_session_unmount(se);
178182
fuse_remove_signal_handlers(se);
179183

184+
debug_print("Filesystem unmounted");
185+
180186
fs.shutdown_complete.release();
181187

182188
fuse_opt_free_args(&args);
183189

190+
debug_print("Filesystem exited with code {}", ret);
191+
184192
return ret;
185193
}

src/quota.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "quota.hpp"
2+
#include <condition_variable>
3+
#include <mutex>
24
#include <unordered_set>
35
#include "inode.hpp"
46

@@ -48,8 +50,16 @@ void QuotaManager::calculate_usage() {
4850
}
4951

5052
void QuotaManager::background_scanner(std::stop_token st) {
53+
std::mutex mtx;
54+
std::condition_variable_any cv;
55+
5156
while (!st.stop_requested()) {
52-
if (std::this_thread::sleep_for(rescan_interval); st.stop_requested()) {
57+
std::unique_lock lock(mtx);
58+
59+
bool stop_now =
60+
cv.wait_for(lock, st, rescan_interval, [&st] { return st.stop_requested(); });
61+
62+
if (stop_now) {
5363
break;
5464
}
5565

0 commit comments

Comments
 (0)