-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dbg: mutex should be unlocked while calling print handler #1113
Conversation
Wouldn't this make the mutex ineffective? If dbg output goes to stdout from multiple threads, then the lines could be mixed. |
this is a good question. stdout is line-buffered and stderr has no buffering. This patch is about the print handler. It makes sure that the mutex lock is unlocked while calling The dbg code does not have any control of what the print_handler is doing. |
Okay. I see now that |
int dbg_level = dbg.level; | ||
dbg_print_h *ph = dbg.ph; | ||
void *arg = dbg.arg; | ||
dbg_unlock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would does this locking protect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be an additional lock in dbg_handler_set()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mutex should protect all members of the struct.
/** Debug configuration */
static struct {
uint64_t tick; /**< Init ticks */
int level; /**< Current debug level */
enum dbg_flags flags; /**< Debug flags */
dbg_print_h *ph; /**< Optional print handler */
void *arg; /**< Handler argument */
} dbg = {
0,
DBG_INFO,
DBG_ANSI,
NULL,
NULL,
}; |
Looks good now |
@sreimers please merge to main if you agree .. |
No description provided.