]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Debug output uses local buffer to avoid clashes between threads.
authorMaria Matejka <mq@ucw.cz>
Wed, 26 May 2021 14:42:02 +0000 (16:42 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 10 Sep 2021 15:37:46 +0000 (17:37 +0200)
sysdep/unix/log.c

index 14d18c018b2e56a6b5bc33b4c9e93e62af4df7f4..4e9df069eccf6290d405e44658ef897944b53c62 100644 (file)
@@ -309,22 +309,15 @@ die(const char *msg, ...)
 void
 debug(const char *msg, ...)
 {
-#define MAX_DEBUG_BUFSIZE       65536
+#define MAX_DEBUG_BUFSIZE 16384
   va_list args;
-  static uint bufsize = 4096;
-  static char *buf = NULL;
-
-  if (!buf)
-    buf = mb_alloc(&root_pool, bufsize);
+  char buf[MAX_DEBUG_BUFSIZE];
 
   va_start(args, msg);
   if (dbgf)
     {
-      while (bvsnprintf(buf, bufsize, msg, args) < 0)
-        if (bufsize >= MAX_DEBUG_BUFSIZE)
-          bug("Extremely long debug output, split it.");
-        else
-          buf = mb_realloc(buf, (bufsize *= 2));
+      if (bvsnprintf(buf, MAX_DEBUG_BUFSIZE, msg, args) < 0)
+       bug("Extremely long debug output, split it.");
 
       fputs(buf, dbgf);
     }