Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions features/net/FEATURE_IPV4/lwip-interface/lwip_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,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) {
Expand Down
9 changes: 6 additions & 3 deletions features/net/network-socket/TCPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down