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

Commit 0766e9fa authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Android Git Automerger
Browse files

am c3a86422: Merge "Limit the time PAN can occupy the BTU stack thread" into lmp-dev

* commit 'c3a86422':
  Limit the time PAN can occupy the BTU stack thread
parents 92615a2c c3a86422
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -428,6 +428,8 @@ int btpan_tap_open()
    BTM_GetLocalDeviceAddr (local_addr);
    BTM_GetLocalDeviceAddr (local_addr);
    if(tap_if_up(TAP_IF_NAME, local_addr) == 0)
    if(tap_if_up(TAP_IF_NAME, local_addr) == 0)
    {
    {
        int flags = fcntl(fd, F_GETFL, 0);
        fcntl(fd, F_SETFL, flags | O_NONBLOCK);
        return fd;
        return fd;
    }
    }
    BTIF_TRACE_ERROR("can not bring up tap interface:%s", TAP_IF_NAME);
    BTIF_TRACE_ERROR("can not bring up tap interface:%s", TAP_IF_NAME);
@@ -678,8 +680,10 @@ static void btu_exec_tap_fd_read(void *p_param) {
    if (fd == -1 || fd != btpan_cb.tap_fd)
    if (fd == -1 || fd != btpan_cb.tap_fd)
        return;
        return;


    // Keep sending until someone either turns off BTIF or disables data the flow.
    // Don't occupy BTU context too long, avoid GKI buffer overruns and
    while (btif_is_enabled() && btpan_cb.flow) {
    // give other profiles a chance to run by limiting the amount of memory
    // PAN can use from the shared pool buffer.
    for(int i = 0; i < PAN_POOL_MAX && btif_is_enabled() && btpan_cb.flow; i++) {
        BT_HDR *buffer = (BT_HDR *)GKI_getpoolbuf(PAN_POOL_ID);
        BT_HDR *buffer = (BT_HDR *)GKI_getpoolbuf(PAN_POOL_ID);
        if (!buffer) {
        if (!buffer) {
            BTIF_TRACE_WARNING("%s unable to allocate buffer for packet.", __func__);
            BTIF_TRACE_WARNING("%s unable to allocate buffer for packet.", __func__);
+2 −0
Original line number Original line Diff line number Diff line
@@ -533,6 +533,8 @@


#ifndef PAN_POOL_ID
#ifndef PAN_POOL_ID
#define PAN_POOL_ID                 GKI_POOL_ID_3
#define PAN_POOL_ID                 GKI_POOL_ID_3
/* Maximum amount of the shared buffer to allocate for PAN */
#define PAN_POOL_MAX                (GKI_BUF3_MAX / 4)
#endif
#endif


/* UNV pool for read/write serialization */
/* UNV pool for read/write serialization */