Skip to content

Commit d47f18a

Browse files
michalpasztamobicaadbridge
authored andcommitted
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 e7cbad4 commit d47f18a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ 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
124+
&& (status == MESH_CONNECTED || status == MESH_CONNECTED_LOCAL
125+
|| status == MESH_CONNECTED_GLOBAL)) {
125126
connect_semaphore.release();
126127
} else if (status == MESH_DISCONNECTED) {
127128
disconnect_semaphore.release();

0 commit comments

Comments
 (0)