/*
* Command LTTNG_SET_CONSUMER_URI processed by the client thread.
*/
-int cmd_set_consumer_uri(int domain, struct ltt_session *session,
- size_t nb_uri, struct lttng_uri *uris)
+int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri,
+ struct lttng_uri *uris)
{
int ret, i;
struct ltt_kernel_session *ksess = session->kernel_session;
struct ltt_ust_session *usess = session->ust_session;
- struct consumer_output *consumer = NULL;
assert(session);
assert(uris);
goto error;
}
- /*
- * This case switch makes sure the domain session has a temporary consumer
- * so the URL can be set.
- */
- switch (domain) {
- case 0:
- /* Code flow error. A session MUST always have a consumer object */
- assert(session->consumer);
- /*
- * The URL will be added to the tracing session consumer instead of a
- * specific domain consumer.
- */
- consumer = session->consumer;
- break;
- case LTTNG_DOMAIN_KERNEL:
- /* Code flow error if we don't have a kernel session here. */
- assert(ksess);
- assert(ksess->consumer);
- consumer = ksess->consumer;
- break;
- case LTTNG_DOMAIN_UST:
- /* Code flow error if we don't have a kernel session here. */
- assert(usess);
- assert(usess->consumer);
- consumer = usess->consumer;
- break;
- }
-
+ /* Set the "global" consumer URIs */
for (i = 0; i < nb_uri; i++) {
- ret = add_uri_to_consumer(consumer, &uris[i], domain, session->name);
+ ret = add_uri_to_consumer(session->consumer,
+ &uris[i], 0, session->name);
if (ret != LTTNG_OK) {
goto error;
}
}
+ /* Set UST session URIs */
+ if (session->ust_session) {
+ for (i = 0; i < nb_uri; i++) {
+ ret = add_uri_to_consumer(
+ session->ust_session->consumer,
+ &uris[i], LTTNG_DOMAIN_UST,
+ session->name);
+ if (ret != LTTNG_OK) {
+ goto error;
+ }
+ }
+ }
+
+ /* Set kernel session URIs */
+ if (session->kernel_session) {
+ for (i = 0; i < nb_uri; i++) {
+ ret = add_uri_to_consumer(
+ session->kernel_session->consumer,
+ &uris[i], LTTNG_DOMAIN_KERNEL,
+ session->name);
+ if (ret != LTTNG_OK) {
+ goto error;
+ }
+ }
+ }
+
/*
* Make sure to set the session in output mode after we set URI since a
* session can be created without URL (thus flagged in no output mode).
session->output_traces = 1;
if (ksess) {
ksess->output_traces = 1;
- } else if (usess) {
+ }
+
+ if (usess) {
usess->output_traces = 1;
}
}
if (uris) {
- ret = cmd_set_consumer_uri(0, session, nb_uri, uris);
+ ret = cmd_set_consumer_uri(session, nb_uri, uris);
if (ret != LTTNG_OK) {
goto consumer_error;
}
/* Consumer commands */
int cmd_register_consumer(struct ltt_session *session, int domain,
const char *sock_path, struct consumer_data *cdata);
-int cmd_set_consumer_uri(int domain, struct ltt_session *session,
- size_t nb_uri, struct lttng_uri *uris);
+int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri,
+ struct lttng_uri *uris);
int cmd_setup_relayd(struct ltt_session *session);
/* Listing commands */
goto error;
}
- ret = cmd_set_consumer_uri(cmd_ctx->lsm->domain.type, cmd_ctx->session,
- nb_uri, uris);
+ ret = cmd_set_consumer_uri(cmd_ctx->session, nb_uri, uris);
+ free(uris);
if (ret != LTTNG_OK) {
- free(uris);
goto error;
}
- /*
- * XXX: 0 means that this URI should be applied on the session. Should
- * be a DOMAIN enuam.
- */
- if (cmd_ctx->lsm->domain.type == 0) {
- /* Add the URI for the UST session if a consumer is present. */
- if (cmd_ctx->session->ust_session &&
- cmd_ctx->session->ust_session->consumer) {
- ret = cmd_set_consumer_uri(LTTNG_DOMAIN_UST, cmd_ctx->session,
- nb_uri, uris);
- } else if (cmd_ctx->session->kernel_session &&
- cmd_ctx->session->kernel_session->consumer) {
- ret = cmd_set_consumer_uri(LTTNG_DOMAIN_KERNEL,
- cmd_ctx->session, nb_uri, uris);
- }
- }
-
- free(uris);
break;
}