aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2022-05-13 22:47:51 -0400
committerSteven Rostedt (Google) <rostedt@goodmis.org>2022-05-21 20:01:09 -0400
commitd45104e444487e862801171d7eab9bf25e1648a1 (patch)
treec176ad0b6acac4144d7f0b04758db3c84eefeaea
parenta2f33146648dfcb0a0cb418712c3e7aae0926ff2 (diff)
downloadtrace-cmd-d45104e444487e862801171d7eab9bf25e1648a1.tar.gz
trace-cmd library: Add tracecmd_msg_flush_data()
Add tracecmd_msg_flush_data() that will flush the current cached data to the network and restart the cache file. Link: https://lore.kernel.org/linux-trace-devel/20220514024756.1319681-22-rostedt@goodmis.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r--lib/trace-cmd/include/private/trace-cmd-private.h1
-rw-r--r--lib/trace-cmd/trace-msg.c20
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index 28fa712c..053866d5 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -416,6 +416,7 @@ int tracecmd_msg_send_init_data(struct tracecmd_msg_handle *msg_handle,
int tracecmd_msg_data_send(struct tracecmd_msg_handle *msg_handle,
const char *buf, int size);
int tracecmd_msg_finish_sending_data(struct tracecmd_msg_handle *msg_handle);
+int tracecmd_msg_flush_data(struct tracecmd_msg_handle *msg_handle);
int tracecmd_msg_send_close_msg(struct tracecmd_msg_handle *msg_handle);
int tracecmd_msg_send_close_resp_msg(struct tracecmd_msg_handle *msg_handle);
int tracecmd_msg_wait_close(struct tracecmd_msg_handle *msg_handle);
diff --git a/lib/trace-cmd/trace-msg.c b/lib/trace-cmd/trace-msg.c
index 963ef94e..a0c7f181 100644
--- a/lib/trace-cmd/trace-msg.c
+++ b/lib/trace-cmd/trace-msg.c
@@ -823,6 +823,26 @@ int tracecmd_msg_data_send(struct tracecmd_msg_handle *msg_handle,
return ret;
}
+/**
+ * tracecmd_msg_flush_data - Send the current cache data over the network
+ * @msg_handle: message handle, holding the communication context
+ *
+ * Send the content in the cache file over the nework, reset the file
+ * and start the cache up again (with nothing in it).
+ */
+int tracecmd_msg_flush_data(struct tracecmd_msg_handle *msg_handle)
+{
+ struct tracecmd_msg msg;
+ int ret;
+
+ flush_cache(msg_handle);
+ tracecmd_msg_init(MSG_FIN_DATA, &msg);
+ ret = tracecmd_msg_send(msg_handle, &msg);
+ if (ret < 0)
+ return ret;
+ return tracecmd_msg_handle_cache(msg_handle);
+}
+
int tracecmd_msg_finish_sending_data(struct tracecmd_msg_handle *msg_handle)
{
struct tracecmd_msg msg;