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

Commit a916b339 authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Automerger Merge Worker
Browse files

Merge "gatt: Improve handling outstanging encryption" am: 3582787b am: 00b70ae4 am: 77aa427a

parents 188c230e 77aa427a
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@ void gatt_enc_cmpl_cback(const RawAddress* bd_addr, tBT_TRANSPORT transport,
  tGATT_CLCB* p_clcb = p_tcb->pending_enc_clcb.front();
  p_tcb->pending_enc_clcb.pop_front();

  if (p_clcb != NULL) {
    bool status = false;
    if (result == BTM_SUCCESS) {
      if (gatt_get_sec_act(p_tcb) == GATT_SEC_ENCRYPT_MITM) {
@@ -186,13 +187,15 @@ void gatt_enc_cmpl_cback(const RawAddress* bd_addr, tBT_TRANSPORT transport,
    }

    gatt_sec_check_complete(status, p_clcb, p_tcb->sec_act);
  }

  /* start all other pending operation in queue */
  std::deque<tGATT_CLCB*> new_pending_clcbs;
  while (!p_tcb->pending_enc_clcb.empty()) {
    tGATT_CLCB* p_clcb = p_tcb->pending_enc_clcb.front();
    p_tcb->pending_enc_clcb.pop_front();
    if (gatt_security_check_start(p_clcb)) new_pending_clcbs.push_back(p_clcb);
    if (p_clcb != NULL && gatt_security_check_start(p_clcb))
      new_pending_clcbs.push_back(p_clcb);
  }
  p_tcb->pending_enc_clcb = new_pending_clcbs;
}
@@ -229,7 +232,7 @@ void gatt_notify_enc_cmpl(const RawAddress& bd_addr) {
    while (!p_tcb->pending_enc_clcb.empty()) {
      tGATT_CLCB* p_clcb = p_tcb->pending_enc_clcb.front();
      p_tcb->pending_enc_clcb.pop_front();
      if (gatt_security_check_start(p_clcb))
      if (p_clcb != NULL && gatt_security_check_start(p_clcb))
        new_pending_clcbs.push_back(p_clcb);
    }
    p_tcb->pending_enc_clcb = new_pending_clcbs;
+7 −7
Original line number Diff line number Diff line
@@ -1163,13 +1163,13 @@ void gatt_clcb_invalidate(tGATT_TCB* p_tcb, const tGATT_CLCB* p_clcb) {
  uint16_t cid = p_clcb->cid;

  if (!p_tcb->pending_enc_clcb.empty()) {
    auto iter = std::find_if(p_tcb->pending_enc_clcb.begin(),
                             p_tcb->pending_enc_clcb.end(),
                             [p_clcb](auto& el) { return el == p_clcb; });
    if (iter != p_tcb->pending_enc_clcb.end()) {
      p_tcb->pending_enc_clcb.erase(iter);
    for (size_t i = 0; i < p_tcb->pending_enc_clcb.size(); i++) {
      if (p_tcb->pending_enc_clcb.at(i) == p_clcb) {
        LOG_WARN("Removing clcb (%p) for conn id=0x%04x from pending_enc_clcb",
                 p_clcb, p_clcb->conn_id);
        p_tcb->pending_enc_clcb.at(i) = NULL;
        break;
      }
    }
  }