diff mbox series

[3/8] trace-cmd: Remove tracecmd_msg_handle/tracecmd_msg_server distinction

Message ID 20190204070855.8921-4-kaslevs@vmware.com (mailing list archive)
State Accepted
Commit 999cb7a2330f37d983a2221b5bf6867bfbcf3663
Headers show
Series trace-cmd protocol fixes | expand

Commit Message

Slavomir Kaslev Feb. 4, 2019, 7:08 a.m. UTC
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(-)
diff mbox series

Patch

diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
index 86b9b53..33f352b 100644
--- a/include/trace-cmd/trace-cmd.h
+++ b/include/trace-cmd/trace-cmd.h
@@ -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 *
diff --git a/tracecmd/trace-listen.c b/tracecmd/trace-listen.c
index 9b50147..8bd7bad 100644
--- a/tracecmd/trace-listen.c
+++ b/tracecmd/trace-listen.c
@@ -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,
diff --git a/tracecmd/trace-msg.c b/tracecmd/trace-msg.c
index ffebce7..ef2a6d8 100644
--- a/tracecmd/trace-msg.c
+++ b/tracecmd/trace-msg.c
@@ -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;
 
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 3034a4b..8beefab 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -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");