[tracker/journal-err-reporting-merge: 4/5] libtracker-data: Adding comments explaining error handling actions



commit 292414d91accb2a1a6de9c3df5e9e00e9a73f017
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Apr 22 11:34:43 2011 +0200

    libtracker-data: Adding comments explaining error handling actions

 src/libtracker-data/tracker-data-manager.c |    8 +++++---
 src/libtracker-data/tracker-data-update.c  |   12 ++++++++----
 src/libtracker-data/tracker-db-journal.c   |    7 ++++++-
 src/libtracker-data/tracker-db-manager.c   |    4 +++-
 4 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 2f83173..36fa618 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3556,7 +3556,7 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
 	iface = tracker_db_manager_get_db_interface ();
 
 	if (journal_check && is_first_time_index) {
-		/* Call may fail without notice */
+		/* Call may fail without notice (it's handled) */
 		if (tracker_db_journal_reader_init (NULL, NULL)) {
 			if (tracker_db_journal_reader_next (NULL)) {
 				/* journal with at least one valid transaction
@@ -4131,7 +4131,8 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
 			if (g_error_matches (internal_error, TRACKER_DB_INTERFACE_ERROR, TRACKER_DB_NO_SPACE)) {
 				tracker_db_manager_remove_all (FALSE);
 				tracker_db_manager_shutdown ();
-				/* Call may fail without notice, we're in error handling already */
+				/* Call may fail without notice, we're in error handling already.
+				 * When fails it means that close() of journal file failed. */
 				tracker_db_journal_shutdown (NULL);
 			}
 
@@ -4206,7 +4207,8 @@ tracker_data_manager_shutdown (void)
 
 	if (error) {
 		/* TODO: propagate error */
-		g_warning ("%s", error->message);
+		g_warning ("While shutting down journal %s",
+		           error->message ? error->message : "No error given");
 		g_error_free (error);
 	}
 
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 7560e06..e65bd16 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2964,6 +2964,7 @@ tracker_data_begin_transaction (GError **error)
 			tracker_db_journal_start_ontology_transaction (resource_time, &n_error);
 
 			if (n_error) {
+				/* Q: Should we do a tracker_data_rollback_transaction () here? */
 				tracker_db_interface_end_db_transaction (iface, NULL);
 				g_propagate_error (error, n_error);
 				return;
@@ -3115,7 +3116,9 @@ tracker_data_rollback_transaction (void)
 
 		if (ignorable) {
 			/* Not sure if this is also ignorable: it's the close() of the
-			 * journal file failing. */
+			 * journal file failing (in case of TRANSACTION_FORMAT_ONTOLOGY) */
+			g_warning ("Error ignored while rolling back transaction in journal: %s",
+			           ignorable->message ? ignorable->message : "No error given");
 			g_error_free (ignorable);
 		}
 
@@ -3216,7 +3219,8 @@ tracker_data_replay_journal (TrackerBusyCallback   busy_callback,
 
 	tracker_db_journal_reader_init (NULL, &n_error);
 	if (n_error) {
-		/* This is fatal */
+		/* This is fatal (doesn't happen when file doesn't exist, does happen
+		 * when for some other reason the reader can't be created) */
 		g_propagate_error (error, n_error);
 		return;
 	}
@@ -3482,7 +3486,7 @@ tracker_data_replay_journal (TrackerBusyCallback   busy_callback,
 
 		tracker_db_journal_init (NULL, FALSE, &n_error);
 		if (n_error) {
-			/* This is fatal */
+			/* This is fatal (journal file not writable, etc) */
 			g_propagate_error (error, n_error);
 			return;
 		}
@@ -3490,7 +3494,7 @@ tracker_data_replay_journal (TrackerBusyCallback   busy_callback,
 		tracker_db_journal_shutdown (&n_error);
 
 		if (n_error) {
-			/* This is fatal */
+			/* This is fatal (close of journal file failed after truncate) */
 			g_propagate_error (error, n_error);
 			return;
 		}
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index d59e4b4..7626b49 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -477,6 +477,8 @@ db_journal_init_file (JournalWriter  *jwriter,
 
 		/* If it didn't expand properly */
 		if (jwriter->cur_block == NULL) {
+			/* Q: Should we set error with out of memory here? When adding error
+			 * reporting there where no warnings or criticals here. */
 			g_free (jwriter->journal_filename);
 			jwriter->journal_filename = NULL;
 			return FALSE;
@@ -492,6 +494,9 @@ db_journal_init_file (JournalWriter  *jwriter,
 		jwriter->cur_block[7] = '4';
 
 		if (!write_all_data (jwriter->journal, jwriter->cur_block, 8)) {
+			/* Q: Can't write 8 bytes to the file, should we set error with out
+			 * of diskspace here? When adding error reporting there where no
+			 * warnings or criticals here. */
 			g_free (jwriter->journal_filename);
 			jwriter->journal_filename = NULL;
 			return FALSE;
@@ -1203,7 +1208,7 @@ tracker_db_journal_commit_db_transaction (GError **error)
 #endif /* GLib check */
 	}
 
-	/* Only report the first error here */
+	/* Coalesces the two error reports: */
 	if (n_error) {
 		g_propagate_error (error, n_error);
 		if (nn_error) {
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 3427eb6..67bec64 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -410,7 +410,9 @@ db_manager_remove_journal (void)
 	tracker_db_journal_shutdown (&error);
 
 	if (error) {
-		g_message ("%s", error->message);
+		/* TODO: propagate error */
+		g_message ("Ignored error while shutting down journal during remove: %s",
+		           error->message ? error->message : "No error given");
 		g_error_free (error);
 	}
 



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