Skip to content

Commit 4414762

Browse files
MbedClient: improving logic of readSocket
1 parent 105c172 commit 4414762

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: libraries/SocketWrapper/src/MbedClient.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ void arduino::MbedClient::readSocket() {
1919
uint8_t data[SOCKET_BUFFER_SIZE];
2020
int ret = NSAPI_ERROR_WOULD_BLOCK;
2121
do {
22-
if (rxBuffer.availableForStore() == 0) {
22+
mutex->lock();
23+
if (sock != nullptr && rxBuffer.availableForStore() == 0) {
24+
mutex->unlock();
2325
yield();
2426
continue;
25-
}
26-
mutex->lock();
27-
if (sock == nullptr) {
27+
} else if (sock == nullptr) {
2828
goto cleanup;
2929
}
3030
ret = sock->recv(data, rxBuffer.availableForStore());

0 commit comments

Comments
 (0)