Skip to content

Commit

Permalink
Fix a file descriptor leak when module is deleted (iovisor#2530)
Browse files Browse the repository at this point in the history
Fix issue iovisor#989

When module is cleaned up, let us also close all bpf program
file descriptors to avoid fd leaking.

Signed-off-by: Yonghong Song <[email protected]>
  • Loading branch information
yonghong-song authored Sep 25, 2019
1 parent 903513e commit 115b959
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,8 @@ def cleanup(self):
if self.tracefile:
self.tracefile.close()
self.tracefile = None
for name, fn in list(self.funcs.items()):
os.close(fn.fd)
if self.module:
lib.bpf_module_destroy(self.module)
self.module = None
Expand Down

0 comments on commit 115b959

Please sign in to comment.