-
Notifications
You must be signed in to change notification settings - Fork 83
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
jbuf: allocate mutex and lock also jbuf_debug() #693
Conversation
Now I have a better solution. |
Thats not very reliable. Better fix allocation, so you can rely on mutex. So we handle this on other places too. |
Okay, coming soon. |
How do you like the variant how struct mbuf *mb = mbuf_alloc(512);
struct re_printf pfh = {
vprintf_handler,
mb
}; |
src/jbuf/jbuf.c
Outdated
struct re_printf pfh = { | ||
vprintf_handler, | ||
mb | ||
}; |
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.
I think it is better to have straightforward and readable code.
I dont think that you get much performance benefit with this approach.
In general, clean and maintainable code should be preferred over performance.
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.
@sreimers once wrote that printing to stdout may block sometimes.
I don't want to print to stdout while the mutex is locked. But I agree also with you and there might be a simpler solution with an mbuf. A commit will follow.
This reverts commit 5d3c2b8.
For the RX thread baresip/baresip#2445
jbuf_debug()
should also be thread safe.