mirror of https://github.com/ARMmbed/mbed-os.git
nsapi - Corrected handling of errors in TCPServer accept
- Corrected handling, before errors would forcibly restart the accept loop without checks for timeouts - Rearranged accept logic to match the logic of recv/send/recvfrom/sendtopull/2579/head
parent
506aa3d4ea
commit
db2738f850
|
|
@ -76,16 +76,19 @@ int TCPServer::accept(TCPSocket *connection, SocketAddress *address)
|
|||
|
||||
connection->_lock.unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
if (NSAPI_ERROR_WOULD_BLOCK == ret) {
|
||||
} else if (NSAPI_ERROR_WOULD_BLOCK != ret) {
|
||||
break;
|
||||
} else {
|
||||
int32_t count;
|
||||
|
||||
// Release lock before blocking so other threads
|
||||
// accessing this object aren't blocked
|
||||
_lock.unlock();
|
||||
count = _accept_sem.wait(_timeout);
|
||||
_lock.lock();
|
||||
|
||||
if (count < 1) {
|
||||
// Semaphore wait timed out so break out and return
|
||||
ret = NSAPI_ERROR_WOULD_BLOCK;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue