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"
28 #include "ust-field-utils.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 const struct ust_registry_event
*key
;
38 struct ust_registry_event
*event
;
44 event
= caa_container_of(node
, struct ust_registry_event
, node
.node
);
48 /* It has to be a perfect match. First, compare the event names. */
49 if (strncmp(event
->name
, key
->name
, sizeof(event
->name
))) {
53 /* Compare log levels. */
54 if (event
->loglevel_value
!= key
->loglevel_value
) {
58 /* Compare the number of fields. */
59 if (event
->nr_fields
!= key
->nr_fields
) {
63 /* Compare each field individually. */
64 for (i
= 0; i
< event
->nr_fields
; i
++) {
65 if (!match_ustctl_field(&event
->fields
[i
], &key
->fields
[i
])) {
70 /* Compare model URI. */
71 if (event
->model_emf_uri
!= NULL
&& key
->model_emf_uri
== NULL
) {
73 } else if(event
->model_emf_uri
== NULL
&& key
->model_emf_uri
!= NULL
) {
75 } else if (event
->model_emf_uri
!= NULL
&& key
->model_emf_uri
!= NULL
) {
76 if (strcmp(event
->model_emf_uri
, key
->model_emf_uri
)) {
88 static unsigned long ht_hash_event(void *_key
, unsigned long seed
)
91 struct ust_registry_event
*key
= _key
;
95 hashed_key
= (uint64_t) hash_key_str(key
->name
, seed
);
97 return hash_key_u64(&hashed_key
, seed
);
100 static int compare_enums(const struct ust_registry_enum
*reg_enum_a
,
101 const struct ust_registry_enum
*reg_enum_b
)
106 assert(strcmp(reg_enum_a
->name
, reg_enum_b
->name
) == 0);
107 if (reg_enum_a
->nr_entries
!= reg_enum_b
->nr_entries
) {
111 for (i
= 0; i
< reg_enum_a
->nr_entries
; i
++) {
112 const struct ustctl_enum_entry
*entries_a
, *entries_b
;
114 entries_a
= ®_enum_a
->entries
[i
];
115 entries_b
= ®_enum_b
->entries
[i
];
116 if (entries_a
->start
.value
!= entries_b
->start
.value
) {
120 if (entries_a
->end
.value
!= entries_b
->end
.value
) {
124 if (entries_a
->start
.signedness
!= entries_b
->start
.signedness
) {
128 if (entries_a
->end
.signedness
!= entries_b
->end
.signedness
) {
133 if (strcmp(entries_a
->string
, entries_b
->string
)) {
143 * Hash table match function for enumerations in the session. Match is
144 * performed on enumeration name, and confirmed by comparing the enum
147 static int ht_match_enum(struct cds_lfht_node
*node
, const void *_key
)
149 struct ust_registry_enum
*_enum
;
150 const struct ust_registry_enum
*key
;
155 _enum
= caa_container_of(node
, struct ust_registry_enum
,
160 if (strncmp(_enum
->name
, key
->name
, LTTNG_UST_SYM_NAME_LEN
)) {
163 if (compare_enums(_enum
, key
)) {
175 * Hash table match function for enumerations in the session. Match is
176 * performed by enumeration ID.
178 static int ht_match_enum_id(struct cds_lfht_node
*node
, const void *_key
)
180 struct ust_registry_enum
*_enum
;
181 const struct ust_registry_enum
*key
= _key
;
186 _enum
= caa_container_of(node
, struct ust_registry_enum
, node
.node
);
189 if (_enum
->id
!= key
->id
) {
201 * Hash table hash function for enumerations in the session. The
202 * enumeration name is used for hashing.
204 static unsigned long ht_hash_enum(void *_key
, unsigned long seed
)
206 struct ust_registry_enum
*key
= _key
;
209 return hash_key_str(key
->name
, seed
);
213 * Return negative value on error, 0 if OK.
215 * TODO: we could add stricter verification of more types to catch
216 * errors in liblttng-ust implementation earlier than consumption by the
220 int validate_event_field(struct ustctl_field
*field
,
221 const char *event_name
,
226 switch(field
->type
.atype
) {
227 case ustctl_atype_integer
:
228 case ustctl_atype_enum
:
229 case ustctl_atype_array
:
230 case ustctl_atype_sequence
:
231 case ustctl_atype_string
:
232 case ustctl_atype_variant
:
234 case ustctl_atype_struct
:
235 if (field
->type
.u
._struct
.nr_fields
!= 0) {
236 WARN("Unsupported non-empty struct field.");
242 case ustctl_atype_float
:
243 switch (field
->type
.u
.basic
._float
.mant_dig
) {
245 WARN("UST application '%s' (pid: %d) has unknown float mantissa '%u' "
246 "in field '%s', rejecting event '%s'",
248 field
->type
.u
.basic
._float
.mant_dig
,
267 int validate_event_fields(size_t nr_fields
, struct ustctl_field
*fields
,
268 const char *event_name
, struct ust_app
*app
)
272 for (i
= 0; i
< nr_fields
; i
++) {
273 if (validate_event_field(&fields
[i
], event_name
, app
) < 0)
280 * Allocate event and initialize it. This does NOT set a valid event id from a
283 static struct ust_registry_event
*alloc_event(int session_objd
,
284 int channel_objd
, char *name
, char *sig
, size_t nr_fields
,
285 struct ustctl_field
*fields
, int loglevel_value
,
286 char *model_emf_uri
, struct ust_app
*app
)
288 struct ust_registry_event
*event
= NULL
;
291 * Ensure that the field content is valid.
293 if (validate_event_fields(nr_fields
, fields
, name
, app
) < 0) {
297 event
= zmalloc(sizeof(*event
));
299 PERROR("zmalloc ust registry event");
303 event
->session_objd
= session_objd
;
304 event
->channel_objd
= channel_objd
;
305 /* Allocated by ustctl. */
306 event
->signature
= sig
;
307 event
->nr_fields
= nr_fields
;
308 event
->fields
= fields
;
309 event
->loglevel_value
= loglevel_value
;
310 event
->model_emf_uri
= model_emf_uri
;
312 /* Copy event name and force NULL byte. */
313 strncpy(event
->name
, name
, sizeof(event
->name
));
314 event
->name
[sizeof(event
->name
) - 1] = '\0';
316 cds_lfht_node_init(&event
->node
.node
);
323 * Free event data structure. This does NOT delete it from any hash table. It's
324 * safe to pass a NULL pointer. This shoudl be called inside a call RCU if the
325 * event is previously deleted from a rcu hash table.
327 static void destroy_event(struct ust_registry_event
*event
)
334 free(event
->model_emf_uri
);
335 free(event
->signature
);
340 * Destroy event function call of the call RCU.
342 static void destroy_event_rcu(struct rcu_head
*head
)
344 struct lttng_ht_node_u64
*node
=
345 caa_container_of(head
, struct lttng_ht_node_u64
, head
);
346 struct ust_registry_event
*event
=
347 caa_container_of(node
, struct ust_registry_event
, node
);
349 destroy_event(event
);
353 * Find an event using the name and signature in the given registry. RCU read
354 * side lock MUST be acquired before calling this function and as long as the
355 * event reference is kept by the caller.
357 * On success, the event pointer is returned else NULL.
359 struct ust_registry_event
*ust_registry_find_event(
360 struct ust_registry_channel
*chan
, char *name
, char *sig
)
362 struct lttng_ht_node_u64
*node
;
363 struct lttng_ht_iter iter
;
364 struct ust_registry_event
*event
= NULL
;
365 struct ust_registry_event key
;
371 /* Setup key for the match function. */
372 strncpy(key
.name
, name
, sizeof(key
.name
));
373 key
.name
[sizeof(key
.name
) - 1] = '\0';
376 cds_lfht_lookup(chan
->ht
->ht
, chan
->ht
->hash_fct(&key
, lttng_ht_seed
),
377 chan
->ht
->match_fct
, &key
, &iter
.iter
);
378 node
= lttng_ht_iter_get_node_u64(&iter
);
382 event
= caa_container_of(node
, struct ust_registry_event
, node
);
389 * Create a ust_registry_event from the given parameters and add it to the
390 * registry hash table. If event_id is valid, it is set with the newly created
393 * On success, return 0 else a negative value. The created event MUST be unique
394 * so on duplicate entry -EINVAL is returned. On error, event_id is untouched.
396 * Should be called with session registry mutex held.
398 int ust_registry_create_event(struct ust_registry_session
*session
,
399 uint64_t chan_key
, int session_objd
, int channel_objd
, char *name
,
400 char *sig
, size_t nr_fields
, struct ustctl_field
*fields
,
401 int loglevel_value
, char *model_emf_uri
, int buffer_type
,
402 uint32_t *event_id_p
, struct ust_app
*app
)
406 struct cds_lfht_node
*nptr
;
407 struct ust_registry_event
*event
= NULL
;
408 struct ust_registry_channel
*chan
;
418 * This should not happen but since it comes from the UST tracer, an
419 * external party, don't assert and simply validate values.
421 if (session_objd
< 0 || channel_objd
< 0) {
426 chan
= ust_registry_channel_find(session
, chan_key
);
432 /* Check if we've reached the maximum possible id. */
433 if (ust_registry_is_max_id(chan
->used_event_id
)) {
438 event
= alloc_event(session_objd
, channel_objd
, name
, sig
, nr_fields
,
439 fields
, loglevel_value
, model_emf_uri
, app
);
445 DBG3("UST registry creating event with event: %s, sig: %s, id: %u, "
446 "chan_objd: %u, sess_objd: %u, chan_id: %u", event
->name
,
447 event
->signature
, event
->id
, event
->channel_objd
,
448 event
->session_objd
, chan
->chan_id
);
451 * This is an add unique with a custom match function for event. The node
452 * are matched using the event name and signature.
454 nptr
= cds_lfht_add_unique(chan
->ht
->ht
, chan
->ht
->hash_fct(event
,
455 lttng_ht_seed
), chan
->ht
->match_fct
, event
, &event
->node
.node
);
456 if (nptr
!= &event
->node
.node
) {
457 if (buffer_type
== LTTNG_BUFFER_PER_UID
) {
459 * This is normal, we just have to send the event id of the
460 * returned node and make sure we destroy the previously allocated
463 destroy_event(event
);
464 event
= caa_container_of(nptr
, struct ust_registry_event
,
467 event_id
= event
->id
;
469 ERR("UST registry create event add unique failed for event: %s, "
470 "sig: %s, id: %u, chan_objd: %u, sess_objd: %u",
471 event
->name
, event
->signature
, event
->id
,
472 event
->channel_objd
, event
->session_objd
);
477 /* Request next event id if the node was successfully added. */
478 event_id
= event
->id
= ust_registry_get_next_event_id(chan
);
481 *event_id_p
= event_id
;
483 if (!event
->metadata_dumped
) {
484 /* Append to metadata */
485 ret
= ust_metadata_event_statedump(session
, chan
, event
);
487 ERR("Error appending event metadata (errno = %d)", ret
);
502 destroy_event(event
);
507 * For a given event in a registry, delete the entry and destroy the event.
508 * This MUST be called within a RCU read side lock section.
510 void ust_registry_destroy_event(struct ust_registry_channel
*chan
,
511 struct ust_registry_event
*event
)
514 struct lttng_ht_iter iter
;
519 /* Delete the node first. */
520 iter
.iter
.node
= &event
->node
.node
;
521 ret
= lttng_ht_del(chan
->ht
, &iter
);
524 call_rcu(&event
->node
.head
, destroy_event_rcu
);
529 static void destroy_enum(struct ust_registry_enum
*reg_enum
)
534 free(reg_enum
->entries
);
538 static void destroy_enum_rcu(struct rcu_head
*head
)
540 struct ust_registry_enum
*reg_enum
=
541 caa_container_of(head
, struct ust_registry_enum
, rcu_head
);
543 destroy_enum(reg_enum
);
547 * Lookup enumeration by name and comparing enumeration entries.
548 * Needs to be called from RCU read-side critical section.
550 struct ust_registry_enum
*
551 ust_registry_lookup_enum(struct ust_registry_session
*session
,
552 const struct ust_registry_enum
*reg_enum_lookup
)
554 struct ust_registry_enum
*reg_enum
= NULL
;
555 struct lttng_ht_node_str
*node
;
556 struct lttng_ht_iter iter
;
558 cds_lfht_lookup(session
->enums
->ht
,
559 ht_hash_enum((void *) reg_enum_lookup
, lttng_ht_seed
),
560 ht_match_enum
, reg_enum_lookup
, &iter
.iter
);
561 node
= lttng_ht_iter_get_node_str(&iter
);
565 reg_enum
= caa_container_of(node
, struct ust_registry_enum
, node
);
571 * Lookup enumeration by enum ID.
572 * Needs to be called from RCU read-side critical section.
574 struct ust_registry_enum
*
575 ust_registry_lookup_enum_by_id(struct ust_registry_session
*session
,
576 const char *enum_name
, uint64_t enum_id
)
578 struct ust_registry_enum
*reg_enum
= NULL
;
579 struct lttng_ht_node_str
*node
;
580 struct lttng_ht_iter iter
;
581 struct ust_registry_enum reg_enum_lookup
;
583 memset(®_enum_lookup
, 0, sizeof(reg_enum_lookup
));
584 strncpy(reg_enum_lookup
.name
, enum_name
, LTTNG_UST_SYM_NAME_LEN
);
585 reg_enum_lookup
.name
[LTTNG_UST_SYM_NAME_LEN
- 1] = '\0';
586 reg_enum_lookup
.id
= enum_id
;
587 cds_lfht_lookup(session
->enums
->ht
,
588 ht_hash_enum((void *) ®_enum_lookup
, lttng_ht_seed
),
589 ht_match_enum_id
, ®_enum_lookup
, &iter
.iter
);
590 node
= lttng_ht_iter_get_node_str(&iter
);
594 reg_enum
= caa_container_of(node
, struct ust_registry_enum
, node
);
600 * Create a ust_registry_enum from the given parameters and add it to the
601 * registry hash table, or find it if already there.
603 * On success, return 0 else a negative value.
605 * Should be called with session registry mutex held.
607 * We receive ownership of entries.
609 int ust_registry_create_or_find_enum(struct ust_registry_session
*session
,
610 int session_objd
, char *enum_name
,
611 struct ustctl_enum_entry
*entries
, size_t nr_entries
,
615 struct cds_lfht_node
*nodep
;
616 struct ust_registry_enum
*reg_enum
= NULL
, *old_reg_enum
;
624 * This should not happen but since it comes from the UST tracer, an
625 * external party, don't assert and simply validate values.
627 if (session_objd
< 0) {
632 /* Check if the enumeration was already dumped */
633 reg_enum
= zmalloc(sizeof(*reg_enum
));
635 PERROR("zmalloc ust registry enumeration");
639 strncpy(reg_enum
->name
, enum_name
, LTTNG_UST_SYM_NAME_LEN
);
640 reg_enum
->name
[LTTNG_UST_SYM_NAME_LEN
- 1] = '\0';
641 /* entries will be owned by reg_enum. */
642 reg_enum
->entries
= entries
;
643 reg_enum
->nr_entries
= nr_entries
;
646 old_reg_enum
= ust_registry_lookup_enum(session
, reg_enum
);
648 DBG("enum %s already in sess_objd: %u", enum_name
, session_objd
);
649 /* Fall through. Use prior enum. */
650 destroy_enum(reg_enum
);
651 reg_enum
= old_reg_enum
;
653 DBG("UST registry creating enum: %s, sess_objd: %u",
654 enum_name
, session_objd
);
655 if (session
->next_enum_id
== -1ULL) {
657 destroy_enum(reg_enum
);
660 reg_enum
->id
= session
->next_enum_id
++;
661 cds_lfht_node_init(®_enum
->node
.node
);
662 nodep
= cds_lfht_add_unique(session
->enums
->ht
,
663 ht_hash_enum(reg_enum
, lttng_ht_seed
),
664 ht_match_enum_id
, reg_enum
,
665 ®_enum
->node
.node
);
666 assert(nodep
== ®_enum
->node
.node
);
668 DBG("UST registry reply with enum %s with id %" PRIu64
" in sess_objd: %u",
669 enum_name
, reg_enum
->id
, session_objd
);
670 *enum_id
= reg_enum
->id
;
678 * For a given enumeration in a registry, delete the entry and destroy
680 * This MUST be called within a RCU read side lock section.
682 void ust_registry_destroy_enum(struct ust_registry_session
*reg_session
,
683 struct ust_registry_enum
*reg_enum
)
686 struct lttng_ht_iter iter
;
691 /* Delete the node first. */
692 iter
.iter
.node
= ®_enum
->node
.node
;
693 ret
= lttng_ht_del(reg_session
->enums
, &iter
);
695 call_rcu(®_enum
->rcu_head
, destroy_enum_rcu
);
699 * We need to execute ht_destroy outside of RCU read-side critical
700 * section and outside of call_rcu thread, so we postpone its execution
701 * using ht_cleanup_push. It is simpler than to change the semantic of
702 * the many callers of delete_ust_app_session().
705 void destroy_channel_rcu(struct rcu_head
*head
)
707 struct ust_registry_channel
*chan
=
708 caa_container_of(head
, struct ust_registry_channel
, rcu_head
);
711 ht_cleanup_push(chan
->ht
);
713 free(chan
->ctx_fields
);
718 * Destroy every element of the registry and free the memory. This does NOT
719 * free the registry pointer since it might not have been allocated before so
720 * it's the caller responsability.
722 static void destroy_channel(struct ust_registry_channel
*chan
)
724 struct lttng_ht_iter iter
;
725 struct ust_registry_event
*event
;
730 /* Destroy all event associated with this registry. */
731 cds_lfht_for_each_entry(chan
->ht
->ht
, &iter
.iter
, event
, node
.node
) {
732 /* Delete the node from the ht and free it. */
733 ust_registry_destroy_event(chan
, event
);
736 call_rcu(&chan
->rcu_head
, destroy_channel_rcu
);
740 * Initialize registry with default values.
742 int ust_registry_channel_add(struct ust_registry_session
*session
,
746 struct ust_registry_channel
*chan
;
750 chan
= zmalloc(sizeof(*chan
));
752 PERROR("zmalloc ust registry channel");
757 chan
->ht
= lttng_ht_new(0, LTTNG_HT_TYPE_STRING
);
763 /* Set custom match function. */
764 chan
->ht
->match_fct
= ht_match_event
;
765 chan
->ht
->hash_fct
= ht_hash_event
;
768 * Assign a channel ID right now since the event notification comes
769 * *before* the channel notify so the ID needs to be set at this point so
770 * the metadata can be dumped for that event.
772 if (ust_registry_is_max_id(session
->used_channel_id
)) {
776 chan
->chan_id
= ust_registry_get_next_chan_id(session
);
779 lttng_ht_node_init_u64(&chan
->node
, key
);
780 lttng_ht_add_unique_u64(session
->channels
, &chan
->node
);
786 destroy_channel(chan
);
792 * Find a channel in the given registry. RCU read side lock MUST be acquired
793 * before calling this function and as long as the event reference is kept by
796 * On success, the pointer is returned else NULL.
798 struct ust_registry_channel
*ust_registry_channel_find(
799 struct ust_registry_session
*session
, uint64_t key
)
801 struct lttng_ht_node_u64
*node
;
802 struct lttng_ht_iter iter
;
803 struct ust_registry_channel
*chan
= NULL
;
806 assert(session
->channels
);
808 DBG3("UST registry channel finding key %" PRIu64
, key
);
810 lttng_ht_lookup(session
->channels
, &key
, &iter
);
811 node
= lttng_ht_iter_get_node_u64(&iter
);
815 chan
= caa_container_of(node
, struct ust_registry_channel
, node
);
822 * Remove channel using key from registry and free memory.
824 void ust_registry_channel_del_free(struct ust_registry_session
*session
,
827 struct lttng_ht_iter iter
;
828 struct ust_registry_channel
*chan
;
834 chan
= ust_registry_channel_find(session
, key
);
840 iter
.iter
.node
= &chan
->node
.node
;
841 ret
= lttng_ht_del(session
->channels
, &iter
);
844 destroy_channel(chan
);
851 * Initialize registry with default values and set the newly allocated session
852 * pointer to sessionp.
854 * Return 0 on success and sessionp is set or else return -1 and sessionp is
857 int ust_registry_session_init(struct ust_registry_session
**sessionp
,
859 uint32_t bits_per_long
,
860 uint32_t uint8_t_alignment
,
861 uint32_t uint16_t_alignment
,
862 uint32_t uint32_t_alignment
,
863 uint32_t uint64_t_alignment
,
864 uint32_t long_alignment
,
868 const char *root_shm_path
,
869 const char *shm_path
,
874 struct ust_registry_session
*session
;
878 session
= zmalloc(sizeof(*session
));
880 PERROR("zmalloc ust registry session");
884 pthread_mutex_init(&session
->lock
, NULL
);
885 session
->bits_per_long
= bits_per_long
;
886 session
->uint8_t_alignment
= uint8_t_alignment
;
887 session
->uint16_t_alignment
= uint16_t_alignment
;
888 session
->uint32_t_alignment
= uint32_t_alignment
;
889 session
->uint64_t_alignment
= uint64_t_alignment
;
890 session
->long_alignment
= long_alignment
;
891 session
->byte_order
= byte_order
;
892 session
->metadata_fd
= -1;
895 session
->next_enum_id
= 0;
896 session
->major
= major
;
897 session
->minor
= minor
;
898 strncpy(session
->root_shm_path
, root_shm_path
,
899 sizeof(session
->root_shm_path
));
900 session
->root_shm_path
[sizeof(session
->root_shm_path
) - 1] = '\0';
902 strncpy(session
->shm_path
, shm_path
,
903 sizeof(session
->shm_path
));
904 session
->shm_path
[sizeof(session
->shm_path
) - 1] = '\0';
905 strncpy(session
->metadata_path
, shm_path
,
906 sizeof(session
->metadata_path
));
907 session
->metadata_path
[sizeof(session
->metadata_path
) - 1] = '\0';
908 strncat(session
->metadata_path
, "/metadata",
909 sizeof(session
->metadata_path
)
910 - strlen(session
->metadata_path
) - 1);
912 if (session
->shm_path
[0]) {
913 ret
= run_as_mkdir_recursive(session
->shm_path
,
917 PERROR("run_as_mkdir_recursive");
921 if (session
->metadata_path
[0]) {
922 /* Create metadata file */
923 ret
= run_as_open(session
->metadata_path
,
924 O_WRONLY
| O_CREAT
| O_EXCL
,
925 S_IRUSR
| S_IWUSR
, euid
, egid
);
927 PERROR("Opening metadata file");
930 session
->metadata_fd
= ret
;
933 session
->enums
= lttng_ht_new(0, LTTNG_HT_TYPE_STRING
);
934 if (!session
->enums
) {
938 /* hash/match functions are specified at call site. */
939 session
->enums
->match_fct
= NULL
;
940 session
->enums
->hash_fct
= NULL
;
942 session
->channels
= lttng_ht_new(0, LTTNG_HT_TYPE_U64
);
943 if (!session
->channels
) {
947 ret
= lttng_uuid_generate(session
->uuid
);
949 ERR("Failed to generate UST uuid (errno = %d)", ret
);
953 pthread_mutex_lock(&session
->lock
);
954 ret
= ust_metadata_session_statedump(session
, app
, major
, minor
);
955 pthread_mutex_unlock(&session
->lock
);
957 ERR("Failed to generate session metadata (errno = %d)", ret
);
966 ust_registry_session_destroy(session
);
973 * Destroy session registry. This does NOT free the given pointer since it
974 * might get passed as a reference. The registry lock should NOT be acquired.
976 void ust_registry_session_destroy(struct ust_registry_session
*reg
)
979 struct lttng_ht_iter iter
;
980 struct ust_registry_channel
*chan
;
981 struct ust_registry_enum
*reg_enum
;
987 /* On error, EBUSY can be returned if lock. Code flow error. */
988 ret
= pthread_mutex_destroy(®
->lock
);
993 /* Destroy all event associated with this registry. */
994 cds_lfht_for_each_entry(reg
->channels
->ht
, &iter
.iter
, chan
,
996 /* Delete the node from the ht and free it. */
997 ret
= lttng_ht_del(reg
->channels
, &iter
);
999 destroy_channel(chan
);
1002 ht_cleanup_push(reg
->channels
);
1005 free(reg
->metadata
);
1006 if (reg
->metadata_fd
>= 0) {
1007 ret
= close(reg
->metadata_fd
);
1011 ret
= run_as_unlink(reg
->metadata_path
,
1012 reg
->uid
, reg
->gid
);
1017 if (reg
->root_shm_path
[0]) {
1019 * Try deleting the directory hierarchy.
1021 (void) run_as_recursive_rmdir(reg
->root_shm_path
,
1022 reg
->uid
, reg
->gid
);
1024 /* Destroy the enum hash table */
1027 /* Destroy all enum entries associated with this registry. */
1028 cds_lfht_for_each_entry(reg
->enums
->ht
, &iter
.iter
, reg_enum
,
1030 ust_registry_destroy_enum(reg
, reg_enum
);
1033 ht_cleanup_push(reg
->enums
);