}
 }
 
+static int reentrancy = 0;
+
 static void _Open(const char *szName, const char *szExtension) {
    _Close();
    
    if(g_gzFile == NULL)
       return;
    
+   if (reentrancy > 1)
+      return;
+
    gzwrite(g_gzFile, sBuffer, dwBytesToWrite);
 }
 
 
 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();
 }