From 700741dccd632e2520da055406582f39ab403795 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 24 Jul 2020 13:48:00 -0400 Subject: [PATCH] sessiond: client: use common payload send fds util MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use lttcomm_send_payload_view_fds_unix_sock instead of an open-coded version of the same functionality. Signed-off-by: Jérémie Galarneau Change-Id: I36627423287a059e8b2ab1cc5cb42ca0db53e144 --- src/bin/lttng-sessiond/client.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/bin/lttng-sessiond/client.c b/src/bin/lttng-sessiond/client.c index 1bf55f60b..84a177b9c 100644 --- a/src/bin/lttng-sessiond/client.c +++ b/src/bin/lttng-sessiond/client.c @@ -735,32 +735,10 @@ static int send_unix_sock(int sock, struct lttng_payload_view *view) } if (fd_count > 0) { - int i; - struct lttng_dynamic_array raw_fds; - - /* - * Never holds ownership of the FDs; this is just used - * to put the FDs in a contiguous array. - */ - lttng_dynamic_array_init(&raw_fds, sizeof(int), NULL); - - for (i = 0; i < fd_count; i++) { - struct fd_handle *handle = - lttng_payload_view_pop_fd_handle(view); - const int raw_fd = fd_handle_get_fd(handle); - - ret = lttng_dynamic_array_add_element(&raw_fds, &raw_fd); - fd_handle_put(handle); - if (ret) { - lttng_dynamic_array_reset(&raw_fds); - goto end; - } + ret = lttcomm_send_payload_view_fds_unix_sock(sock, view); + if (ret < 0) { + goto end; } - - ret = lttcomm_send_fds_unix_sock(sock, - (const int *) raw_fds.buffer.data, - fd_count); - lttng_dynamic_array_reset(&raw_fds); } end: -- 2.34.1