From: David Goulet Date: Fri, 27 May 2011 20:40:44 +0000 (-0400) Subject: Add lttng-kconsumerd.h X-Git-Tag: v2.0-pre1~100 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5dc1855009c9b215a108bc56e7df64d9862c8144;p=lttng-tools.git Add lttng-kconsumerd.h This header files contains data shared between the kconsumerd daemon and the session daemon. Signed-off-by: David Goulet --- diff --git a/include/Makefile.am b/include/Makefile.am index 8f0946be5..f86ccda3d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,4 +1,4 @@ nobase_include_HEADERS = \ lttng/liblttngctl.h -noinst_HEADERS = lttngerr.h +noinst_HEADERS = lttngerr.h lttng-kernel.h lttng-kconsumerd.h lttng-share.h diff --git a/include/lttng-kconsumerd.h b/include/lttng-kconsumerd.h new file mode 100644 index 000000000..fa10ee25d --- /dev/null +++ b/include/lttng-kconsumerd.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011 - Julien Desfossez + * David Goulet + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _LTTNG_KCONSUMERD_H +#define _LTTNG_KCONSUMERD_H + +#include "lttng-share.h" + +/* Kernel consumer path */ +#define KCONSUMERD_PATH LTTNG_RUNDIR "/kconsumerd" +#define KCONSUMERD_CMD_SOCK_PATH KCONSUMERD_PATH "/command" +#define KCONSUMERD_ERR_SOCK_PATH KCONSUMERD_PATH "/error" + +/* Commands for kconsumerd */ +enum kconsumerd_command { + ADD_STREAM, + UPDATE_STREAM, /* pause, delete, start depending on fd state */ + STOP, /* delete all */ +}; + +/* State of each fd in consumerd */ +enum kconsumerd_fd_state { + ACTIVE_FD, + PAUSE_FD, + DELETE_FD, +}; + +#endif /* _LTTNG_KCONSUMERD_H */ diff --git a/include/lttng-share.h b/include/lttng-share.h index 1965ffcb1..f61e24dbb 100644 --- a/include/lttng-share.h +++ b/include/lttng-share.h @@ -24,4 +24,6 @@ typedef uint32_t u32; typedef uint64_t u64; +#define LTTNG_RUNDIR "/var/run/lttng" + #endif /* _LTTNG_SHARE_H */ diff --git a/kconsumerd/kconsumerd.c b/kconsumerd/kconsumerd.c index 592bc0842..69aa47a6e 100644 --- a/kconsumerd/kconsumerd.c +++ b/kconsumerd/kconsumerd.c @@ -392,7 +392,7 @@ end: * Update a fd according to what we just received */ static void change_fd_state(int sessiond_fd, - enum lttcomm_kconsumerd_fd_state state) + enum kconsumerd_fd_state state) { struct ltt_kconsumerd_fd *iter; cds_list_for_each_entry(iter, &kconsumerd_fd_list.head, list) { @@ -411,7 +411,7 @@ static void change_fd_state(int sessiond_fd, * Returns the size of received data */ static int consumerd_recv_fd(int sfd, int size, - enum lttcomm_consumerd_command cmd_type) + enum kconsumerd_command cmd_type) { struct msghdr msg; struct iovec iov[1]; @@ -459,7 +459,7 @@ static int consumerd_recv_fd(int sfd, int size, DBG("Receive : expecting %d fds", nb_fd); for (i = 0; i < nb_fd; i++) { switch (cmd_type) { - case LTTCOMM_ADD_STREAM: + case ADD_STREAM: DBG("add_fd %s (%d)", buf[i].path_name, ((int *)CMSG_DATA(cmsg))[i]); ret = add_fd(&buf[i], ((int *)CMSG_DATA(cmsg))[i]); if (ret < 0) { @@ -467,7 +467,7 @@ static int consumerd_recv_fd(int sfd, int size, goto end; } break; - case LTTCOMM_UPDATE_STREAM: + case UPDATE_STREAM: change_fd_state(buf[i].fd, buf[i].state); break; default: diff --git a/kconsumerd/kconsumerd.h b/kconsumerd/kconsumerd.h index 6c78663f5..2aff4ef50 100644 --- a/kconsumerd/kconsumerd.h +++ b/kconsumerd/kconsumerd.h @@ -19,6 +19,8 @@ #ifndef _LTT_KCONSUMERD_H #define _LTT_KCONSUMERD_H +#include "lttng-kconsumerd.h" + struct ltt_kconsumerd_fd_list { struct cds_list_head head; }; @@ -34,7 +36,7 @@ struct ltt_kconsumerd_fd { int out_fd; /* output file to write the data */ off_t out_fd_offset; /* write position in the output file descriptor */ char path_name[PATH_MAX]; /* tracefile name */ - enum lttcomm_kconsumerd_fd_state state; + enum kconsumerd_fd_state state; unsigned long max_sb_size; /* the subbuffer size for this channel */ }; diff --git a/liblttsessiondcomm/liblttsessiondcomm.h b/liblttsessiondcomm/liblttsessiondcomm.h index 6c46ac255..d63f9b62c 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.h +++ b/liblttsessiondcomm/liblttsessiondcomm.h @@ -26,19 +26,12 @@ #include "lttng-share.h" -#define LTTNG_RUNDIR "/var/run/lttng" - /* Default unix socket path */ #define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-ltt-sessiond" #define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-ltt-sessiond" #define DEFAULT_HOME_APPS_UNIX_SOCK "%s/.apps-ltt-sessiond" #define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-ltt-sessiond" -/* Kernel consumer path */ -#define KCONSUMERD_PATH LTTNG_RUNDIR "/kconsumerd" -#define KCONSUMERD_CMD_SOCK_PATH KCONSUMERD_PATH "/command" -#define KCONSUMERD_ERR_SOCK_PATH KCONSUMERD_PATH "/error" - /* Queue size of listen(2) */ #define MAX_LISTEN 10 @@ -132,20 +125,6 @@ enum lttcomm_return_code { LTTCOMM_NR, /* Last element */ }; -/* commands for kconsumerd */ -enum lttcomm_consumerd_command { - LTTCOMM_ADD_STREAM = 1100, - LTTCOMM_UPDATE_STREAM, /* pause, delete, start depending on fd state */ - LTTCOMM_STOP, /* delete all */ -}; - -/* state of each fd in consumerd */ -enum lttcomm_kconsumerd_fd_state { - ACTIVE_FD, - PAUSE_FD, - DELETE_FD, -}; - /* * Data structure received from lttng client to session daemon. */ diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 4b2fb52c2..5327804c3 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -45,6 +45,7 @@ #include "ust-ctl.h" #include "session.h" #include "traceable-app.h" +#include "lttng-kconsumerd.h" /* * TODO: @@ -584,7 +585,7 @@ static int send_kconsumerd_fds(int sock, struct ltt_kernel_session *session) /* Setup header */ lkh.payload_size = nb_fd * sizeof(struct lttcomm_kconsumerd_msg); - lkh.cmd_type = LTTCOMM_ADD_STREAM; + lkh.cmd_type = ADD_STREAM; DBG("Sending kconsumerd header");