Skip to content

Commit

Permalink
add lock while running background task
Browse files Browse the repository at this point in the history
Signed-off-by: Lakshmipathi <lakshmipathi@giis.co.in>
  • Loading branch information
Lakshmipathi committed Oct 9, 2023
1 parent e7fb007 commit 9ceba80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Binary file modified ebpf-diskalert
Binary file not shown.
6 changes: 5 additions & 1 deletion src/ebpf_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/binary"
"log"
"os"
"sync"

"github.com/cilium/ebpf/link"
"github.com/cilium/ebpf/perf"
Expand Down Expand Up @@ -58,7 +59,7 @@ func ebpf_loader(ci *ConfigData, di *Devinfo) {
if err != nil {
logger.Fatalf("ebpf_loader: reader error")
}

var m sync.Mutex
for {
ev, err := rd.Read()
if err != nil {
Expand All @@ -79,6 +80,9 @@ func ebpf_loader(ci *ConfigData, di *Devinfo) {
}

logger.Printf("Command:%s User: %d wrote to the mountpoint:%s\n", data.Command, data.Pid, di.MountPoint)

m.Lock()
checkDiskUSage(ci, di)
m.Unlock()
}
}

0 comments on commit 9ceba80

Please sign in to comment.