[gvfs] When a p2p connection is closed, cancel all pending jobs



commit f64b26a5762659d9eb24ab79c4e64acc8d35ee8e
Author: Benjamin Otte <otte gnome org>
Date:   Mon Jul 20 17:08:54 2009 +0200

    When a p2p connection is closed, cancel all pending jobs
    
    Not cancelling them caused long running jobs - like a GvfsJobPull for a
    multi-GB file on a remote ftp mount - to not stop running and finish
    downloading the file.

 daemon/gvfsdaemon.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsdaemon.c b/daemon/gvfsdaemon.c
index ef409b7..15fffc7 100644
--- a/daemon/gvfsdaemon.c
+++ b/daemon/gvfsdaemon.c
@@ -999,10 +999,25 @@ peer_to_peer_filter_func (DBusConnection *conn,
 			  DBusMessage    *message,
 			  gpointer        data)
 {
+  GVfsDaemon *daemon = data;
+
   if (dbus_message_is_signal (message,
 			      DBUS_INTERFACE_LOCAL,
 			      "Disconnected"))
     {
+      GList *l;
+
+      g_mutex_lock (daemon->lock);
+      for (l = daemon->jobs; l != NULL; l = l->next)
+        {
+          GVfsJob *job = l->data;
+          
+          if (G_VFS_IS_JOB_DBUS (job) &&
+              G_VFS_JOB_DBUS (job)->connection == conn)
+            g_vfs_job_cancel (job);
+        }
+      g_mutex_unlock (daemon->lock);
+
       /* The peer-to-peer connection was disconnected */
       dbus_connection_unref (conn);
       return DBUS_HANDLER_RESULT_HANDLED;



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