From f158a754906b7c657d64db23c506c6648773bc92 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sun, 23 Oct 2011 09:23:12 -0400 Subject: [PATCH] Use UST comm lib Signed-off-by: Mathieu Desnoyers --- include/lttng-sessiond-comm.h | 2 +- liblttng-sessiond-comm/lttng-sessiond-comm.c | 4 ++-- ltt-sessiond/Makefile.am | 4 ++++ ltt-sessiond/ust-comm.c | 5 +++-- ltt-sessiond/ust-ctl.c | 22 ++++++++++---------- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/lttng-sessiond-comm.h b/include/lttng-sessiond-comm.h index 60005ac5e..68d8b9109 100644 --- a/include/lttng-sessiond-comm.h +++ b/include/lttng-sessiond-comm.h @@ -38,7 +38,7 @@ #define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-ltt-sessiond" /* Queue size of listen(2) */ -#define MAX_LISTEN 64 +#define LTTNG_SESSIOND_COMM_MAX_LISTEN 64 /* * Get the error code index from 0 since LTTCOMM_OK start at 1000 diff --git a/liblttng-sessiond-comm/lttng-sessiond-comm.c b/liblttng-sessiond-comm/lttng-sessiond-comm.c index 4bb6ed578..5ba609e5a 100644 --- a/liblttng-sessiond-comm/lttng-sessiond-comm.c +++ b/liblttng-sessiond-comm/lttng-sessiond-comm.c @@ -206,13 +206,13 @@ error: } /* - * Make the socket listen using MAX_LISTEN. + * Make the socket listen using LTTNG_SESSIOND_COMM_MAX_LISTEN. */ int lttcomm_listen_unix_sock(int sock) { int ret; - ret = listen(sock, MAX_LISTEN); + ret = listen(sock, LTTNG_SESSIOND_COMM_MAX_LISTEN); if (ret < 0) { perror("listen"); } diff --git a/ltt-sessiond/Makefile.am b/ltt-sessiond/Makefile.am index 0d284efb1..ecc977ab1 100644 --- a/ltt-sessiond/Makefile.am +++ b/ltt-sessiond/Makefile.am @@ -39,3 +39,7 @@ ltt_sessiond_LDADD = -lrt \ $(top_builddir)/liblttng-sessiond-comm/liblttng-sessiond-comm.la \ $(top_builddir)/libkernelctl/libkernelctl.la \ $(top_builddir)/liblttngctl/liblttngctl.la + +if LTTNG_TOOLS_HAVE_UST +ltt_sessiond_LDADD += -llttng-ust-comm +endif diff --git a/ltt-sessiond/ust-comm.c b/ltt-sessiond/ust-comm.c index 724260511..4a54bf784 100644 --- a/ltt-sessiond/ust-comm.c +++ b/ltt-sessiond/ust-comm.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "ust-comm.h" /* @@ -41,7 +42,7 @@ struct lttcomm_ust_reply *ustcomm_send_command(int sock, DBG2("Sending UST command %d to sock %d", msg->cmd, sock); /* Send UST msg */ - len = lttcomm_send_unix_sock(sock, msg, sizeof(*msg)); + len = ustcomm_send_unix_sock(sock, msg, sizeof(*msg)); if (len < 0) { goto error; } @@ -55,7 +56,7 @@ struct lttcomm_ust_reply *ustcomm_send_command(int sock, DBG2("Receiving UST reply on sock %d", sock); /* Get UST reply */ - len = lttcomm_recv_unix_sock(sock, reply, sizeof(*reply)); + len = ustcomm_recv_unix_sock(sock, reply, sizeof(*reply)); if (len < 0 || len < sizeof(*reply)) { goto error; } diff --git a/ltt-sessiond/ust-ctl.c b/ltt-sessiond/ust-ctl.c index 2f43b1e60..7f70b8975 100644 --- a/ltt-sessiond/ust-ctl.c +++ b/ltt-sessiond/ust-ctl.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include "ust-comm.h" @@ -47,8 +47,8 @@ int ustctl_register_done(int sock) goto error; } - if (reply->ret_code != LTTCOMM_OK) { - DBG("Return code: %s", lttcomm_get_readable_code(reply->ret_code)); + if (reply->ret_code != USTCOMM_OK) { + DBG("Return code: %s", ustcomm_get_readable_code(reply->ret_code)); goto error; } @@ -74,8 +74,8 @@ int ustctl_create_session(int sock, struct ltt_ust_session *session) goto error; } - if (reply->ret_code != LTTCOMM_OK) { - DBG("Return code: %s", lttcomm_get_readable_code(reply->ret_code)); + if (reply->ret_code != USTCOMM_OK) { + DBG("Return code: %s", ustcomm_get_readable_code(reply->ret_code)); goto error; } @@ -119,9 +119,9 @@ int ustctl_create_channel(int sock, struct ltt_ust_session *session, goto error; } - if (reply->ret_code != LTTCOMM_OK) { + if (reply->ret_code != USTCOMM_OK) { DBG("Return code (%d): %s", reply->ret_code, - lttcomm_get_readable_code(reply->ret_code)); + ustcomm_get_readable_code(reply->ret_code)); goto error; } @@ -159,9 +159,9 @@ int ustctl_enable_channel(int sock, struct ltt_ust_session *session, goto error; } - if (reply->ret_code != LTTCOMM_OK) { + if (reply->ret_code != USTCOMM_OK) { DBG("Return code (%d): %s", reply->ret_code, - lttcomm_get_readable_code(reply->ret_code)); + ustcomm_get_readable_code(reply->ret_code)); goto error; } else if (reply->handle != chan->handle) { ERR("Receive wrong handle from UST reply on enable channel"); @@ -198,9 +198,9 @@ int ustctl_disable_channel(int sock, struct ltt_ust_session *session, goto error; } - if (reply->ret_code != LTTCOMM_OK) { + if (reply->ret_code != USTCOMM_OK) { DBG("Return code (%d): %s", reply->ret_code, - lttcomm_get_readable_code(reply->ret_code)); + ustcomm_get_readable_code(reply->ret_code)); goto error; } else if (reply->handle != chan->handle) { ERR("Receive wrong handle from UST reply on enable channel"); -- 2.34.1