mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
fix race condition on 'log' command processing
This commit is contained in:
parent
6cac541e33
commit
d6f72a51fe
@ -314,22 +314,23 @@ static int h_log(int argc, unsigned char ** argv){
|
||||
}
|
||||
conf.logtime = time(0);
|
||||
if(conf.logname)myfree(conf.logname);
|
||||
pthread_mutex_lock(&log_mutex);
|
||||
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
||||
fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
|
||||
if(!fp){
|
||||
perror("fopen()");
|
||||
perror(tmpbuf);
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
pthread_mutex_lock(&log_mutex);
|
||||
if(conf.stdlog)fclose(conf.stdlog);
|
||||
conf.stdlog = fp;
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
#ifdef _WINCE
|
||||
freopen(tmpbuf, "w", stdout);
|
||||
freopen(tmpbuf, "w", stderr);
|
||||
#endif
|
||||
}
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user