mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #2579 from geky/nsapi-max-socket-accept
lwip - Fix handling of max sockets in socket_acceptpull/2593/head
commit
a35cd7f81f
|
@ -313,6 +313,9 @@ static int lwip_socket_accept(nsapi_stack_t *stack, nsapi_socket_t server, nsapi
|
|||
{
|
||||
struct lwip_socket *s = (struct lwip_socket *)server;
|
||||
struct lwip_socket *ns = lwip_arena_alloc();
|
||||
if (!ns) {
|
||||
return NSAPI_ERROR_NO_SOCKET;
|
||||
}
|
||||
|
||||
err_t err = netconn_accept(s->conn, &ns->conn);
|
||||
if (err != ERR_OK) {
|
||||
|
|
|
@ -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