29
29
#include <string.h>
30
30
#include <stdarg.h>
31
31
#include <syslog.h>
32
- #include <pthread.h> /* pthread_self() */
33
32
#include "error.h"
34
33
#include "common.h"
35
34
#include "configuration.h"
@@ -42,8 +41,6 @@ static int *debug = &zero;
42
41
static int * quiet = & zero ;
43
42
static int * verbose = & three ;
44
43
45
- pthread_mutex_t error_mutex = PTHREAD_MUTEX_INITIALIZER ;
46
-
47
44
static int printf_stderr (const char * fmt , ...) {
48
45
va_list args ;
49
46
int rc ;
@@ -170,15 +167,12 @@ void _critical(const char *const function_name, const char *fmt, ...) {
170
167
if (* quiet )
171
168
return ;
172
169
173
- pthread_mutex_lock (& error_mutex );
174
-
175
170
outputmethod_t method = * outputmethod ;
176
171
177
172
{
178
173
va_list args ;
179
- pthread_t thread = pthread_self ();
180
174
181
- outfunct [method ]("Critical (thread %p) : %s(): " , thread , function_name );
175
+ outfunct [method ]("Critical: %s(): " , function_name );
182
176
va_start (args , fmt );
183
177
voutfunct [method ](fmt , args );
184
178
va_end (args );
@@ -197,7 +191,6 @@ void _critical(const char *const function_name, const char *fmt, ...) {
197
191
outfunct [method ]("_critical(): Got error, but cannot print the backtrace. Current errno: %u: %s\n" ,
198
192
errno , strerror (errno ));
199
193
flushfunct [method ](LOG_CRIT );
200
- pthread_mutex_unlock (& error_mutex );
201
194
exit (EXIT_FAILURE );
202
195
}
203
196
@@ -208,7 +201,6 @@ void _critical(const char *const function_name, const char *fmt, ...) {
208
201
}
209
202
#endif
210
203
211
- pthread_mutex_unlock (& error_mutex );
212
204
exit (errno );
213
205
214
206
return ;
@@ -223,20 +215,16 @@ void _error(const char *const function_name, const char *fmt, ...) {
223
215
if (* verbose < 1 )
224
216
return ;
225
217
226
- pthread_mutex_lock (& error_mutex );
227
-
228
- pthread_t thread = pthread_self ();
229
218
outputmethod_t method = * outputmethod ;
230
219
231
- outfunct [method ](* debug ? "Error (thread %p) : %s(): " : "Error: " , thread , function_name );
220
+ outfunct [method ](* debug ? "Error: %s(): " : "Error: " , function_name );
232
221
va_start (args , fmt );
233
222
voutfunct [method ](fmt , args );
234
223
va_end (args );
235
224
if (errno )
236
225
outfunct [method ](" (%i: %s)" , errno , strerror (errno ));
237
226
flushfunct [method ](LOG_ERR );
238
227
239
- pthread_mutex_unlock (& error_mutex );
240
228
return ;
241
229
}
242
230
@@ -249,18 +237,14 @@ void _info_short(const char *const function_name, const char *fmt, ...) {
249
237
if (* verbose < 3 )
250
238
return ;
251
239
252
- pthread_mutex_lock (& error_mutex );
253
-
254
- pthread_t thread = pthread_self ();
255
240
outputmethod_t method = * outputmethod ;
256
241
257
- outfunct [method ](* debug ? "Info (thread %p) : %s(): " : "" , thread , function_name );
242
+ outfunct [method ](* debug ? "Info: %s(): " : "" , function_name );
258
243
va_start (args , fmt );
259
244
voutfunct [method ](fmt , args );
260
245
va_end (args );
261
246
flushfunct [method ](LOG_INFO );
262
247
263
- pthread_mutex_unlock (& error_mutex );
264
248
return ;
265
249
}
266
250
@@ -273,18 +257,14 @@ void _info(const char *const function_name, const char *fmt, ...) {
273
257
if (* verbose < 3 )
274
258
return ;
275
259
276
- pthread_mutex_lock (& error_mutex );
277
-
278
- pthread_t thread = pthread_self ();
279
260
outputmethod_t method = * outputmethod ;
280
261
281
- outfunct [method ](* debug ? "Info (thread %p) : %s(): " : "Info: " , thread , function_name );
262
+ outfunct [method ](* debug ? "Info: %s(): " : "Info: " , function_name );
282
263
va_start (args , fmt );
283
264
voutfunct [method ](fmt , args );
284
265
va_end (args );
285
266
flushfunct [method ](LOG_INFO );
286
267
287
- pthread_mutex_unlock (& error_mutex );
288
268
return ;
289
269
}
290
270
@@ -297,18 +277,14 @@ void _warning(const char *const function_name, const char *fmt, ...) {
297
277
if (* verbose < 2 )
298
278
return ;
299
279
300
- pthread_mutex_lock (& error_mutex );
301
-
302
- pthread_t thread = pthread_self ();
303
280
outputmethod_t method = * outputmethod ;
304
281
305
- outfunct [method ](* debug ? "Warning (thread %p) : %s(): " : "Warning: " , thread , function_name );
282
+ outfunct [method ](* debug ? "Warning: %s(): " : "Warning: " , function_name );
306
283
va_start (args , fmt );
307
284
voutfunct [method ](fmt , args );
308
285
va_end (args );
309
286
flushfunct [method ](LOG_WARNING );
310
287
311
- pthread_mutex_unlock (& error_mutex );
312
288
return ;
313
289
}
314
290
@@ -321,18 +297,14 @@ void _debug(int debug_level, const char *const function_name, const char *fmt, .
321
297
if (debug_level > * debug )
322
298
return ;
323
299
324
- pthread_mutex_lock (& error_mutex );
325
-
326
- pthread_t thread = pthread_self ();
327
300
outputmethod_t method = * outputmethod ;
328
301
329
- outfunct [method ]("Debug%u (thread %p) : %s(): " , debug_level , thread , function_name );
302
+ outfunct [method ]("Debug%u: %s(): " , debug_level , function_name );
330
303
va_start (args , fmt );
331
304
voutfunct [method ](fmt , args );
332
305
va_end (args );
333
306
flushfunct [method ](LOG_DEBUG );
334
307
335
- pthread_mutex_unlock (& error_mutex );
336
308
return ;
337
309
}
338
310
@@ -341,9 +313,6 @@ void error_init(void *_outputmethod, int *_quiet, int *_verbose, int *_debug) {
341
313
quiet = _quiet ;
342
314
verbose = _verbose ;
343
315
debug = _debug ;
344
-
345
- pthread_mutex_init (& error_mutex , NULL );
346
-
347
316
return ;
348
317
}
349
318
0 commit comments