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

Commit 6d4df2a6 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov Committed by android-build-merger
Browse files

Allocate/free the SDP connection timers only during stack startup/shutdown am: d1c857e3

am: d4c8149d

Change-Id: I6fda9a621d422563e6bb25b2a06b52bf431b1547
parents 305696ac d4c8149d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ void btu_free_core(void) {
  /* Free the mandatory core stack components */
  l2c_free();

  sdp_free();

  gatt_free();
}

+11 −0
Original line number Diff line number Diff line
@@ -73,6 +73,10 @@ void sdp_init(void) {
  /* Clears all structures and local SDP database (if Server is enabled) */
  memset(&sdp_cb, 0, sizeof(tSDP_CB));

  for (int i = 0; i < SDP_MAX_CONNECTIONS; i++) {
    sdp_cb.ccb[i].sdp_conn_timer = alarm_new("sdp.sdp_conn_timer");
  }

  /* Initialize the L2CAP configuration. We only care about MTU and flush */
  sdp_cb.l2cap_my_cfg.mtu_present = true;
  sdp_cb.l2cap_my_cfg.mtu = SDP_MTU_SIZE;
@@ -122,6 +126,13 @@ void sdp_init(void) {
  }
}

void sdp_free(void) {
  for (int i = 0; i < SDP_MAX_CONNECTIONS; i++) {
    alarm_free(sdp_cb.ccb[i].sdp_conn_timer);
    sdp_cb.ccb[i].sdp_conn_timer = NULL;
  }
}

#if (SDP_DEBUG == TRUE)
/*******************************************************************************
 *
+3 −3
Original line number Diff line number Diff line
@@ -108,8 +108,9 @@ tCONN_CB* sdpu_allocate_ccb(void) {
  /* Look through each connection control block for a free one */
  for (xx = 0, p_ccb = sdp_cb.ccb; xx < SDP_MAX_CONNECTIONS; xx++, p_ccb++) {
    if (p_ccb->con_state == SDP_STATE_IDLE) {
      alarm_t* alarm = p_ccb->sdp_conn_timer;
      memset(p_ccb, 0, sizeof(tCONN_CB));
      p_ccb->sdp_conn_timer = alarm_new("sdp.sdp_conn_timer");
      p_ccb->sdp_conn_timer = alarm;
      return (p_ccb);
    }
  }
@@ -129,8 +130,7 @@ tCONN_CB* sdpu_allocate_ccb(void) {
 ******************************************************************************/
void sdpu_release_ccb(tCONN_CB* p_ccb) {
  /* Ensure timer is stopped */
  alarm_free(p_ccb->sdp_conn_timer);
  p_ccb->sdp_conn_timer = NULL;
  alarm_cancel(p_ccb->sdp_conn_timer);

  /* Drop any response pointer we may be holding */
  p_ccb->con_state = SDP_STATE_IDLE;
+1 −0
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ extern tSDP_CB sdp_cb;

/* Functions provided by sdp_main.cc */
extern void sdp_init(void);
extern void sdp_free(void);
extern void sdp_disconnect(tCONN_CB* p_ccb, uint16_t reason);

#if (SDP_DEBUG == TRUE)