mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-21 15:36:31 -05:00
Retry nanosleep on EINTR in monitor thread
nanosleep returns -1 with errno EINTR when interrupted by a signal. The remaining time was discarded (second arg was NULL), causing the monitor to wake early and sample a shortened interval. This produced artificially low throughput numbers that corrupted the EMA and could trigger unnecessary scale-down decisions. Loop on EINTR using the remaining time output parameter so the full sample interval is always honored. Also check _stop on each retry so the monitor exits promptly during shutdown. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
beb6961769
commit
b150f2c685
1 changed files with 8 additions and 1 deletions
|
|
@ -498,7 +498,14 @@ ThreadPool::monitor_routine(void *arg_)
|
|||
|
||||
while(!btp->_stop.load(std::memory_order_acquire))
|
||||
{
|
||||
nanosleep(&sleep_ts,NULL);
|
||||
{
|
||||
struct timespec remaining = sleep_ts;
|
||||
while(nanosleep(&remaining,&remaining) == -1 && errno == EINTR)
|
||||
{
|
||||
if(btp->_stop.load(std::memory_order_acquire))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(btp->_stop.load(std::memory_order_acquire))
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue