From c74bd922870214c48ac5d032f13b0751ef32be59 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Sun, 7 Sep 2008 13:24:31 +0200 Subject: - Fix serialization of debug printouts. - Add a MFS_DB_LOCK/UNLOCK which handles locking of the SQLITE database if SQLITE_THREADED compile option is not specified. - Remove duplicate open/close of database during initial scan. --- include/debug.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include/debug.h') diff --git a/include/debug.h b/include/debug.h index a30af63..350a27e 100644 --- a/include/debug.h +++ b/include/debug.h @@ -25,10 +25,15 @@ #ifdef DEBUGGING # include # define DEBUGPATH "debug.txt" +extern pthread_mutex_t __debug_lock__; FILE *__debug_handle__; -# define DEBUG(...) __debug_handle__ = fopen(DEBUGPATH, "a"); \ - fprintf (__debug_handle__, __VA_ARGS__); \ - fclose(__debug_handle__); +# define DEBUG(...) do { \ + pthread_mutex_lock(&__debug_lock__); \ + __debug_handle__ = fopen(DEBUGPATH, "a"); \ + fprintf (__debug_handle__, __VA_ARGS__); \ + fclose(__debug_handle__); \ + pthread_mutex_unlock(&__debug_lock__); \ + } while (0) #else # define DEBUG(...) #endif -- cgit v1.2.3