Skip to content

Commit

Permalink
MbedClient: improving logic of readSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
andreagilardoni committed Apr 23, 2024
1 parent 2d27acf commit b172e12
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions libraries/SocketWrapper/src/MbedClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b172e12

Please sign in to comment.