From c7c70844234ce49379734db8f39c52dc6fc5aad8 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 26 Mar 2015 16:55:51 -0700 Subject: [PATCH] NuDB: Enforce pool_thresh minimum of 1: pool_thresh is prevented from going to zero. This solves a problem when using callgrind where the CPU is monopolized, causing operations that should complete quickly to take days. --- beast/nudb/store.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/beast/nudb/store.h b/beast/nudb/store.h index dd8414e0f..a6355e782 100644 --- a/beast/nudb/store.h +++ b/beast/nudb/store.h @@ -124,7 +124,7 @@ private: detail::key_file_header const kh; // pool commit high water mark - std::size_t pool_thresh = 0; + std::size_t pool_thresh = 1; state (state const&) = delete; state& operator= (state const&) = delete; @@ -916,7 +916,9 @@ store::run() if (timeout) { m.lock(); - s_->pool_thresh /= 2; + s_->pool_thresh = + std::max( + 1, s_->pool_thresh / 2); s_->p1.shrink_to_fit(); s_->p0.shrink_to_fit(); s_->c1.shrink_to_fit();