mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
Fix: config change may stop log rotation
This commit is contained in:
parent
d7373be071
commit
02d52e89e9
19
src/conf.c
19
src/conf.c
@ -282,14 +282,14 @@ static int h_external(int argc, unsigned char ** argv){
|
|||||||
|
|
||||||
static int h_log(int argc, unsigned char ** argv){
|
static int h_log(int argc, unsigned char ** argv){
|
||||||
unsigned char tmpbuf[8192];
|
unsigned char tmpbuf[8192];
|
||||||
|
int notchanged = 0;
|
||||||
|
|
||||||
|
|
||||||
havelog = 1;
|
havelog = 1;
|
||||||
if(argc > 1 && conf.logtarget && *argv[1]!= '&' && *argv[1]!= '@' && !strcmp((char *)conf.logtarget, (char *)argv[1])) {
|
if(argc > 1 && conf.logtarget && !strcmp((char *)conf.logtarget, (char *)argv[1])) {
|
||||||
conf.logfunc = logstdout;
|
notchanged = 1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
if(conf.logtarget){
|
if(!notchanged && conf.logtarget){
|
||||||
myfree(conf.logtarget);
|
myfree(conf.logtarget);
|
||||||
conf.logtarget = NULL;
|
conf.logtarget = NULL;
|
||||||
}
|
}
|
||||||
@ -298,20 +298,22 @@ static int h_log(int argc, unsigned char ** argv){
|
|||||||
conf.logfunc = lognone;
|
conf.logfunc = lognone;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
conf.logtarget = (unsigned char *)mystrdup((char *)argv[1]);
|
if(!notchanged) conf.logtarget = (unsigned char *)mystrdup((char *)argv[1]);
|
||||||
if(*argv[1]=='@'){
|
if(*argv[1]=='@'){
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
openlog((char *)conf.logtarget+1, LOG_PID, LOG_DAEMON);
|
|
||||||
conf.logfunc = logsyslog;
|
conf.logfunc = logsyslog;
|
||||||
|
if(notchanged) return 0;
|
||||||
|
openlog((char *)conf.logtarget+1, LOG_PID, LOG_DAEMON);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifndef NOODBC
|
#ifndef NOODBC
|
||||||
else if(*argv[1]=='&'){
|
else if(*argv[1]=='&'){
|
||||||
|
if(notchanged) return 0;
|
||||||
|
conf.logfunc = logsql;
|
||||||
pthread_mutex_lock(&log_mutex);
|
pthread_mutex_lock(&log_mutex);
|
||||||
close_sql();
|
close_sql();
|
||||||
init_sql((char *)argv[1]+1);
|
init_sql((char *)argv[1]+1);
|
||||||
pthread_mutex_unlock(&log_mutex);
|
pthread_mutex_unlock(&log_mutex);
|
||||||
conf.logfunc = logsql;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef NORADIUS
|
#ifndef NORADIUS
|
||||||
@ -323,6 +325,8 @@ static int h_log(int argc, unsigned char ** argv){
|
|||||||
if(argc > 2) {
|
if(argc > 2) {
|
||||||
conf.logtype = getrotate(*argv[2]);
|
conf.logtype = getrotate(*argv[2]);
|
||||||
}
|
}
|
||||||
|
conf.logfunc = logstdout;
|
||||||
|
if(notchanged) return 0;
|
||||||
conf.logtime = time(0);
|
conf.logtime = time(0);
|
||||||
if(conf.logname)myfree(conf.logname);
|
if(conf.logname)myfree(conf.logname);
|
||||||
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
||||||
@ -332,7 +336,6 @@ static int h_log(int argc, unsigned char ** argv){
|
|||||||
perror((char *)tmpbuf);
|
perror((char *)tmpbuf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
conf.logfunc = logstdout;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user