mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Use Eventfd() from x/sys/unix
Use unix.Eventfd() instead of C.eventfd and also use the correct corresponding unix.EFD_CLOEXEC flag. This allows to get rid of cgo.
This commit is contained in:
parent
4a69005fa1
commit
5acfb16023
@ -4,23 +4,10 @@ licenses(["notice"])
|
|||||||
|
|
||||||
load(
|
load(
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
"@io_bazel_rules_go//go:def.bzl",
|
||||||
"cgo_genrule",
|
|
||||||
"go_library",
|
"go_library",
|
||||||
"go_test",
|
"go_test",
|
||||||
)
|
)
|
||||||
|
|
||||||
cgo_genrule(
|
|
||||||
name = "cgo_codegen",
|
|
||||||
srcs = ["threshold_notifier_linux.go"],
|
|
||||||
clinkopts = [
|
|
||||||
"-lz",
|
|
||||||
"-lm",
|
|
||||||
"-lpthread",
|
|
||||||
"-ldl",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_test(
|
go_test(
|
||||||
name = "go_default_test",
|
name = "go_default_test",
|
||||||
srcs = [
|
srcs = [
|
||||||
@ -53,9 +40,9 @@ go_library(
|
|||||||
"doc.go",
|
"doc.go",
|
||||||
"eviction_manager.go",
|
"eviction_manager.go",
|
||||||
"helpers.go",
|
"helpers.go",
|
||||||
|
"threshold_notifier_linux.go",
|
||||||
"types.go",
|
"types.go",
|
||||||
],
|
],
|
||||||
library = ":cgo_codegen",
|
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/api:go_default_library",
|
"//pkg/api:go_default_library",
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build cgo
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2016 The Kubernetes Authors.
|
Copyright 2016 The Kubernetes Authors.
|
||||||
|
|
||||||
@ -18,11 +16,6 @@ limitations under the License.
|
|||||||
|
|
||||||
package eviction
|
package eviction
|
||||||
|
|
||||||
/*
|
|
||||||
#include <sys/eventfd.h>
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
@ -61,11 +54,10 @@ func NewMemCGThresholdNotifier(path, attribute, threshold, description string, h
|
|||||||
unix.Close(controlfd)
|
unix.Close(controlfd)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
efd, err := C.eventfd(0, C.EFD_CLOEXEC)
|
eventfd, err := unix.Eventfd(0, unix.EFD_CLOEXEC)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
eventfd := int(efd)
|
|
||||||
if eventfd < 0 {
|
if eventfd < 0 {
|
||||||
err = fmt.Errorf("eventfd call failed")
|
err = fmt.Errorf("eventfd call failed")
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user