Commit cbfd2853 authored by 4ast's avatar 4ast Committed by GitHub

Merge pull request #1585 from palmtenor/usdt_destruct

Destruct USDTContext correctly in Python
parents e01c993a e0604644
...@@ -414,8 +414,10 @@ void *bcc_usdt_new_frompath(const char *path) { ...@@ -414,8 +414,10 @@ void *bcc_usdt_new_frompath(const char *path) {
} }
void bcc_usdt_close(void *usdt) { void bcc_usdt_close(void *usdt) {
USDT::Context *ctx = static_cast<USDT::Context *>(usdt); if (usdt) {
delete ctx; USDT::Context *ctx = static_cast<USDT::Context *>(usdt);
delete ctx;
}
} }
int bcc_usdt_enable_probe(void *usdt, const char *probe_name, int bcc_usdt_enable_probe(void *usdt, const char *probe_name,
......
...@@ -142,6 +142,9 @@ class USDT(object): ...@@ -142,6 +142,9 @@ class USDT(object):
raise USDTException( raise USDTException(
"either a pid or a binary path must be specified") "either a pid or a binary path must be specified")
def __del__(self):
lib.bcc_usdt_close(self.context)
def enable_probe(self, probe, fn_name): def enable_probe(self, probe, fn_name):
if lib.bcc_usdt_enable_probe(self.context, probe.encode('ascii'), if lib.bcc_usdt_enable_probe(self.context, probe.encode('ascii'),
fn_name.encode('ascii')) != 0: fn_name.encode('ascii')) != 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment