- ret = create_ust_app_metadata(ua_sess, usess->pathname, app);
- if (ret < 0) {
- ret = LTTNG_ERR_UST_META_FAIL;
- goto error_rcu_unlock;
- }
-
- /* For each channel */
- cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan,
- node.node) {
- /* Create all streams */
- while (1) {
- /* Create UST stream */
- ustream = zmalloc(sizeof(*ustream));
- if (ustream == NULL) {
- PERROR("zmalloc ust stream");
- goto error_rcu_unlock;
- }
-
- /* We are going to receive 2 fds, we need to reserve them. */
- ret = lttng_fd_get(LTTNG_FD_APPS, 2);
- if (ret < 0) {
- ERR("Exhausted number of available FD upon stream create");
- free(ustream);
- goto error_rcu_unlock;
- }
-
- health_code_update(&health_thread_cmd);
-
- ret = ustctl_create_stream(app->sock, ua_chan->obj,
- &ustream->obj);
- if (ret < 0) {
- /* Got all streams */
- lttng_fd_put(LTTNG_FD_APPS, 2);
- free(ustream);
- ret = LTTNG_ERR_UST_STREAM_FAIL;
- break;
- }
- ustream->handle = ustream->obj->handle;
-
- health_code_update(&health_thread_cmd);
-
- /* Order is important */
- cds_list_add_tail(&ustream->list, &ua_chan->streams.head);
- ret = snprintf(ustream->name, sizeof(ustream->name), "%s_%u",
- ua_chan->name, ua_chan->streams.count);
- ua_chan->streams.count++;
- if (ret < 0) {
- PERROR("asprintf UST create stream");
- /*
- * XXX what should we do here with the
- * stream ?
- */
- continue;
- }
- DBG2("UST stream %d ready (handle: %d)", ua_chan->streams.count,
- ustream->handle);
- }
-
- health_code_update(&health_thread_cmd);
- }
-
- switch (app->bits_per_long) {
- case 64:
- socket = consumer_find_socket(uatomic_read(&ust_consumerd64_fd),
- usess->consumer);
- if (socket == NULL) {
- goto skip_setup;
- }
- break;
- case 32:
- socket = consumer_find_socket(uatomic_read(&ust_consumerd32_fd),
- usess->consumer);
- if (socket == NULL) {
- goto skip_setup;
- }
- break;
- default:
- ret = -EINVAL;
- goto error_rcu_unlock;
- }
-
- /* Setup UST consumer socket and send fds to it */
- ret = ust_consumer_send_session(ua_sess, usess->consumer, socket);