X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=700a83a13eaa022476935a7bd74c6637943d286e;hp=b2f25ecd06ac58c471f94c4ea34daa2d30383cbb;hb=fe489250ce102edf511e99669025934ec9587c63;hpb=dd1bac00c933616842aaf51ad4c4240ccee98838 diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index b2f25ecd0..700a83a13 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -23,10 +23,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -39,6 +41,7 @@ #include #include #include +#include #include "filter/filter-ast.h" #include "filter/filter-parser.h" @@ -627,9 +630,10 @@ int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message, { int ret; struct lttcomm_lttng_msg llm; + const int fd_count = lttng_payload_view_get_fd_handle_count(message); assert(reply->buffer.size == 0); - assert(reply->_fds.size == 0); + assert(lttng_dynamic_pointer_array_get_count(&reply->_fd_handles) == 0); ret = connect_sessiond(); if (ret < 0) { @@ -648,10 +652,13 @@ int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message, goto end; } - if (lttng_payload_view_get_fd_count(message) > 0) { - ret = lttcomm_send_fds_unix_sock(sessiond_socket, - (const int *) message->_fds.buffer.data, - lttng_dynamic_array_get_count(&message->_fds)); + if (fd_count > 0) { + ret = lttcomm_send_payload_view_fds_unix_sock(sessiond_socket, + message); + if (ret < 0) { + ret = -LTTNG_ERR_FATAL; + goto end; + } } /* Get header from data transmission */ @@ -685,19 +692,9 @@ int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message, } if (llm.fd_count > 0) { - ret = lttng_dynamic_array_set_count(&reply->_fds, llm.fd_count); - if (ret) { - ret = -LTTNG_ERR_NOMEM; - goto end; - } - - ret = lttcomm_recv_fds_unix_sock(sessiond_socket, - (int *) reply->_fds.buffer.data, llm.fd_count); - if (ret > 0 && ret != llm.fd_count * sizeof(int)) { - ret = -LTTNG_ERR_INVALID_PROTOCOL; - goto end; - } else if (ret <= 0) { - ret = -LTTNG_ERR_FATAL; + ret = lttcomm_recv_payload_fds_unix_sock( + sessiond_socket, llm.fd_count, reply); + if (ret < 0) { goto end; } } @@ -1360,7 +1357,7 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle, { struct lttng_payload_view view = lttng_payload_view_from_payload( &payload, 0, -1); - int fd_count = lttng_payload_view_get_fd_count(&view); + int fd_count = lttng_payload_view_get_fd_handle_count(&view); int fd_to_send; if (fd_count < 0) { @@ -1369,12 +1366,15 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle, assert(fd_count == 0 || fd_count == 1); if (fd_count == 1) { - ret = lttng_payload_view_pop_fd(&view); - if (ret < 0) { + struct fd_handle *handle = + lttng_payload_view_pop_fd_handle(&view); + + if (!handle) { goto mem_error; } - fd_to_send = ret; + fd_to_send = fd_handle_get_fd(handle); + fd_handle_put(handle); } ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,