Debug output uses local buffer to avoid clashes between threads.
This commit is contained in:
parent
eb20251655
commit
227e2d5541
1 changed files with 4 additions and 11 deletions
|
@ -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)
|
||||
if (bvsnprintf(buf, MAX_DEBUG_BUFSIZE, msg, args) < 0)
|
||||
bug("Extremely long debug output, split it.");
|
||||
else
|
||||
buf = mb_realloc(buf, (bufsize *= 2));
|
||||
|
||||
fputs(buf, dbgf);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue