From: José Fonseca Date: Mon, 22 Nov 2010 15:27:57 +0000 (+0000) Subject: Ignore reentrant calls. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=cd62ed535fe873e20a5b58b885dbb1e9534b8fe7;p=apitrace Ignore reentrant calls. --- diff --git a/log.cpp b/log.cpp index ea306de..b4708f3 100644 --- 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(); }