evolution-data-server r9157 - trunk/camel



Author: jjohnny
Date: Mon Jul 21 11:15:43 2008
New Revision: 9157
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9157&view=rev

Log:
2008-07-21  Sankar P  <psankar novell com>

	* camel-db.c (cdb_sql_exec)
	* camel-folder-summary.c (camel_folder_summary_migrate_infos): Hold the
	rights when a transaction in place.


Modified:
   trunk/camel/ChangeLog
   trunk/camel/camel-db.c
   trunk/camel/camel-folder-summary.c

Modified: trunk/camel/camel-db.c
==============================================================================
--- trunk/camel/camel-db.c	(original)
+++ trunk/camel/camel-db.c	Mon Jul 21 11:15:43 2008
@@ -37,6 +37,7 @@
 
 #define d(x) 
 
+static GStaticRecMutex trans_lock = G_STATIC_REC_MUTEX_INIT;	
 
 static int 
 cdb_sql_exec (sqlite3 *db, const char* stmt, CamelException *ex) 
@@ -46,20 +47,12 @@
 
 	d(g_print("Camel SQL Exec:\n%s\n", stmt));
 
-	/* FIXME: TWo calls on the same database even with different sqlite handles is hanging. This needs to be looked and if needed upstreamed to sqlite. 
-	   Until then , a static lock will do. --Sankar */
-
-	static GStaticRecMutex connecting_to_db = G_STATIC_REC_MUTEX_INIT;	
-
-	g_static_rec_mutex_lock (&connecting_to_db);
 
 	ret = sqlite3_exec(db, stmt, 0, 0, &errmsg);
 	while (ret == SQLITE_BUSY || ret == SQLITE_LOCKED || ret == -1) {
 			ret = sqlite3_exec(db, stmt, 0, 0, &errmsg);
 	}
 
-	g_static_rec_mutex_unlock (&connecting_to_db);
-
 	if (ret != SQLITE_OK) {
 			d(g_print ("Error in SQL EXEC statement: %s [%s].\n", stmt, errmsg));
 			if (ex)	
@@ -151,6 +144,7 @@
 {
 	if (!cdb)
 		return -1;
+	g_static_rec_mutex_lock (&trans_lock);
 
 	d(g_print ("\n\aBEGIN TRANSACTION \n\a"));
 	g_mutex_lock (cdb->lock);
@@ -167,6 +161,8 @@
 	d(g_print ("\nCOMMIT TRANSACTION \n"));
 	ret = cdb_sql_exec (cdb->db, "COMMIT", ex);
 	g_mutex_unlock (cdb->lock);
+	g_static_rec_mutex_unlock (&trans_lock);
+
 	CAMEL_DB_RELEASE_SQLITE_MEMORY;
 	
 	return ret;

Modified: trunk/camel/camel-folder-summary.c
==============================================================================
--- trunk/camel/camel-folder-summary.c	(original)
+++ trunk/camel/camel-folder-summary.c	Mon Jul 21 11:15:43 2008
@@ -1106,18 +1106,13 @@
 		return -1;
 	}
 	
-	camel_db_begin_transaction (cdb, &ex);
 	ret = camel_db_write_folder_info_record (cdb, record, &ex);
 	g_free (record);
 
 	if (ret != 0) {
-		camel_db_abort_transaction (cdb, &ex);
 		return -1;
 	}
 
-	camel_db_end_transaction (cdb, &ex);
-
-	
 	return ret;
 
 error:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]