From e77234624408c3d201a901121845fa5c4b93179e Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sun, 21 Aug 2011 18:02:48 -0400 Subject: [PATCH] libust comm: use own message structures Signed-off-by: Mathieu Desnoyers --- include/lttng-sessiond-comm.h | 58 +++-------------------------------- libust/lttng-ust-comm.c | 16 +++++----- 2 files changed, 13 insertions(+), 61 deletions(-) diff --git a/include/lttng-sessiond-comm.h b/include/lttng-sessiond-comm.h index 8dbad391..25925cec 100644 --- a/include/lttng-sessiond-comm.h +++ b/include/lttng-sessiond-comm.h @@ -45,7 +45,7 @@ */ #define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK) -enum lttcomm_sessiond_command { +enum lttcomm_ust_command { /* Tracer command */ LTTNG_ADD_CONTEXT, LTTNG_CALIBRATE, @@ -128,57 +128,19 @@ enum lttcomm_return_code { }; /* - * Data structure received from lttng client to session daemon. + * Data structure for the commands sent from sessiond to UST. */ -struct lttcomm_session_msg { - uint32_t cmd_type; /* enum lttcomm_sessiond_command */ - struct lttng_session session; - struct lttng_domain domain; +struct lttcomm_ust_msg { + uint32_t cmd_type; /* enum lttcomm_ust_command */ union { - struct { - char channel_name[NAME_MAX]; - char name[NAME_MAX]; - } disable; - /* Event data */ - struct { - char channel_name[NAME_MAX]; - struct lttng_event event; - } enable; - /* Create channel */ - struct { - struct lttng_channel chan; - } channel; - /* Context */ - struct { - char channel_name[NAME_MAX]; - char event_name[NAME_MAX]; - struct lttng_event_context ctx; - } context; - /* List */ - struct { - char channel_name[NAME_MAX]; - } list; - struct lttng_calibrate calibrate; } u; }; -/* - * Data structure for the response from sessiond to the lttng client. - */ -struct lttcomm_lttng_msg { - uint32_t cmd_type; /* enum lttcomm_sessiond_command */ - uint32_t ret_code; /* enum lttcomm_return_code */ - uint32_t pid; /* pid_t */ - uint32_t data_size; - /* Contains: trace_name + data */ - char payload[]; -}; - /* * Data structure for the response from UST to the session daemon. * cmd_type is sent back in the reply for validation. */ -struct lttcomm_ust_msg { +struct lttcomm_ust_reply { uint32_t cmd_type; /* enum lttcomm_sessiond_command */ uint32_t ret_code; /* enum enum lttcomm_return_code */ union { @@ -205,16 +167,6 @@ struct lttcomm_kconsumerd_header { uint32_t cmd_type; /* enum kconsumerd_command */ }; -/* lttcomm_kconsumerd_msg represents a file descriptor to consume the - * data and a path name to write it - */ -struct lttcomm_kconsumerd_msg { - char path_name[PATH_MAX]; - int fd; - uint32_t state; /* enum lttcomm_kconsumerd_fd_state */ - unsigned long max_sb_size; /* the subbuffer size for this channel */ -}; - extern int lttcomm_create_unix_sock(const char *pathname); extern int lttcomm_connect_unix_sock(const char *pathname); extern int lttcomm_accept_unix_sock(int sock); diff --git a/libust/lttng-ust-comm.c b/libust/lttng-ust-comm.c index 0d8fcdd0..e28c39c6 100644 --- a/libust/lttng-ust-comm.c +++ b/libust/lttng-ust-comm.c @@ -69,15 +69,15 @@ int register_app_to_sessiond(int socket) static -int handle_message(int sock, struct lttcomm_session_msg *lsm) +int handle_message(int sock, struct lttcomm_ust_msg *lum) { ssize_t len; int ret; - switch (lsm->cmd_type) { + switch (lum->cmd_type) { case LTTNG_CREATE_SESSION: { - struct lttcomm_ust_msg lur; + struct lttcomm_ust_reply lur; DBG("Handling create session message"); memset(&lur, 0, sizeof(lur)); @@ -109,7 +109,7 @@ int handle_message(int sock, struct lttcomm_session_msg *lsm) break; } default: - ERR("Unimplemented command %d", (int) lsm->cmd_type); + ERR("Unimplemented command %d", (int) lum->cmd_type); return -1; } return 0; @@ -141,17 +141,17 @@ restart: } for (;;) { ssize_t len; - struct lttcomm_session_msg lsm; + struct lttcomm_ust_msg lum; /* Receive session handle */ - len = lttcomm_recv_unix_sock(sock, &lsm, sizeof(lsm)); + len = lttcomm_recv_unix_sock(sock, &lum, sizeof(lum)); switch (len) { case 0: /* orderly shutdown */ DBG("ltt-sessiond has performed an orderly shutdown\n"); goto end; - case sizeof(lsm): + case sizeof(lum): DBG("message received\n"); - ret = handle_message(sock, &lsm); + ret = handle_message(sock, &lum); if (ret) { ERR("Error handling message\n"); } -- 2.34.1