Refactoring/fix: syscall table unregister/destroy
[lttng-modules.git] / src / lttng-events.c
index fe29870d09b65c2b2cba7289a4364a98567330f0..dd8b55e065f06b16b63d6ab966f27174678f56f7 100644 (file)
@@ -360,7 +360,7 @@ void lttng_session_destroy(struct lttng_kernel_session *session)
        mutex_lock(&sessions_mutex);
        WRITE_ONCE(session->active, 0);
        list_for_each_entry(chan_priv, &session->priv->chan, node) {
-               ret = lttng_syscalls_unregister_channel(chan_priv->pub);
+               ret = lttng_syscalls_unregister_syscall_table(&chan_priv->parent.syscall_table);
                WARN_ON(ret);
        }
        list_for_each_entry(event_recorder_priv, &session->priv->events, node) {
@@ -369,7 +369,7 @@ void lttng_session_destroy(struct lttng_kernel_session *session)
        }
        synchronize_trace();    /* Wait for in-flight events to complete */
        list_for_each_entry(chan_priv, &session->priv->chan, node) {
-               ret = lttng_syscalls_destroy_channel(chan_priv->pub);
+               ret = lttng_syscalls_destroy_syscall_table(&chan_priv->parent.syscall_table);
                WARN_ON(ret);
        }
        list_for_each_entry_safe(event_recorder_enabler, tmp_event_recorder_enabler,
@@ -410,7 +410,7 @@ void lttng_event_notifier_group_destroy(
 
        mutex_lock(&sessions_mutex);
 
-       ret = lttng_syscalls_unregister_event_notifier_group(event_notifier_group);
+       ret = lttng_syscalls_unregister_syscall_table(&event_notifier_group->syscall_table);
        WARN_ON(ret);
 
        list_for_each_entry_safe(event_notifier_priv, tmpevent_notifier_priv,
@@ -424,7 +424,8 @@ void lttng_event_notifier_group_destroy(
 
        irq_work_sync(&event_notifier_group->wakeup_pending);
 
-       kfree(event_notifier_group->syscall_table.sc_filter);
+       ret = lttng_syscalls_destroy_syscall_table(&event_notifier_group->syscall_table);
+       WARN_ON(ret);
 
        list_for_each_entry_safe(event_notifier_enabler, tmp_event_notifier_enabler,
                        &event_notifier_group->enablers_head, node)
@@ -578,47 +579,60 @@ end:
        return ret;
 }
 
-int lttng_channel_enable(struct lttng_kernel_channel_buffer *channel)
+static
+bool is_channel_buffer_metadata(struct lttng_kernel_channel_common *channel)
+{
+       struct lttng_kernel_channel_buffer *chan_buf;
+
+       if (channel->type != LTTNG_KERNEL_CHANNEL_TYPE_BUFFER)
+               return false;
+       chan_buf = container_of(channel, struct lttng_kernel_channel_buffer, parent);
+       if (chan_buf->priv->channel_type == METADATA_CHANNEL)
+               return true;
+       return false;
+}
+
+int lttng_channel_enable(struct lttng_kernel_channel_common *channel)
 {
        int ret = 0;
 
        mutex_lock(&sessions_mutex);
-       if (channel->priv->channel_type == METADATA_CHANNEL) {
+       if (is_channel_buffer_metadata(channel)) {
                ret = -EPERM;
                goto end;
        }
-       if (channel->parent.enabled) {
+       if (channel->enabled) {
                ret = -EEXIST;
                goto end;
        }
        /* Set transient enabler state to "enabled" */
-       channel->priv->parent.tstate = 1;
-       lttng_session_sync_event_enablers(channel->parent.session);
+       channel->priv->tstate = 1;
+       lttng_session_sync_event_enablers(channel->session);
        /* Set atomically the state to "enabled" */
-       WRITE_ONCE(channel->parent.enabled, 1);
+       WRITE_ONCE(channel->enabled, 1);
 end:
        mutex_unlock(&sessions_mutex);
        return ret;
 }
 
-int lttng_channel_disable(struct lttng_kernel_channel_buffer *channel)
+int lttng_channel_disable(struct lttng_kernel_channel_common *channel)
 {
        int ret = 0;
 
        mutex_lock(&sessions_mutex);
-       if (channel->priv->channel_type == METADATA_CHANNEL) {
+       if (is_channel_buffer_metadata(channel)) {
                ret = -EPERM;
                goto end;
        }
-       if (!channel->parent.enabled) {
+       if (!channel->enabled) {
                ret = -EEXIST;
                goto end;
        }
        /* Set atomically the state to "disabled" */
-       WRITE_ONCE(channel->parent.enabled, 0);
+       WRITE_ONCE(channel->enabled, 0);
        /* Set transient enabler state to "enabled" */
-       channel->priv->parent.tstate = 0;
-       lttng_session_sync_event_enablers(channel->parent.session);
+       channel->priv->tstate = 0;
+       lttng_session_sync_event_enablers(channel->session);
 end:
        mutex_unlock(&sessions_mutex);
        return ret;
@@ -752,7 +766,7 @@ end:
        return ret;
 }
 
-struct lttng_kernel_channel_buffer *lttng_channel_create(struct lttng_kernel_session *session,
+struct lttng_kernel_channel_buffer *lttng_channel_buffer_create(struct lttng_kernel_session *session,
                                       const char *transport_name,
                                       void *buf_addr,
                                       size_t subbuf_size, size_t num_subbuf,
This page took 0.04924 seconds and 4 git commands to generate.