mirror of
https://github.com/3proxy/3proxy.git
synced 2026-10-16 08:35:48 +08:00
Keep the clock, timetoexit and needreload out of conf
They are the state of the process, not configuration: conf.time (now curtime), timetoexit and needreload are globals of their own. Plugins reach needreload through a pointer added at the end of struct pluginlink; LdapPlugin uses it. The extern for a paused global, never defined, goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3b2d664563
commit
a2592f4038
52
src/3proxy.c
52
src/3proxy.c
@ -72,7 +72,7 @@ void __stdcall CommandHandler( DWORD dwCommand )
|
|||||||
case SERVICE_CONTROL_STOP:
|
case SERVICE_CONTROL_STOP:
|
||||||
case SERVICE_CONTROL_SHUTDOWN:
|
case SERVICE_CONTROL_SHUTDOWN:
|
||||||
SetStatus( SERVICE_STOP_PENDING, 0, 1 );
|
SetStatus( SERVICE_STOP_PENDING, 0, 1 );
|
||||||
conf.timetoexit = 1;
|
timetoexit = 1;
|
||||||
conf.paused++;
|
conf.paused++;
|
||||||
/* ServiceMain() reports the service stopped once cyclestep() has
|
/* ServiceMain() reports the service stopped once cyclestep() has
|
||||||
seen this and the services are done */
|
seen this and the services are done */
|
||||||
@ -84,7 +84,7 @@ void __stdcall CommandHandler( DWORD dwCommand )
|
|||||||
break;
|
break;
|
||||||
case SERVICE_CONTROL_CONTINUE:
|
case SERVICE_CONTROL_CONTINUE:
|
||||||
SetStatus( SERVICE_CONTINUE_PENDING, 0, 1 );
|
SetStatus( SERVICE_CONTINUE_PENDING, 0, 1 );
|
||||||
conf.needreload = 1;
|
needreload = 1;
|
||||||
SetStatus( SERVICE_RUNNING, 0, 0 );
|
SetStatus( SERVICE_RUNNING, 0, 0 );
|
||||||
break;
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
@ -115,7 +115,7 @@ void __stdcall ServiceMain(int argc, unsigned char* argv[] )
|
|||||||
|
|
||||||
|
|
||||||
void mysigusr1 (int sig){
|
void mysigusr1 (int sig){
|
||||||
conf.needreload = 1;
|
needreload = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int even = 0;
|
int even = 0;
|
||||||
@ -125,13 +125,13 @@ void mysigpause (int sig){
|
|||||||
conf.paused++;
|
conf.paused++;
|
||||||
even = !even;
|
even = !even;
|
||||||
if(!even){
|
if(!even){
|
||||||
conf.needreload = 1;
|
needreload = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mysigterm (int sig){
|
void mysigterm (int sig){
|
||||||
conf.paused++;
|
conf.paused++;
|
||||||
conf.timetoexit = 1;
|
timetoexit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -183,10 +183,10 @@ void doschedule(void){
|
|||||||
struct schedule *sched, *prevsched = NULL, *nextsched;
|
struct schedule *sched, *prevsched = NULL, *nextsched;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
conf.time = time(0);
|
curtime = time(0);
|
||||||
for(sched=schedule; sched; sched=sched->next){
|
for(sched=schedule; sched; sched=sched->next){
|
||||||
if(conf.needreload || conf.timetoexit || (conf.time > sched->start_time && timechanged(sched->start_time, conf.time, sched->type))){
|
if(needreload || timetoexit || (curtime > sched->start_time && timechanged(sched->start_time, curtime, sched->type))){
|
||||||
sched->start_time = conf.time;
|
sched->start_time = curtime;
|
||||||
nextsched = sched->next;
|
nextsched = sched->next;
|
||||||
res = (*sched->function)(sched->data);
|
res = (*sched->function)(sched->data);
|
||||||
switch(res){
|
switch(res){
|
||||||
@ -206,8 +206,8 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
|||||||
struct trafcount *tl;
|
struct trafcount *tl;
|
||||||
if(counterd >= 0 && tlin) {
|
if(counterd >= 0 && tlin) {
|
||||||
|
|
||||||
conf.time = time(0);
|
curtime = time(0);
|
||||||
if(cheader.updated && conf.countertype && timechanged(cheader.updated, conf.time, conf.countertype)){
|
if(cheader.updated && conf.countertype && timechanged(cheader.updated, curtime, conf.countertype)){
|
||||||
FILE * cfp;
|
FILE * cfp;
|
||||||
|
|
||||||
cfp = fopen((char *)dologname(tmpbuf, (unsigned char *)conf.counterfile, NULL, conf.countertype, cheader.updated), "w");
|
cfp = fopen((char *)dologname(tmpbuf, (unsigned char *)conf.counterfile, NULL, conf.countertype, cheader.updated), "w");
|
||||||
@ -221,7 +221,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cheader.updated = conf.time;
|
cheader.updated = curtime;
|
||||||
if(lseek(counterd, 0, SEEK_SET) >= 0 && write(counterd, &cheader, sizeof(struct counter_header))){}
|
if(lseek(counterd, 0, SEEK_SET) >= 0 && write(counterd, &cheader, sizeof(struct counter_header))){}
|
||||||
for(tl=tlin; tl; tl = tl->next){
|
for(tl=tlin; tl; tl = tl->next){
|
||||||
if(tl->number){
|
if(tl->number){
|
||||||
@ -234,8 +234,8 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
|||||||
if(write(counterd, &crecord, sizeof(struct counter_record))){}
|
if(write(counterd, &crecord, sizeof(struct counter_record))){}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
|
if(tl->type!=NEVER && timechanged(tl->cleared, curtime, tl->type)){
|
||||||
tl->cleared = conf.time;
|
tl->cleared = curtime;
|
||||||
tl->traf64 = 0;
|
tl->traf64 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,15 +284,15 @@ void cyclestep(void){
|
|||||||
for(;;){
|
for(;;){
|
||||||
usleep(SLEEPTIME*999);
|
usleep(SLEEPTIME*999);
|
||||||
|
|
||||||
conf.time = time(0);
|
curtime = time(0);
|
||||||
if(conf.needreload) {
|
if(needreload) {
|
||||||
doschedule();
|
doschedule();
|
||||||
reload();
|
reload();
|
||||||
conf.needreload = 0;
|
needreload = 0;
|
||||||
}
|
}
|
||||||
doschedule();
|
doschedule();
|
||||||
if(conf.stdlog)fflush(conf.stdlog);
|
if(conf.stdlog)fflush(conf.stdlog);
|
||||||
if(timechanged(minutecounter, conf.time, MINUTELY)) {
|
if(timechanged(minutecounter, curtime, MINUTELY)) {
|
||||||
struct filemon *fm;
|
struct filemon *fm;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
@ -300,14 +300,14 @@ void cyclestep(void){
|
|||||||
if(!stat(fm->path, &sb)){
|
if(!stat(fm->path, &sb)){
|
||||||
if(fm->sb.st_mtime != sb.st_mtime || fm->sb.st_size != sb.st_size){
|
if(fm->sb.st_mtime != sb.st_mtime || fm->sb.st_size != sb.st_size){
|
||||||
stat(fm->path, &fm->sb);
|
stat(fm->path, &fm->sb);
|
||||||
conf.needreload = 1;
|
needreload = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(timechanged(basetime, conf.time, DAILY)) {
|
if(timechanged(basetime, curtime, DAILY)) {
|
||||||
tm = localtime(&conf.time);
|
tm = localtime(&curtime);
|
||||||
if(tm){
|
if(tm){
|
||||||
wday = (1 << tm->tm_wday);
|
wday = (1 << tm->tm_wday);
|
||||||
tm->tm_hour = tm->tm_min = tm->tm_sec = 0;
|
tm->tm_hour = tm->tm_min = tm->tm_sec = 0;
|
||||||
@ -315,10 +315,10 @@ void cyclestep(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(conf.logname) {
|
if(conf.logname) {
|
||||||
if(timechanged(conf.logtime, conf.time, conf.logtype)) {
|
if(timechanged(conf.logtime, curtime, conf.logtype)) {
|
||||||
if(conf.stdlog) conf.stdlog = freopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.time), "a", conf.stdlog);
|
if(conf.stdlog) conf.stdlog = freopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, curtime), "a", conf.stdlog);
|
||||||
else conf.stdlog = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.time), "a");
|
else conf.stdlog = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, curtime), "a");
|
||||||
conf.logtime = conf.time;
|
conf.logtime = curtime;
|
||||||
if(conf.logtype != NONE && conf.rotate) {
|
if(conf.logtype != NONE && conf.rotate) {
|
||||||
int t;
|
int t;
|
||||||
t = 1;
|
t = 1;
|
||||||
@ -364,11 +364,11 @@ void cyclestep(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(conf.counterd >= 0 && conf.trafcounter) {
|
if(conf.counterd >= 0 && conf.trafcounter) {
|
||||||
if(timechanged(cheader.updated, conf.time, MINUTELY)){
|
if(timechanged(cheader.updated, curtime, MINUTELY)){
|
||||||
dumpcounters(conf.trafcounter, conf.counterd);
|
dumpcounters(conf.trafcounter, conf.counterd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(conf.timetoexit){
|
if(timetoexit){
|
||||||
conf.paused++;
|
conf.paused++;
|
||||||
doschedule();
|
doschedule();
|
||||||
waitservices();
|
waitservices();
|
||||||
|
|||||||
@ -144,7 +144,7 @@ int doauth(struct clientparam * param){
|
|||||||
ac.sinsl_family = *SAFAMILY(¶m->sinsl);
|
ac.sinsl_family = *SAFAMILY(¶m->sinsl);
|
||||||
memcpy(ac.sinsl_addr, SAADDR(¶m->sinsl), SAADDRLEN(¶m->sinsl));
|
memcpy(ac.sinsl_addr, SAADDR(¶m->sinsl), SAADDRLEN(¶m->sinsl));
|
||||||
}
|
}
|
||||||
hashadd(&auth_table, param, &ac, conf.time + param->srv->authcachetime);
|
hashadd(&auth_table, param, &ac, curtime + param->srv->authcachetime);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -200,6 +200,10 @@ char *rotations[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* State of the process, not configuration. */
|
||||||
|
time_t curtime;
|
||||||
|
int timetoexit = 0, needreload = 0;
|
||||||
|
|
||||||
int timeouts[12] = {
|
int timeouts[12] = {
|
||||||
1, /* SINGLEBYTE_S */
|
1, /* SINGLEBYTE_S */
|
||||||
5, /* SINGLEBYTE_L */
|
5, /* SINGLEBYTE_L */
|
||||||
@ -250,8 +254,6 @@ struct extparam conf = {
|
|||||||
.demon = 0,
|
.demon = 0,
|
||||||
.maxchild = DEFAULT_MAXCHILD,
|
.maxchild = DEFAULT_MAXCHILD,
|
||||||
.backlog = 0,
|
.backlog = 0,
|
||||||
.needreload = 0,
|
|
||||||
.timetoexit = 0,
|
|
||||||
.version = 0,
|
.version = 0,
|
||||||
.noforce = 0,
|
.noforce = 0,
|
||||||
.bandlimver = 0,
|
.bandlimver = 0,
|
||||||
@ -290,7 +292,6 @@ struct extparam conf = {
|
|||||||
.stdlog = NULL,
|
.stdlog = NULL,
|
||||||
.stringtable = NULL,
|
.stringtable = NULL,
|
||||||
.logtime = (time_t)0,
|
.logtime = (time_t)0,
|
||||||
.time = (time_t)0,
|
|
||||||
.logdumpsrv = 0,
|
.logdumpsrv = 0,
|
||||||
.logdumpcli = 0,
|
.logdumpcli = 0,
|
||||||
.delimchar = '@',
|
.delimchar = '@',
|
||||||
|
|||||||
@ -2397,7 +2397,7 @@ void freeconf(struct extparam *confp){
|
|||||||
confp->logformat = NULL;
|
confp->logformat = NULL;
|
||||||
confp->rotate = 0;
|
confp->rotate = 0;
|
||||||
confp->logtype = NONE;
|
confp->logtype = NONE;
|
||||||
confp->logtime = confp->time = 0;
|
confp->logtime = curtime = 0;
|
||||||
confp->poolmax = -1;
|
confp->poolmax = -1;
|
||||||
confp->pooltimeout = 60;
|
confp->pooltimeout = 60;
|
||||||
|
|
||||||
|
|||||||
14
src/hash.c
14
src/hash.c
@ -100,10 +100,10 @@ static void hashcompact(struct hashtable *ht){
|
|||||||
int i;
|
int i;
|
||||||
uint32_t he, *hep;
|
uint32_t he, *hep;
|
||||||
|
|
||||||
if((conf.time - ht->compacted) < 300 || !ht->tablesize || !ht->poolsize || ht->ihashempty) return;
|
if((curtime - ht->compacted) < 300 || !ht->tablesize || !ht->poolsize || ht->ihashempty) return;
|
||||||
for(i = 0; i < ht->tablesize; i++){
|
for(i = 0; i < ht->tablesize; i++){
|
||||||
for(hep = ht->ihashtable + i; (he = *hep) != 0; ){
|
for(hep = ht->ihashtable + i; (he = *hep) != 0; ){
|
||||||
if(hvalue(ht,he)->expires < conf.time ) {
|
if(hvalue(ht,he)->expires < curtime ) {
|
||||||
(*hep) = hvalue(ht,he)->inext;
|
(*hep) = hvalue(ht,he)->inext;
|
||||||
hvalue(ht,he)->expires = 0;
|
hvalue(ht,he)->expires = 0;
|
||||||
hvalue(ht,he)->inext = ht->ihashempty;
|
hvalue(ht,he)->inext = ht->ihashempty;
|
||||||
@ -112,7 +112,7 @@ static void hashcompact(struct hashtable *ht){
|
|||||||
else hep=&(hvalue(ht,he)->inext);
|
else hep=&(hvalue(ht,he)->inext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ht->compacted = conf.time;
|
ht->compacted = curtime;
|
||||||
if(ht->ihashempty) return;
|
if(ht->ihashempty) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ void hashadd(struct hashtable *ht, void* name, void* value, time_t expires){
|
|||||||
index = hashindex(ht, ht->tablesize, hash);
|
index = hashindex(ht, ht->tablesize, hash);
|
||||||
|
|
||||||
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
||||||
if(hvalue(ht,he)->expires < conf.time || !memcmp(hash, hhash(ht,he), ht->hash_size)) {
|
if(hvalue(ht,he)->expires < curtime || !memcmp(hash, hhash(ht,he), ht->hash_size)) {
|
||||||
(*hep) = hvalue(ht,he)->inext;
|
(*hep) = hvalue(ht,he)->inext;
|
||||||
hvalue(ht,he)->expires = 0;
|
hvalue(ht,he)->expires = 0;
|
||||||
hvalue(ht,he)->inext = ht->ihashempty;
|
hvalue(ht,he)->inext = ht->ihashempty;
|
||||||
@ -228,14 +228,14 @@ int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl){
|
|||||||
_3proxy_mutex_lock(&ht->hash_mutex);
|
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||||
index = hashindex(ht, ht->tablesize, hash);
|
index = hashindex(ht, ht->tablesize, hash);
|
||||||
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
||||||
if(hvalue(ht, he)->expires < conf.time) {
|
if(hvalue(ht, he)->expires < curtime) {
|
||||||
(*hep) = hvalue(ht,he)->inext;
|
(*hep) = hvalue(ht,he)->inext;
|
||||||
hvalue(ht,he)->expires = 0;
|
hvalue(ht,he)->expires = 0;
|
||||||
hvalue(ht,he)->inext = ht->ihashempty;
|
hvalue(ht,he)->inext = ht->ihashempty;
|
||||||
ht->ihashempty = he;
|
ht->ihashempty = he;
|
||||||
}
|
}
|
||||||
else if(!memcmp(hash, hhash(ht,he), ht->hash_size)){
|
else if(!memcmp(hash, hhash(ht,he), ht->hash_size)){
|
||||||
if(ttl) *ttl = (uint32_t)(hvalue(ht,he)->expires - conf.time);
|
if(ttl) *ttl = (uint32_t)(hvalue(ht,he)->expires - curtime);
|
||||||
memcpy(value, hvalue(ht,he)->value, ht->recsize);
|
memcpy(value, hvalue(ht,he)->value, ht->recsize);
|
||||||
_3proxy_mutex_unlock(&ht->hash_mutex);
|
_3proxy_mutex_unlock(&ht->hash_mutex);
|
||||||
return 1;
|
return 1;
|
||||||
@ -259,7 +259,7 @@ void hashdelete(struct hashtable *ht, void *name){
|
|||||||
_3proxy_mutex_lock(&ht->hash_mutex);
|
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||||
index = hashindex(ht, ht->tablesize, hash);
|
index = hashindex(ht, ht->tablesize, hash);
|
||||||
for(hep = ht->ihashtable + index; (he = *hep) != 0; ){
|
for(hep = ht->ihashtable + index; (he = *hep) != 0; ){
|
||||||
if((hvalue(ht, he)->expires && hvalue(ht, he)->expires < conf.time) || !memcmp(hash, hhash(ht, he), ht->hash_size)) {
|
if((hvalue(ht, he)->expires && hvalue(ht, he)->expires < curtime) || !memcmp(hash, hhash(ht, he), ht->hash_size)) {
|
||||||
(*hep) = hvalue(ht, he)->inext;
|
(*hep) = hvalue(ht, he)->inext;
|
||||||
hvalue(ht, he)->expires = 0;
|
hvalue(ht, he)->expires = 0;
|
||||||
hvalue(ht, he)->inext = ht->ihashempty;
|
hvalue(ht, he)->inext = ht->ihashempty;
|
||||||
|
|||||||
@ -27,9 +27,9 @@ int startconnlims (struct clientparam *param){
|
|||||||
ce->rating++;
|
ce->rating++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
delta = conf.time - ce->basetime;
|
delta = curtime - ce->basetime;
|
||||||
if(ce->period <= delta || ce->basetime > conf.time){
|
if(ce->period <= delta || ce->basetime > curtime){
|
||||||
ce->basetime = conf.time;
|
ce->basetime = curtime;
|
||||||
ce->rating = 0x100000;
|
ce->rating = 0x100000;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ int startconnlims (struct clientparam *param){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ce->rating = rating;
|
ce->rating = rating;
|
||||||
ce->basetime = conf.time;
|
ce->basetime = curtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ret) {
|
if(ret) {
|
||||||
@ -185,7 +185,7 @@ void trafcountfunc(struct clientparam *param){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tc->traf64 += param->statssrv64;
|
tc->traf64 += param->statssrv64;
|
||||||
tc->updated = conf.time;
|
tc->updated = curtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(countout) for(tc = conf.trafcounter; tc; tc = tc->next) {
|
if(countout) for(tc = conf.trafcounter; tc; tc = tc->next) {
|
||||||
@ -195,7 +195,7 @@ void trafcountfunc(struct clientparam *param){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tc->traf64 += param->statscli64;
|
tc->traf64 += param->statscli64;
|
||||||
tc->updated = conf.time;
|
tc->updated = curtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -134,6 +134,7 @@ struct pluginlink pluginlink = {
|
|||||||
parseusername,
|
parseusername,
|
||||||
parseconnusername,
|
parseconnusername,
|
||||||
&so,
|
&so,
|
||||||
dologname
|
dologname,
|
||||||
|
&needreload
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -131,7 +131,7 @@ int savecounters(void *v)
|
|||||||
|
|
||||||
|
|
||||||
/*return 1 delete job , return 0 no delete job*/
|
/*return 1 delete job , return 0 no delete job*/
|
||||||
if (mypluginlink->conf->needreload !=0 )
|
if ((*mypluginlink->needreload) !=0 )
|
||||||
{
|
{
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -222,7 +222,8 @@ extern RESOLVFUNC resolvfunc;
|
|||||||
|
|
||||||
extern int wday;
|
extern int wday;
|
||||||
extern time_t basetime;
|
extern time_t basetime;
|
||||||
extern int timetoexit;
|
extern int timetoexit, needreload;
|
||||||
|
extern time_t curtime; /* the clock, kept by the main thread */
|
||||||
|
|
||||||
extern struct extparam conf;
|
extern struct extparam conf;
|
||||||
|
|
||||||
@ -315,7 +316,6 @@ int socks5_udp_build_hdr(unsigned char *buf, PROXYSOCKADDRTYPE *addr);
|
|||||||
extern struct auth authfuncs[];
|
extern struct auth authfuncs[];
|
||||||
|
|
||||||
int reload (void);
|
int reload (void);
|
||||||
extern int paused;
|
|
||||||
extern int demon;
|
extern int demon;
|
||||||
|
|
||||||
unsigned char * mycrypt(const unsigned char *key, const unsigned char *salt, unsigned char *buf);
|
unsigned char * mycrypt(const unsigned char *key, const unsigned char *salt, unsigned char *buf);
|
||||||
|
|||||||
@ -165,7 +165,7 @@ static int poolpark(struct clientparam *param){
|
|||||||
int timeout;
|
int timeout;
|
||||||
|
|
||||||
_3proxy_mutex_lock(&tpool.mutex);
|
_3proxy_mutex_lock(&tpool.mutex);
|
||||||
if(conf.timetoexit || nsbroken() || tpool.nidle >= poollimit()){
|
if(timetoexit || nsbroken() || tpool.nidle >= poollimit()){
|
||||||
_3proxy_mutex_unlock(&tpool.mutex);
|
_3proxy_mutex_unlock(&tpool.mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,7 +183,7 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
|||||||
memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
|
memcpy(value, buf + k + 12, af == AF_INET6? 16:4);
|
||||||
if(ttl < 0 || ttl > (3600*12)) ttl = 3600*12;
|
if(ttl < 0 || ttl > (3600*12)) ttl = 3600*12;
|
||||||
if(!ttl) ttl = 1;
|
if(!ttl) ttl = 1;
|
||||||
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, conf.time+ttl);
|
hashadd(af == AF_INET6?&dns6_table:&dns_table, name, value, curtime+ttl);
|
||||||
if(retttl) *retttl = ttl;
|
if(retttl) *retttl = ttl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ int socksend(struct clientparam *param, SOCKET sock, unsigned char * buf, int bu
|
|||||||
fds.fd = sock;
|
fds.fd = sock;
|
||||||
fds.events = POLLOUT;
|
fds.events = POLLOUT;
|
||||||
do {
|
do {
|
||||||
if(conf.timetoexit) return 0;
|
if(timetoexit) return 0;
|
||||||
/* try to send first; poll only when the socket would block */
|
/* try to send first; poll only when the socket would block */
|
||||||
res = param?param->srv->so._send(param->sostate, sock, (char *)buf + sent, bufsize - sent, 0) : so._send(so.state, sock, (char *)buf + sent, bufsize - sent, 0);
|
res = param?param->srv->so._send(param->sostate, sock, (char *)buf + sent, bufsize - sent, 0) : so._send(so.state, sock, (char *)buf + sent, bufsize - sent, 0);
|
||||||
if(res > 0) {
|
if(res > 0) {
|
||||||
@ -38,7 +38,7 @@ int socksendto(struct clientparam *param, SOCKET sock, struct sockaddr * sin, un
|
|||||||
|
|
||||||
fds.fd = sock;
|
fds.fd = sock;
|
||||||
do {
|
do {
|
||||||
if(conf.timetoexit) return 0;
|
if(timetoexit) return 0;
|
||||||
fds.events = POLLOUT;
|
fds.events = POLLOUT;
|
||||||
res = param?param->srv->so._poll(param->sostate, &fds, 1, to):so._poll(so.state, &fds, 1, to);
|
res = param?param->srv->so._poll(param->sostate, &fds, 1, to):so._poll(so.state, &fds, 1, to);
|
||||||
if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue;
|
if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue;
|
||||||
@ -60,7 +60,7 @@ int sockrecvfrom(struct clientparam *param, SOCKET sock, struct sockaddr * sin,
|
|||||||
|
|
||||||
fds.fd = sock;
|
fds.fd = sock;
|
||||||
fds.events = POLLIN;
|
fds.events = POLLIN;
|
||||||
if(conf.timetoexit) return EOF;
|
if(timetoexit) return EOF;
|
||||||
res = param?param->srv->so._poll(param->sostate, &fds, 1, to):so._poll(so.state, &fds, 1, to);
|
res = param?param->srv->so._poll(param->sostate, &fds, 1, to):so._poll(so.state, &fds, 1, to);
|
||||||
if (res<1) return 0;
|
if (res<1) return 0;
|
||||||
sasize = sizeof(PROXYSOCKADDRTYPE);
|
sasize = sizeof(PROXYSOCKADDRTYPE);
|
||||||
|
|||||||
@ -225,8 +225,8 @@ log(logbuf);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(needaction && param->srv->gracedelay && !sleeptime){
|
if(needaction && param->srv->gracedelay && !sleeptime){
|
||||||
if(gracetime != conf.time){
|
if(gracetime != curtime){
|
||||||
gracetime = conf.time;
|
gracetime = curtime;
|
||||||
graceclinum=gracesrvnum=graceclitraf=gracesrvtraf=0;
|
graceclinum=gracesrvnum=graceclitraf=gracesrvtraf=0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -863,7 +863,7 @@ struct extparam {
|
|||||||
struct srvparam *services;
|
struct srvparam *services;
|
||||||
int stacksize,
|
int stacksize,
|
||||||
counterd, haveerror, rotate, paused, archiverc,
|
counterd, haveerror, rotate, paused, archiverc,
|
||||||
demon, maxchild, backlog, needreload, timetoexit, version, noforce, bandlimver, parentretries;
|
demon, maxchild, backlog, version, noforce, bandlimver, parentretries;
|
||||||
unsigned authcachetype, authcachetime;
|
unsigned authcachetype, authcachetime;
|
||||||
int filtermaxsize;
|
int filtermaxsize;
|
||||||
int poolmax, pooltimeout; /* threadpool: idle workers kept, -1 automatic */
|
int poolmax, pooltimeout; /* threadpool: idle workers kept, -1 automatic */
|
||||||
@ -889,7 +889,7 @@ struct extparam {
|
|||||||
struct auth *authfuncs;
|
struct auth *authfuncs;
|
||||||
FILE *stdlog;
|
FILE *stdlog;
|
||||||
unsigned char **stringtable;
|
unsigned char **stringtable;
|
||||||
time_t logtime, time;
|
time_t logtime;
|
||||||
unsigned logdumpsrv, logdumpcli;
|
unsigned logdumpsrv, logdumpcli;
|
||||||
char delimchar;
|
char delimchar;
|
||||||
struct nserver nservers[MAXNSERVERS], authnserver;
|
struct nserver nservers[MAXNSERVERS], authnserver;
|
||||||
@ -1025,6 +1025,7 @@ struct pluginlink {
|
|||||||
int (*parseconnusername)(char *username, struct clientparam *param, int extpasswd, uint16_t port);
|
int (*parseconnusername)(char *username, struct clientparam *param, int extpasswd, uint16_t port);
|
||||||
struct sockfuncs *so;
|
struct sockfuncs *so;
|
||||||
unsigned char * (*dologname) (unsigned char *buf, unsigned char *name, const unsigned char *ext, ROTATION lt, time_t t);
|
unsigned char * (*dologname) (unsigned char *buf, unsigned char *name, const unsigned char *ext, ROTATION lt, time_t t);
|
||||||
|
int *needreload; /* state of the process rather than configuration */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct counter_header {
|
struct counter_header {
|
||||||
|
|||||||
@ -491,7 +491,7 @@ int op_admin_reload(struct httpreq *r, const unsigned char *params)
|
|||||||
|
|
||||||
if(r->param->srv->s_option) printstr(&pp, (char *)conf.stringtable[WEBBANNERS]);
|
if(r->param->srv->s_option) printstr(&pp, (char *)conf.stringtable[WEBBANNERS]);
|
||||||
else {
|
else {
|
||||||
conf.needreload = 1;
|
needreload = 1;
|
||||||
printstr(&pp, "<h3>Reload scheduled</h3>");
|
printstr(&pp, "<h3>Reload scheduled</h3>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user