Fix: disable-event for an agent domain
authorDavid Goulet <dgoulet@efficios.com>
Fri, 5 Sep 2014 16:13:55 +0000 (12:13 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 5 Sep 2014 16:13:55 +0000 (12:13 -0400)
This fixes the disable-event command for an agent that was not working
properly in the case an application was spawned after the command.

Also, for the disable all event command for an agent, the disable
command will try first to disable the '*' event and will disable all
already existing events after. This is to make sure the refcount on the
agent side is synchronized with the amount of enable event prior.

Fixes #831

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/event.c

index 52fd9f5478a753492eb9ffee7b0c6d8eaf18d5e4..7c42a928abf8dfc56bd1fe8115e063076c7acdd5 100644 (file)
@@ -774,6 +774,12 @@ int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
                goto error;
        }
 
+       /*
+        * Flag event that it's disabled so the shadow copy on the ust app side
+        * will disable it if an application shows up.
+        */
+       uevent->enabled = 0;
+
        ret = agent_disable_event(aevent, agt->domain);
        if (ret != LTTNG_OK) {
                goto error;
@@ -793,40 +799,35 @@ error:
 int event_agent_disable_all(struct ltt_ust_session *usess,
                struct agent *agt)
 {
-       int ret, do_disable = 0;
+       int ret;
        struct agent_event *aevent;
        struct lttng_ht_iter iter;
 
        assert(agt);
        assert(usess);
 
-       /* Disable event on agent application through TCP socket. */
+       /*
+        * Disable event on agent application. Continue to disable all other events
+        * if the * event is not found.
+        */
        ret = event_agent_disable(usess, agt, "*");
-       if (ret != LTTNG_OK) {
-               if (ret == LTTNG_ERR_UST_EVENT_NOT_FOUND) {
-                       /*
-                        * This means that no enable all was done before but still a user
-                        * could want to disable everything even though the * wild card
-                        * event does not exists.
-                        */
-                       do_disable = 1;
-               } else {
-                       goto error;
-               }
+       if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_NOT_FOUND) {
+               goto error;
        }
 
        /* Flag every event that they are now enabled. */
        rcu_read_lock();
        cds_lfht_for_each_entry(agt->events->ht, &iter.iter, aevent,
                        node.node) {
-               if (aevent->enabled && do_disable) {
-                       ret = event_agent_disable(usess, agt, aevent->name);
-                       if (ret != LTTNG_OK) {
-                               rcu_read_unlock();
-                               goto error;
-                       }
+               if (!aevent->enabled) {
+                       continue;
+               }
+
+               ret = event_agent_disable(usess, agt, aevent->name);
+               if (ret != LTTNG_OK) {
+                       rcu_read_unlock();
+                       goto error;
                }
-               aevent->enabled = 0;
        }
        rcu_read_unlock();
 
This page took 0.028491 seconds and 5 git commands to generate.