Add backlog config option

This commit is contained in:
Daniel Winzen 2022-11-08 15:01:39 +01:00
parent 65e57a251d
commit 9a6908e623
No known key found for this signature in database
GPG Key ID: 222FCC3F35C41077
6 changed files with 23 additions and 4 deletions

View File

@ -20,7 +20,7 @@
<li><a href="#NOTHING">How to make 3proxy start</a></li> <li><a href="#NOTHING">How to make 3proxy start</a></li>
<li><a href="#LIMITS">How to make limitation (access, bandwidth, traffic, connections) work</a></li> <li><a href="#LIMITS">How to make limitation (access, bandwidth, traffic, connections) work</a></li>
<li><a href="#SERVICE">How to make 3proxy to run as a service</a></li> <li><a href="#SERVICE">How to make 3proxy to run as a service</a></li>
<li><a href="#INTEXT">How to understand internal ¨ external</a></li> <li><a href="#INTEXT">How to understand internal and external</a></li>
<li><a href="#ODBC">How to make ODBC logging work?</a></li> <li><a href="#ODBC">How to make ODBC logging work?</a></li>
<li><a href="#IPV6">How to make IPv6 work</a></li> <li><a href="#IPV6">How to make IPv6 work</a></li>
<li><a href="#CRASH">How to fix 3proxy crashes</a></li> <li><a href="#CRASH">How to fix 3proxy crashes</a></li>

View File

@ -489,6 +489,12 @@ started after this command on network level. Default is 100.
new connections, while connlim will report back to the client that new connections, while connlim will report back to the client that
the connection limit has been reached. the connection limit has been reached.
.br
.B backlog
.br
sets the listening socket backlog of new connections. Default is
1+(maxconn>>3). Maximum value is capped by kernel tunable somaxconn.
.br .br
.B service .B service
.br .br

View File

@ -102,7 +102,7 @@ struct extparam conf = {
NULL, NULL,
0, 0,
0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0,
0, 500, 0, 0, 0, 0, 0, 2, 0, 500, 13, 0, 0, 0, 0, 0, 2,
0, 0, 0, 0, 0, 0,
6, 600, 6, 600,
1048576, 1048576,

View File

@ -550,6 +550,7 @@ static int h_maxconn(int argc, unsigned char **argv){
if(!conf.maxchild) { if(!conf.maxchild) {
return(1); return(1);
} }
conf.backlog = 1 + (conf.maxchild>>3);
#ifndef _WIN32 #ifndef _WIN32
{ {
struct rlimit rl; struct rlimit rl;
@ -565,6 +566,14 @@ static int h_maxconn(int argc, unsigned char **argv){
return 0; return 0;
} }
static int h_backlog(int argc, unsigned char **argv){
conf.backlog = atoi((char *)argv[1]);
if(!conf.backlog) {
return(1);
}
return 0;
}
static int h_flush(int argc, unsigned char **argv){ static int h_flush(int argc, unsigned char **argv){
freeacl(conf.acl); freeacl(conf.acl);
conf.acl = NULL; conf.acl = NULL;
@ -1612,6 +1621,7 @@ struct commands commandhandlers[]={
#ifndef NORADIUS #ifndef NORADIUS
{commandhandlers+65, "radius", h_radius, 3, 0}, {commandhandlers+65, "radius", h_radius, 3, 0},
#endif #endif
{commandhandlers+66, "backlog", h_backlog, 2, 2},
{specificcommands, "", h_noop, 1, 0} {specificcommands, "", h_noop, 1, 0}
}; };
@ -1855,6 +1865,7 @@ void freeconf(struct extparam *confp){
*SAFAMILY(&confp->intsa) = AF_INET; *SAFAMILY(&confp->intsa) = AF_INET;
*SAFAMILY(&confp->extsa) = AF_INET; *SAFAMILY(&confp->extsa) = AF_INET;
confp->maxchild = 100; confp->maxchild = 100;
confp->backlog = 13;
resolvfunc = NULL; resolvfunc = NULL;
numservers = 0; numservers = 0;
acl = confp->acl; acl = confp->acl;

View File

@ -649,7 +649,7 @@ int MODULEMAINFUNC (int argc, char** argv){
} }
} }
if(!isudp){ if(!isudp){
if(so._listen (sock, srv.maxchild)==-1) { if(so._listen (sock, srv.backlog)==-1) {
sprintf((char *)buf, "listen(): %s", strerror(errno)); sprintf((char *)buf, "listen(): %s", strerror(errno));
if(!srv.silent)dolog(&defparam, buf); if(!srv.silent)dolog(&defparam, buf);
return -4; return -4;
@ -917,6 +917,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
srv->authfunc = conf.authfunc; srv->authfunc = conf.authfunc;
srv->usentlm = 0; srv->usentlm = 0;
srv->maxchild = conf.maxchild; srv->maxchild = conf.maxchild;
srv->backlog = conf.backlog;
srv->stacksize = conf.stacksize; srv->stacksize = conf.stacksize;
srv->time_start = time(NULL); srv->time_start = time(NULL);
if(havelog && conf.logtarget){ if(havelog && conf.logtarget){

View File

@ -429,6 +429,7 @@ struct srvparam {
SOCKET srvsock, cbsock; SOCKET srvsock, cbsock;
int childcount; int childcount;
int maxchild; int maxchild;
int backlog;
int paused, version; int paused, version;
int singlepacket; int singlepacket;
int usentlm; int usentlm;
@ -578,7 +579,7 @@ struct extparam {
struct srvparam *services; struct srvparam *services;
int stacksize, int stacksize,
threadinit, counterd, haveerror, rotate, paused, archiverc, threadinit, counterd, haveerror, rotate, paused, archiverc,
demon, maxchild, needreload, timetoexit, version, noforce, bandlimver, parentretries; demon, maxchild, backlog, needreload, timetoexit, version, noforce, bandlimver, parentretries;
int authcachetype, authcachetime; int authcachetype, authcachetime;
int filtermaxsize; int filtermaxsize;
int gracetraf, gracenum, gracedelay; int gracetraf, gracenum, gracedelay;