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.
pull/10532/head
Michal Paszta 2019-04-24 10:09:11 +03:00 committed by adbridge
parent e7cbad4558
commit d47f18a130
1 changed files with 3 additions and 2 deletions

View File

@ -120,8 +120,9 @@ nsapi_error_t MeshInterfaceNanostack::initialize(NanostackRfPhy *phy)
void Nanostack::Interface::network_handler(mesh_connection_status_t status)
{
if (_blocking) {
if (status == MESH_CONNECTED || status == MESH_CONNECTED_LOCAL ||
status == MESH_CONNECTED_GLOBAL) {
if (_connect_status == NSAPI_STATUS_CONNECTING
&& (status == MESH_CONNECTED || status == MESH_CONNECTED_LOCAL
|| status == MESH_CONNECTED_GLOBAL)) {
connect_semaphore.release();
} else if (status == MESH_DISCONNECTED) {
disconnect_semaphore.release();