Skip to content

Commit

Permalink
Remove unused efd, add close method
Browse files Browse the repository at this point in the history
  • Loading branch information
tahsinrahman committed Aug 7, 2019
1 parent 20cb935 commit ba7f126
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion elf/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ type RawTracepointProgram struct {
Name string
insns *C.struct_bpf_insn
fd int
efd int
}

// SchedProgram represents a traffic classifier program
Expand Down Expand Up @@ -705,6 +704,15 @@ func (b *Module) closeTracepointPrograms() error {
return nil
}

func (b *Module) closeRawTracepointPrograms() error {
for _, program := range b.rawTracepointPrograms {
if err := syscall.Close(program.fd); err != nil {
return fmt.Errorf("error closing raw tracepoint program fd: %v", err)
}
}
return nil
}

func (b *Module) closeCgroupPrograms() error {
for _, program := range b.cgroupPrograms {
if err := syscall.Close(program.fd); err != nil {
Expand Down Expand Up @@ -805,6 +813,9 @@ func (b *Module) CloseExt(options map[string]CloseOptions) error {
if err := b.closeTracepointPrograms(); err != nil {
return err
}
if err := b.closeRawTracepointPrograms(); err != nil {
return err
}
if err := b.closeSocketFilters(); err != nil {
return err
}
Expand Down

0 comments on commit ba7f126

Please sign in to comment.