-
When my baresip Android app calls There is function
Could a new function be introduced that only returns the result without any log messages? In void re_thread_enter(void)
{
struct re *re = re_get();
if (!re) {
DEBUG_WARNING("re_thread_enter: re not ready\n");
return;
}
re_lock(re);
/* set only for non-re threads */
if (!thrd_equal(re->tid, thrd_current())) {
re_atomic_rlx_set(&re->thread_enter, true);
}
} Or is the call harmless and does not cause any lockup? |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments 2 replies
-
The first question was answered by commit 40a1b04. Regarding the second question, I read some pthread docs and got impression that second call of |
Beta Was this translation helpful? Give feedback.
-
I added debug to my ua_hangup function:
When the thread check is commented out, second call of
But when I hangup while still on re thread, the second
In my opinion this is dangerous. re_thread_enter/leave should have some checks that automatically prevent this kind of lockups. |
Beta Was this translation helpful? Give feedback.
-
I still don't understand how the re functions operate:
|
Beta Was this translation helpful? Give feedback.
-
A simplified example: /* RE thread */
re_main(...)
{
re_unlock();
/* waiting for events (epoll_wait...) */
re_lock();
/* execute timers and async events (network etc.) */
} With /*
* This function can be called from the application's thread
*/
int application_ua_connect(void)
{
int err;
re_thread_enter();
err = ua_connect()
re_thread_leave();
return err;
} And if you have a callback handler registered that interacts with same application code (that possible calls /*
* The callback handler is called from the RE thread.
*/
static void ua_event_handler(struct ua *ua, enum ua_event ev,
struct call *call, const char *prm, void *arg)
{
re_thread_leave();
call_ui_function();
re_thread_enter();
} A alternative solution is to use a thread safe message queue ( |
Beta Was this translation helpful? Give feedback.
-
Can you try this PR: #782 it should help in some cases, to avoid a deadlock. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggestion. I installed the PR and here is my test code:
And here is what I got to log:
My understanding is that the error comes from |
Beta Was this translation helpful? Give feedback.
-
Just in case it matters, I call
|
Beta Was this translation helpful? Give feedback.
-
Without the PR, there is no error message, but the app hangs. Therefore I'm currently not calling re_thread_leave/enter in |
Beta Was this translation helpful? Give feedback.
-
a recursive pthread unlock returns error if you try to unlock and the current thread is not the owner of the lock. PTHREAD_MUTEX_LOCK(3P):
|
Beta Was this translation helpful? Give feedback.
-
I'm calling Could baresip start code #774 (comment) create the lock (e.g. in |
Beta Was this translation helpful? Give feedback.
-
I add debug to baresip start code:
and the result is:
So could the lock be created by |
Beta Was this translation helpful? Give feedback.
-
static int runLoggingThread()
} |
Beta Was this translation helpful? Give feedback.
-
I added
So looks this is not correct example:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks, PR #784 helped a lot. No more hang at baresip start. I'll do more testing after lunch break. |
Beta Was this translation helpful? Give feedback.
-
I made more tests and #784 allowed me to remove all |
Beta Was this translation helpful? Give feedback.
Can you try: #784