Skip to content

Commit 1f211da

Browse files
Nanostack: release connect_semaphore only when it is pending
Only release if the current _connect_status is CONNECTING. If the semaphore is released many times for each connect, then the next connect will not wait(), as it will be able to decrement the semaphore imediatelly.
1 parent 46603f8 commit 1f211da

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

features/nanostack/mbed-mesh-api/source/MeshInterfaceNanostack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ nsapi_error_t MeshInterfaceNanostack::initialize(NanostackRfPhy *phy)
120120
void Nanostack::Interface::network_handler(mesh_connection_status_t status)
121121
{
122122
if (_blocking) {
123-
if (status == MESH_CONNECTED || status == MESH_CONNECTED_LOCAL ||
124-
status == MESH_CONNECTED_GLOBAL) {
123+
if (_connect_status == NSAPI_STATUS_CONNECTING && (status == MESH_CONNECTED
124+
|| status == MESH_CONNECTED_LOCAL || status == MESH_CONNECTED_GLOBAL)) {
125125
connect_semaphore.release();
126126
} else if (status == MESH_DISCONNECTED) {
127127
disconnect_semaphore.release();

0 commit comments

Comments
 (0)