From 0bcf2388ce19271c98512d04f719f9efb1c87d39 Mon Sep 17 00:00:00 2001 From: Daniel Xu Date: Fri, 5 Jun 2020 15:27:47 -0700 Subject: [PATCH] usdt: Have Context::addsem_probe() nop if pid not specified This makes bcc_usdt_addsem*() more consistent with the bcc_usdt_enable*() interface where if a USDT::Context was not constructed with a pid the semaphore enablement nops. --- src/cc/usdt/usdt.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cc/usdt/usdt.cc b/src/cc/usdt/usdt.cc index 5c487d738a22..0a18c2b14892 100644 --- a/src/cc/usdt/usdt.cc +++ b/src/cc/usdt/usdt.cc @@ -359,8 +359,12 @@ bool Context::addsem_probe(const std::string &provider_name, int16_t val) { Probe *found_probe = get_checked(provider_name, probe_name); - if (found_probe != nullptr) - return found_probe->add_to_semaphore(val); + if (found_probe != nullptr) { + if (found_probe->need_enable()) + return found_probe->add_to_semaphore(val); + + return true; + } return false; }