Skip to content

Commit

Permalink
Fixes a serial mutex acquicition bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Veijo Pesonen committed Nov 9, 2018
1 parent ac4384c commit 483ba89
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ESP8266/ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,13 +624,16 @@ int32_t ESP8266::_recv_tcp_passive(int id, void *data, uint32_t amount, uint32_t
{
int32_t ret;

_smutex.lock();

_process_oob(timeout, true);

// return immediately if no data is available
if (_sock_i[id].tcp_data_avbl == 0) {
if (_sock_i[id].tcp_data_avbl == 0 && _sock_i[id].open) {
_smutex.unlock();
return NSAPI_ERROR_WOULD_BLOCK;
}

_smutex.lock();

_sock_i[id].tcp_data = (char*)data;
_sock_i[id].tcp_data_rcvd = NSAPI_ERROR_WOULD_BLOCK;
_sock_active_id = id;
Expand Down

0 comments on commit 483ba89

Please sign in to comment.