Skip to content

Commit

Permalink
dbg: mutex should be unlocked while calling print handler
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh committed Apr 28, 2024
1 parent b5da6fc commit 2bfc129
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/dbg/dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,24 @@ static void dbg_vprintf(int level, const char *fmt, va_list ap)
static void dbg_fmt_vprintf(int level, const char *fmt, va_list ap)
{
char buf[256];
int len;

dbg_lock();
int dbg_level = dbg.level;
dbg_print_h *ph = dbg.ph;
void *arg = dbg.arg;
dbg_unlock();

if (level > dbg.level)
goto out;

if (!dbg.ph)
goto out;

len = re_vsnprintf(buf, sizeof(buf), fmt, ap);
if (len <= 0)
goto out;
if (level > dbg_level)
return;

/* Print handler? */
if (dbg.ph) {
dbg.ph(level, buf, len, dbg.arg);
}
if (ph) {
int len = re_vsnprintf(buf, sizeof(buf), fmt, ap);
if (len <= 0)
return;

out:
dbg_unlock();
ph(level, buf, len, arg);
}
}


Expand Down

0 comments on commit 2bfc129

Please sign in to comment.