mirror of
				https://github.com/eledio-devices/thirdparty-AsyncTCPSock.git
				synced 2025-10-31 16:14:15 +01:00 
			
		
		
		
	Stop accept()-ing connections if already at max connection limit
The constant CONFIG_LWIP_MAX_SOCKETS, if available, tells how many sockets can be opened at once. If already at this limit, and an attempt is made to accept() an additional incoming connection from a listening socket, the accept() call will fail. Fix this by checking the socket list and refusing to add the listening socket to the set of readable sockets to check in the select() call. This will cause connections to remain in the listening backlog until some other socket is closed.
This commit is contained in:
		| @@ -92,12 +92,19 @@ void _asynctcpsock_task(void *) | ||||
|         FD_ZERO(&sockSet_r); FD_ZERO(&sockSet_w); | ||||
|         for (it = _socketBaseList.begin(); it != _socketBaseList.end(); it++) { | ||||
|             if ((*it)->_socket != -1) { | ||||
|                 FD_SET((*it)->_socket, &sockSet_r); | ||||
| #ifdef CONFIG_LWIP_MAX_SOCKETS | ||||
|                 if (!(*it)->_isServer() || _socketBaseList.size() < CONFIG_LWIP_MAX_SOCKETS) { | ||||
| #endif | ||||
|                     FD_SET((*it)->_socket, &sockSet_r); | ||||
|                     if (max_sock <= (*it)->_socket) max_sock = (*it)->_socket + 1; | ||||
| #ifdef CONFIG_LWIP_MAX_SOCKETS | ||||
|                 } | ||||
| #endif | ||||
|                 if ((*it)->_pendingWrite()) { | ||||
|                     FD_SET((*it)->_socket, &sockSet_w); | ||||
|                     if (max_sock <= (*it)->_socket) max_sock = (*it)->_socket + 1; | ||||
|                 } | ||||
|                 (*it)->_selected = true; | ||||
|                 if (max_sock <= (*it)->_socket) max_sock = (*it)->_socket + 1; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user