Skip to content

Commit

Permalink
Python: fix detach_kprobe()
Browse files Browse the repository at this point in the history
As open_kprobes contains not fd but pointer to struct perf_reader,
it should call lib.perf_reader_free() instead of os.close()
  • Loading branch information
kyeongmincho committed Oct 23, 2015
1 parent f701b52 commit bf96d37
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def detach_kprobe(event):
ev_name = "p_" + event.replace("+", "_").replace(".", "_")
if ev_name not in open_kprobes:
raise Exception("Kprobe %s is not attached" % event)
os.close(open_kprobes[ev_name])
lib.perf_reader_free(open_kprobes[ev_name])
desc = "-:kprobes/%s" % ev_name
res = lib.bpf_detach_kprobe(desc.encode("ascii"))
if res < 0:
Expand Down Expand Up @@ -612,7 +612,7 @@ def detach_kretprobe(event):
ev_name = "r_" + event.replace("+", "_").replace(".", "_")
if ev_name not in open_kprobes:
raise Exception("Kretprobe %s is not attached" % event)
os.close(open_kprobes[ev_name])
lib.perf_reader_free(open_kprobes[ev_name])
desc = "-:kprobes/%s" % ev_name
res = lib.bpf_detach_kprobe(desc.encode("ascii"))
if res < 0:
Expand Down

0 comments on commit bf96d37

Please sign in to comment.