Browse code

improve output handling

git-svn: trunk@1627

Tomasz Kojm authored on 2005/06/23 03:17:30
Showing 4 changed files
... ...
@@ -1,3 +1,8 @@
1
+Wed Jun 22 20:12:54 CEST 2005 (tk)
2
+----------------------------------
3
+  * clamd/clamd.c, shared/output.c: improve output handling (Patch by Mark
4
+				Pizzolato <clamav-devel*subscriptions.pizzolato.net>)
5
+
1 6
 Wed Jun 22 17:52:08 CEST 2005 (tk)
2 7
 ----------------------------------
3 8
   * clamd: support operation of both TCP and Unix domain sockets simultaneously
... ...
@@ -163,7 +163,7 @@ void clamd(struct optstruct *opt)
163 163
     logg_time = cfgopt(copt, "LogTime")->enabled;
164 164
     logok = cfgopt(copt, "LogClean")->enabled;
165 165
     logg_size = cfgopt(copt, "LogFileMaxSize")->numarg;
166
-    logg_verbose = cfgopt(copt, "LogVerbose")->enabled;
166
+    logg_verbose = mprintf_verbose = cfgopt(copt, "LogVerbose")->enabled;
167 167
 
168 168
     if(cfgopt(copt, "Debug")->enabled) /* enable debug messages in libclamav */
169 169
 	cl_debug();
... ...
@@ -115,7 +115,7 @@ int main(int argc, char **argv)
115 115
 
116 116
     free_opt(opt);
117 117
 
118
-    logg("*exit main()");
118
+    mprintf("*exit main()");
119 119
     return(0);
120 120
 }
121 121
 
... ...
@@ -129,10 +129,10 @@ int logg(const char *str, ...)
129 129
     va_start(argscpy, str);
130 130
     va_start(argsout, str);
131 131
 
132
-    if(logg_file) {
133 132
 #ifdef CL_THREAD_SAFE
134
-	pthread_mutex_lock(&logg_mutex);
133
+    pthread_mutex_lock(&logg_mutex);
135 134
 #endif
135
+    if(logg_file) {
136 136
 	if(!logg_fd) {
137 137
 	    old_umask = umask(0037);
138 138
 	    if((logg_fd = fopen(logg_file, "a")) == NULL) {
... ...
@@ -200,9 +200,6 @@ int logg(const char *str, ...)
200 200
 
201 201
 	fflush(logg_fd);
202 202
 
203
-#ifdef CL_THREAD_SAFE
204
-	pthread_mutex_unlock(&logg_mutex);
205
-#endif
206 203
     }
207 204
 
208 205
 #if defined(USE_SYSLOG) && !defined(C_AIX)
... ...
@@ -244,6 +241,10 @@ int logg(const char *str, ...)
244 244
 	    mprintf(vbuff, str);
245 245
     }
246 246
 
247
+#ifdef CL_THREAD_SAFE
248
+    pthread_mutex_unlock(&logg_mutex);
249
+#endif
250
+
247 251
     va_end(args);
248 252
     va_end(argscpy);
249 253
     va_end(argsout);