From 6713530fda9721b52cc42c668886338613fb9d4d Mon Sep 17 00:00:00 2001 From: z3APA3A <3APA3A@3proxy.ru> Date: Fri, 5 Feb 2016 19:04:16 +0300 Subject: [PATCH] log_mutex init moved to proxymain --- src/3proxy.c | 3 --- src/common.c | 10 ---------- src/dighosts.c | 1 + src/proxy.h | 1 - src/proxymain.c | 6 ++++++ 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/3proxy.c b/src/3proxy.c index 4a5eb70..f5b7f07 100644 --- a/src/3proxy.c +++ b/src/3proxy.c @@ -510,9 +510,6 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int return 1; } - pthread_mutex_init(&log_mutex, NULL); - logmutexinit = 1; - pthread_mutex_init(&config_mutex, NULL); pthread_mutex_init(&bandlim_mutex, NULL); pthread_mutex_init(&hash_mutex, NULL); diff --git a/src/common.c b/src/common.c index 55aef52..1244ec6 100644 --- a/src/common.c +++ b/src/common.c @@ -601,17 +601,11 @@ void lognone(struct clientparam * param, const unsigned char *s) { if(param->trafcountfunc)(*param->trafcountfunc)(param); clearstat(param); } -pthread_mutex_t log_mutex; -int logmutexinit = 0; unsigned char tmpbuf[8192]; void logstdout(struct clientparam * param, const unsigned char *s) { FILE *log; - if(!logmutexinit){ - pthread_mutex_init(&log_mutex, NULL); - logmutexinit = 1; - } pthread_mutex_lock(&log_mutex); log = param->srv->stdlog?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout; dobuf(param, tmpbuf, s, NULL); @@ -624,10 +618,6 @@ void logstdout(struct clientparam * param, const unsigned char *s) { #ifndef _WIN32 void logsyslog(struct clientparam * param, const unsigned char *s) { - if(!logmutexinit){ - pthread_mutex_init(&log_mutex, NULL); - logmutexinit = 1; - } pthread_mutex_lock(&log_mutex); dobuf(param, tmpbuf, s, NULL); if(!param->nolog)syslog(LOG_INFO, "%s", tmpbuf); diff --git a/src/dighosts.c b/src/dighosts.c index 2d25989..2df5150 100644 --- a/src/dighosts.c +++ b/src/dighosts.c @@ -6,6 +6,7 @@ */ #include "proxy.h" +pthread_mutex_t log_mutex; int sockgetchar(SOCKET sock, int timeosec, int timeousec){ diff --git a/src/proxy.h b/src/proxy.h index f92960a..2cb0eca 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -316,7 +316,6 @@ extern pthread_mutex_t hash_mutex; extern pthread_mutex_t tc_mutex; extern pthread_mutex_t pwl_mutex; extern pthread_mutex_t log_mutex; -extern int logmutexinit; extern struct datatype datatypes[64]; diff --git a/src/proxymain.c b/src/proxymain.c index dfb073d..25b3223 100644 --- a/src/proxymain.c +++ b/src/proxymain.c @@ -8,6 +8,8 @@ #include "proxy.h" +pthread_mutex_t log_mutex; +int logmutexinit = 0; #define param ((struct clientparam *) p) #ifdef _WIN32 @@ -179,6 +181,10 @@ int MODULEMAINFUNC (int argc, char** argv){ #endif #endif + if(!logmutexinit){ + pthread_mutex_init(&log_mutex, NULL); + logmutexinit = 1; + } srvinit(&srv, &defparam); srv.pf = childdef.pf;