mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Resolve races on log buffer without mutex
This commit is contained in:
1 parent
1d162abec3
commit
d3f9d80b65
2 files changed
+4
-3
No files matched your search
+1
-3
@@ -285,6 +285,7 @@ static int h_external(int argc, unsigned char ** argv){
|
||||
}
|
||||
|
||||
static int h_log(int argc, unsigned char ** argv){
|
||||
unsigned char tmpbuf[8192];
|
||||
conf.logfunc = logstdout;
|
||||
if(conf.logtarget){
|
||||
myfree(conf.logtarget);
|
||||
@@ -314,12 +315,10 @@ 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(tmpbuf);
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
@@ -330,7 +329,6 @@ static int h_log(int argc, unsigned char ** argv){
|
||||
freopen(tmpbuf, "w", stderr);
|
||||
#endif
|
||||
}
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user