mirror of
https://github.com/prometheus-community/windows_exporter
synced 2024-12-26 08:22:07 +00:00
terminal_services: Fix "The operation completed successfully." error (#1548)
This commit is contained in:
parent
9026bc02ff
commit
dffc53eff8
@ -138,13 +138,17 @@ func WTSCloseServer(server syscall.Handle) error {
|
||||
}
|
||||
|
||||
func WTSFreeMemoryEx(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) error {
|
||||
_, _, err := procWTSFreeMemoryEx.Call(
|
||||
r1, _, err := procWTSFreeMemoryEx.Call(
|
||||
uintptr(class),
|
||||
pMemory,
|
||||
uintptr(NumberOfEntries),
|
||||
)
|
||||
|
||||
return err
|
||||
if r1 != 1 {
|
||||
return fmt.Errorf("failed to free memory: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func WTSEnumerateSessionsEx(server syscall.Handle, logger log.Logger) ([]WTSSession, error) {
|
||||
@ -168,7 +172,7 @@ func WTSEnumerateSessionsEx(server syscall.Handle, logger log.Logger) ([]WTSSess
|
||||
defer func(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) {
|
||||
err := WTSFreeMemoryEx(class, pMemory, NumberOfEntries)
|
||||
if err != nil {
|
||||
_ = level.Error(logger).Log("msg", "failed to free memory", "err", err)
|
||||
_ = level.Error(logger).Log("msg", "failed to free memory", "err", fmt.Errorf("WTSEnumerateSessionsEx: %w", err))
|
||||
}
|
||||
}(WTSTypeSessionInfoLevel1, sessionInfoPointer, count)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user