X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=9ef1fde3694eddd90b67d18c3aa68d410d309a27;hb=88c5f0d8ee74f6c3a19299e9bb34091247d50d64;hp=38ce83c7eefd308cc8b6e2f1b50abddbc5bedf9c;hpb=1896972b00c0158cb09eb356e3f54fda9900950a;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 38ce83c7e..9ef1fde36 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -478,22 +478,15 @@ error: * On success, the relayd_sock pointer is set to the created socket. * Else, it's stays untouched and a lttcomm error code is returned. */ -static int create_connect_relayd(struct consumer_output *output, - const char *session_name, struct lttng_uri *uri, - struct lttcomm_sock **relayd_sock) +static int create_connect_relayd(struct lttng_uri *uri, + struct lttcomm_relayd_sock **relayd_sock) { int ret; - struct lttcomm_sock *sock; + struct lttcomm_relayd_sock *rsock; - /* Create socket object from URI */ - sock = lttcomm_alloc_sock_from_uri(uri); - if (sock == NULL) { - ret = LTTNG_ERR_FATAL; - goto error; - } - - ret = lttcomm_create_sock(sock); - if (ret < 0) { + rsock = lttcomm_alloc_relayd_sock(uri, RELAYD_VERSION_COMM_MAJOR, + RELAYD_VERSION_COMM_MINOR); + if (!rsock) { ret = LTTNG_ERR_FATAL; goto error; } @@ -504,7 +497,7 @@ static int create_connect_relayd(struct consumer_output *output, * state to be in poll execution. */ health_poll_entry(); - ret = relayd_connect(sock); + ret = relayd_connect(rsock); health_poll_exit(); if (ret < 0) { ERR("Unable to reach lttng-relayd"); @@ -517,8 +510,7 @@ static int create_connect_relayd(struct consumer_output *output, DBG3("Creating relayd stream socket from URI"); /* Check relayd version */ - ret = relayd_version_check(sock, RELAYD_VERSION_COMM_MAJOR, - RELAYD_VERSION_COMM_MINOR); + ret = relayd_version_check(rsock); if (ret < 0) { ret = LTTNG_ERR_RELAYD_VERSION_FAIL; goto close_sock; @@ -532,18 +524,15 @@ static int create_connect_relayd(struct consumer_output *output, goto close_sock; } - *relayd_sock = sock; + *relayd_sock = rsock; return LTTNG_OK; close_sock: - if (sock) { - (void) relayd_close(sock); - } + /* The returned value is not useful since we are on an error path. */ + (void) relayd_close(rsock); free_sock: - if (sock) { - lttcomm_destroy_sock(sock); - } + free(rsock); error: return ret; } @@ -556,13 +545,14 @@ static int send_consumer_relayd_socket(int domain, struct ltt_session *session, struct consumer_socket *consumer_sock) { int ret; - struct lttcomm_sock *sock = NULL; + struct lttcomm_relayd_sock *rsock = NULL; /* Connect to relayd and make version check if uri is the control. */ - ret = create_connect_relayd(consumer, session->name, relayd_uri, &sock); + ret = create_connect_relayd(relayd_uri, &rsock); if (ret != LTTNG_OK) { - goto close_sock; + goto error; } + assert(rsock); /* If the control socket is connected, network session is ready */ if (relayd_uri->stype == LTTNG_STREAM_CONTROL) { @@ -582,8 +572,8 @@ static int send_consumer_relayd_socket(int domain, struct ltt_session *session, } /* Send relayd socket to consumer. */ - ret = consumer_send_relayd_socket(consumer_sock, sock, - consumer, relayd_uri->stype, session->id); + ret = consumer_send_relayd_socket(consumer_sock, rsock, consumer, + relayd_uri->stype, session->id); if (ret < 0) { ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL; goto close_sock; @@ -604,11 +594,10 @@ static int send_consumer_relayd_socket(int domain, struct ltt_session *session, */ close_sock: - if (sock) { - (void) relayd_close(sock); - lttcomm_destroy_sock(sock); - } + (void) relayd_close(rsock); + free(rsock); +error: if (ret != LTTNG_OK) { /* * On error, nullify the consumer sequence index so streams are not @@ -616,7 +605,6 @@ close_sock: */ uatomic_set(&consumer->net_seq_index, -1); } - return ret; } @@ -1932,6 +1920,7 @@ ssize_t cmd_list_domains(struct ltt_session *session, if (session->ust_session != NULL) { (*domains)[index].type = LTTNG_DOMAIN_UST; + (*domains)[index].buf_type = session->ust_session->buffer_type; index++; }