diff options
author | tomasz1986 <twilczynski@naver.com> | 2023-07-21 06:38:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-21 04:38:15 +0000 |
commit | d70eb569f2db11ea39b2b18c4ebe448b6d37eaa0 (patch) | |
tree | af69890a834c5793dfcb95cdda37c7fee155ca00 | |
parent | 21c074cc2cbdf6d2341eea21bed2f3c3f10467cf (diff) | |
download | syncthing-d70eb569f2db11ea39b2b18c4ebe448b6d37eaa0.tar.gz syncthing-d70eb569f2db11ea39b2b18c4ebe448b6d37eaa0.zip |
lib/osutil: Skip setLowPriority in Windows if already lower (fixes #6597) (#8993)
-rw-r--r-- | lib/osutil/lowprio_windows.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/osutil/lowprio_windows.go b/lib/osutil/lowprio_windows.go index 1efee52b2..3cf97aa1a 100644 --- a/lib/osutil/lowprio_windows.go +++ b/lib/osutil/lowprio_windows.go @@ -21,6 +21,11 @@ func SetLowPriority() error { } defer windows.CloseHandle(handle) + if cur, err := windows.GetPriorityClass(handle); err == nil && (cur == windows.IDLE_PRIORITY_CLASS || cur == windows.BELOW_NORMAL_PRIORITY_CLASS) { + // We're done here. + return nil + } + if err := windows.SetPriorityClass(handle, windows.BELOW_NORMAL_PRIORITY_CLASS); err != nil { return fmt.Errorf("set priority class: %w", err) } |