mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45: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,
|
||||
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,
|
||||
1048576,
|
||||
NULL, NULL,
|
||||
@ -84,7 +84,7 @@ struct extparam conf = {
|
||||
NULL,
|
||||
(time_t)0, (time_t)0,
|
||||
0,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
|
||||
char *chrootp = NULL;
|
||||
static pthread_attr_t pa;
|
||||
#endif
|
||||
char * curconf = NULL;
|
||||
|
||||
@ -142,14 +143,14 @@ int start_proxy_thread(struct child * chp){
|
||||
conf.threadinit = 1;
|
||||
#ifdef _WIN32
|
||||
#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
|
||||
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
|
||||
if(h)CloseHandle(h);
|
||||
#else
|
||||
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_create(&thread, &pa, startsrv, (void *)chp);
|
||||
#endif
|
||||
@ -334,6 +335,11 @@ static int h_log(int argc, unsigned char ** argv){
|
||||
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){
|
||||
return 0;
|
||||
}
|
||||
@ -1392,6 +1398,7 @@ struct commands commandhandlers[]={
|
||||
{commandhandlers+55, "msnpr", h_proxy, 4, 0},
|
||||
{commandhandlers+56, "delimchar",h_delimchar, 2, 2},
|
||||
{commandhandlers+57, "authnserver", h_authnserver, 2, 2},
|
||||
{commandhandlers+58, "stacksize", h_stacksize, 2, 2},
|
||||
{specificcommands, "", h_noop, 1, 0}
|
||||
};
|
||||
|
||||
|
@ -122,8 +122,6 @@
|
||||
#ifdef _WIN32
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#else
|
||||
extern pthread_attr_t pa;
|
||||
#endif
|
||||
|
||||
#ifndef SOCKET_ERROR
|
||||
|
@ -126,7 +126,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
" -fFORMAT logging format (see documentation)\n"
|
||||
" -l log to stderr\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"
|
||||
" -iIP ip address or internal interface (clients are expected to connect)\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
|
||||
unsigned long ul = 1;
|
||||
#else
|
||||
pthread_attr_t pa;
|
||||
#ifdef STDMAIN
|
||||
int inetd = 0;
|
||||
#endif
|
||||
@ -175,9 +177,6 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
#else
|
||||
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
|
||||
|
||||
@ -304,6 +303,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
case 'T':
|
||||
srv.transparent = 1;
|
||||
break;
|
||||
case 'S':
|
||||
srv.stacksize = atoi(argv[i]+2);
|
||||
break;
|
||||
case 's':
|
||||
case 'a':
|
||||
srv.singlepacket = 1 + atoi(argv[i]+2);
|
||||
@ -399,6 +401,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
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
|
||||
|
||||
|
||||
@ -651,9 +656,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
}
|
||||
#ifdef _WIN32
|
||||
#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
|
||||
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
|
||||
srv.childcount++;
|
||||
if (h) {
|
||||
@ -715,6 +720,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
||||
srv->authfunc = conf.authfunc;
|
||||
srv->usentlm = 0;
|
||||
srv->maxchild = conf.maxchild;
|
||||
srv->stacksize = conf.stacksize;
|
||||
srv->time_start = time(NULL);
|
||||
if(conf.logtarget){
|
||||
if(srv->logtarget) myfree(srv->logtarget);
|
||||
|
@ -372,6 +372,7 @@ struct srvparam {
|
||||
int transparent;
|
||||
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
|
||||
int family;
|
||||
int stacksize;
|
||||
unsigned bufsize;
|
||||
unsigned logdumpsrv, logdumpcli;
|
||||
#ifndef NOIPV6
|
||||
@ -422,6 +423,9 @@ struct clientparam {
|
||||
|
||||
REDIRTYPE redirtype;
|
||||
|
||||
uint64_t waitclient64,
|
||||
waitserver64;
|
||||
|
||||
int redirected,
|
||||
operation,
|
||||
nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv,
|
||||
@ -429,8 +433,6 @@ struct clientparam {
|
||||
|
||||
int res,
|
||||
status;
|
||||
uint64_t waitclient64,
|
||||
waitserver64;
|
||||
int pwtype,
|
||||
threadid,
|
||||
weight,
|
||||
@ -491,7 +493,7 @@ struct extparam {
|
||||
struct bandlim * bandlimiter, *bandlimiterout;
|
||||
struct trafcount * trafcounter;
|
||||
struct srvparam *services;
|
||||
int threadinit, counterd, haveerror, rotate, paused, archiverc,
|
||||
int stacksize, threadinit, counterd, haveerror, rotate, paused, archiverc,
|
||||
demon, maxchild, singlepacket, needreload, timetoexit;
|
||||
int authcachetype, authcachetime;
|
||||
int filtermaxsize;
|
||||
|
Loading…
Reference in New Issue
Block a user