summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-17 20:54:13 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-17 20:54:13 +0000
commit588b93a2bad8f9326a67e87c28778cf32d11122c (patch)
tree2a47833ccec0cf353d5a24c7d7eb31676fc36eff /src
parent0ff5bafa32e76a447f4a1315177de0ee12111d4e (diff)
Added configurable SOMAXCONN size
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1419 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp15
-rw-r--r--src/inspircd_io.cpp3
-rw-r--r--src/servers.cpp3
3 files changed, 15 insertions, 6 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index d5156117a..baebc350c 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -88,7 +88,8 @@ int WHOWAS_STALE = 48; // default WHOWAS Entries last 2 days before they go 'sta
int WHOWAS_MAX = 100; // default 100 people maximum in the WHOWAS list
int DieDelay = 5;
time_t startup_time = time(NULL);
-int NetBufferSize = 10240; // NetBufferSize used as the buffer size for all read() ops
+int NetBufferSize = 10240; // NetBufferSize used as the buffer size for all read() ops
+int MaxConn = SOMAXCONN; // size of accept() backlog (128 by default on *BSD)
extern int MaxWhoResults;
time_t nb_start = 0;
int dns_timeout = 5;
@@ -232,7 +233,7 @@ std::string getadminnick()
void ReadConfig(bool bail, userrec* user)
{
- char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF],NB[MAXBUF],flood[MAXBUF],MW[MAXBUF];
+ char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF],NB[MAXBUF],flood[MAXBUF],MW[MAXBUF],MCON[MAXBUF];
char AH[MAXBUF],AP[MAXBUF],AF[MAXBUF],DNT[MAXBUF],pfreq[MAXBUF],thold[MAXBUF],sqmax[MAXBUF],rqmax[MAXBUF];
ConnectClass c;
std::stringstream errstr;
@@ -293,12 +294,18 @@ void ReadConfig(bool bail, userrec* user)
ConfValue("dns","timeout",0,DNT,&config_f);
ConfValue("options","moduledir",0,ModPath,&config_f);
ConfValue("disabled","commands",0,DisabledCommands,&config_f);
+ ConfValue("options","somaxconn",0,MCON,&config_f);
+ MaxConn = atoi(MCON);
+ if (MaxConn > SOMAXCONN)
+ log(DEFAULT,"WARNING: <options:somaxconn> value may be higher than the system-defined SOMAXCONN value!");
NetBufferSize = atoi(NB);
MaxWhoResults = atoi(MW);
dns_timeout = atoi(DNT);
if (!dns_timeout)
dns_timeout = 5;
+ if (!MaxConn)
+ MaxConn = SOMAXCONN;
if (!DNSServer[0])
strlcpy(DNSServer,"127.0.0.1",MAXBUF);
if (!ModPath[0])
@@ -2704,7 +2711,7 @@ int InspIRCd(char** argv, int argc)
{
struct kevent ke;
log(DEBUG,"kqueue: Add listening socket to events, kq=%d socket=%d",lkq,openSockfd[count]);
- EV_SET(&ke, openSockfd[count], EVFILT_READ, EV_ADD, 0, 32, NULL);
+ EV_SET(&ke, openSockfd[count], EVFILT_READ, EV_ADD, 0, MaxConn, NULL);
int i = kevent(lkq, &ke, 1, 0, 0, NULL);
if (i == -1)
{
@@ -2719,7 +2726,7 @@ int InspIRCd(char** argv, int argc)
if (me[t])
{
log(DEBUG,"kqueue: Add listening SERVER socket to events, kq=%d socket=%d",skq,me[t]->fd);
- EV_SET(&ke, me[t]->fd, EVFILT_READ, EV_ADD, 0, 32, NULL);
+ EV_SET(&ke, me[t]->fd, EVFILT_READ, EV_ADD, 0, MaxConn, NULL);
int i = kevent(skq, &ke, 1, 0, 0, NULL);
if (i == -1)
{
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index e5a0bdcac..1a5046068 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -35,6 +35,7 @@ extern int boundPortCount;
extern int openSockfd[MAXSOCKS];
extern time_t TIME;
extern bool unlimitcore;
+extern int MaxConn;
void WriteOpers(char* text, ...);
@@ -637,7 +638,7 @@ int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server
}
else
{
- listen(sockfd,32);
+ listen(sockfd, MaxConn);
return(TRUE);
}
}
diff --git a/src/servers.cpp b/src/servers.cpp
index 56e0d0c41..440a01e38 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -35,6 +35,7 @@ using namespace std;
#include "connection.h"
extern time_t TIME;
+extern int MaxConn;
std::deque<std::string> xsums;
@@ -128,7 +129,7 @@ bool serverrec::CreateListener(char* newhost, int p)
this->port = p;
- listen(this->fd,32);
+ listen(this->fd, MaxConn);
return true;
}