2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <common/common.h>
23 #include <common/hashtable/utils.h>
24 #include <lttng/lttng.h>
26 #include "ust-registry.h"
29 #include "lttng-sessiond.h"
30 #include "notification-thread-commands.h"
33 * Hash table match function for event in the registry.
35 static int ht_match_event(struct cds_lfht_node
*node
, const void *_key
)
37 struct ust_registry_event
*event
;
38 const struct ust_registry_event
*key
;
43 event
= caa_container_of(node
, struct ust_registry_event
, node
.node
);
47 /* It has to be a perfect match. */
48 if (strncmp(event
->name
, key
->name
, sizeof(event
->name
))) {
52 /* It has to be a perfect match. */
53 if (strncmp(event
->signature
, key
->signature
,
54 strlen(event
->signature
))) {
65 static unsigned long ht_hash_event(void *_key
, unsigned long seed
)
68 struct ust_registry_event
*key
= _key
;
72 xored_key
= (uint64_t) (hash_key_str(key
->name
, seed
) ^
73 hash_key_str(key
->signature
, seed
));
75 return hash_key_u64(&xored_key
, seed
);
78 static int compare_enums(const struct ust_registry_enum
*reg_enum_a
,
79 const struct ust_registry_enum
*reg_enum_b
)
84 assert(strcmp(reg_enum_a
->name
, reg_enum_b
->name
) == 0);
85 if (reg_enum_a
->nr_entries
!= reg_enum_b
->nr_entries
) {
89 for (i
= 0; i
< reg_enum_a
->nr_entries
; i
++) {
90 const struct ustctl_enum_entry
*entries_a
, *entries_b
;
92 entries_a
= ®_enum_a
->entries
[i
];
93 entries_b
= ®_enum_b
->entries
[i
];
94 if (entries_a
->start
.value
!= entries_b
->start
.value
) {
98 if (entries_a
->end
.value
!= entries_b
->end
.value
) {
102 if (entries_a
->start
.signedness
!= entries_b
->start
.signedness
) {
106 if (entries_a
->end
.signedness
!= entries_b
->end
.signedness
) {
111 if (strcmp(entries_a
->string
, entries_b
->string
)) {
121 * Hash table match function for enumerations in the session. Match is
122 * performed on enumeration name, and confirmed by comparing the enum
125 static int ht_match_enum(struct cds_lfht_node
*node
, const void *_key
)
127 struct ust_registry_enum
*_enum
;
128 const struct ust_registry_enum
*key
;
133 _enum
= caa_container_of(node
, struct ust_registry_enum
,
138 if (strncmp(_enum
->name
, key
->name
, LTTNG_UST_SYM_NAME_LEN
)) {
141 if (compare_enums(_enum
, key
)) {
153 * Hash table match function for enumerations in the session. Match is
154 * performed by enumeration ID.
156 static int ht_match_enum_id(struct cds_lfht_node
*node
, const void *_key
)
158 struct ust_registry_enum
*_enum
;
159 const struct ust_registry_enum
*key
= _key
;
164 _enum
= caa_container_of(node
, struct ust_registry_enum
, node
.node
);
167 if (_enum
->id
!= key
->id
) {
179 * Hash table hash function for enumerations in the session. The
180 * enumeration name is used for hashing.
182 static unsigned long ht_hash_enum(void *_key
, unsigned long seed
)
184 struct ust_registry_enum
*key
= _key
;
187 return hash_key_str(key
->name
, seed
);
191 * Return negative value on error, 0 if OK.
193 * TODO: we could add stricter verification of more types to catch
194 * errors in liblttng-ust implementation earlier than consumption by the
198 int validate_event_field(struct ustctl_field
*field
,
199 const char *event_name
,
204 switch(field
->type
.atype
) {
205 case ustctl_atype_integer
:
206 case ustctl_atype_enum
:
207 case ustctl_atype_array
:
208 case ustctl_atype_sequence
:
209 case ustctl_atype_string
:
210 case ustctl_atype_variant
:
212 case ustctl_atype_struct
:
213 if (field
->type
.u
._struct
.nr_fields
!= 0) {
214 WARN("Unsupported non-empty struct field.");
220 case ustctl_atype_float
:
221 switch (field
->type
.u
.basic
._float
.mant_dig
) {
223 WARN("UST application '%s' (pid: %d) has unknown float mantissa '%u' "
224 "in field '%s', rejecting event '%s'",
226 field
->type
.u
.basic
._float
.mant_dig
,
245 int validate_event_fields(size_t nr_fields
, struct ustctl_field
*fields
,
246 const char *event_name
, struct ust_app
*app
)
250 for (i
= 0; i
< nr_fields
; i
++) {
251 if (validate_event_field(&fields
[i
], event_name
, app
) < 0)
258 * Allocate event and initialize it. This does NOT set a valid event id from a
261 static struct ust_registry_event
*alloc_event(int session_objd
,
262 int channel_objd
, char *name
, char *sig
, size_t nr_fields
,
263 struct ustctl_field
*fields
, int loglevel_value
,
264 char *model_emf_uri
, struct ust_app
*app
)
266 struct ust_registry_event
*event
= NULL
;
269 * Ensure that the field content is valid.
271 if (validate_event_fields(nr_fields
, fields
, name
, app
) < 0) {
275 event
= zmalloc(sizeof(*event
));
277 PERROR("zmalloc ust registry event");
281 event
->session_objd
= session_objd
;
282 event
->channel_objd
= channel_objd
;
283 /* Allocated by ustctl. */
284 event
->signature
= sig
;
285 event
->nr_fields
= nr_fields
;
286 event
->fields
= fields
;
287 event
->loglevel_value
= loglevel_value
;
288 event
->model_emf_uri
= model_emf_uri
;
290 /* Copy event name and force NULL byte. */
291 strncpy(event
->name
, name
, sizeof(event
->name
));
292 event
->name
[sizeof(event
->name
) - 1] = '\0';
294 cds_lfht_node_init(&event
->node
.node
);
301 * Free event data structure. This does NOT delete it from any hash table. It's
302 * safe to pass a NULL pointer. This shoudl be called inside a call RCU if the
303 * event is previously deleted from a rcu hash table.
305 static void destroy_event(struct ust_registry_event
*event
)
312 free(event
->model_emf_uri
);
313 free(event
->signature
);
318 * Destroy event function call of the call RCU.
320 static void destroy_event_rcu(struct rcu_head
*head
)
322 struct lttng_ht_node_u64
*node
=
323 caa_container_of(head
, struct lttng_ht_node_u64
, head
);
324 struct ust_registry_event
*event
=
325 caa_container_of(node
, struct ust_registry_event
, node
);
327 destroy_event(event
);
331 * Find an event using the name and signature in the given registry. RCU read
332 * side lock MUST be acquired before calling this function and as long as the
333 * event reference is kept by the caller.
335 * On success, the event pointer is returned else NULL.
337 struct ust_registry_event
*ust_registry_find_event(
338 struct ust_registry_channel
*chan
, char *name
, char *sig
)
340 struct lttng_ht_node_u64
*node
;
341 struct lttng_ht_iter iter
;
342 struct ust_registry_event
*event
= NULL
;
343 struct ust_registry_event key
;
349 /* Setup key for the match function. */
350 strncpy(key
.name
, name
, sizeof(key
.name
));
351 key
.name
[sizeof(key
.name
) - 1] = '\0';
354 cds_lfht_lookup(chan
->ht
->ht
, chan
->ht
->hash_fct(&key
, lttng_ht_seed
),
355 chan
->ht
->match_fct
, &key
, &iter
.iter
);
356 node
= lttng_ht_iter_get_node_u64(&iter
);
360 event
= caa_container_of(node
, struct ust_registry_event
, node
);
367 * Create a ust_registry_event from the given parameters and add it to the
368 * registry hash table. If event_id is valid, it is set with the newly created
371 * On success, return 0 else a negative value. The created event MUST be unique
372 * so on duplicate entry -EINVAL is returned. On error, event_id is untouched.
374 * Should be called with session registry mutex held.
376 int ust_registry_create_event(struct ust_registry_session
*session
,
377 uint64_t chan_key
, int session_objd
, int channel_objd
, char *name
,
378 char *sig
, size_t nr_fields
, struct ustctl_field
*fields
,
379 int loglevel_value
, char *model_emf_uri
, int buffer_type
,
380 uint32_t *event_id_p
, struct ust_app
*app
)
384 struct cds_lfht_node
*nptr
;
385 struct ust_registry_event
*event
= NULL
;
386 struct ust_registry_channel
*chan
;
396 * This should not happen but since it comes from the UST tracer, an
397 * external party, don't assert and simply validate values.
399 if (session_objd
< 0 || channel_objd
< 0) {
404 chan
= ust_registry_channel_find(session
, chan_key
);
410 /* Check if we've reached the maximum possible id. */
411 if (ust_registry_is_max_id(chan
->used_event_id
)) {
416 event
= alloc_event(session_objd
, channel_objd
, name
, sig
, nr_fields
,
417 fields
, loglevel_value
, model_emf_uri
, app
);
423 DBG3("UST registry creating event with event: %s, sig: %s, id: %u, "
424 "chan_objd: %u, sess_objd: %u, chan_id: %u", event
->name
,
425 event
->signature
, event
->id
, event
->channel_objd
,
426 event
->session_objd
, chan
->chan_id
);
429 * This is an add unique with a custom match function for event. The node
430 * are matched using the event name and signature.
432 nptr
= cds_lfht_add_unique(chan
->ht
->ht
, chan
->ht
->hash_fct(event
,
433 lttng_ht_seed
), chan
->ht
->match_fct
, event
, &event
->node
.node
);
434 if (nptr
!= &event
->node
.node
) {
435 if (buffer_type
== LTTNG_BUFFER_PER_UID
) {
437 * This is normal, we just have to send the event id of the
438 * returned node and make sure we destroy the previously allocated
441 destroy_event(event
);
442 event
= caa_container_of(nptr
, struct ust_registry_event
,
445 event_id
= event
->id
;
447 ERR("UST registry create event add unique failed for event: %s, "
448 "sig: %s, id: %u, chan_objd: %u, sess_objd: %u",
449 event
->name
, event
->signature
, event
->id
,
450 event
->channel_objd
, event
->session_objd
);
455 /* Request next event id if the node was successfully added. */
456 event_id
= event
->id
= ust_registry_get_next_event_id(chan
);
459 *event_id_p
= event_id
;
461 if (!event
->metadata_dumped
) {
462 /* Append to metadata */
463 ret
= ust_metadata_event_statedump(session
, chan
, event
);
465 ERR("Error appending event metadata (errno = %d)", ret
);
480 destroy_event(event
);
485 * For a given event in a registry, delete the entry and destroy the event.
486 * This MUST be called within a RCU read side lock section.
488 void ust_registry_destroy_event(struct ust_registry_channel
*chan
,
489 struct ust_registry_event
*event
)
492 struct lttng_ht_iter iter
;
497 /* Delete the node first. */
498 iter
.iter
.node
= &event
->node
.node
;
499 ret
= lttng_ht_del(chan
->ht
, &iter
);
502 call_rcu(&event
->node
.head
, destroy_event_rcu
);
507 static void destroy_enum(struct ust_registry_enum
*reg_enum
)
512 free(reg_enum
->entries
);
516 static void destroy_enum_rcu(struct rcu_head
*head
)
518 struct ust_registry_enum
*reg_enum
=
519 caa_container_of(head
, struct ust_registry_enum
, rcu_head
);
521 destroy_enum(reg_enum
);
525 * Lookup enumeration by name and comparing enumeration entries.
526 * Needs to be called from RCU read-side critical section.
528 struct ust_registry_enum
*
529 ust_registry_lookup_enum(struct ust_registry_session
*session
,
530 const struct ust_registry_enum
*reg_enum_lookup
)
532 struct ust_registry_enum
*reg_enum
= NULL
;
533 struct lttng_ht_node_str
*node
;
534 struct lttng_ht_iter iter
;
536 cds_lfht_lookup(session
->enums
->ht
,
537 ht_hash_enum((void *) ®_enum_lookup
, lttng_ht_seed
),
538 ht_match_enum
, ®_enum_lookup
, &iter
.iter
);
539 node
= lttng_ht_iter_get_node_str(&iter
);
543 reg_enum
= caa_container_of(node
, struct ust_registry_enum
, node
);
549 * Lookup enumeration by enum ID.
550 * Needs to be called from RCU read-side critical section.
552 struct ust_registry_enum
*
553 ust_registry_lookup_enum_by_id(struct ust_registry_session
*session
,
554 const char *enum_name
, uint64_t enum_id
)
556 struct ust_registry_enum
*reg_enum
= NULL
;
557 struct lttng_ht_node_str
*node
;
558 struct lttng_ht_iter iter
;
559 struct ust_registry_enum reg_enum_lookup
;
561 memset(®_enum_lookup
, 0, sizeof(reg_enum_lookup
));
562 strncpy(reg_enum_lookup
.name
, enum_name
, LTTNG_UST_SYM_NAME_LEN
);
563 reg_enum_lookup
.name
[LTTNG_UST_SYM_NAME_LEN
- 1] = '\0';
564 reg_enum_lookup
.id
= enum_id
;
565 cds_lfht_lookup(session
->enums
->ht
,
566 ht_hash_enum((void *) ®_enum_lookup
, lttng_ht_seed
),
567 ht_match_enum_id
, ®_enum_lookup
, &iter
.iter
);
568 node
= lttng_ht_iter_get_node_str(&iter
);
572 reg_enum
= caa_container_of(node
, struct ust_registry_enum
, node
);
578 * Create a ust_registry_enum from the given parameters and add it to the
579 * registry hash table, or find it if already there.
581 * On success, return 0 else a negative value.
583 * Should be called with session registry mutex held.
585 * We receive ownership of entries.
587 int ust_registry_create_or_find_enum(struct ust_registry_session
*session
,
588 int session_objd
, char *enum_name
,
589 struct ustctl_enum_entry
*entries
, size_t nr_entries
,
593 struct cds_lfht_node
*nodep
;
594 struct ust_registry_enum
*reg_enum
= NULL
, *old_reg_enum
;
602 * This should not happen but since it comes from the UST tracer, an
603 * external party, don't assert and simply validate values.
605 if (session_objd
< 0) {
610 /* Check if the enumeration was already dumped */
611 reg_enum
= zmalloc(sizeof(*reg_enum
));
613 PERROR("zmalloc ust registry enumeration");
617 strncpy(reg_enum
->name
, enum_name
, LTTNG_UST_SYM_NAME_LEN
);
618 reg_enum
->name
[LTTNG_UST_SYM_NAME_LEN
- 1] = '\0';
619 /* entries will be owned by reg_enum. */
620 reg_enum
->entries
= entries
;
621 reg_enum
->nr_entries
= nr_entries
;
624 old_reg_enum
= ust_registry_lookup_enum(session
, reg_enum
);
626 DBG("enum %s already in sess_objd: %u", enum_name
, session_objd
);
627 /* Fall through. Use prior enum. */
628 destroy_enum(reg_enum
);
629 reg_enum
= old_reg_enum
;
631 DBG("UST registry creating enum: %s, sess_objd: %u",
632 enum_name
, session_objd
);
633 if (session
->next_enum_id
== -1ULL) {
635 destroy_enum(reg_enum
);
638 reg_enum
->id
= session
->next_enum_id
++;
639 cds_lfht_node_init(®_enum
->node
.node
);
640 nodep
= cds_lfht_add_unique(session
->enums
->ht
,
641 ht_hash_enum(reg_enum
, lttng_ht_seed
),
642 ht_match_enum_id
, reg_enum
,
643 ®_enum
->node
.node
);
644 assert(nodep
== ®_enum
->node
.node
);
646 DBG("UST registry reply with enum %s with id %" PRIu64
" in sess_objd: %u",
647 enum_name
, reg_enum
->id
, session_objd
);
648 *enum_id
= reg_enum
->id
;
656 * For a given enumeration in a registry, delete the entry and destroy
658 * This MUST be called within a RCU read side lock section.
660 void ust_registry_destroy_enum(struct ust_registry_session
*reg_session
,
661 struct ust_registry_enum
*reg_enum
)
664 struct lttng_ht_iter iter
;
669 /* Delete the node first. */
670 iter
.iter
.node
= ®_enum
->node
.node
;
671 ret
= lttng_ht_del(reg_session
->enums
, &iter
);
673 call_rcu(®_enum
->rcu_head
, destroy_enum_rcu
);
677 * We need to execute ht_destroy outside of RCU read-side critical
678 * section and outside of call_rcu thread, so we postpone its execution
679 * using ht_cleanup_push. It is simpler than to change the semantic of
680 * the many callers of delete_ust_app_session().
683 void destroy_channel_rcu(struct rcu_head
*head
)
685 struct ust_registry_channel
*chan
=
686 caa_container_of(head
, struct ust_registry_channel
, rcu_head
);
689 ht_cleanup_push(chan
->ht
);
691 free(chan
->ctx_fields
);
696 * Destroy every element of the registry and free the memory. This does NOT
697 * free the registry pointer since it might not have been allocated before so
698 * it's the caller responsability.
700 static void destroy_channel(struct ust_registry_channel
*chan
, bool notif
)
702 struct lttng_ht_iter iter
;
703 struct ust_registry_event
*event
;
704 enum lttng_error_code cmd_ret
;
709 cmd_ret
= notification_thread_command_remove_channel(
710 notification_thread_handle
, chan
->consumer_key
,
712 if (cmd_ret
!= LTTNG_OK
) {
713 ERR("Failed to remove channel from notification thread");
718 /* Destroy all event associated with this registry. */
719 cds_lfht_for_each_entry(chan
->ht
->ht
, &iter
.iter
, event
, node
.node
) {
720 /* Delete the node from the ht and free it. */
721 ust_registry_destroy_event(chan
, event
);
724 call_rcu(&chan
->rcu_head
, destroy_channel_rcu
);
728 * Initialize registry with default values.
730 int ust_registry_channel_add(struct ust_registry_session
*session
,
734 struct ust_registry_channel
*chan
;
738 chan
= zmalloc(sizeof(*chan
));
740 PERROR("zmalloc ust registry channel");
745 chan
->ht
= lttng_ht_new(0, LTTNG_HT_TYPE_STRING
);
751 /* Set custom match function. */
752 chan
->ht
->match_fct
= ht_match_event
;
753 chan
->ht
->hash_fct
= ht_hash_event
;
756 * Assign a channel ID right now since the event notification comes
757 * *before* the channel notify so the ID needs to be set at this point so
758 * the metadata can be dumped for that event.
760 if (ust_registry_is_max_id(session
->used_channel_id
)) {
764 chan
->chan_id
= ust_registry_get_next_chan_id(session
);
767 lttng_ht_node_init_u64(&chan
->node
, key
);
768 lttng_ht_add_unique_u64(session
->channels
, &chan
->node
);
774 destroy_channel(chan
, false);
780 * Find a channel in the given registry. RCU read side lock MUST be acquired
781 * before calling this function and as long as the event reference is kept by
784 * On success, the pointer is returned else NULL.
786 struct ust_registry_channel
*ust_registry_channel_find(
787 struct ust_registry_session
*session
, uint64_t key
)
789 struct lttng_ht_node_u64
*node
;
790 struct lttng_ht_iter iter
;
791 struct ust_registry_channel
*chan
= NULL
;
794 assert(session
->channels
);
796 DBG3("UST registry channel finding key %" PRIu64
, key
);
798 lttng_ht_lookup(session
->channels
, &key
, &iter
);
799 node
= lttng_ht_iter_get_node_u64(&iter
);
803 chan
= caa_container_of(node
, struct ust_registry_channel
, node
);
810 * Remove channel using key from registry and free memory.
812 void ust_registry_channel_del_free(struct ust_registry_session
*session
,
813 uint64_t key
, bool notif
)
815 struct lttng_ht_iter iter
;
816 struct ust_registry_channel
*chan
;
822 chan
= ust_registry_channel_find(session
, key
);
828 iter
.iter
.node
= &chan
->node
.node
;
829 ret
= lttng_ht_del(session
->channels
, &iter
);
832 destroy_channel(chan
, notif
);
839 * Initialize registry with default values and set the newly allocated session
840 * pointer to sessionp.
842 * Return 0 on success and sessionp is set or else return -1 and sessionp is
845 int ust_registry_session_init(struct ust_registry_session
**sessionp
,
847 uint32_t bits_per_long
,
848 uint32_t uint8_t_alignment
,
849 uint32_t uint16_t_alignment
,
850 uint32_t uint32_t_alignment
,
851 uint32_t uint64_t_alignment
,
852 uint32_t long_alignment
,
856 const char *root_shm_path
,
857 const char *shm_path
,
862 struct ust_registry_session
*session
;
866 session
= zmalloc(sizeof(*session
));
868 PERROR("zmalloc ust registry session");
872 pthread_mutex_init(&session
->lock
, NULL
);
873 session
->bits_per_long
= bits_per_long
;
874 session
->uint8_t_alignment
= uint8_t_alignment
;
875 session
->uint16_t_alignment
= uint16_t_alignment
;
876 session
->uint32_t_alignment
= uint32_t_alignment
;
877 session
->uint64_t_alignment
= uint64_t_alignment
;
878 session
->long_alignment
= long_alignment
;
879 session
->byte_order
= byte_order
;
880 session
->metadata_fd
= -1;
883 session
->next_enum_id
= 0;
884 session
->major
= major
;
885 session
->minor
= minor
;
886 strncpy(session
->root_shm_path
, root_shm_path
,
887 sizeof(session
->root_shm_path
));
888 session
->root_shm_path
[sizeof(session
->root_shm_path
) - 1] = '\0';
890 strncpy(session
->shm_path
, shm_path
,
891 sizeof(session
->shm_path
));
892 session
->shm_path
[sizeof(session
->shm_path
) - 1] = '\0';
893 strncpy(session
->metadata_path
, shm_path
,
894 sizeof(session
->metadata_path
));
895 session
->metadata_path
[sizeof(session
->metadata_path
) - 1] = '\0';
896 strncat(session
->metadata_path
, "/metadata",
897 sizeof(session
->metadata_path
)
898 - strlen(session
->metadata_path
) - 1);
900 if (session
->shm_path
[0]) {
901 ret
= run_as_mkdir_recursive(session
->shm_path
,
905 PERROR("run_as_mkdir_recursive");
909 if (session
->metadata_path
[0]) {
910 /* Create metadata file */
911 ret
= run_as_open(session
->metadata_path
,
912 O_WRONLY
| O_CREAT
| O_EXCL
,
913 S_IRUSR
| S_IWUSR
, euid
, egid
);
915 PERROR("Opening metadata file");
918 session
->metadata_fd
= ret
;
921 session
->enums
= lttng_ht_new(0, LTTNG_HT_TYPE_STRING
);
922 if (!session
->enums
) {
923 ERR("Failed to create enums hash table");
926 /* hash/match functions are specified at call site. */
927 session
->enums
->match_fct
= NULL
;
928 session
->enums
->hash_fct
= NULL
;
930 session
->channels
= lttng_ht_new(0, LTTNG_HT_TYPE_U64
);
931 if (!session
->channels
) {
935 ret
= lttng_uuid_generate(session
->uuid
);
937 ERR("Failed to generate UST uuid (errno = %d)", ret
);
941 pthread_mutex_lock(&session
->lock
);
942 ret
= ust_metadata_session_statedump(session
, app
, major
, minor
);
943 pthread_mutex_unlock(&session
->lock
);
945 ERR("Failed to generate session metadata (errno = %d)", ret
);
954 ust_registry_session_destroy(session
);
961 * Destroy session registry. This does NOT free the given pointer since it
962 * might get passed as a reference. The registry lock should NOT be acquired.
964 void ust_registry_session_destroy(struct ust_registry_session
*reg
)
967 struct lttng_ht_iter iter
;
968 struct ust_registry_channel
*chan
;
969 struct ust_registry_enum
*reg_enum
;
975 /* On error, EBUSY can be returned if lock. Code flow error. */
976 ret
= pthread_mutex_destroy(®
->lock
);
981 /* Destroy all event associated with this registry. */
982 cds_lfht_for_each_entry(reg
->channels
->ht
, &iter
.iter
, chan
,
984 /* Delete the node from the ht and free it. */
985 ret
= lttng_ht_del(reg
->channels
, &iter
);
987 destroy_channel(chan
, true);
990 ht_cleanup_push(reg
->channels
);
994 if (reg
->metadata_fd
>= 0) {
995 ret
= close(reg
->metadata_fd
);
999 ret
= run_as_unlink(reg
->metadata_path
,
1000 reg
->uid
, reg
->gid
);
1005 if (reg
->root_shm_path
[0]) {
1007 * Try deleting the directory hierarchy.
1009 (void) run_as_rmdir_recursive(reg
->root_shm_path
,
1010 reg
->uid
, reg
->gid
);
1012 /* Destroy the enum hash table */
1015 /* Destroy all enum entries associated with this registry. */
1016 cds_lfht_for_each_entry(reg
->enums
->ht
, &iter
.iter
, reg_enum
,
1018 ust_registry_destroy_enum(reg
, reg_enum
);
1021 ht_cleanup_push(reg
->enums
);