summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-04-08 16:24:31 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-05-24 18:15:02 -0700
commit0a9c3be1e5246d377617c17b669df02a6149aa03 (patch)
tree294690b3bfca1e6682d93a0f3f5f59ca52802f07 /src
parent545782cbfe49398d64d9e94e20e737466057d7af (diff)
trace: Make calls dumping threadsafe.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/trace/tr_dump.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 29bc54f0950..c999577176a 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -45,6 +45,7 @@
#endif
#include "pipe/p_compiler.h"
+#include "pipe/p_thread.h"
#include "pipe/p_debug.h"
#include "util/u_memory.h"
#include "util/u_string.h"
@@ -55,6 +56,7 @@
static struct util_stream *stream = NULL;
static unsigned refcount = 0;
+static pipe_mutex call_mutex;
static long unsigned call_no = 0;
@@ -217,6 +219,7 @@ trace_dump_trace_close(void)
stream = NULL;
refcount = 0;
call_no = 0;
+ pipe_mutex_destroy(call_mutex);
}
}
@@ -234,6 +237,8 @@ boolean trace_dump_trace_begin()
if(!stream)
return FALSE;
+ pipe_mutex_init(call_mutex);
+
trace_dump_writes("<?xml version='1.0' encoding='UTF-8'?>\n");
trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
trace_dump_writes("<trace version='0.1'>\n");
@@ -264,6 +269,7 @@ void trace_dump_trace_end(void)
void trace_dump_call_begin(const char *klass, const char *method)
{
+ pipe_mutex_lock(call_mutex);
++call_no;
trace_dump_indent(1);
trace_dump_writes("<call no=\'");
@@ -282,6 +288,7 @@ void trace_dump_call_end(void)
trace_dump_tag_end("call");
trace_dump_newline();
util_stream_flush(stream);
+ pipe_mutex_unlock(call_mutex);
}
void trace_dump_arg_begin(const char *name)