mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-29 19:37:00 -05:00
Replace usleep with nanosleep in monitor thread
usleep is POSIX-obsolescent and its behavior on signal interruption is under-specified. Replace with nanosleep which is the current POSIX standard and has well-defined EINTR semantics. Pre-compute the timespec once outside the loop since the interval is constant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f8ac649e6f
commit
d166418675
1 changed files with 6 additions and 1 deletions
|
|
@ -481,9 +481,14 @@ ThreadPool::monitor_routine(void *arg_)
|
|||
constexpr int decline_threshold = 2;
|
||||
int warmup_samples = 0;
|
||||
|
||||
const struct timespec sleep_ts = {
|
||||
static_cast<time_t>(interval / 1000000),
|
||||
static_cast<long>((interval % 1000000) * 1000)
|
||||
};
|
||||
|
||||
while(!btp->_stop.load(std::memory_order_acquire))
|
||||
{
|
||||
usleep(interval);
|
||||
nanosleep(&sleep_ts,NULL);
|
||||
|
||||
if(btp->_stop.load(std::memory_order_acquire))
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue