mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
Fixed prevention of sleep.
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -21,12 +22,14 @@ var pulseTime = 60 * time.Second
|
|||||||
|
|
||||||
func Preconfig(kill bool) {
|
func Preconfig(kill bool) {
|
||||||
go func() {
|
go func() {
|
||||||
|
// need work on one thread because SetThreadExecutionState sets flag to thread. We need set and clear flag for same thread.
|
||||||
|
runtime.LockOSThread()
|
||||||
// don't sleep/hibernate windows
|
// don't sleep/hibernate windows
|
||||||
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||||
setThreadExecStateProc := kernel32.NewProc("SetThreadExecutionState")
|
setThreadExecStateProc := kernel32.NewProc("SetThreadExecutionState")
|
||||||
currentExecState := uintptr(EsContinuous)
|
currentExecState := uintptr(EsContinuous)
|
||||||
normalExecutionState := uintptr(EsContinuous)
|
normalExecutionState := uintptr(EsContinuous)
|
||||||
systemRequireState := uintptr(EsSystemRequired | EsContinuous)
|
systemRequireState := uintptr(EsSystemRequired | EsContinuous)
|
||||||
pulse := time.NewTicker(pulseTime)
|
pulse := time.NewTicker(pulseTime)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|||||||
Reference in New Issue
Block a user