From cd62ed535fe873e20a5b58b885dbb1e9534b8fe7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 22 Nov 2010 15:27:57 +0000 Subject: [PATCH] Ignore reentrant calls. --- log.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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(); } -- 2.7.4