diff mbox series

[2/4] rt-tests: rt-utils: Add function to close trace fds

Message ID 20201107095843.11909-3-kurt@linutronix.de
State New
Headers show
Series rt-tests: rt-utils: Close trace fds | expand

Commit Message

Kurt Kanzenbach Nov. 7, 2020, 9:58 a.m. UTC
Currently the trace fds are not closed. Add a function for it.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/include/rt-utils.h |  1 +
 src/lib/rt-utils.c     | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

Comments

John Kacur Nov. 11, 2020, 2:30 a.m. UTC | #1
On Sat, 7 Nov 2020, Kurt Kanzenbach wrote:

> Currently the trace fds are not closed. Add a function for it.

> 

> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>

> ---

>  src/include/rt-utils.h |  1 +

>  src/lib/rt-utils.c     | 14 ++++++++++++++

>  2 files changed, 15 insertions(+)

> 

> diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h

> index 4ed1cbc53ece..c6fb220cdb0a 100644

> --- a/src/include/rt-utils.h

> +++ b/src/include/rt-utils.h

> @@ -31,6 +31,7 @@ int parse_time_string(char *val);

>  

>  void enable_trace_mark(void);

>  void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));

> +void disable_trace_mark(void);

>  

>  #define MSEC_PER_SEC		1000

>  #define USEC_PER_SEC		1000000

> diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c

> index 85d41b9542a2..a30e1e4ce436 100644

> --- a/src/lib/rt-utils.c

> +++ b/src/lib/rt-utils.c

> @@ -390,6 +390,15 @@ static void open_tracemark_fd(void)

>  	}

>  }

>  

> +static void close_tracemark_fd(void)

> +{

> +	if (tracemark_fd > 0)

> +		close(tracemark_fd);

> +

> +	if (trace_fd > 0)

> +		close(trace_fd);

> +}

> +

>  static int trace_file_exists(char *name)

>  {

>  	struct stat sbuf;

> @@ -437,3 +446,8 @@ void enable_trace_mark(void)

>  	debugfs_prepare();

>  	open_tracemark_fd();

>  }

> +

> +void disable_trace_mark(void)

> +{

> +	close_tracemark_fd();

> +}

> -- 

> 2.26.2

> 

> 

Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index 4ed1cbc53ece..c6fb220cdb0a 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -31,6 +31,7 @@  int parse_time_string(char *val);
 
 void enable_trace_mark(void);
 void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
+void disable_trace_mark(void);
 
 #define MSEC_PER_SEC		1000
 #define USEC_PER_SEC		1000000
diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
index 85d41b9542a2..a30e1e4ce436 100644
--- a/src/lib/rt-utils.c
+++ b/src/lib/rt-utils.c
@@ -390,6 +390,15 @@  static void open_tracemark_fd(void)
 	}
 }
 
+static void close_tracemark_fd(void)
+{
+	if (tracemark_fd > 0)
+		close(tracemark_fd);
+
+	if (trace_fd > 0)
+		close(trace_fd);
+}
+
 static int trace_file_exists(char *name)
 {
 	struct stat sbuf;
@@ -437,3 +446,8 @@  void enable_trace_mark(void)
 	debugfs_prepare();
 	open_tracemark_fd();
 }
+
+void disable_trace_mark(void)
+{
+	close_tracemark_fd();
+}