You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/09/07 12:07:10 UTC

[GitHub] [mynewt-nimble] haukepetersen opened a new pull request #861: host/l2cap_coc: harden TX thread safety

haukepetersen opened a new pull request #861:
URL: https://github.com/apache/mynewt-nimble/pull/861


   I also stumbled upon some more non-thread-safe lines in the `ble_l2cap_coc` code while debugging erratic node behavior in the context of #865.
   
   Mainly the operation of setting `tx->sdu = sdu_tx;` in `ble_l2cap_coc_send()`, called by any user thread, could theoretically be interrupted from the NimBLE host thread and be overwritten before `ble_l2cap_coc_send()` returns. This is now prevented by doing this assignment inside a locked host. 
   
   To further prevent any context switch to interfere, I moved both calls to `ble_l2cap_event_coc_unstalled()` inside a locked host environment. With this it is guaranteed, that any changes to the sending state (possible by `ble_l2cap_coc_send()` or `ble_l2cap_coc_le_credits_update()`) are always complete before any interruption can occur.
   
   I have been successfully using this fix together with #865 for a little while now in my experiment runs.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] apache-mynewt-bot commented on pull request #861: host/l2cap_coc: harden TX thread safety

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #861:
URL: https://github.com/apache/mynewt-nimble/pull/861#issuecomment-688283434


   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### nimble/host/src/ble_l2cap_coc.c
   <details>
   
   ```diff
   @@ -496,8 +496,7 @@
            tx->flags &= ~BLE_L2CAP_COC_FLAG_STALLED;
            ble_hs_unlock();
            ble_l2cap_event_coc_unstalled(chan, 0);
   -    }
   -    else {
   +    } else   {
            ble_hs_unlock();
        }
    
   @@ -512,8 +511,7 @@
            tx->flags &= ~BLE_L2CAP_COC_FLAG_STALLED;
            ble_hs_unlock();
            ble_l2cap_event_coc_unstalled(chan, rc);
   -    }
   -    else {
   +    } else   {
            ble_hs_unlock();
        }
    
   ```
   
   </details>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on pull request #861: host/l2cap_coc: harden TX thread safety

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on pull request #861:
URL: https://github.com/apache/mynewt-nimble/pull/861#issuecomment-688283434


   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### nimble/host/src/ble_l2cap_coc.c
   <details>
   
   ```diff
   @@ -496,8 +496,7 @@
            tx->flags &= ~BLE_L2CAP_COC_FLAG_STALLED;
            ble_hs_unlock();
            ble_l2cap_event_coc_unstalled(chan, 0);
   -    }
   -    else {
   +    } else   {
            ble_hs_unlock();
        }
    
   @@ -512,8 +511,7 @@
            tx->flags &= ~BLE_L2CAP_COC_FLAG_STALLED;
            ble_hs_unlock();
            ble_l2cap_event_coc_unstalled(chan, rc);
   -    }
   -    else {
   +    } else   {
            ble_hs_unlock();
        }
    
   ```
   
   </details>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] haukepetersen merged pull request #861: host/l2cap_coc: harden TX thread safety

Posted by GitBox <gi...@apache.org>.
haukepetersen merged pull request #861:
URL: https://github.com/apache/mynewt-nimble/pull/861


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] haukepetersen commented on pull request #861: host/l2cap_coc: harden TX thread safety

Posted by GitBox <gi...@apache.org>.
haukepetersen commented on pull request #861:
URL: https://github.com/apache/mynewt-nimble/pull/861#issuecomment-690618130


   Thanks! Lets go then...


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] haukepetersen commented on pull request #861: host/l2cap_coc: harden TX thread safety

Posted by GitBox <gi...@apache.org>.
haukepetersen commented on pull request #861:
URL: https://github.com/apache/mynewt-nimble/pull/861#issuecomment-688290030


   fixed style issues.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-nimble] apache-mynewt-bot commented on pull request #861: host/l2cap_coc: harden TX thread safety

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #861:
URL: https://github.com/apache/mynewt-nimble/pull/861#issuecomment-688297274


   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org