We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d27acf commit b172e12Copy full SHA for b172e12
libraries/SocketWrapper/src/MbedClient.cpp
@@ -22,15 +22,13 @@ void arduino::MbedClient::readSocket() {
22
int ret = NSAPI_ERROR_WOULD_BLOCK;
23
do {
24
mutex->lock();
25
- if (sock == nullptr) {
26
- goto cleanup;
27
- }
28
- mutex->unlock();
29
- if (rxBuffer.availableForStore() == 0) {
+ if (sock != nullptr && rxBuffer.availableForStore() == 0) {
+ mutex->unlock();
30
yield();
31
continue;
+ } else if (sock == nullptr) {
+ goto cleanup;
32
}
33
- mutex->lock();
34
ret = sock->recv(data, rxBuffer.availableForStore());
35
if (ret < 0 && ret != NSAPI_ERROR_WOULD_BLOCK) {
36
goto cleanup;
0 commit comments