summaryrefslogtreecommitdiff
path: root/sysdep/unix
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2021-05-26 16:42:02 +0200
committerMaria Matejka <mq@ucw.cz>2021-09-10 17:37:46 +0200
commit227e2d5541e86210b383c8e8054805692ad3cf14 (patch)
treefb5711b953487dcef0011c56ca84bff8049821ef /sysdep/unix
parenteb2025165546d12114ca5ca4f2b338765f338af6 (diff)
Debug output uses local buffer to avoid clashes between threads.
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/log.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c
index 14d18c01..4e9df069 100644
--- a/sysdep/unix/log.c
+++ b/sysdep/unix/log.c
@@ -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);
}