Commit 566f7908 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

* Better check to see if we've run out of available slots, if we have emit a...

* Better check to see if we've run out of available slots, if we have emit a warning and close connection
- Thanks Raphael Marichez

parent 039f9e6d
......@@ -153,6 +153,8 @@ main(int argc, char **argv)
if(FD_ISSET(listenfd, &rset)) /* new client connection */
{
int found_free_slot = 0;
clilen=sizeof(cliaddr);
connfd=w_accept(listenfd, (struct sockaddr *) &cliaddr, &clilen);
......@@ -161,10 +163,21 @@ main(int argc, char **argv)
client[numi] = connfd; /* save file descriptor */
if(DEBUG > 0)
logmessage("DEBUG: saved fd: numi = %d, connfd = %d\n", numi, connfd);
found_free_slot = 1;
break;
}
}
/* check if we ran out of slots and didn't find one above */
if (!found_free_slot)
{
logmessage("WARNING: No free slots found, closing connection from %s:%d\n",
w_inet_ntop(AF_INET, &cliaddr.sin_addr, host, sizeof(host)),
ntohs(cliaddr.sin_port));
w_close(connfd);
continue;
}
/* tcp acl check */
/*
if(w_tcp_conn_acl(w_inet_ntop(AF_INET, &cliaddr.sin_addr, host, sizeof(host))) == -1)
......@@ -177,16 +190,6 @@ main(int argc, char **argv)
*/
/* max fds */
if(numi==MAXFDS)
{
logmessage("connection from: %s port: %d slots: %d of %d used (**WARNING**)\n",
w_inet_ntop(AF_INET, &cliaddr.sin_addr, host, sizeof(host)),
ntohs(cliaddr.sin_port), numi, MAXFDS);
w_close(connfd);
continue;
}
logmessage("connection from: %s port: %d slots: %d of %d used\n",
w_inet_ntop(AF_INET, &cliaddr.sin_addr, host, sizeof(host)),
ntohs(cliaddr.sin_port), numi, MAXFDS);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment