fix setioprio on mac

This commit is contained in:
Adrian Stobbe 2024-07-02 11:39:47 +02:00
parent 7696b625e9
commit 8021c541f4
3 changed files with 37 additions and 3 deletions

View File

@ -16,8 +16,6 @@ import (
"path"
"strconv"
"time"
"golang.org/x/sys/unix"
)
var (
@ -97,7 +95,7 @@ func (c *Client) setIOPriority() error {
prioVal := ((targetClass & ioPrioClassMask) << ioPrioClassShift) | (targetPrio & ioPrioPrioMask)
// see https://man7.org/linux/man-pages/man2/ioprio_set.2.html
ret, _, errno := unix.Syscall(unix.SYS_IOPRIO_SET, ioPrioWhoProcess, uintptr(pid), uintptr(prioVal))
ret, _, errno := setioprio(ioPrioWhoProcess, uintptr(pid), uintptr(prioVal))
if ret != 0 {
return fmt.Errorf("setting I/O priority for etcd: %w", errno)
}

View File

@ -0,0 +1,17 @@
//go:build !linux
/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package etcdio
import (
"syscall"
)
func setioprio(_, _, _ uintptr) (uintptr, uintptr, syscall.Errno) {
panic("setioprio not implemented on non-Linux platforms")
}

View File

@ -0,0 +1,19 @@
//go:build linux
/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package etcdio
import (
"syscall"
"golang.org/x/sys/unix"
)
func setioprio(ioPrioWhoProcess, pid, prioVal uintptr) (uintptr, uintptr, syscall.Errno) {
return unix.Syscall(unix.SYS_IOPRIO_SET, ioPrioWhoProcess, pid, prioVal)
}