From: Mathieu Desnoyers Date: Mon, 8 Nov 2021 16:32:04 +0000 (-0500) Subject: Refactoring: combine common code into lttng_event_enabler_attach_filter_bytecode X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4b066aebe2fbcfaff9b8b7217dd5c3435691c95b;p=lttng-ust.git Refactoring: combine common code into lttng_event_enabler_attach_filter_bytecode Signed-off-by: Mathieu Desnoyers Change-Id: I130317af55aaef3273079450b56d4218e878324e --- diff --git a/src/lib/lttng-ust/events.h b/src/lib/lttng-ust/events.h index ea985127..0f56f940 100644 --- a/src/lib/lttng-ust/events.h +++ b/src/lib/lttng-ust/events.h @@ -55,11 +55,11 @@ int lttng_event_enabler_disable(struct lttng_event_enabler_common *enabler) __attribute__((visibility("hidden"))); /* - * Attach filter bytecode program to `struct lttng_event_enabler` and all + * Attach filter bytecode program to `struct lttng_event_enabler_common` and all * events related to this enabler. */ int lttng_event_enabler_attach_filter_bytecode( - struct lttng_event_enabler_session_common *enabler, + struct lttng_event_enabler_common *enabler, struct lttng_ust_bytecode_node **bytecode) __attribute__((visibility("hidden"))); @@ -121,15 +121,6 @@ struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( struct lttng_ust_abi_event_notifier *event_notifier_param) __attribute__((visibility("hidden"))); -/* - * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and - * all event notifiers related to this enabler. - */ -int lttng_event_notifier_enabler_attach_filter_bytecode( - struct lttng_event_notifier_enabler *event_notifier_enabler, - struct lttng_ust_bytecode_node **bytecode) - __attribute__((visibility("hidden"))); - /* * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and * all event_notifiers related to this enabler. diff --git a/src/lib/lttng-ust/lttng-events.c b/src/lib/lttng-ust/lttng-events.c index 25b86fbf..396ac9a0 100644 --- a/src/lib/lttng-ust/lttng-events.c +++ b/src/lib/lttng-ust/lttng-events.c @@ -1808,22 +1808,14 @@ int lttng_event_enabler_disable(struct lttng_event_enabler_common *event_enabler return 0; } -static -void _lttng_enabler_attach_filter_bytecode(struct lttng_event_enabler_common *enabler, +int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler_common *event_enabler, struct lttng_ust_bytecode_node **bytecode) { - (*bytecode)->enabler = enabler; - cds_list_add_tail(&(*bytecode)->node, &enabler->filter_bytecode_head); + (*bytecode)->enabler = event_enabler; + cds_list_add_tail(&(*bytecode)->node, &event_enabler->filter_bytecode_head); /* Take ownership of bytecode */ *bytecode = NULL; -} - -int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler_session_common *event_enabler, - struct lttng_ust_bytecode_node **bytecode) -{ - _lttng_enabler_attach_filter_bytecode(&event_enabler->parent, bytecode); - - lttng_session_lazy_sync_event_enablers(event_enabler->chan->session); + lttng_event_enabler_sync(event_enabler); return 0; } @@ -1846,18 +1838,6 @@ int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler_session_comm return 0; } -int lttng_event_notifier_enabler_attach_filter_bytecode( - struct lttng_event_notifier_enabler *event_notifier_enabler, - struct lttng_ust_bytecode_node **bytecode) -{ - _lttng_enabler_attach_filter_bytecode( - lttng_event_notifier_enabler_as_enabler(event_notifier_enabler), - bytecode); - - lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group); - return 0; -} - int lttng_event_notifier_enabler_attach_capture_bytecode( struct lttng_event_notifier_enabler *event_notifier_enabler, struct lttng_ust_bytecode_node **bytecode) diff --git a/src/lib/lttng-ust/lttng-ust-abi.c b/src/lib/lttng-ust/lttng-ust-abi.c index 390e291f..b10541ab 100644 --- a/src/lib/lttng-ust/lttng-ust-abi.c +++ b/src/lib/lttng-ust/lttng-ust-abi.c @@ -858,8 +858,8 @@ long lttng_event_notifier_enabler_cmd(int objd, unsigned int cmd, unsigned long struct lttng_event_notifier_enabler *event_notifier_enabler = objd_private(objd); switch (cmd) { case LTTNG_UST_ABI_FILTER: - return lttng_event_notifier_enabler_attach_filter_bytecode( - event_notifier_enabler, + return lttng_event_enabler_attach_filter_bytecode( + &event_notifier_enabler->parent, (struct lttng_ust_bytecode_node **) arg); case LTTNG_UST_ABI_EXCLUSION: return lttng_event_notifier_enabler_attach_exclusion(event_notifier_enabler, @@ -1776,7 +1776,7 @@ long lttng_event_enabler_cmd(int objd, unsigned int cmd, unsigned long arg, { int ret; - ret = lttng_event_enabler_attach_filter_bytecode(enabler, + ret = lttng_event_enabler_attach_filter_bytecode(&enabler->parent, (struct lttng_ust_bytecode_node **) arg); if (ret) return ret;