-
- consumer = usess->tmp_consumer;
- if (consumer == NULL) {
- ret = LTTNG_OK;
- /* No temp. consumer output exists. Using the current one. */
- DBG3("No temporary consumer. Using default");
- consumer = usess->consumer;
- goto error;
- }
-
- switch (consumer->type) {
- case CONSUMER_DST_LOCAL:
- DBG2("Consumer output is local. Creating directory(ies)");
-
- /* Create directory(ies) */
- ret = run_as_mkdir_recursive(consumer->dst.trace_path,
- S_IRWXU | S_IRWXG, session->uid, session->gid);
- if (ret < 0) {
- if (ret != -EEXIST) {
- ERR("Trace directory creation error");
- ret = LTTNG_ERR_FATAL;
- goto error;
- }
- }
- break;
- case CONSUMER_DST_NET:
- DBG2("Consumer output is network. Validating URIs");
- /* Validate if we have both control and data path set. */
- if (!consumer->dst.net.control_isset) {
- ret = LTTNG_ERR_URL_CTRL_MISS;
- goto error;
- }
-
- if (!consumer->dst.net.data_isset) {
- ret = LTTNG_ERR_URL_DATA_MISS;
- goto error;
- }
-
- /* Check established network session state */
- if (session->net_handle == 0) {
- ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
- DBG2("Session network handle is not set on enable-consumer");
- goto error;
- }
-
- if (consumer->net_seq_index == -1) {
- ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
- DBG2("Network index is not set on the consumer");
- goto error;
- }
-
- break;
- }
-
- /* Append default kernel trace dir to subdir */
- strncat(usess->consumer->subdir, DEFAULT_UST_TRACE_DIR,
- sizeof(usess->consumer->subdir) -
- strlen(usess->consumer->subdir) - 1);
-
- /*
- * @session-lock
- * This is race free for now since the session lock is acquired before
- * ending up in this function. No other threads can access this kernel
- * session without this lock hence freeing the consumer output object
- * is valid.
- */
- rcu_read_lock();
- consumer_destroy_output(usess->consumer);
- rcu_read_unlock();
- usess->consumer = consumer;
- usess->tmp_consumer = NULL;
-
- break;