(Patch) Some fixes for the stream cache implementation



	Hi,

	This patch fixes some issues detected on testing the new stream cache.

Changelog would be:
* libtinymail/tny-cached-file-stream.c:
  Linked the reset implementation to the stream interface.
* libtinymail/tny-cached-file.c:
  Create the files synchronously, to avoid accessing the file from other
  thread if this has not been created yet.

-- 
José Dapena Paz <jdapena igalia com>
Igalia
Index: libtinymail/tny-cached-file-stream.c
===================================================================
--- libtinymail/tny-cached-file-stream.c	(revision 3701)
+++ libtinymail/tny-cached-file-stream.c	(working copy)
@@ -211,6 +211,7 @@
 	klass->read= tny_cached_file_stream_read;
 	klass->write= tny_cached_file_stream_write;
 	klass->close= tny_cached_file_stream_close;
+	klass->reset= tny_cached_file_stream_reset;
 
 	return;
 }
Index: libtinymail/tny-cached-file.c
===================================================================
--- libtinymail/tny-cached-file.c	(revision 3701)
+++ libtinymail/tny-cached-file.c	(working copy)
@@ -190,7 +190,7 @@
 	priv = TNY_CACHED_FILE_GET_PRIVATE (self);
 	flags = O_RDWR;
 	if (creation) {
-		flags = O_CREAT | O_RDWR;
+		flags = O_CREAT | O_RDWR | O_SYNC;
 	} else {
 		flags |= O_RDONLY;
 	}
@@ -291,7 +291,7 @@
 
 typedef struct {
 	TnyCachedFile *self;
-	TnyStream *write_stream;
+	gint write_fd;
 } AsyncFetchStreamData;
 
 static gpointer
@@ -301,15 +301,12 @@
 	TnyCachedFile *self;
 	TnyCachedFilePriv *priv;
 	TnyStream *write_stream;
-	int write_fd;
 
 	self = afs_data->self;
 	priv = TNY_CACHED_FILE_GET_PRIVATE (self);
 
 	/* First we dump the read stream contents to file cache */
-	write_fd = get_new_fd_of_stream (self, TRUE, TRUE);
-	lseek (write_fd, 0, SEEK_SET);
-	write_stream = tny_fs_stream_new (write_fd);
+	write_stream = tny_fs_stream_new (afs_data->write_fd);
 	while (!tny_stream_is_eos (priv->fetch_stream)) {
 		gssize readed, written;
 		char buffer[1024];
@@ -427,6 +424,8 @@
 		/* we begin retrieval of the stream to disk. This should be cancellable */
 		afs_data = g_slice_new0 (AsyncFetchStreamData);
 		afs_data->self = g_object_ref (result);
+		afs_data->write_fd = get_new_fd_of_stream (result, TRUE, TRUE);
+		lseek (afs_data->write_fd, 0, SEEK_SET);
 		g_thread_create (async_fetch_stream, afs_data, FALSE, NULL);
 	} else {
 		gchar *fullpath;


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