2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
9 #include <common/credentials.h>
10 #include <common/dynamic-array.h>
11 #include <common/error.h>
12 #include <common/optional.h>
13 #include <common/payload-view.h>
14 #include <common/payload.h>
16 #include <lttng/action/action-internal.h>
17 #include <lttng/condition/buffer-usage.h>
18 #include <lttng/condition/condition-internal.h>
19 #include <lttng/condition/event-rule-matches-internal.h>
20 #include <lttng/condition/event-rule-matches.h>
21 #include <lttng/domain.h>
22 #include <lttng/event-expr-internal.h>
23 #include <lttng/event-rule/event-rule-internal.h>
24 #include <lttng/trigger/trigger-internal.h>
28 bool lttng_trigger_validate(const struct lttng_trigger
*trigger
)
37 if (!trigger
->creds
.uid
.is_set
) {
42 valid
= lttng_condition_validate(trigger
->condition
) &&
43 lttng_action_validate(trigger
->action
);
48 struct lttng_trigger
*lttng_trigger_create(
49 struct lttng_condition
*condition
,
50 struct lttng_action
*action
)
52 struct lttng_trigger
*trigger
= NULL
;
54 if (!condition
|| !action
) {
58 trigger
= zmalloc(sizeof(struct lttng_trigger
));
63 urcu_ref_init(&trigger
->ref
);
65 lttng_condition_get(condition
);
66 trigger
->condition
= condition
;
68 lttng_action_get(action
);
69 trigger
->action
= action
;
71 pthread_mutex_init(&trigger
->lock
, NULL
);
72 trigger
->registered
= false;
79 * Note: the lack of reference counting 'get' on the condition object is normal.
80 * This API was exposed as such in 2.11. The client is not expected to call
81 * lttng_condition_destroy on the returned object.
83 struct lttng_condition
*lttng_trigger_get_condition(
84 struct lttng_trigger
*trigger
)
86 return trigger
? trigger
->condition
: NULL
;
89 const struct lttng_condition
*lttng_trigger_get_const_condition(
90 const struct lttng_trigger
*trigger
)
92 return trigger
? trigger
->condition
: NULL
;
96 * Note: the lack of reference counting 'get' on the action object is normal.
97 * This API was exposed as such in 2.11. The client is not expected to call
98 * lttng_action_destroy on the returned object.
100 struct lttng_action
*lttng_trigger_get_action(
101 struct lttng_trigger
*trigger
)
103 return trigger
? trigger
->action
: NULL
;
106 const struct lttng_action
*lttng_trigger_get_const_action(
107 const struct lttng_trigger
*trigger
)
109 return trigger
? trigger
->action
: NULL
;
112 static void trigger_destroy_ref(struct urcu_ref
*ref
)
114 struct lttng_trigger
*trigger
=
115 container_of(ref
, struct lttng_trigger
, ref
);
116 struct lttng_action
*action
= lttng_trigger_get_action(trigger
);
117 struct lttng_condition
*condition
=
118 lttng_trigger_get_condition(trigger
);
123 /* Release ownership. */
124 lttng_action_put(action
);
125 lttng_condition_put(condition
);
127 pthread_mutex_destroy(&trigger
->lock
);
133 void lttng_trigger_destroy(struct lttng_trigger
*trigger
)
135 lttng_trigger_put(trigger
);
139 ssize_t
lttng_trigger_create_from_payload(
140 struct lttng_payload_view
*src_view
,
141 struct lttng_trigger
**_trigger
)
143 ssize_t ret
, offset
= 0, condition_size
, action_size
, name_size
= 0;
144 struct lttng_condition
*condition
= NULL
;
145 struct lttng_action
*action
= NULL
;
146 const struct lttng_trigger_comm
*trigger_comm
;
147 const char *name
= NULL
;
148 struct lttng_credentials creds
= {
149 .uid
= LTTNG_OPTIONAL_INIT_UNSET
,
150 .gid
= LTTNG_OPTIONAL_INIT_UNSET
,
152 struct lttng_trigger
*trigger
= NULL
;
153 const struct lttng_payload_view trigger_comm_view
=
154 lttng_payload_view_from_view(
155 src_view
, 0, sizeof(*trigger_comm
));
157 if (!src_view
|| !_trigger
) {
162 if (!lttng_payload_view_is_valid(&trigger_comm_view
)) {
163 /* Payload not large enough to contain the header. */
168 /* lttng_trigger_comm header */
169 trigger_comm
= (typeof(trigger_comm
)) trigger_comm_view
.buffer
.data
;
171 /* Set the trigger's creds. */
172 if (trigger_comm
->uid
> (uint64_t) ((uid_t
) -1)) {
173 /* UID out of range for this platform. */
178 LTTNG_OPTIONAL_SET(&creds
.uid
, trigger_comm
->uid
);
180 offset
+= sizeof(*trigger_comm
);
182 if (trigger_comm
->name_length
!= 0) {
184 const struct lttng_payload_view name_view
=
185 lttng_payload_view_from_view(
187 trigger_comm
->name_length
);
189 if (!lttng_payload_view_is_valid(&name_view
)) {
194 name
= name_view
.buffer
.data
;
195 if (!lttng_buffer_view_contains_string(&name_view
.buffer
, name
,
196 trigger_comm
->name_length
)) {
201 offset
+= trigger_comm
->name_length
;
202 name_size
= trigger_comm
->name_length
;
206 /* struct lttng_condition */
207 struct lttng_payload_view condition_view
=
208 lttng_payload_view_from_view(
209 src_view
, offset
, -1);
211 condition_size
= lttng_condition_create_from_payload(&condition_view
,
215 if (condition_size
< 0) {
216 ret
= condition_size
;
220 offset
+= condition_size
;
222 /* struct lttng_action */
223 struct lttng_payload_view action_view
=
224 lttng_payload_view_from_view(
225 src_view
, offset
, -1);
227 action_size
= lttng_action_create_from_payload(&action_view
, &action
);
230 if (action_size
< 0) {
234 offset
+= action_size
;
236 /* Unexpected size of inner-elements; the buffer is corrupted. */
237 if ((ssize_t
) trigger_comm
->length
!= condition_size
+ action_size
+ name_size
) {
242 trigger
= lttng_trigger_create(condition
, action
);
248 lttng_trigger_set_credentials(trigger
, &creds
);
251 * The trigger object owns references to the action and condition
254 lttng_condition_put(condition
);
257 lttng_action_put(action
);
261 const enum lttng_trigger_status status
=
262 lttng_trigger_set_name(trigger
, name
);
264 if (status
!= LTTNG_TRIGGER_STATUS_OK
) {
273 lttng_condition_put(condition
);
274 lttng_action_put(action
);
279 lttng_trigger_put(trigger
);
286 * Both elements are stored contiguously, see their "*_comm" structure
287 * for the detailed format.
290 int lttng_trigger_serialize(const struct lttng_trigger
*trigger
,
291 struct lttng_payload
*payload
)
294 size_t header_offset
, size_before_payload
, size_name
;
295 struct lttng_trigger_comm trigger_comm
= {};
296 struct lttng_trigger_comm
*header
;
297 const struct lttng_credentials
*creds
= NULL
;
299 creds
= lttng_trigger_get_credentials(trigger
);
302 trigger_comm
.uid
= LTTNG_OPTIONAL_GET(creds
->uid
);
304 if (trigger
->name
!= NULL
) {
305 size_name
= strlen(trigger
->name
) + 1;
310 trigger_comm
.name_length
= size_name
;
312 header_offset
= payload
->buffer
.size
;
313 ret
= lttng_dynamic_buffer_append(&payload
->buffer
, &trigger_comm
,
314 sizeof(trigger_comm
));
319 size_before_payload
= payload
->buffer
.size
;
322 ret
= lttng_dynamic_buffer_append(
323 &payload
->buffer
, trigger
->name
, size_name
);
328 ret
= lttng_condition_serialize(trigger
->condition
, payload
);
333 ret
= lttng_action_serialize(trigger
->action
, payload
);
338 /* Update payload size. */
339 header
= (typeof(header
)) (payload
->buffer
.data
+ header_offset
);
340 header
->length
= payload
->buffer
.size
- size_before_payload
;
346 bool lttng_trigger_is_equal(
347 const struct lttng_trigger
*a
, const struct lttng_trigger
*b
)
349 if (!!a
->name
!= !!b
->name
) {
350 /* Both must be either anonymous or named. */
354 if (a
->name
&& strcmp(a
->name
, b
->name
) != 0) {
358 if (!lttng_condition_is_equal(a
->condition
, b
->condition
)) {
362 if (!lttng_action_is_equal(a
->action
, b
->action
)) {
366 if (!lttng_credentials_is_equal(lttng_trigger_get_credentials(a
),
367 lttng_trigger_get_credentials(b
))) {
375 enum lttng_trigger_status
lttng_trigger_set_name(struct lttng_trigger
*trigger
,
378 char *name_copy
= NULL
;
379 enum lttng_trigger_status status
= LTTNG_TRIGGER_STATUS_OK
;
382 status
= LTTNG_TRIGGER_STATUS_INVALID
;
387 name_copy
= strdup(name
);
389 status
= LTTNG_TRIGGER_STATUS_ERROR
;
396 trigger
->name
= name_copy
;
402 enum lttng_trigger_status
lttng_trigger_get_name(
403 const struct lttng_trigger
*trigger
, const char **name
)
405 enum lttng_trigger_status status
= LTTNG_TRIGGER_STATUS_OK
;
407 if (!trigger
|| !name
) {
408 status
= LTTNG_TRIGGER_STATUS_INVALID
;
412 if (!trigger
->name
) {
413 status
= LTTNG_TRIGGER_STATUS_UNSET
;
416 *name
= trigger
->name
;
422 int lttng_trigger_assign_name(struct lttng_trigger
*dst
,
423 const struct lttng_trigger
*src
)
426 enum lttng_trigger_status status
;
428 status
= lttng_trigger_set_name(dst
, src
->name
);
429 if (status
!= LTTNG_TRIGGER_STATUS_OK
) {
431 ERR("Failed to set name for trigger");
439 void lttng_trigger_set_tracer_token(struct lttng_trigger
*trigger
,
443 LTTNG_OPTIONAL_SET(&trigger
->tracer_token
, token
);
447 uint64_t lttng_trigger_get_tracer_token(const struct lttng_trigger
*trigger
)
451 return LTTNG_OPTIONAL_GET(trigger
->tracer_token
);
455 int lttng_trigger_generate_name(struct lttng_trigger
*trigger
,
459 char *generated_name
= NULL
;
461 ret
= asprintf(&generated_name
, "T%" PRIu64
"", unique_id
);
463 ERR("Failed to generate trigger name");
470 trigger
->name
= generated_name
;
476 void lttng_trigger_get(struct lttng_trigger
*trigger
)
478 urcu_ref_get(&trigger
->ref
);
482 void lttng_trigger_put(struct lttng_trigger
*trigger
)
488 urcu_ref_put(&trigger
->ref
, trigger_destroy_ref
);
491 static void delete_trigger_array_element(void *ptr
)
493 struct lttng_trigger
*trigger
= ptr
;
495 lttng_trigger_put(trigger
);
499 struct lttng_triggers
*lttng_triggers_create(void)
501 struct lttng_triggers
*triggers
= NULL
;
503 triggers
= zmalloc(sizeof(*triggers
));
508 lttng_dynamic_pointer_array_init(&triggers
->array
, delete_trigger_array_element
);
515 struct lttng_trigger
*lttng_triggers_borrow_mutable_at_index(
516 const struct lttng_triggers
*triggers
, unsigned int index
)
518 struct lttng_trigger
*trigger
= NULL
;
521 if (index
>= lttng_dynamic_pointer_array_get_count(&triggers
->array
)) {
525 trigger
= (struct lttng_trigger
*)
526 lttng_dynamic_pointer_array_get_pointer(
527 &triggers
->array
, index
);
533 int lttng_triggers_add(
534 struct lttng_triggers
*triggers
, struct lttng_trigger
*trigger
)
541 lttng_trigger_get(trigger
);
543 ret
= lttng_dynamic_pointer_array_add_pointer(&triggers
->array
, trigger
);
545 lttng_trigger_put(trigger
);
551 const struct lttng_trigger
*lttng_triggers_get_at_index(
552 const struct lttng_triggers
*triggers
, unsigned int index
)
554 return lttng_triggers_borrow_mutable_at_index(triggers
, index
);
557 enum lttng_trigger_status
lttng_triggers_get_count(const struct lttng_triggers
*triggers
, unsigned int *count
)
559 enum lttng_trigger_status status
= LTTNG_TRIGGER_STATUS_OK
;
561 if (!triggers
|| !count
) {
562 status
= LTTNG_TRIGGER_STATUS_INVALID
;
566 *count
= lttng_dynamic_pointer_array_get_count(&triggers
->array
);
571 void lttng_triggers_destroy(struct lttng_triggers
*triggers
)
577 lttng_dynamic_pointer_array_reset(&triggers
->array
);
581 int lttng_triggers_serialize(const struct lttng_triggers
*triggers
,
582 struct lttng_payload
*payload
)
585 unsigned int i
, count
;
586 size_t size_before_payload
;
587 struct lttng_triggers_comm triggers_comm
= {};
588 struct lttng_triggers_comm
*header
;
589 enum lttng_trigger_status status
;
590 const size_t header_offset
= payload
->buffer
.size
;
592 status
= lttng_triggers_get_count(triggers
, &count
);
593 if (status
!= LTTNG_TRIGGER_STATUS_OK
) {
594 ret
= LTTNG_ERR_INVALID
;
598 triggers_comm
.count
= count
;
600 /* Placeholder header; updated at the end. */
601 ret
= lttng_dynamic_buffer_append(&payload
->buffer
, &triggers_comm
,
602 sizeof(triggers_comm
));
607 size_before_payload
= payload
->buffer
.size
;
609 for (i
= 0; i
< count
; i
++) {
610 const struct lttng_trigger
*trigger
=
611 lttng_triggers_get_at_index(triggers
, i
);
615 ret
= lttng_trigger_serialize(trigger
, payload
);
621 /* Update payload size. */
622 header
= (struct lttng_triggers_comm
*) ((char *) payload
->buffer
.data
+ header_offset
);
623 header
->length
= payload
->buffer
.size
- size_before_payload
;
629 ssize_t
lttng_triggers_create_from_payload(
630 struct lttng_payload_view
*src_view
,
631 struct lttng_triggers
**triggers
)
633 ssize_t ret
, offset
= 0, triggers_size
= 0;
635 const struct lttng_triggers_comm
*triggers_comm
;
636 struct lttng_triggers
*local_triggers
= NULL
;
638 if (!src_view
|| !triggers
) {
643 /* lttng_trigger_comms header */
644 triggers_comm
= (const struct lttng_triggers_comm
*) src_view
->buffer
.data
;
645 offset
+= sizeof(*triggers_comm
);
647 local_triggers
= lttng_triggers_create();
648 if (!local_triggers
) {
653 for (i
= 0; i
< triggers_comm
->count
; i
++) {
654 struct lttng_trigger
*trigger
= NULL
;
655 struct lttng_payload_view trigger_view
=
656 lttng_payload_view_from_view(src_view
, offset
, -1);
657 ssize_t trigger_size
;
659 trigger_size
= lttng_trigger_create_from_payload(
660 &trigger_view
, &trigger
);
661 if (trigger_size
< 0) {
666 /* Transfer ownership of the trigger to the collection. */
667 ret
= lttng_triggers_add(local_triggers
, trigger
);
668 lttng_trigger_put(trigger
);
674 offset
+= trigger_size
;
675 triggers_size
+= trigger_size
;
678 /* Unexpected size of inner-elements; the buffer is corrupted. */
679 if ((ssize_t
) triggers_comm
->length
!= triggers_size
) {
684 /* Pass ownership to caller. */
685 *triggers
= local_triggers
;
686 local_triggers
= NULL
;
691 lttng_triggers_destroy(local_triggers
);
696 const struct lttng_credentials
*lttng_trigger_get_credentials(
697 const struct lttng_trigger
*trigger
)
699 return &trigger
->creds
;
703 void lttng_trigger_set_credentials(struct lttng_trigger
*trigger
,
704 const struct lttng_credentials
*creds
)
707 trigger
->creds
= *creds
;
710 enum lttng_trigger_status
lttng_trigger_set_owner_uid(
711 struct lttng_trigger
*trigger
, uid_t uid
)
713 enum lttng_trigger_status ret
= LTTNG_TRIGGER_STATUS_OK
;
714 const uid_t euid
= geteuid();
715 const struct lttng_credentials creds
= {
716 .uid
= LTTNG_OPTIONAL_INIT_VALUE(uid
),
717 .gid
= LTTNG_OPTIONAL_INIT_UNSET
,
721 ret
= LTTNG_TRIGGER_STATUS_INVALID
;
725 /* Client-side validation only to report a clearer error. */
726 if (euid
!= 0 && euid
!= uid
) {
727 ret
= LTTNG_TRIGGER_STATUS_PERMISSION_DENIED
;
731 lttng_trigger_set_credentials(trigger
, &creds
);
737 enum lttng_trigger_status
lttng_trigger_get_owner_uid(
738 const struct lttng_trigger
*trigger
, uid_t
*uid
)
740 enum lttng_trigger_status ret
= LTTNG_TRIGGER_STATUS_OK
;
741 const struct lttng_credentials
*creds
= NULL
;
743 if (!trigger
|| !uid
) {
744 ret
= LTTNG_TRIGGER_STATUS_INVALID
;
748 if (!trigger
->creds
.uid
.is_set
) {
749 ret
= LTTNG_TRIGGER_STATUS_UNSET
;
753 creds
= lttng_trigger_get_credentials(trigger
);
754 *uid
= lttng_credentials_get_uid(creds
);
761 enum lttng_domain_type
lttng_trigger_get_underlying_domain_type_restriction(
762 const struct lttng_trigger
*trigger
)
764 enum lttng_domain_type type
= LTTNG_DOMAIN_NONE
;
765 const struct lttng_event_rule
*event_rule
;
766 enum lttng_condition_status c_status
;
767 enum lttng_condition_type c_type
;
770 assert(trigger
->condition
);
772 c_type
= lttng_condition_get_type(trigger
->condition
);
773 assert (c_type
!= LTTNG_CONDITION_TYPE_UNKNOWN
);
776 case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE
:
777 case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING
:
778 case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED
:
779 /* Apply to any domain. */
780 type
= LTTNG_DOMAIN_NONE
;
782 case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES
:
783 /* Return the domain of the event rule. */
784 c_status
= lttng_condition_event_rule_matches_get_rule(
785 trigger
->condition
, &event_rule
);
786 assert(c_status
== LTTNG_CONDITION_STATUS_OK
);
787 type
= lttng_event_rule_get_domain_type(event_rule
);
789 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
:
790 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
:
791 /* Return the domain of the channel being monitored. */
792 c_status
= lttng_condition_buffer_usage_get_domain_type(
793 trigger
->condition
, &type
);
794 assert(c_status
== LTTNG_CONDITION_STATUS_OK
);
804 * Generate bytecode related to the trigger.
805 * On success LTTNG_OK. On error, returns lttng_error code.
808 enum lttng_error_code
lttng_trigger_generate_bytecode(
809 struct lttng_trigger
*trigger
,
810 const struct lttng_credentials
*creds
)
812 enum lttng_error_code ret
;
813 struct lttng_condition
*condition
= NULL
;
815 condition
= lttng_trigger_get_condition(trigger
);
817 ret
= LTTNG_ERR_INVALID_TRIGGER
;
821 switch (lttng_condition_get_type(condition
)) {
822 case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES
:
824 struct lttng_event_rule
*event_rule
;
825 const enum lttng_condition_status condition_status
=
826 lttng_condition_event_rule_matches_borrow_rule_mutable(
827 condition
, &event_rule
);
829 assert(condition_status
== LTTNG_CONDITION_STATUS_OK
);
831 /* Generate the filter bytecode. */
832 ret
= lttng_event_rule_generate_filter_bytecode(
834 if (ret
!= LTTNG_OK
) {
838 /* Generate the capture bytecode. */
839 ret
= lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode(
841 if (ret
!= LTTNG_OK
) {
857 struct lttng_trigger
*lttng_trigger_copy(const struct lttng_trigger
*trigger
)
860 struct lttng_payload copy_buffer
;
861 struct lttng_condition
*condition_copy
= NULL
;
862 struct lttng_action
*action_copy
= NULL
;
863 struct lttng_trigger
*copy
= NULL
;
864 enum lttng_trigger_status trigger_status
;
865 const char *trigger_name
;
866 uid_t trigger_owner_uid
;
868 lttng_payload_init(©_buffer
);
870 ret
= lttng_condition_serialize(trigger
->condition
, ©_buffer
);
876 struct lttng_payload_view view
=
877 lttng_payload_view_from_payload(
878 ©_buffer
, 0, -1);
880 ret
= lttng_condition_create_from_payload(
881 &view
, &condition_copy
);
887 lttng_payload_clear(©_buffer
);
889 ret
= lttng_action_serialize(trigger
->action
, ©_buffer
);
895 struct lttng_payload_view view
=
896 lttng_payload_view_from_payload(
897 ©_buffer
, 0, -1);
899 ret
= lttng_action_create_from_payload(
900 &view
, &action_copy
);
906 copy
= lttng_trigger_create(condition_copy
, action_copy
);
908 ERR("Failed to allocate trigger during trigger copy");
912 trigger_status
= lttng_trigger_get_name(trigger
, &trigger_name
);
913 switch (trigger_status
) {
914 case LTTNG_TRIGGER_STATUS_OK
:
915 trigger_status
= lttng_trigger_set_name(copy
, trigger_name
);
916 if (trigger_status
!= LTTNG_TRIGGER_STATUS_OK
) {
917 ERR("Failed to set name of new trigger during copy");
918 goto error_cleanup_trigger
;
921 case LTTNG_TRIGGER_STATUS_UNSET
:
924 ERR("Failed to get name of original trigger during copy");
925 goto error_cleanup_trigger
;
928 trigger_status
= lttng_trigger_get_owner_uid(
929 trigger
, &trigger_owner_uid
);
930 switch (trigger_status
) {
931 case LTTNG_TRIGGER_STATUS_OK
:
932 LTTNG_OPTIONAL_SET(©
->creds
.uid
, trigger_owner_uid
);
934 case LTTNG_TRIGGER_STATUS_UNSET
:
937 ERR("Failed to get owner uid of original trigger during copy");
938 goto error_cleanup_trigger
;
941 copy
->tracer_token
= trigger
->tracer_token
;
942 copy
->registered
= trigger
->registered
;
945 error_cleanup_trigger
:
946 lttng_trigger_destroy(copy
);
949 lttng_condition_put(condition_copy
);
950 lttng_action_put(action_copy
);
951 lttng_payload_reset(©_buffer
);
956 bool lttng_trigger_needs_tracer_notifier(const struct lttng_trigger
*trigger
)
958 bool needs_tracer_notifier
= false;
959 const struct lttng_condition
*condition
=
960 lttng_trigger_get_const_condition(trigger
);
962 switch (lttng_condition_get_type(condition
)) {
963 case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES
:
964 needs_tracer_notifier
= true;
966 case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE
:
967 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
:
968 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
:
969 case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING
:
970 case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED
:
972 case LTTNG_CONDITION_TYPE_UNKNOWN
:
977 return needs_tracer_notifier
;
981 void lttng_trigger_set_as_registered(struct lttng_trigger
*trigger
)
983 pthread_mutex_lock(&trigger
->lock
);
984 trigger
->registered
= true;
985 pthread_mutex_unlock(&trigger
->lock
);
989 void lttng_trigger_set_as_unregistered(struct lttng_trigger
*trigger
)
991 pthread_mutex_lock(&trigger
->lock
);
992 trigger
->registered
= false;
993 pthread_mutex_unlock(&trigger
->lock
);
997 * The trigger must be locked before calling lttng_trigger_registered.
998 * The lock is necessary since a trigger can be unregistered at anytime.
999 * Manipulations requiring that the trigger be registered must always acquire
1000 * the trigger lock for the duration of the manipulation using
1001 * `lttng_trigger_lock` and `lttng_trigger_unlock`.
1004 bool lttng_trigger_is_registered(struct lttng_trigger
*trigger
)
1006 ASSERT_LOCKED(trigger
->lock
);
1007 return trigger
->registered
;
1011 void lttng_trigger_lock(struct lttng_trigger
*trigger
)
1013 pthread_mutex_lock(&trigger
->lock
);
1017 void lttng_trigger_unlock(struct lttng_trigger
*trigger
)
1019 pthread_mutex_unlock(&trigger
->lock
);