+ * Match function for the events hash table lookup by name.
+ */
+static int ht_match_event_by_name(struct cds_lfht_node *node,
+ const void *_key)
+{
+ struct jul_event *event;
+ const struct jul_ht_key *key;
+
+ assert(node);
+ assert(_key);
+
+ event = caa_container_of(node, struct jul_event, node.node);
+ key = _key;
+
+ /* Match 1 elements of the key: name. */
+
+ /* Event name */
+ if (strncmp(event->name, key->name, sizeof(event->name)) != 0) {
+ goto no_match;
+ }
+ /* Match. */
+ return 1;
+
+no_match:
+ return 0;
+}
+
+/*
+ * Match function for the events hash table lookup by name and loglevel.
+ */
+static int ht_match_event(struct cds_lfht_node *node,
+ const void *_key)
+{
+ struct jul_event *event;
+ const struct jul_ht_key *key;
+
+ assert(node);
+ assert(_key);
+
+ event = caa_container_of(node, struct jul_event, node.node);
+ key = _key;
+
+ /* Match 2 elements of the key: name and loglevel. */
+
+ /* Event name */
+ if (strncmp(event->name, key->name, sizeof(event->name)) != 0) {
+ goto no_match;
+ }
+
+ if (event->loglevel != key->loglevel) {
+ if (event->loglevel_type == LTTNG_EVENT_LOGLEVEL_ALL &&
+ key->loglevel == 0 && event->loglevel == -1) {
+ goto match;
+ }
+ goto no_match;
+ }
+match:
+ return 1;
+
+no_match:
+ return 0;
+}
+
+/*
+ * Add unique JUL event based on the event name and loglevel.
+ */
+static void add_unique_jul_event(struct lttng_ht *ht, struct jul_event *event)
+{
+ struct cds_lfht_node *node_ptr;
+ struct jul_ht_key key;
+
+ assert(ht);
+ assert(ht->ht);
+ assert(event);
+
+ key.name = event->name;
+ key.loglevel = event->loglevel;
+
+ node_ptr = cds_lfht_add_unique(ht->ht,
+ ht->hash_fct(event->node.key, lttng_ht_seed),
+ ht_match_event, &key, &event->node.node);
+ assert(node_ptr == &event->node.node);
+}
+
+/*
+ * URCU delayed JUL event reclaim.