|
|
22d06c |
diff -up evolution-data-server-3.8.5/camel/camel-db.c.cameldb-track-pending-syncs evolution-data-server-3.8.5/camel/camel-db.c
|
|
|
22d06c |
--- evolution-data-server-3.8.5/camel/camel-db.c.cameldb-track-pending-syncs 2013-08-11 00:00:52.000000000 +0200
|
|
|
22d06c |
+++ evolution-data-server-3.8.5/camel/camel-db.c 2014-12-05 08:55:12.403985638 +0100
|
|
|
22d06c |
@@ -55,6 +55,12 @@ typedef struct {
|
|
|
22d06c |
GRecMutex sync_mutex;
|
|
|
22d06c |
guint timeout_id;
|
|
|
22d06c |
gint flags;
|
|
|
22d06c |
+
|
|
|
22d06c |
+ /* Do know how many syncs are pending, to not close
|
|
|
22d06c |
+ the file before the last sync is over */
|
|
|
22d06c |
+ guint pending_syncs;
|
|
|
22d06c |
+ GMutex pending_syncs_lock;
|
|
|
22d06c |
+ GCond pending_syncs_cond;
|
|
|
22d06c |
} CamelSqlite3File;
|
|
|
22d06c |
|
|
|
22d06c |
static gint
|
|
|
22d06c |
@@ -93,6 +99,13 @@ sync_request_thread_cb (gpointer task_da
|
|
|
22d06c |
|
|
|
22d06c |
call_old_file_Sync (sync_data->cFile, sync_data->flags);
|
|
|
22d06c |
|
|
|
22d06c |
+ g_mutex_lock (&sync_data->cFile->pending_syncs_lock);
|
|
|
22d06c |
+ g_warn_if_fail (sync_data->cFile->pending_syncs > 0);
|
|
|
22d06c |
+ sync_data->cFile->pending_syncs--;
|
|
|
22d06c |
+ if (!sync_data->cFile->pending_syncs)
|
|
|
22d06c |
+ g_cond_signal (&sync_data->cFile->pending_syncs_cond);
|
|
|
22d06c |
+ g_mutex_unlock (&sync_data->cFile->pending_syncs_lock);
|
|
|
22d06c |
+
|
|
|
22d06c |
done = sync_data->done;
|
|
|
22d06c |
g_free (sync_data);
|
|
|
22d06c |
|
|
|
22d06c |
@@ -138,6 +151,10 @@ sync_push_request (CamelSqlite3File *cFi
|
|
|
22d06c |
|
|
|
22d06c |
cFile->flags = 0;
|
|
|
22d06c |
|
|
|
22d06c |
+ g_mutex_lock (&cFile->pending_syncs_lock);
|
|
|
22d06c |
+ cFile->pending_syncs++;
|
|
|
22d06c |
+ g_mutex_unlock (&cFile->pending_syncs_lock);
|
|
|
22d06c |
+
|
|
|
22d06c |
g_rec_mutex_unlock (&cFile->sync_mutex);
|
|
|
22d06c |
|
|
|
22d06c |
g_thread_pool_push (sync_pool, data, &error);
|
|
|
22d06c |
@@ -251,6 +268,12 @@ camel_sqlite3_file_xClose (sqlite3_file
|
|
|
22d06c |
/* Make the last sync. */
|
|
|
22d06c |
sync_push_request (cFile, TRUE);
|
|
|
22d06c |
|
|
|
22d06c |
+ g_mutex_lock (&cFile->pending_syncs_lock);
|
|
|
22d06c |
+ while (cFile->pending_syncs > 0) {
|
|
|
22d06c |
+ g_cond_wait (&cFile->pending_syncs_cond, &cFile->pending_syncs_lock);
|
|
|
22d06c |
+ }
|
|
|
22d06c |
+ g_mutex_unlock (&cFile->pending_syncs_lock);
|
|
|
22d06c |
+
|
|
|
22d06c |
if (cFile->old_vfs_file->pMethods)
|
|
|
22d06c |
res = cFile->old_vfs_file->pMethods->xClose (cFile->old_vfs_file);
|
|
|
22d06c |
else
|
|
|
22d06c |
@@ -260,6 +283,8 @@ camel_sqlite3_file_xClose (sqlite3_file
|
|
|
22d06c |
cFile->old_vfs_file = NULL;
|
|
|
22d06c |
|
|
|
22d06c |
g_rec_mutex_clear (&cFile->sync_mutex);
|
|
|
22d06c |
+ g_mutex_clear (&cFile->pending_syncs_lock);
|
|
|
22d06c |
+ g_cond_clear (&cFile->pending_syncs_cond);
|
|
|
22d06c |
|
|
|
22d06c |
return res;
|
|
|
22d06c |
}
|
|
|
22d06c |
@@ -319,6 +344,10 @@ camel_sqlite3_vfs_xOpen (sqlite3_vfs *pV
|
|
|
22d06c |
}
|
|
|
22d06c |
|
|
|
22d06c |
g_rec_mutex_init (&cFile->sync_mutex);
|
|
|
22d06c |
+ g_mutex_init (&cFile->pending_syncs_lock);
|
|
|
22d06c |
+ g_cond_init (&cFile->pending_syncs_cond);
|
|
|
22d06c |
+
|
|
|
22d06c |
+ cFile->pending_syncs = 0;
|
|
|
22d06c |
|
|
|
22d06c |
g_rec_mutex_lock (&only_once_lock);
|
|
|
22d06c |
|