Bug#442894: patches
Leszek Koltunski
leszek at 3miasto.net.pl
Fri Jan 11 10:18:21 UTC 2008
001 - enable nautilus workaround ( makes those irritating disconnections
much more scarce ) In reality, this is just a workaround and the real
reason for disconnections is still unknown. This also has the downside
that it is now not possible to interrupt an FS transaction. ( but that
didn't really work before anyway )
full story:
https://bugs.launchpad.net/gnome-vfs-obexftp/+bug/121514
https://bugs.launchpad.net/gnome-vfs-obexftp/+bug/140478
002 - speed optimizations in obex-method.c ( previous version catched
listing of only one directory , this one catches everything. Also some
other minor optimizations ) Probably could be split into two patches:
'multiple cache' and 'other minor things'
full story:
https://bugs.launchpad.net/gnome-vfs-obexftp/+bug/140480
https://bugs.launchpad.net/gnome-vfs-obexftp/+bug/140437
https://bugs.launchpad.net/gnome-vfs-obexftp/+bug/140509
003 - fix of a bug in om-utils which caused slowdowns. If this patch is
not applied, MULTIPLE_CACHE will not really work.
full story:
https://bugs.launchpad.net/gnome-vfs-obexftp/+bug/140446
REMARKS:
this version works much better on my Nokia 6260: browsing is faster,
copying files around does not fail, disconnections are gone. I however
didn't really test things like deleting a file or moving it around the
obexftp vfs.
-------------- next part --------------
--- src/obex-method.c.orig 2007-09-20 23:56:58.000000000 +0800
+++ src/obex-method.c 2008-01-11 17:55:42.000000000 +0800
@@ -40,6 +40,7 @@
#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/dbus.h>
+#define ENABLE_NAUTILUS_WORKAROUND
/* For debug output (like errors/warnings). */
#define d(x) x
-------------- next part --------------
--- src/obex-method.c.orig 2008-01-11 17:55:42.000000000 +0800
+++ src/obex-method.c 2008-01-11 17:55:45.000000000 +0800
@@ -41,6 +41,8 @@
#include <dbus/dbus.h>
#define ENABLE_NAUTILUS_WORKAROUND
+#define MULTIPLE_CACHE
+
/* For debug output (like errors/warnings). */
#define d(x) x
@@ -70,8 +72,11 @@
GwObex *obex;
gchar *current_dir;
+#ifdef MULTIPLE_CACHE
+ GList *cache;
+#else
GList *current_listing;
-
+#endif
/* This mutex is used to make sure only one thread tries to execute an
* action over the obex link.
*/
@@ -109,6 +114,13 @@
GList *current;
} DirectoryHandle;
+#ifdef MULTIPLE_CACHE
+typedef struct {
+ GList *listing;
+ gchar *dir;
+} CachedListing;
+#endif
+
typedef struct {
GnomeVFSURI *uri;
GnomeVFSMonitorType monitor_type;
@@ -268,9 +280,7 @@
g_free (conn->current_dir);
g_free (conn->file_name);
- if (conn->current_listing) {
- gnome_vfs_file_info_list_free (conn->current_listing);
- }
+ om_connection_invalidate_cache(conn);
g_mutex_free (conn->mutex);
g_free (conn);
@@ -305,11 +315,75 @@
static void
om_connection_invalidate_cache (ObexConnection *conn)
{
- /* Invalidate the folder listing cache. */
- if (conn->current_listing) {
- gnome_vfs_file_info_list_free (conn->current_listing);
- conn->current_listing = NULL;
- }
+#ifdef MULTIPLE_CACHE
+GList* l;
+
+for(l=conn->cache; l; l=l->next)
+ {
+ CachedListing *cl = l->data;
+
+ gnome_vfs_file_info_list_free(cl->listing);
+
+ g_free(cl->dir);
+ g_free(cl);
+ }
+
+g_list_free(conn->cache);
+conn->cache = NULL;
+
+#else
+if (conn->current_listing)
+ {
+ gnome_vfs_file_info_list_free (conn->current_listing);
+ conn->current_listing = NULL;
+ }
+#endif
+}
+
+static GList*
+om_connection_return_cached_listing(ObexConnection *conn,
+ gchar *path)
+{
+#ifdef MULTIPLE_CACHE
+GList *l;
+
+for(l=conn->cache; l; l=l->next)
+ {
+ CachedListing *cl= l->data;
+
+ if( strcmp(cl->dir,path)==0 )
+ {
+ return cl->listing;
+ }
+ }
+
+#else
+if( conn->current_dir && conn->current_listing!=NULL && strcmp(path,conn->current_dir)==0 )
+ {
+ return conn->current_listing;
+ }
+#endif
+
+return NULL;
+}
+
+static void
+om_connection_add_cached_listing(ObexConnection *conn,
+ gchar *path,
+ GList *cache)
+{
+#ifdef MULTIPLE_CACHE
+CachedListing* new_cl = g_new (CachedListing,1);
+
+new_cl->dir = g_strdup(path);
+new_cl->listing = gnome_vfs_file_info_list_copy(cache);
+
+conn->cache = g_list_append( conn->cache, new_cl );
+
+#else
+om_connection_invalidate_cache (conn);
+conn->current_listing = gnome_vfs_file_info_list_copy (cache);
+#endif
}
static GnomeVFSResult
@@ -623,17 +697,21 @@
path = om_utils_get_path_from_uri (uri);
}
- if (path && conn->current_dir &&
- strcmp (path, conn->current_dir) == 0 &&
- conn->current_listing != NULL) {
- if (list) {
- *list = gnome_vfs_file_info_list_copy (conn->current_listing);
- }
-
- g_free (path);
- return GNOME_VFS_OK;
- }
- g_free (path);
+ if (path)
+ {
+ GList* tmp = om_connection_return_cached_listing(conn,path);
+
+ if( tmp )
+ {
+ if (list)
+ {
+ *list = gnome_vfs_file_info_list_copy (tmp);
+ }
+
+ g_free (path);
+ return GNOME_VFS_OK;
+ }
+ }
/* Chdir to the correct path */
result = om_chdir_to_uri (conn, uri, parent_list);
@@ -664,11 +742,9 @@
return GNOME_VFS_ERROR_INTERNAL;
}
- /* Free the old cached list */
- om_connection_invalidate_cache (conn);
+ om_connection_add_cached_listing(conn,path,elements);
+ g_free(path);
- conn->current_listing = gnome_vfs_file_info_list_copy (elements);
-
if (list) {
*list = elements;
}
@@ -693,7 +769,7 @@
return GNOME_VFS_OK;
}
- om_connection_invalidate_cache (conn);
+ //om_connection_invalidate_cache (conn);
g_free (conn->current_dir);
conn->current_dir = NULL;
@@ -883,6 +959,8 @@
return result;
}
+ om_connection_invalidate_cache(conn);
+
om_set_cancel_context (conn, context);
result = om_chdir_to_uri (conn, uri, TRUE);
if (result != GNOME_VFS_OK) {
@@ -1252,23 +1330,10 @@
return GNOME_VFS_ERROR_INVALID_URI;
}
- conn = om_get_connection (uri, &result);
- if (!conn) {
- return result;
- }
-
/* Special-case the root. */
if (strcmp (path, "/") == 0) {
g_free (path);
- result = om_get_folder_listing (conn, uri, FALSE, context,
- NULL);
- om_connection_unref (conn);
-
- if (result != GNOME_VFS_OK) {
- return result;
- }
-
file_info->valid_fields = GNOME_VFS_FILE_INFO_FIELDS_NONE;
file_info->name = g_strdup ("/");
@@ -1283,6 +1348,11 @@
g_free (path);
+ conn = om_get_connection (uri, &result);
+ if (!conn) {
+ return result;
+ }
+
result = om_get_folder_listing (conn, uri, TRUE, context, &elements);
if (result != GNOME_VFS_OK) {
om_connection_unref (conn);
-------------- next part --------------
--- src/om-utils.c.orig 2007-09-20 23:56:58.000000000 +0800
+++ src/om-utils.c 2008-01-11 12:38:38.000000000 +0800
@@ -107,23 +107,15 @@
{
GnomeVFSURI *parent;
gchar *parent_path;
- gchar *tmp;
parent = gnome_vfs_uri_get_parent (uri);
if (parent == NULL) {
return NULL;
}
- tmp = om_utils_get_path_from_uri (parent);
- gnome_vfs_uri_unref (parent);
-
- if (tmp == NULL) {
- return NULL;
- }
-
- parent_path = g_strconcat (tmp, "/", NULL);
+ parent_path = om_utils_get_path_from_uri (parent);
- g_free (tmp);
+ gnome_vfs_uri_unref (parent);
return parent_path;
}
More information about the pkg-gnome-maintainers
mailing list