From: David Goulet Date: Fri, 6 May 2011 15:25:29 +0000 (-0400) Subject: Rename data structure for naming consistency X-Git-Tag: v2.0-pre1~145 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6abb15de23fcd1413963aef20f9f2c243f1bf749;p=lttng-tools.git Rename data structure for naming consistency Signed-off-by: David Goulet --- diff --git a/liblttngctl/liblttngctl.c b/liblttngctl/liblttngctl.c index 1793bc53a..3ff1529a1 100644 --- a/liblttngctl/liblttngctl.c +++ b/liblttngctl/liblttngctl.c @@ -35,11 +35,11 @@ static char sessiond_sock_path[PATH_MAX]; /* Communication structure to ltt-sessiond */ static struct lttcomm_session_msg lsm; -static struct lttcomm_lttng_msg llm; +static struct lttcomm_lttng_header llh; /* Prototypes */ static int check_tracing_group(const char *grp_name); -static int ask_sessiond(enum lttcomm_command_type lct, void **buf); +static int ask_sessiond(enum lttcomm_sessiond_command lct, void **buf); static int recv_data_sessiond(void *buf, size_t len); static int send_data_sessiond(void); static int set_session_daemon_path(void); @@ -105,7 +105,7 @@ end: * * Return size of data (only payload, not header). */ -static int ask_sessiond(enum lttcomm_command_type lct, void **buf) +static int ask_sessiond(enum lttcomm_sessiond_command lct, void **buf) { int ret; size_t size; @@ -125,18 +125,18 @@ static int ask_sessiond(enum lttcomm_command_type lct, void **buf) } /* Get header from data transmission */ - ret = recv_data_sessiond(&llm, sizeof(llm)); + ret = recv_data_sessiond(&llh, sizeof(llh)); if (ret < 0) { goto end; } /* Check error code if OK */ - if (llm.ret_code != LTTCOMM_OK) { - ret = -llm.ret_code; + if (llh.ret_code != LTTCOMM_OK) { + ret = -llh.ret_code; goto end; } - size = llm.size_payload; + size = llh.payload_size; if (size == 0) { goto end; } @@ -278,7 +278,7 @@ int lttng_create_session(char *name, uuid_t *session_id) goto end; } - uuid_copy(*session_id, llm.session_id); + uuid_copy(*session_id, llh.session_id); end: return ret; diff --git a/liblttsessiondcomm/liblttsessiondcomm.h b/liblttsessiondcomm/liblttsessiondcomm.h index e51b81317..5cac0b798 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.h +++ b/liblttsessiondcomm/liblttsessiondcomm.h @@ -45,7 +45,7 @@ */ #define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK) -enum lttcomm_command_type { +enum lttcomm_sessiond_command { LTTNG_CREATE_SESSION, LTTNG_DESTROY_SESSION, LTTNG_FORCE_SUBBUF_SWITCH, @@ -113,7 +113,7 @@ enum lttcomm_kconsumerd_fd_state { */ struct lttcomm_session_msg { /* Common data to almost all command */ - enum lttcomm_command_type cmd_type; + enum lttcomm_sessiond_command cmd_type; uuid_t session_id; char trace_name[NAME_MAX]; char session_name[NAME_MAX]; @@ -151,13 +151,13 @@ struct lttcomm_session_msg { * the header of the transmission. NEVER put variable * size data in here. */ -struct lttcomm_lttng_msg { - enum lttcomm_command_type cmd_type; +struct lttcomm_lttng_header { + enum lttcomm_sessiond_command cmd_type; enum lttcomm_return_code ret_code; uuid_t session_id; pid_t pid; char trace_name[NAME_MAX]; - unsigned int size_payload; + unsigned int payload_size; }; /* diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index f2205e4b1..90aea69fc 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -59,11 +59,11 @@ static int process_client_msg(int sock, struct lttcomm_session_msg*); static int send_unix_sock(int sock, void *buf, size_t len); static int set_signal_handler(void); static int set_permissions(void); -static int setup_data_buffer(char **buf, size_t size, struct lttcomm_lttng_msg *llm); +static int setup_data_buffer(char **buf, size_t size, struct lttcomm_lttng_header *llh); static int create_lttng_rundir(void); static int set_kconsumerd_sockets(void); static void cleanup(void); -static void copy_common_data(struct lttcomm_lttng_msg *llm, struct lttcomm_session_msg *lsm); +static void copy_common_data(struct lttcomm_lttng_header *llh, struct lttcomm_session_msg *lsm); static void sighandler(int sig); static void *thread_manage_clients(void *data); @@ -232,7 +232,7 @@ static void *thread_manage_clients(void *data) /* This function dispatch the work to the LTTng or UST libs * and then sends back the response to the client. This is needed - * because there might be more then one lttcomm_lttng_msg to + * because there might be more then one lttcomm_lttng_header to * send out so process_client_msg do both jobs. */ ret = process_client_msg(sock, &lsm); @@ -454,20 +454,20 @@ error: /* * copy_common_data * - * Copy common data between lttcomm_lttng_msg and lttcomm_session_msg + * Copy common data between lttcomm_lttng_header and lttcomm_session_msg */ -static void copy_common_data(struct lttcomm_lttng_msg *llm, struct lttcomm_session_msg *lsm) +static void copy_common_data(struct lttcomm_lttng_header *llh, struct lttcomm_session_msg *lsm) { - llm->cmd_type = lsm->cmd_type; - llm->pid = lsm->pid; + llh->cmd_type = lsm->cmd_type; + llh->pid = lsm->pid; /* Manage uuid */ if (!uuid_is_null(lsm->session_id)) { - uuid_copy(llm->session_id, lsm->session_id); + uuid_copy(llh->session_id, lsm->session_id); } - strncpy(llm->trace_name, lsm->trace_name, strlen(llm->trace_name)); - llm->trace_name[strlen(llm->trace_name) - 1] = '\0'; + strncpy(llh->trace_name, lsm->trace_name, strlen(llh->trace_name)); + llh->trace_name[strlen(llh->trace_name) - 1] = '\0'; } /* @@ -478,12 +478,12 @@ static void copy_common_data(struct lttcomm_lttng_msg *llm, struct lttcomm_sessi * * Return total size of the buffer pointed by buf. */ -static int setup_data_buffer(char **buf, size_t s_data, struct lttcomm_lttng_msg *llm) +static int setup_data_buffer(char **buf, size_t s_data, struct lttcomm_lttng_header *llh) { int ret = 0; size_t buf_size; - buf_size = sizeof(struct lttcomm_lttng_msg) + s_data; + buf_size = sizeof(struct lttcomm_lttng_header) + s_data; *buf = malloc(buf_size); if (*buf == NULL) { perror("malloc"); @@ -491,11 +491,11 @@ static int setup_data_buffer(char **buf, size_t s_data, struct lttcomm_lttng_msg goto error; } - /* Setup lttcomm_lttng_msg data and copy + /* Setup lttcomm_lttng_header data and copy * it to the newly allocated buffer. */ - llm->size_payload = s_data; - memcpy(*buf, llm, sizeof(struct lttcomm_lttng_msg)); + llh->payload_size = s_data; + memcpy(*buf, llh, sizeof(struct lttcomm_lttng_header)); return buf_size; @@ -518,14 +518,14 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) int buf_size; size_t header_size; char *send_buf = NULL; - struct lttcomm_lttng_msg llm; + struct lttcomm_lttng_header llh; DBG("Processing client message"); /* Copy common data to identify the response * on the lttng client side. */ - copy_common_data(&llm, lsm); + copy_common_data(&llh, lsm); /* Check command that needs a session */ if (lsm->cmd_type != LTTNG_CREATE_SESSION && @@ -542,15 +542,15 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) /* Default return code. * In our world, everything is OK... right? ;) */ - llm.ret_code = LTTCOMM_OK; + llh.ret_code = LTTCOMM_OK; - header_size = sizeof(struct lttcomm_lttng_msg); + header_size = sizeof(struct lttcomm_lttng_header); /* Process by command type */ switch (lsm->cmd_type) { case LTTNG_CREATE_SESSION: { - ret = create_session(lsm->session_name, &llm.session_id); + ret = create_session(lsm->session_name, &llh.session_id); if (ret < 0) { if (ret == -1) { ret = LTTCOMM_EXIST_SESS; @@ -560,7 +560,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) goto end; } - buf_size = setup_data_buffer(&send_buf, 0, &llm); + buf_size = setup_data_buffer(&send_buf, 0, &llh); if (buf_size < 0) { ret = LTTCOMM_FATAL; goto end; @@ -577,7 +577,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) ret = LTTCOMM_OK; } - /* No auxiliary data so only send the llm struct. */ + /* No auxiliary data so only send the llh struct. */ goto end; } case LTTNG_LIST_TRACES: @@ -590,7 +590,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) } buf_size = setup_data_buffer(&send_buf, - sizeof(struct lttng_trace) * trace_count, &llm); + sizeof(struct lttng_trace) * trace_count, &llh); if (buf_size < 0) { ret = LTTCOMM_FATAL; goto end; @@ -610,7 +610,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) goto end; } - /* No auxiliary data so only send the llm struct. */ + /* No auxiliary data so only send the llh struct. */ goto end; } case UST_LIST_APPS: @@ -624,7 +624,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) /* Setup data buffer and details for transmission */ buf_size = setup_data_buffer(&send_buf, - sizeof(pid_t) * app_count, &llm); + sizeof(pid_t) * app_count, &llh); if (buf_size < 0) { ret = LTTCOMM_FATAL; goto end; @@ -638,14 +638,14 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) { ret = ust_start_trace(lsm->pid); - /* No auxiliary data so only send the llm struct. */ + /* No auxiliary data so only send the llh struct. */ goto end; } case UST_STOP_TRACE: { ret = ust_stop_trace(lsm->pid); - /* No auxiliary data so only send the llm struct. */ + /* No auxiliary data so only send the llh struct. */ goto end; } case LTTNG_LIST_SESSIONS: @@ -659,7 +659,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) /* Setup data buffer and details for transmission */ buf_size = setup_data_buffer(&send_buf, - (sizeof(struct lttng_session) * session_count), &llm); + (sizeof(struct lttng_session) * session_count), &llh); if (buf_size < 0) { ret = LTTCOMM_FATAL; goto end; @@ -688,9 +688,9 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) end: DBG("Return code to client %d", ret); /* Notify client of error */ - llm.ret_code = ret; - llm.size_payload = 0; - send_unix_sock(sock, (void*) &llm, sizeof(llm)); + llh.ret_code = ret; + llh.payload_size = 0; + send_unix_sock(sock, (void*) &llh, sizeof(llh)); return ret; }