diff --git a/CHANGES b/CHANGES index 5f792de44e..d9d41f7e71 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,9 @@ +2.1-654 | 2013-05-17 13:49:52 -0700 + + * Tweaks to sqlite3 configuration to address threading issues. + (Bernhard Amann) + 2.1-651 | 2013-05-17 13:37:16 -0700 * Fix uninitialized DPM member. (Jon Siwek) diff --git a/VERSION b/VERSION index 03cea9c71f..3318fb06e3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1-651 +2.1-654 diff --git a/src/3rdparty/sqlite3.c b/src/3rdparty/sqlite3.c index 77f14da90d..ba6a30e132 100644 --- a/src/3rdparty/sqlite3.c +++ b/src/3rdparty/sqlite3.c @@ -1,3 +1,6 @@ +# define SQLITE_THREADSAFE 2 +# define SQLITE_DEFAULT_MEMSTATUS 0 + /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite ** version 3.7.16.2. By combining all the individual C code files into this diff --git a/src/logging/writers/SQLite.cc b/src/logging/writers/SQLite.cc index 22037f029e..81c52fe198 100644 --- a/src/logging/writers/SQLite.cc +++ b/src/logging/writers/SQLite.cc @@ -35,13 +35,17 @@ SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend) db = 0; io = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo(set_separator, unset_field, empty_field)); + st = 0; } SQLite::~SQLite() { if ( db != 0 ) { - sqlite3_close(db); + sqlite3_finalize(st); + if ( ! sqlite3_close(db) ) + Error("Sqlite could not close connection"); + db = 0; } diff --git a/src/threading/Queue.h b/src/threading/Queue.h index 5988c94042..792fb63f9c 100644 --- a/src/threading/Queue.h +++ b/src/threading/Queue.h @@ -113,8 +113,9 @@ private: inline static void safe_lock(pthread_mutex_t* mutex) { - if ( pthread_mutex_lock(mutex) != 0 ) - reporter->FatalErrorWithCore("cannot lock mutex"); + int res = pthread_mutex_lock(mutex); + if ( res != 0 ) + reporter->FatalErrorWithCore("cannot lock mutex: %d(%s)", res, strerror(res)); } inline static void safe_unlock(pthread_mutex_t* mutex)