- if (!trace_ust_pid_tracker_lookup(usess, app->pid)) {
- /* Skip. */
- continue;
- }
-
- /*
- * Create session on the tracer side and add it to app session HT. Note
- * that if session exist, it will simply return a pointer to the ust
- * app session.
- */
- ret = find_or_create_ust_app_session(usess, app, &ua_sess, &created);
- if (ret < 0) {
- switch (ret) {
- case -ENOTCONN:
- /*
- * The application's socket is not valid. Either a bad socket
- * or a timeout on it. We can't inform the caller that for a
- * specific app, the session failed so lets continue here.
- */
- ret = 0; /* Not an error. */
- continue;
- case -ENOMEM:
- default:
- goto error_rcu_unlock;
- }
- }
- assert(ua_sess);
-
- pthread_mutex_lock(&ua_sess->lock);
-
- if (ua_sess->deleted) {
- pthread_mutex_unlock(&ua_sess->lock);
- continue;
- }
-
- if (!strncmp(uchan->name, DEFAULT_METADATA_NAME,
- sizeof(uchan->name))) {
- copy_channel_attr_to_ustctl(&ua_sess->metadata_attr, &uchan->attr);
- ret = 0;
- } else {
- /* Create channel onto application. We don't need the chan ref. */
- ret = create_ust_app_channel(ua_sess, uchan, app,
- LTTNG_UST_CHAN_PER_CPU, usess, NULL);
- }
- pthread_mutex_unlock(&ua_sess->lock);
- if (ret < 0) {
- /* Cleanup the created session if it's the case. */
- if (created) {
- destroy_app_session(app, ua_sess);
- }
- switch (ret) {
- case -ENOTCONN:
- /*
- * The application's socket is not valid. Either a bad socket
- * or a timeout on it. We can't inform the caller that for a
- * specific app, the session failed so lets continue here.
- */
- ret = 0; /* Not an error. */
- continue;
- case -ENOMEM:
- default:
- goto error_rcu_unlock;
- }
- }
- }
-
-error_rcu_unlock:
- rcu_read_unlock();
- return ret;
-}
-
-/*
- * Enable event for a specific session and channel on the tracer.
- */
-int ust_app_enable_event_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
-{
- int ret = 0;
- struct lttng_ht_iter iter, uiter;
- struct lttng_ht_node_str *ua_chan_node;
- struct ust_app *app;
- struct ust_app_session *ua_sess;
- struct ust_app_channel *ua_chan;
- struct ust_app_event *ua_event;
-
- DBG("UST app enabling event %s for all apps for session id %" PRIu64,
- uevent->attr.name, usess->id);
-
- /*
- * NOTE: At this point, this function is called only if the session and
- * channel passed are already created for all apps. and enabled on the
- * tracer also.
- */
-
- rcu_read_lock();
-
- /* For all registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
- if (!app->compatible) {
- /*
- * TODO: In time, we should notice the caller of this error by
- * telling him that this is a version error.
- */
- continue;
- }
- ua_sess = lookup_session_by_app(usess, app);
- if (!ua_sess) {
- /* The application has problem or is probably dead. */