Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2febd399 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Fix crashes in btif_sendmsg when worqueue not initialized

Instead of crashing whole stack when trying to post task to
uninitialized queue, log error message. This can happen in two cases:
stack is not initialized yet, or we're shutting down and already cleaned
up the workqueue thread.

Bug: 28889608
Change-Id: I9b8652d27abc2489b2489997c928634b68433a3e
parent 34c5479c
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -298,10 +298,21 @@ static void bt_jni_msg_ready(void *context) {

void btif_sendmsg(void *p_msg)
{
  if (!bt_jni_workqueue_thread) {
    BTIF_TRACE_ERROR("%s: message dropped, queue not initialized or gone", __func__);
    osi_free(p_msg);
    return;
  }

  thread_post(bt_jni_workqueue_thread, bt_jni_msg_ready, p_msg);
}

void btif_thread_post(thread_fn func, void *context) {
  if (!bt_jni_workqueue_thread) {
    BTIF_TRACE_ERROR("%s: call dropped, queue not initialized or gone", __func__);
    return;
  }

  thread_post(bt_jni_workqueue_thread, func, context);
}