diff --git a/libraries/SocketWrapper/src/MbedClient.cpp b/libraries/SocketWrapper/src/MbedClient.cpp index 06427b293..49188df7e 100644 --- a/libraries/SocketWrapper/src/MbedClient.cpp +++ b/libraries/SocketWrapper/src/MbedClient.cpp @@ -22,15 +22,13 @@ void arduino::MbedClient::readSocket() { int ret = NSAPI_ERROR_WOULD_BLOCK; do { mutex->lock(); - if (sock == nullptr) { - goto cleanup; - } - mutex->unlock(); - if (rxBuffer.availableForStore() == 0) { + if (sock != nullptr && rxBuffer.availableForStore() == 0) { + mutex->unlock(); yield(); continue; + } else if (sock == nullptr) { + goto cleanup; } - mutex->lock(); ret = sock->recv(data, rxBuffer.availableForStore()); if (ret < 0 && ret != NSAPI_ERROR_WOULD_BLOCK) { goto cleanup;
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: