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.
21 #include <common/common.h>
27 * URCU intermediate call to complete destroy a JUL event.
29 static void destroy_event_jul_rcu(struct rcu_head
*head
)
31 struct lttng_ht_node_str
*node
=
32 caa_container_of(head
, struct lttng_ht_node_str
, head
);
33 struct jul_event
*event
=
34 caa_container_of(node
, struct jul_event
, node
);
40 * Initialize an already allocated JUL domain object.
42 * Return 0 on success or else a negative errno value.
44 int jul_init_domain(struct jul_domain
*dom
)
50 dom
->events
= lttng_ht_new(0, LTTNG_HT_TYPE_STRING
);
63 * Create a newly allocated JUL event data structure. If name is valid, it's
64 * copied into the created event.
66 * Return a new object else NULL on error.
68 struct jul_event
*jul_create_event(const char *name
)
70 struct jul_event
*event
;
72 DBG3("JUL create new event with name %s", name
);
74 event
= zmalloc(sizeof(*event
));
80 strncpy(event
->name
, name
, sizeof(event
->name
));
81 event
->name
[sizeof(event
->name
) - 1] = '\0';
89 * Unique add of a JUL event to a given domain.
91 void jul_add_event(struct jul_event
*event
, struct jul_domain
*dom
)
97 DBG3("JUL adding event %s to domain", event
->name
);
99 lttng_ht_add_unique_str(dom
->events
, &event
->node
);
103 * Find a JUL event in the given domain using name.
105 * RCU read side lock MUST be acquired.
107 * Return object if found else NULL.
109 struct jul_event
*jul_find_by_name(const char *name
, struct jul_domain
*dom
)
111 struct lttng_ht_node_str
*node
;
112 struct lttng_ht_iter iter
;
118 lttng_ht_lookup(dom
->events
, (void *)name
, &iter
);
119 node
= lttng_ht_iter_get_node_str(&iter
);
124 DBG3("JUL found by name %s in domain.", name
);
125 return caa_container_of(node
, struct jul_event
, node
);
128 DBG3("JUL NOT found by name %s in domain.", name
);
133 * Delete JUL event from given domain. Events hash table MUST be initialized.
135 void jul_delete_event(struct jul_event
*event
, struct jul_domain
*dom
)
138 struct lttng_ht_iter iter
;
144 DBG3("JUL deleting event %s from domain", event
->name
);
146 iter
.iter
.node
= &event
->node
.node
;
148 ret
= lttng_ht_del(dom
->events
, &iter
);
154 * Free given JUl event. After this call, the pointer is not usable anymore.
156 void jul_destroy_event(struct jul_event
*event
)
164 * Destroy a JUL domain completely. Note that the given pointer is NOT freed
165 * thus a reference can be passed to this function.
167 void jul_destroy_domain(struct jul_domain
*dom
)
169 struct lttng_ht_node_str
*node
;
170 struct lttng_ht_iter iter
;
174 DBG3("JUL destroy domain");
177 * Just ignore if no events hash table exists. This is possible if for
178 * instance a JUL domain object was allocated but not initialized.
185 cds_lfht_for_each_entry(dom
->events
->ht
, &iter
.iter
, node
, node
) {
188 ret
= lttng_ht_del(dom
->events
, &iter
);
190 call_rcu(&node
->head
, destroy_event_jul_rcu
);
194 ht_cleanup_push(dom
->events
);
This page took 0.039767 seconds and 5 git commands to generate.