diff --git a/doc/html/howtoe.html b/doc/html/howtoe.html index 8adcfb0..9d49696 100644 --- a/doc/html/howtoe.html +++ b/doc/html/howtoe.html @@ -20,7 +20,7 @@
  • How to make 3proxy start
  • How to make limitation (access, bandwidth, traffic, connections) work
  • How to make 3proxy to run as a service
  • -
  • How to understand internal ¨ external
  • +
  • How to understand internal and external
  • How to make ODBC logging work?
  • How to make IPv6 work
  • How to fix 3proxy crashes
  • diff --git a/man/3proxy.cfg.3 b/man/3proxy.cfg.3 index 82ba02a..cdeef48 100644 --- a/man/3proxy.cfg.3 +++ b/man/3proxy.cfg.3 @@ -482,8 +482,18 @@ External or -e can be given twice: once with IPv4 and once with IPv6 address. .B maxconn .br - sets maximum number of simulationeous connections to each services -started after this command. Default is 100. + sets maximum number of simulationeous connections to each service +started after this command on network level. Default is 100. +.br + To limit clients, use connlim instead. maxconn will silently ignore +new connections, while connlim will report back to the client that +the connection limit has been reached. + +.br +.B backlog +.br + sets the listening socket backlog of new connections. Default is +1 + maxconn/8. Maximum value is capped by kernel tunable somaxconn. .br .B service diff --git a/src/common.c b/src/common.c index 81839fe..e8106e2 100644 --- a/src/common.c +++ b/src/common.c @@ -102,7 +102,7 @@ struct extparam conf = { NULL, 0, 0, -1, 0, 0, 0, 0, - 0, 500, 0, 0, 0, 0, 0, 2, + 0, 500, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 6, 600, 1048576, diff --git a/src/conf.c b/src/conf.c index 4cbe211..3d7a545 100644 --- a/src/conf.c +++ b/src/conf.c @@ -565,6 +565,14 @@ static int h_maxconn(int argc, unsigned char **argv){ return 0; } +static int h_backlog(int argc, unsigned char **argv){ + conf.backlog = atoi((char *)argv[1]); + if(conf.maxchild < 0) { + return(1); + } + return 0; +} + static int h_flush(int argc, unsigned char **argv){ freeacl(conf.acl); conf.acl = NULL; @@ -1609,8 +1617,9 @@ struct commands commandhandlers[]={ {commandhandlers+62, "noforce", h_noforce, 1, 1}, {commandhandlers+63, "parentretries", h_parentretries, 2, 2}, {commandhandlers+64, "auto", h_proxy, 1, 0}, + {commandhandlers+65, "backlog", h_backlog, 2, 2}, #ifndef NORADIUS - {commandhandlers+65, "radius", h_radius, 3, 0}, + {commandhandlers+66, "radius", h_radius, 3, 0}, #endif {specificcommands, "", h_noop, 1, 0} }; @@ -1855,6 +1864,7 @@ void freeconf(struct extparam *confp){ *SAFAMILY(&confp->intsa) = AF_INET; *SAFAMILY(&confp->extsa) = AF_INET; confp->maxchild = 100; + confp->backlog = 0; resolvfunc = NULL; numservers = 0; acl = confp->acl; diff --git a/src/proxymain.c b/src/proxymain.c index 419d745..40f7141 100644 --- a/src/proxymain.c +++ b/src/proxymain.c @@ -649,7 +649,7 @@ int MODULEMAINFUNC (int argc, char** argv){ } } if(!isudp){ - if(so._listen (sock, 1 + (srv.maxchild>>4))==-1) { + if(so._listen (sock, srv.backlog?srv.backlog : 1+(srv.maxchild>>3))==-1) { sprintf((char *)buf, "listen(): %s", strerror(errno)); if(!srv.silent)dolog(&defparam, buf); return -4; @@ -917,6 +917,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){ srv->authfunc = conf.authfunc; srv->usentlm = 0; srv->maxchild = conf.maxchild; + srv->backlog = conf.backlog; srv->stacksize = conf.stacksize; srv->time_start = time(NULL); if(havelog && conf.logtarget){ diff --git a/src/structures.h b/src/structures.h index 5adb361..8d41374 100644 --- a/src/structures.h +++ b/src/structures.h @@ -429,6 +429,7 @@ struct srvparam { SOCKET srvsock, cbsock; int childcount; int maxchild; + int backlog; int paused, version; int singlepacket; int usentlm; @@ -578,7 +579,7 @@ struct extparam { struct srvparam *services; int stacksize, 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 filtermaxsize; int gracetraf, gracenum, gracedelay;