[gvfs] ftp: Remove custom progress callback rate limiting



commit cf884c045b939f2ec148ae0b9c69d123b55fef4e
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Tue Dec 3 21:36:30 2013 +0000

    ftp: Remove custom progress callback rate limiting
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719807

 daemon/gvfsbackendftp.c |   92 ++++-------------------------------------------
 1 files changed, 7 insertions(+), 85 deletions(-)
---
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 80a2f9a..c28bf84 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -1398,19 +1398,6 @@ out:
   g_vfs_ftp_task_done (&task);
 }
 
-static void
-cancel_timer_cb (GCancellable *orig, GCancellable *to_cancel)
-{
-  g_cancellable_cancel (to_cancel);
-}
-
-static gboolean
-cancel_cancellable (gpointer cancellable)
-{
-  g_cancellable_cancel (cancellable);
-  return FALSE;
-}
-
 static gssize
 ftp_output_stream_splice (GOutputStream *output,
                           GInputStream *input,
@@ -1423,96 +1410,31 @@ ftp_output_stream_splice (GOutputStream *output,
   gssize n_read, n_written;
   gssize bytes_copied;
   char buffer[8192], *p;
-  GCancellable *current, *timer_cancel;
-  gulong cancel_cb_id;
-
-  timer_cancel = NULL;
-  cancel_cb_id = 0;
 
   bytes_copied = 0;
-  if (progress_callback)
-    {
-      timer_cancel = g_cancellable_new ();
-      cancel_cb_id = g_cancellable_connect (cancellable, 
-                                            G_CALLBACK (cancel_timer_cb),
-                                            timer_cancel,
-                                            NULL);
-    }
-  current = cancellable;
   for (;;) 
     {
-      n_read = g_input_stream_read (input, buffer, sizeof (buffer), current, error);
+      n_read = g_input_stream_read (input, buffer, sizeof (buffer), cancellable, error);
       if (n_read == -1)
-        {
-          if (g_cancellable_is_cancelled (timer_cancel) &&
-              !g_cancellable_is_cancelled (cancellable))
-            {
-              g_cancellable_reset (timer_cancel);
-              current = cancellable;
-              g_clear_error (error);
-              if (progress_callback)
-                progress_callback (bytes_copied, total_size, progress_callback_data);
-              continue;
-            }
-          else
-            {
-              bytes_copied = -1;
-              break;
-            }
-          g_assert_not_reached();
-        }
+        return -1;
       if (n_read == 0)
         break;
 
       p = buffer;
       while (n_read > 0)
         {
-          n_written = g_output_stream_write (output, p, n_read, current, error);
+          n_written = g_output_stream_write (output, p, n_read, cancellable, error);
           if (n_written == -1)
-            {
-              if (g_cancellable_is_cancelled (timer_cancel) &&
-                  !g_cancellable_is_cancelled (cancellable))
-                {
-                  g_cancellable_reset (timer_cancel);
-                  current = cancellable;
-                  g_clear_error (error);
-                  if (progress_callback)
-                    progress_callback (bytes_copied, total_size, progress_callback_data);
-                  continue;
-                }
-              else
-                {
-                  bytes_copied = -1;
-                  break;
-                }
-              g_assert_not_reached();
-            }
+            return -1;
 
           p += n_written;
           n_read -= n_written;
           bytes_copied += n_written;
-          if (progress_callback && current != timer_cancel)
-            {
-              g_object_ref (timer_cancel);
-              g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
-                                          1,
-                                          cancel_cancellable,
-                                          timer_cancel,
-                                          g_object_unref);
-              current = timer_cancel;
-            }
-        }
-    }
 
-  if (timer_cancel != NULL)
-    {
-      /* no need to remove the timeout, it'll remove itself fine and we
-       * don't get into races that way */
-      g_cancellable_disconnect (cancellable, cancel_cb_id);
-      g_object_unref (timer_cancel);
+          if (progress_callback)
+            progress_callback (bytes_copied, total_size, progress_callback_data);
+        }
     }
-  if (bytes_copied >= 0 && progress_callback)
-    progress_callback (bytes_copied, total_size, progress_callback_data);
 
   return bytes_copied;
 }


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