]> git.cworth.org Git - apitrace/commitdiff
Ignore reentrant calls.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 22 Nov 2010 15:27:57 +0000 (15:27 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 22 Nov 2010 15:27:57 +0000 (15:27 +0000)
log.cpp

diff --git a/log.cpp b/log.cpp
index ea306de5b4b8786405851ba061af9ab56911fd37..b4708f3f3c3290ce9a38e157593ca8344cb8e9fc 100644 (file)
--- a/log.cpp
+++ b/log.cpp
@@ -48,6 +48,8 @@ static void _Close(void) {
    }
 }
 
+static int reentrancy = 0;
+
 static void _Open(const char *szName, const char *szExtension) {
    _Close();
    
@@ -83,6 +85,9 @@ static inline void Write(const void *sBuffer, size_t dwBytesToWrite) {
    if(g_gzFile == NULL)
       return;
    
+   if (reentrancy > 1)
+      return;
+
    gzwrite(g_gzFile, sBuffer, dwBytesToWrite);
 }
 
@@ -140,11 +145,13 @@ void Close(void) {
 
 void BeginCall(const char *function) {
    OS::AcquireMutex();
+   ++reentrancy;
    WriteString(function);
 }
 
 void EndCall(void) {
    WriteByte(Trace::CALL_END);
+   --reentrancy;
    gzflush(g_gzFile, Z_SYNC_FLUSH);
    OS::ReleaseMutex();
 }