Fix: add missing VALGRIND ifdef checks and documentation
[lttng-tools.git] / src / bin / lttng-sessiond / jul.c
index 8b57b8d70cd7215fbfe393e76be097a6ce01f68c..7b603cf25137031effccd15a7a53f19efa39c713 100644 (file)
@@ -27,7 +27,7 @@
 #include "utils.h"
 
 /*
- * URCU intermediate call to complete destroy a JUL event.
+ * URCU delayed JUL event reclaim.
  */
 static void destroy_event_jul_rcu(struct rcu_head *head)
 {
@@ -40,7 +40,7 @@ static void destroy_event_jul_rcu(struct rcu_head *head)
 }
 
 /*
- * URCU intermediate call to complete destroy a JUL event.
+ * URCU delayed JUL app reclaim.
  */
 static void destroy_app_jul_rcu(struct rcu_head *head)
 {
@@ -53,8 +53,8 @@ static void destroy_app_jul_rcu(struct rcu_head *head)
 }
 
 /*
- * Communication with Java agent call. Send the message header to the given
- * socket all in big endian.
+ * Communication with Java agent. Send the message header to the given
+ * socket in big endian.
  *
  * Return 0 on success or else a negative errno message of sendmsg() op.
  */
@@ -135,9 +135,11 @@ error:
 
 
 /*
- * Internal call to list events on a given app. Populate events.
+ * Internal event listing for a given app. Populate events.
  *
  * Return number of element in the list or else a negative LTTNG_ERR* code.
+ * On success, the caller is responsible for freeing the memory
+ * allocated for "events".
  */
 static ssize_t list_events(struct jul_app *app, struct lttng_event **events)
 {
@@ -220,7 +222,7 @@ error:
 }
 
 /*
- * Internal enable JUL event call on a JUL application. This function
+ * Internal enable JUL event on a JUL application. This function
  * communicates with the Java agent to enable a given event (Logger name).
  *
  * Return LTTNG_OK on success or else a LTTNG_ERR* code.
@@ -246,6 +248,8 @@ static int enable_event(struct jul_app *app, struct jul_event *event)
                goto error_io;
        }
 
+       msg.loglevel = event->loglevel;
+       msg.loglevel_type = event->loglevel_type;
        strncpy(msg.name, event->name, sizeof(msg.name));
        ret = send_payload(app->sock, &msg, sizeof(msg));
        if (ret < 0) {
@@ -436,8 +440,7 @@ int jul_list_events(struct lttng_event **events)
                nb_ev = list_events(app, &jul_events);
                if (nb_ev < 0) {
                        ret = nb_ev;
-                       rcu_read_unlock();
-                       goto error;
+                       goto error_unlock;
                }
 
                if (count >= nbmem) {
@@ -451,9 +454,8 @@ int jul_list_events(struct lttng_event **events)
                        if (!ptr) {
                                PERROR("realloc JUL events");
                                ret = -ENOMEM;
-                               rcu_read_unlock();
                                free(jul_events);
-                               goto error;
+                               goto error_unlock;
                        }
                        tmp_events = ptr;
                }
@@ -468,6 +470,8 @@ int jul_list_events(struct lttng_event **events)
        *events = tmp_events;
        return ret;
 
+error_unlock:
+       rcu_read_unlock();
 error:
        free(tmp_events);
        return ret;
@@ -492,8 +496,6 @@ struct jul_app *jul_create_app(pid_t pid, struct lttcomm_sock *sock)
 
        app->pid = pid;
        app->sock = sock;
-       /* Flag it invalid until assignation. */
-       app->ust_app_sock = -1;
        lttng_ht_node_init_ulong(&app->node, (unsigned long) app->sock->fd);
 
 error:
@@ -544,59 +546,6 @@ void jul_add_app(struct jul_app *app)
        rcu_read_unlock();
 }
 
-/*
- * Attach a given JUL application to an UST app object. This is done by copying
- * the socket fd value into the ust app obj. atomically.
- */
-void jul_attach_app(struct jul_app *japp)
-{
-       struct ust_app *uapp;
-
-       assert(japp);
-
-       rcu_read_lock();
-       uapp = ust_app_find_by_pid(japp->pid);
-       if (!uapp) {
-               goto end;
-       }
-
-       uatomic_set(&uapp->jul_app_sock, japp->sock->fd);
-
-       DBG3("JUL app pid: %d, sock: %d attached to UST app.", japp->pid,
-                       japp->sock->fd);
-
-end:
-       rcu_read_unlock();
-       return;
-}
-
-/*
- * Remove JUL app. reference from an UST app object and set it to NULL.
- */
-void jul_detach_app(struct jul_app *japp)
-{
-       struct ust_app *uapp;
-
-       assert(japp);
-
-       rcu_read_lock();
-
-       if (japp->ust_app_sock < 0) {
-               goto end;
-       }
-
-       uapp = ust_app_find_by_sock(japp->ust_app_sock);
-       if (!uapp) {
-               goto end;
-       }
-
-       uapp->jul_app_sock = -1;
-
-end:
-       rcu_read_unlock();
-       return;
-}
-
 /*
  * Delete JUL application from the global hash table.
  */
@@ -618,7 +567,8 @@ void jul_delete_app(struct jul_app *app)
 
 /*
  * Destroy a JUL application object by detaching it from its corresponding UST
- * app if one, closing the socket and freeing the memory.
+ * app if one is connected by closing the socket. Finally, perform a
+ * delayed memory reclaim.
  */
 void jul_destroy_app(struct jul_app *app)
 {
@@ -730,28 +680,9 @@ error:
 }
 
 /*
- * Delete JUL event from given domain. Events hash table MUST be initialized.
- */
-void jul_delete_event(struct jul_event *event, struct jul_domain *dom)
-{
-       int ret;
-       struct lttng_ht_iter iter;
-
-       assert(event);
-       assert(dom);
-       assert(dom->events);
-
-       DBG3("JUL deleting event %s from domain", event->name);
-
-       iter.iter.node = &event->node.node;
-       rcu_read_lock();
-       ret = lttng_ht_del(dom->events, &iter);
-       rcu_read_unlock();
-       assert(!ret);
-}
-
-/*
- * Free given JUl event. After this call, the pointer is not usable anymore.
+ * Free given JUL event. This event must not be globally visible at this
+ * point (only expected to be used on failure just after event
+ * creation). After this call, the pointer is not usable anymore.
  */
 void jul_destroy_event(struct jul_event *event)
 {
@@ -762,7 +693,7 @@ void jul_destroy_event(struct jul_event *event)
 
 /*
  * Destroy a JUL domain completely. Note that the given pointer is NOT freed
- * thus a reference can be passed to this function.
+ * thus a reference to static or stack data can be passed to this function.
  */
 void jul_destroy_domain(struct jul_domain *dom)
 {
This page took 0.026958 seconds and 5 git commands to generate.