mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-24 02:55:40 +08:00
add stack size configuration
'stacksize' command and -S configuration option added
This commit is contained in:
parent
3680f2d3b1
commit
5fc1d81e5c
@ -58,7 +58,7 @@ struct extparam conf = {
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
0, -1, 0, 0, 0, 0, 0, 500, 0, 0, 0,
|
8192, 0, -1, 0, 0, 0, 0, 0, 500, 0, 0, 0,
|
||||||
6, 600,
|
6, 600,
|
||||||
1048576,
|
1048576,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
@ -84,7 +84,7 @@ struct extparam conf = {
|
|||||||
NULL,
|
NULL,
|
||||||
(time_t)0, (time_t)0,
|
(time_t)0, (time_t)0,
|
||||||
0,0,
|
0,0,
|
||||||
'@'
|
'@',
|
||||||
};
|
};
|
||||||
|
|
||||||
int numservers=0;
|
int numservers=0;
|
||||||
|
13
src/conf.c
13
src/conf.c
@ -32,6 +32,7 @@ struct proxydef childdef = {NULL, 0, 0, S_NOSERVICE, ""};
|
|||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
char *chrootp = NULL;
|
char *chrootp = NULL;
|
||||||
|
static pthread_attr_t pa;
|
||||||
#endif
|
#endif
|
||||||
char * curconf = NULL;
|
char * curconf = NULL;
|
||||||
|
|
||||||
@ -142,14 +143,14 @@ int start_proxy_thread(struct child * chp){
|
|||||||
conf.threadinit = 1;
|
conf.threadinit = 1;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _WINCE
|
#ifndef _WINCE
|
||||||
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, 16384, startsrv, (void *) chp, (DWORD)0, &thread);
|
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, 16384+conf.stacksize, startsrv, (void *) chp, (DWORD)0, &thread);
|
||||||
#else
|
#else
|
||||||
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, 16384, startsrv, (void *) chp, (DWORD)0, &thread);
|
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, 16384+conf.stacksize, startsrv, (void *) chp, (DWORD)0, &thread);
|
||||||
#endif
|
#endif
|
||||||
if(h)CloseHandle(h);
|
if(h)CloseHandle(h);
|
||||||
#else
|
#else
|
||||||
pthread_attr_init(&pa);
|
pthread_attr_init(&pa);
|
||||||
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + 16384);
|
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (16384+conf.stacksize));
|
||||||
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
||||||
pthread_create(&thread, &pa, startsrv, (void *)chp);
|
pthread_create(&thread, &pa, startsrv, (void *)chp);
|
||||||
#endif
|
#endif
|
||||||
@ -334,6 +335,11 @@ static int h_log(int argc, unsigned char ** argv){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int h_stacksize(int argc, unsigned char **argv){
|
||||||
|
conf.stacksize = atoi((char *)argv[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int h_service(int argc, unsigned char **argv){
|
static int h_service(int argc, unsigned char **argv){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1392,6 +1398,7 @@ struct commands commandhandlers[]={
|
|||||||
{commandhandlers+55, "msnpr", h_proxy, 4, 0},
|
{commandhandlers+55, "msnpr", h_proxy, 4, 0},
|
||||||
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
|
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
|
||||||
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
|
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
|
||||||
|
{commandhandlers+58, "stacksize", h_stacksize, 2, 2},
|
||||||
{specificcommands, "", h_noop, 1, 0}
|
{specificcommands, "", h_noop, 1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,8 +122,6 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define strcasecmp stricmp
|
#define strcasecmp stricmp
|
||||||
#define strncasecmp strnicmp
|
#define strncasecmp strnicmp
|
||||||
#else
|
|
||||||
extern pthread_attr_t pa;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SOCKET_ERROR
|
#ifndef SOCKET_ERROR
|
||||||
|
@ -126,7 +126,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
" -fFORMAT logging format (see documentation)\n"
|
" -fFORMAT logging format (see documentation)\n"
|
||||||
" -l log to stderr\n"
|
" -l log to stderr\n"
|
||||||
" -lFILENAME log to FILENAME\n"
|
" -lFILENAME log to FILENAME\n"
|
||||||
" -bBUFSIZE size of network buffer (default 4096 for TCP, 16384 for UDP)\n"
|
" -b(BUFSIZE) size of network buffer (default 4096 for TCP, 16384 for UDP)\n"
|
||||||
|
" -S(STACKSIZE) value to add to default client thread stack size\n"
|
||||||
" -t be silent (do not log service start/stop)\n"
|
" -t be silent (do not log service start/stop)\n"
|
||||||
" -iIP ip address or internal interface (clients are expected to connect)\n"
|
" -iIP ip address or internal interface (clients are expected to connect)\n"
|
||||||
" -eIP ip address or external interface (outgoing connection will have this)\n"
|
" -eIP ip address or external interface (outgoing connection will have this)\n"
|
||||||
@ -140,6 +141,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
#else
|
#else
|
||||||
|
pthread_attr_t pa;
|
||||||
#ifdef STDMAIN
|
#ifdef STDMAIN
|
||||||
int inetd = 0;
|
int inetd = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -175,9 +177,6 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#else
|
#else
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
pthread_attr_init(&pa);
|
|
||||||
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + 8192);
|
|
||||||
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -304,6 +303,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
case 'T':
|
case 'T':
|
||||||
srv.transparent = 1;
|
srv.transparent = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'S':
|
||||||
|
srv.stacksize = atoi(argv[i]+2);
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
case 'a':
|
case 'a':
|
||||||
srv.singlepacket = 1 + atoi(argv[i]+2);
|
srv.singlepacket = 1 + atoi(argv[i]+2);
|
||||||
@ -399,6 +401,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
return((*srv.pf)((void *)newparam)? 1:0);
|
return((*srv.pf)((void *)newparam)? 1:0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
pthread_attr_init(&pa);
|
||||||
|
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (8192 + srv.stacksize));
|
||||||
|
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -651,9 +656,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _WINCE
|
#ifndef _WINCE
|
||||||
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, (unsigned)16384, threadfunc, (void *) newparam, 0, &thread);
|
h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, (unsigned)(16384 + srv.stacksize), threadfunc, (void *) newparam, 0, &thread);
|
||||||
#else
|
#else
|
||||||
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)16384, threadfunc, (void *) newparam, 0, &thread);
|
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)(16384 + srv.stacksize), threadfunc, (void *) newparam, 0, &thread);
|
||||||
#endif
|
#endif
|
||||||
srv.childcount++;
|
srv.childcount++;
|
||||||
if (h) {
|
if (h) {
|
||||||
@ -715,6 +720,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->stacksize = conf.stacksize;
|
||||||
srv->time_start = time(NULL);
|
srv->time_start = time(NULL);
|
||||||
if(conf.logtarget){
|
if(conf.logtarget){
|
||||||
if(srv->logtarget) myfree(srv->logtarget);
|
if(srv->logtarget) myfree(srv->logtarget);
|
||||||
|
@ -372,6 +372,7 @@ struct srvparam {
|
|||||||
int transparent;
|
int transparent;
|
||||||
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
|
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
|
||||||
int family;
|
int family;
|
||||||
|
int stacksize;
|
||||||
unsigned bufsize;
|
unsigned bufsize;
|
||||||
unsigned logdumpsrv, logdumpcli;
|
unsigned logdumpsrv, logdumpcli;
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
@ -422,6 +423,9 @@ struct clientparam {
|
|||||||
|
|
||||||
REDIRTYPE redirtype;
|
REDIRTYPE redirtype;
|
||||||
|
|
||||||
|
uint64_t waitclient64,
|
||||||
|
waitserver64;
|
||||||
|
|
||||||
int redirected,
|
int redirected,
|
||||||
operation,
|
operation,
|
||||||
nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv,
|
nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv,
|
||||||
@ -429,8 +433,6 @@ struct clientparam {
|
|||||||
|
|
||||||
int res,
|
int res,
|
||||||
status;
|
status;
|
||||||
uint64_t waitclient64,
|
|
||||||
waitserver64;
|
|
||||||
int pwtype,
|
int pwtype,
|
||||||
threadid,
|
threadid,
|
||||||
weight,
|
weight,
|
||||||
@ -491,7 +493,7 @@ struct extparam {
|
|||||||
struct bandlim * bandlimiter, *bandlimiterout;
|
struct bandlim * bandlimiter, *bandlimiterout;
|
||||||
struct trafcount * trafcounter;
|
struct trafcount * trafcounter;
|
||||||
struct srvparam *services;
|
struct srvparam *services;
|
||||||
int threadinit, counterd, haveerror, rotate, paused, archiverc,
|
int stacksize, threadinit, counterd, haveerror, rotate, paused, archiverc,
|
||||||
demon, maxchild, singlepacket, needreload, timetoexit;
|
demon, maxchild, singlepacket, needreload, timetoexit;
|
||||||
int authcachetype, authcachetime;
|
int authcachetype, authcachetime;
|
||||||
int filtermaxsize;
|
int filtermaxsize;
|
||||||
|
Loading…
Reference in New Issue
Block a user