Skip to content

Commit

Permalink
Merge pull request #875 from andreagilardoni/mbedclient-issues
Browse files Browse the repository at this point in the history
MbedClient: improving logic of readSocket
  • Loading branch information
pennam authored Apr 30, 2024
2 parents ba5f661 + b172e12 commit 1749b20
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 1749b20

Please sign in to comment.