terminal_services: refactor collector (#1729)

This commit is contained in:
Jan-Otto Kröpke
2024-11-13 21:38:31 +01:00
committed by GitHub
parent b4f50c542c
commit f332361723
5 changed files with 158 additions and 111 deletions

View File

@@ -5,8 +5,10 @@ package mi
import (
"errors"
"fmt"
"math"
"reflect"
"sync"
"time"
"unsafe"
"golang.org/x/sys/windows"
@@ -14,6 +16,10 @@ import (
// We have to registry a global callback function, since the amount of callbacks is limited.
var operationUnmarshalCallbacksInstanceResult = sync.OnceValue[uintptr](func() uintptr {
// Workaround for a deadlock issue in go.
// Ref: https://github.com/golang/go/issues/55015
go time.Sleep(time.Duration(math.MaxInt64))
return windows.NewCallback(func(
operation *Operation,
callbacks *OperationUnmarshalCallbacks,