]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix nested debugs() calls
authorAlexander Komyagin <komyagin@altell.ru>
Mon, 18 Feb 2013 11:37:32 +0000 (00:37 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 18 Feb 2013 11:37:32 +0000 (00:37 +1300)
Since debugs() is a macro, it should not change static Debugs::level
before putting the debug message to the internal stream. Otherwise we
encounter problems when debug message itself containg calls to debugs().

src/Debug.h

index 18c01ca4919d98df19f50263f1dedd45a1a7b2f7..eebb2b3040d187c96c16b327c93a874a19772eb0 100644 (file)
@@ -107,12 +107,13 @@ const char * SkipBuildPrefix(const char* path);
 /* Debug stream */
 #define debugs(SECTION, LEVEL, CONTENT) \
    do { \
-        if ((Debug::level = (LEVEL)) <= Debug::Levels[SECTION]) { \
+        if ((LEVEL) <= Debug::Levels[SECTION]) { \
             Debug::sectionLevel = Debug::Levels[SECTION]; \
             std::ostream &_dbo=Debug::getDebugOut(); \
-            if (Debug::level > DBG_IMPORTANT) \
+            if ((LEVEL) > DBG_IMPORTANT) \
                 _dbo << SkipBuildPrefix(__FILE__)<<"("<<__LINE__<<") "<<__FUNCTION__<<": "; \
             _dbo << CONTENT; \
+            Debug::level = (LEVEL); \
             Debug::finishDebug(); \
         } \
    } while (/*CONSTCOND*/ 0)