Skip to content

Commit

Permalink
service: parallelize api calls
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Nov 18, 2024
1 parent e996af6 commit c6b4891
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/collector/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"regexp"
"strconv"
"sync"
"syscall"
"unsafe"

"github.com/alecthomas/kingpin/v2"
Expand Down Expand Up @@ -381,7 +380,7 @@ func (c *Collector) queryAllServices() ([]windows.ENUM_SERVICE_STATUS_PROCESS, e
break
}

if !errors.Is(err, syscall.ERROR_MORE_DATA) {
if !errors.Is(err, windows.ERROR_MORE_DATA) {
return nil, err
}

Expand Down Expand Up @@ -445,12 +444,13 @@ func (c *Collector) getServiceConfig(service *mgr.Service) (mgr.Config, error) {

for {
serviceConfig = (*windows.QUERY_SERVICE_CONFIG)(unsafe.Pointer(&(*buf)[0]))

err := windows.QueryServiceConfig(service.Handle, serviceConfig, bytesNeeded, &bytesNeeded)
if err == nil {
break
}

if !errors.Is(err.(syscall.Errno), syscall.ERROR_INSUFFICIENT_BUFFER) {
if !errors.Is(err, windows.ERROR_INSUFFICIENT_BUFFER) {
return mgr.Config{}, err
}

Expand Down

0 comments on commit c6b4891

Please sign in to comment.