brasero r1116 - in trunk: . src



Author: philippr
Date: Mon Aug 18 13:28:38 2008
New Revision: 1116
URL: http://svn.gnome.org/viewvc/brasero?rev=1116&view=rev

Log:
	Improved cancellation and secure metadata entry insertion in cache

	* src/brasero-io.c (brasero_io_get_metadata_info),
	(brasero_io_get_file_count_process_directory):

Modified:
   trunk/ChangeLog
   trunk/src/brasero-io.c

Modified: trunk/src/brasero-io.c
==============================================================================
--- trunk/src/brasero-io.c	(original)
+++ trunk/src/brasero-io.c	Mon Aug 18 13:28:38 2008
@@ -646,6 +646,9 @@
 	gboolean result;
 	GList *node;
 
+	if (g_cancellable_is_cancelled (cancel))
+		return FALSE;
+
 	priv = BRASERO_IO_PRIVATE (self);
 
 	mime = g_file_info_get_content_type (info);
@@ -657,6 +660,8 @@
 	||  !strcmp (mime, "application/octet-stream")))
 		return FALSE;
 
+	g_mutex_lock (priv->lock);
+
 	/* Seek in the buffer if we have already explored these metadata. Check 
 	 * the info last modified time in case a result should be updated. */
 	node = g_queue_find_custom (priv->meta_buffer,
@@ -673,11 +678,13 @@
 				/* If there isn't any snapshot retry */
 				if (cached->info->snapshot) {
 					brasero_metadata_info_copy (meta_info, cached->info);
+					g_mutex_unlock (priv->lock);
 					return TRUE;
 				}
 			}
 			else {
 				brasero_metadata_info_copy (meta_info, cached->info);
+				g_mutex_unlock (priv->lock);
 				return TRUE;
 			}
 		}
@@ -692,16 +699,25 @@
 	/* grab an available metadata (NOTE: there should always be at least one
 	 * since we run 2 threads at max and have two metadatas available) */
 	do {
-		g_mutex_lock (priv->lock);
+
+		if (g_cancellable_is_cancelled (cancel)) {
+			g_mutex_unlock (priv->lock);
+			return FALSE;
+		}
+
 		if (priv->metadatas) {
 			metadata = priv->metadatas->data;
 			priv->metadatas = g_slist_remove (priv->metadatas, metadata);
 		}
-		g_mutex_unlock (priv->lock);
 
+		g_mutex_unlock (priv->lock);
 		g_usleep (250);
+		g_mutex_lock (priv->lock);
+
 	} while (!metadata);
 
+	g_mutex_unlock (priv->lock);
+
 	result = brasero_metadata_get_info_wait (metadata,
 						 cancel,
 						 uri,
@@ -709,6 +725,8 @@
 						 NULL);
 	brasero_metadata_set_info (metadata, meta_info);
 
+	g_mutex_lock (priv->lock);
+
 	if (result) {
 		/* see if we should add it to the buffer */
 		if (meta_info->has_audio || meta_info->has_video) {
@@ -728,8 +746,8 @@
 		}
 	}
 
-	g_mutex_lock (priv->lock);
 	priv->metadatas = g_slist_prepend (priv->metadatas, metadata);
+
 	g_mutex_unlock (priv->lock);
 
 	return result;
@@ -1274,6 +1292,11 @@
 	while ((info = g_file_enumerator_next_file (enumerator, cancel, &error)) || error) {
 		GFile *child;
 
+		if (g_cancellable_is_cancelled (cancel)) {
+			g_object_unref (info);
+			break;
+		}
+
 		data->files_num ++;
 
 		if (error) {



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