@@ -293,16 +293,8 @@ void tracecmd_disable_all_tracing(int disable_tracer);
void tracecmd_disable_tracing(void);
void tracecmd_enable_tracing(void);
-enum tracecmd_msg_bits {
- TRACECMD_MSG_BIT_CLIENT = 0,
- TRACECMD_MSG_BIT_SERVER = 1,
- TRACECMD_MSG_BIT_USE_TCP = 2,
-};
-
enum tracecmd_msg_flags {
- TRACECMD_MSG_FL_CLIENT = (1 << TRACECMD_MSG_BIT_CLIENT),
- TRACECMD_MSG_FL_SERVER = (1 << TRACECMD_MSG_BIT_SERVER),
- TRACECMD_MSG_FL_USE_TCP = (1 << TRACECMD_MSG_BIT_USE_TCP),
+ TRACECMD_MSG_FL_USE_TCP = 1 << 0,
};
/* for both client and server */
@@ -311,6 +303,7 @@ struct tracecmd_msg_handle {
short cpu_count;
short version; /* Current protocol version */
unsigned long flags;
+ bool done;
};
struct tracecmd_msg_handle *
@@ -748,7 +748,7 @@ static int do_connection(int cfd, struct sockaddr_storage *peer_addr,
if (ret)
return ret;
- msg_handle = tracecmd_msg_handle_alloc(cfd, TRACECMD_MSG_FL_SERVER);
+ msg_handle = tracecmd_msg_handle_alloc(cfd, 0);
s = getnameinfo((struct sockaddr *)peer_addr, peer_addr_len,
host, NI_MAXHOST,
@@ -49,21 +49,6 @@ static inline void dprint(const char *fmt, ...)
unsigned int page_size;
-struct tracecmd_msg_server {
- struct tracecmd_msg_handle handle;
- int done;
-};
-
-static struct tracecmd_msg_server *
-make_server(struct tracecmd_msg_handle *msg_handle)
-{
- if (!(msg_handle->flags & TRACECMD_MSG_FL_SERVER)) {
- plog("Message handle not of type server\n");
- return NULL;
- }
- return (struct tracecmd_msg_server *)msg_handle;
-}
-
struct tracecmd_msg_opt {
be32 size;
be32 opt_cmd;
@@ -333,16 +318,12 @@ static int msg_wait_to = MSG_WAIT_MSEC;
bool tracecmd_msg_done(struct tracecmd_msg_handle *msg_handle)
{
- struct tracecmd_msg_server *msg_server = make_server(msg_handle);
-
- return (volatile int)msg_server->done;
+ return (volatile int)msg_handle->done;
}
void tracecmd_msg_set_done(struct tracecmd_msg_handle *msg_handle)
{
- struct tracecmd_msg_server *msg_server = make_server(msg_handle);
-
- msg_server->done = true;
+ msg_handle->done = true;
}
static void error_operation(struct tracecmd_msg *msg)
@@ -442,14 +423,8 @@ struct tracecmd_msg_handle *
tracecmd_msg_handle_alloc(int fd, unsigned long flags)
{
struct tracecmd_msg_handle *handle;
- int size;
-
- if (flags == TRACECMD_MSG_FL_SERVER)
- size = sizeof(struct tracecmd_msg_server);
- else
- size = sizeof(struct tracecmd_msg_handle);
- handle = calloc(1, size);
+ handle = calloc(1, sizeof(struct tracecmd_msg_handle));
if (!handle)
return NULL;
@@ -2883,7 +2883,7 @@ again:
if (msg_handle) {
msg_handle->fd = sfd;
} else {
- msg_handle = tracecmd_msg_handle_alloc(sfd, TRACECMD_MSG_FL_CLIENT);
+ msg_handle = tracecmd_msg_handle_alloc(sfd, 0);
if (!msg_handle)
die("Failed to allocate message handle");
The difference between tracecmd_msg_handle and tracecmd_msg_server is a single bool and the tracecmd_msg_set_done/tracecmd_msg_done functions are also useful on the client side in the context of the tracing VMs over vsockets work. Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com> --- include/trace-cmd/trace-cmd.h | 11 ++--------- tracecmd/trace-listen.c | 2 +- tracecmd/trace-msg.c | 31 +++---------------------------- tracecmd/trace-record.c | 2 +- 4 files changed, 7 insertions(+), 39 deletions(-)