git-svn: trunk@1655
Tomasz Kojm authored on 2005/07/20 04:04:38... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Tue Jul 19 21:01:30 CEST 2005 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * shared/output.c: fix mutex handling in the new implementation of logg() |
|
4 |
+ Patch by Mark Pizzolato. |
|
5 |
+ |
|
1 | 6 |
Tue Jul 19 20:15:43 CEST 2005 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* clamscan/clamscan.c: verify arguments passed to --max-dir-recursion and |
... | ... |
@@ -164,42 +164,40 @@ int logg(const char *str, ...) |
164 | 164 |
fprintf(logg_fd, "LOGGING DISABLED (Maximal log file size exceeded).\n"); |
165 | 165 |
fclose(logg_fd); |
166 | 166 |
logg_fd = NULL; |
167 |
-#ifdef CL_THREAD_SAFE |
|
168 |
- pthread_mutex_unlock(&logg_mutex); |
|
169 |
-#endif |
|
170 | 167 |
} |
171 | 168 |
} |
172 | 169 |
} |
173 | 170 |
|
174 |
- /* Need to avoid logging time for verbose messages when logverbose |
|
175 |
- is not set or we get a bunch of timestamps in the log without |
|
176 |
- newlines... */ |
|
177 |
- if(logg_time && ((*str != '*') || logg_verbose)) { |
|
178 |
- time(&currtime); |
|
179 |
- pt = ctime(&currtime); |
|
180 |
- timestr = mcalloc(strlen(pt), sizeof(char)); |
|
181 |
- strncpy(timestr, pt, strlen(pt) - 1); |
|
182 |
- fprintf(logg_fd, "%s -> ", timestr); |
|
183 |
- free(timestr); |
|
184 |
- } |
|
171 |
+ if(logg_fd) { |
|
172 |
+ /* Need to avoid logging time for verbose messages when logverbose |
|
173 |
+ is not set or we get a bunch of timestamps in the log without |
|
174 |
+ newlines... */ |
|
175 |
+ if(logg_time && ((*str != '*') || logg_verbose)) { |
|
176 |
+ time(&currtime); |
|
177 |
+ pt = ctime(&currtime); |
|
178 |
+ timestr = mcalloc(strlen(pt), sizeof(char)); |
|
179 |
+ strncpy(timestr, pt, strlen(pt) - 1); |
|
180 |
+ fprintf(logg_fd, "%s -> ", timestr); |
|
181 |
+ free(timestr); |
|
182 |
+ } |
|
185 | 183 |
|
186 |
- _(str); |
|
187 |
- if(*str == '!') { |
|
188 |
- fprintf(logg_fd, "ERROR: "); |
|
189 |
- vfprintf(logg_fd, str + 1, args); |
|
190 |
- } else if(*str == '^') { |
|
191 |
- fprintf(logg_fd, "WARNING: "); |
|
192 |
- vfprintf(logg_fd, str + 1, args); |
|
193 |
- } else if(*str == '*') { |
|
194 |
- if(logg_verbose) |
|
184 |
+ _(str); |
|
185 |
+ if(*str == '!') { |
|
186 |
+ fprintf(logg_fd, "ERROR: "); |
|
195 | 187 |
vfprintf(logg_fd, str + 1, args); |
196 |
- } else if(*str == '#') { |
|
197 |
- vfprintf(logg_fd, str + 1, args); |
|
198 |
- } else vfprintf(logg_fd, str, args); |
|
199 |
- |
|
188 |
+ } else if(*str == '^') { |
|
189 |
+ fprintf(logg_fd, "WARNING: "); |
|
190 |
+ vfprintf(logg_fd, str + 1, args); |
|
191 |
+ } else if(*str == '*') { |
|
192 |
+ if(logg_verbose) |
|
193 |
+ vfprintf(logg_fd, str + 1, args); |
|
194 |
+ } else if(*str == '#') { |
|
195 |
+ vfprintf(logg_fd, str + 1, args); |
|
196 |
+ } else vfprintf(logg_fd, str, args); |
|
200 | 197 |
|
201 |
- fflush(logg_fd); |
|
202 | 198 |
|
199 |
+ fflush(logg_fd); |
|
200 |
+ } |
|
203 | 201 |
} |
204 | 202 |
|
205 | 203 |
#if defined(USE_SYSLOG) && !defined(C_AIX) |