Index: camel/camel-db.c
===================================================================
--- camel/camel-db.c	(revision 10006)
+++ camel/camel-db.c	(working copy)
@@ -41,6 +41,7 @@
 
 static sqlite3_vfs *old_vfs = NULL;
 
+GStaticRecMutex only_once_lock = G_STATIC_REC_MUTEX_INIT;
 GStaticRecMutex sync_queue_lock = G_STATIC_REC_MUTEX_INIT;
 #define LockQueue()   g_static_rec_mutex_lock   (&sync_queue_lock)
 #define UnlockQueue() g_static_rec_mutex_unlock (&sync_queue_lock)
@@ -333,6 +334,7 @@ camel_sqlite3_vfs_xOpen (sqlite3_vfs *pV
 
 	res = old_vfs->xOpen (old_vfs, zPath, cFile->old_vfs_file, flags, pOutFlags);
 
+	g_static_rec_mutex_lock (&only_once_lock);
 	if (io_methods.xClose == NULL) {
 		/* initialize our subclass function only once */
 		io_methods.iVersion = cFile->old_vfs_file->pMethods->iVersion;
@@ -352,6 +354,7 @@ camel_sqlite3_vfs_xOpen (sqlite3_vfs *pV
 		use_subclassed (xDeviceCharacteristics);
 		#undef use_subclassed
 	}
+	g_static_rec_mutex_unlock (&only_once_lock);
 
 	cFile->parent.pMethods = &io_methods;
 
@@ -363,10 +366,12 @@ init_sqlite_vfs (void)
 {
 	static sqlite3_vfs vfs = { 0 };
 
-	if (old_vfs)
-		return;
+	g_static_rec_mutex_lock (&only_once_lock);
 
-	//sqlite3_initialize ();
+	if (old_vfs) {
+		g_static_rec_mutex_unlock (&only_once_lock);
+		return;
+	}
 
 	old_vfs = sqlite3_vfs_find (NULL);
 	g_return_if_fail (old_vfs != NULL);
@@ -378,6 +383,8 @@ init_sqlite_vfs (void)
 	vfs.xOpen = camel_sqlite3_vfs_xOpen;
 
 	sqlite3_vfs_register (&vfs, 1);
+
+	g_static_rec_mutex_unlock (&only_once_lock);
 }
 
 #define d(x) if (camel_debug("sqlite")) x
