X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=eadb00eda37af2fb293723aab83aa237f9515144;hp=37b2531028c83930537f796bdaca041b83df3bd4;hb=a04d53fc9a0dd3a5d6f9be82d475dfec48205ac0;hpb=ef0e06bcabd5f5fcf609b60d6558c2bdded5e496 diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 37b253102..eadb00eda 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -176,6 +176,35 @@ end: return ret; } +/* + * Send file descriptors to the session daemon. + * + * On success, returns the number of bytes sent (>=0) + * On error, returns -1 + */ +static int send_session_fds(const int *fds, size_t nb_fd) +{ + int ret; + + if (!connected) { + ret = -LTTNG_ERR_NO_SESSIOND; + goto end; + } + + if (!fds || !nb_fd) { + ret = 0; + goto end; + } + + ret = lttcomm_send_fds_unix_sock(sessiond_socket, fds, nb_fd); + if (ret < 0) { + ret = -LTTNG_ERR_FATAL; + } + +end: + return ret; +} + /* * Receive data from the sessiond socket. * @@ -445,15 +474,16 @@ end: /* * Ask the session daemon a specific command and put the data into buf. - * Takes extra var. len. data as input to send to the session daemon. + * Takes extra var. len. data and file descriptors as input to send to the + * session daemon. * * Return size of data (only payload, not header) or a negative error code. */ LTTNG_HIDDEN -int lttng_ctl_ask_sessiond_varlen(struct lttcomm_session_msg *lsm, - const void *vardata, size_t vardata_len, - void **user_payload_buf, void **user_cmd_header_buf, - size_t *user_cmd_header_len) +int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm, + const int *fds, size_t nb_fd, const void *vardata, + size_t vardata_len, void **user_payload_buf, + void **user_cmd_header_buf, size_t *user_cmd_header_len) { int ret; size_t payload_len; @@ -478,6 +508,13 @@ int lttng_ctl_ask_sessiond_varlen(struct lttcomm_session_msg *lsm, goto end; } + /* Send fds */ + ret = send_session_fds(fds, nb_fd); + if (ret < 0) { + /* Ret value is a valid lttng error code. */ + goto end; + } + /* Get header from data transmission */ ret = recv_data_sessiond(&llm, sizeof(llm)); if (ret < 0) { @@ -1873,8 +1910,8 @@ int lttng_list_events(struct lttng_handle *handle, sizeof(lsm.u.list.channel_name)); lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain); - ret = lttng_ctl_ask_sessiond_varlen(&lsm, NULL, 0, (void **) events, - (void **) &cmd_header, &cmd_header_len); + ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm, NULL, 0, NULL, 0, + (void **) events, (void **) &cmd_header, &cmd_header_len); if (ret < 0) { goto error; }