Module: Mesa
Branch: master
Commit: 8ed1279b1068fe3581f70ad151d0a5881a947d26
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8ed1279b1068fe3581f70ad151d0a5881a947d26

Author: José Fonseca <jfons...@vmware.com>
Date:   Fri Feb 22 08:45:07 2013 +0000

trace: Never close stdout/stderr.

This could happen, when a trace screen was destroyed and then recreated.

---

 src/gallium/drivers/trace/tr_dump.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_dump.c 
b/src/gallium/drivers/trace/tr_dump.c
index 48c8914..826ce5b 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -57,6 +57,7 @@
 #include "tr_texture.h"
 
 
+static boolean close_stream = FALSE;
 static FILE *stream = NULL;
 static unsigned refcount = 0;
 pipe_static_mutex(call_mutex);
@@ -228,8 +229,11 @@ trace_dump_trace_close(void)
 {
    if(stream) {
       trace_dump_writes("</trace>\n");
-      fclose(stream);
-      stream = NULL;
+      if (close_stream) {
+         fclose(stream);
+         close_stream = FALSE;
+         stream = NULL;
+      }
       refcount = 0;
       call_no = 0;
    }
@@ -261,12 +265,15 @@ trace_dump_trace_begin(void)
    if(!stream) {
 
       if (strcmp(filename, "stderr") == 0) {
+         close_stream = FALSE;
          stream = stderr;
       }
       else if (strcmp(filename, "stdout") == 0) {
+         close_stream = FALSE;
          stream = stdout;
       }
       else {
+         close_stream = TRUE;
          stream = fopen(filename, "wt");
          if (!stream)
             return FALSE;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to