Severity: Warning
File: src/Servy.Service/Service.cs
Lines: 849–853
Description:
ConditionalResetRestartAttemptsAsync checks the file counter via EnsureRestartAttemptsFileAsync() (which releases _fileSemaphore after), then directly calls File.Exists(_restartAttemptsFile) (line 851) and File.GetLastWriteTimeUtc(...) (line 853) outside any semaphore. Between the semaphore release and these bare file calls, another thread (e.g., a concurrent recovery) can modify the file, producing incorrect reset decisions.
Suggested fix:
Move the file-existence and GetLastWriteTimeUtc calls inside the _fileSemaphore scope, or read both the counter and the timestamp atomically in a single locked section.
Severity: Warning
File:
src/Servy.Service/Service.csLines: 849–853
Description:
ConditionalResetRestartAttemptsAsyncchecks the file counter viaEnsureRestartAttemptsFileAsync()(which releases_fileSemaphoreafter), then directly callsFile.Exists(_restartAttemptsFile)(line 851) andFile.GetLastWriteTimeUtc(...)(line 853) outside any semaphore. Between the semaphore release and these bare file calls, another thread (e.g., a concurrent recovery) can modify the file, producing incorrect reset decisions.Suggested fix:
Move the file-existence and
GetLastWriteTimeUtccalls inside the_fileSemaphorescope, or read both the counter and the timestamp atomically in a single locked section.