@@ -300,7 +300,7 @@ void tracecmd_enable_tracing(void);
int tracecmd_msg_send_init_data(int fd, int total_cpus, int **client_ports);
int tracecmd_msg_metadata_send(int fd, const char *buf, int size);
int tracecmd_msg_finish_sending_metadata(int fd);
-void tracecmd_msg_send_close_msg(void);
+void tracecmd_msg_send_close_msg(int fd);
/* for server */
int tracecmd_msg_initial_setting(int fd, int *cpus, int *pagesize);
@@ -79,7 +79,6 @@ static inline void dprint(const char *fmt, ...)
bool use_tcp;
/* for client */
-static int psfd;
unsigned int page_size;
/* for server */
@@ -545,12 +544,12 @@ int tracecmd_msg_send_port_array(int fd, int total_cpus, int *ports)
return 0;
}
-void tracecmd_msg_send_close_msg(void)
+void tracecmd_msg_send_close_msg(int fd)
{
struct tracecmd_msg msg;
tracecmd_msg_init(MSG_CLOSE, &msg);
- tracecmd_msg_send(psfd, &msg);
+ tracecmd_msg_send(fd, &msg);
}
int tracecmd_msg_metadata_send(int fd, const char *buf, int size)
@@ -599,9 +598,6 @@ int tracecmd_msg_finish_sending_metadata(int fd)
ret = tracecmd_msg_send(fd, &msg);
if (ret < 0)
return ret;
-
- /* psfd will be used for closing */
- psfd = fd;
return 0;
}
@@ -90,6 +90,7 @@ static int clear_function_filters;
static char *host;
static int *client_ports;
static int sfd;
+static int psfd;
static struct tracecmd_output *network_handle;
/* Max size to let a per cpu file get */
@@ -2870,8 +2871,10 @@ again:
network_handle = tracecmd_create_init_fd_glob(sfd, listed_events,
proto_ver == V2_PROTOCOL);
- if (proto_ver == V2_PROTOCOL)
+ if (proto_ver == V2_PROTOCOL) {
+ psfd = sfd; /* used for closing */
tracecmd_msg_finish_sending_metadata(sfd);
+ }
/* OK, we are all set, let'r rip! */
}
@@ -2879,7 +2882,7 @@ again:
static void finish_network(void)
{
if (proto_ver == V2_PROTOCOL)
- tracecmd_msg_send_close_msg();
+ tracecmd_msg_send_close_msg(psfd);
close(sfd);
free(host);
}