summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2013-12-03 21:36:30 +0000
committerRoss Lagerwall <rosslagerwall@gmail.com>2014-01-23 10:27:46 +0200
commitcf884c045b939f2ec148ae0b9c69d123b55fef4e (patch)
treee20cebe7623ae6d9e45e64ea1175785dc6b8d27d /daemon
parent44b66a906c302bd1340fe22b0f6d39f7be6f403e (diff)
downloadgvfs-cf884c045b939f2ec148ae0b9c69d123b55fef4e.tar.gz
ftp: Remove custom progress callback rate limiting
https://bugzilla.gnome.org/show_bug.cgi?id=719807
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsbackendftp.c92
1 files changed, 7 insertions, 85 deletions
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 80a2f9a4..c28bf84f 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;
}