/pidgin/main: 43c34cda245d: HTTP: don't forget to notify about p...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Tue Nov 6 13:55:44 EST 2012


Changeset: 43c34cda245dcaff40668de848975e68779ffd41
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2012-11-06 19:55 +0100
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/43c34cda245d

Description:

HTTP: don't forget to notify about progress before connection freeze

diffstat:

 libpurple/http.c |  26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diffs (62 lines):

diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -111,6 +111,7 @@ struct _PurpleHttpConnection
 	gpointer watcher_user_data;
 	guint watcher_interval_threshold;
 	gint64 watcher_last_call;
+	guint watcher_delayed_handle;
 };
 
 struct _PurpleHttpResponse
@@ -1281,6 +1282,7 @@ PurpleHttpConnection * purple_http_reque
 /*** HTTP connection API ******************************************************/
 
 static void purple_http_connection_free(PurpleHttpConnection *hc);
+static gboolean purple_http_conn_notify_progress_watcher_timeout(gpointer _hc);
 
 static PurpleHttpConnection * purple_http_connection_new(
 	PurpleHttpRequest *request, PurpleConnection *gc)
@@ -1309,6 +1311,8 @@ static void purple_http_connection_free(
 {
 	if (hc->timeout_handle)
 		purple_timeout_remove(hc->timeout_handle);
+	if (hc->watcher_delayed_handle)
+		purple_timeout_remove(hc->watcher_delayed_handle);
 
 	purple_http_url_free(hc->url);
 	purple_http_request_unref(hc->request);
@@ -1449,12 +1453,32 @@ static void purple_http_conn_notify_prog
 
 	now = g_get_monotonic_time();
 	if (hc->watcher_last_call + hc->watcher_interval_threshold
-		> now && processed != total)
+		> now && processed != total) {
+		if (hc->watcher_delayed_handle)
+			return;
+		hc->watcher_delayed_handle = purple_timeout_add_seconds(
+			1 + hc->watcher_interval_threshold / 1000000,
+			purple_http_conn_notify_progress_watcher_timeout, hc);
 		return;
+	}
+
+	if (hc->watcher_delayed_handle)
+		purple_timeout_remove(hc->watcher_delayed_handle);
+	hc->watcher_delayed_handle = 0;
+
 	hc->watcher_last_call = now;
 	hc->watcher(hc, reading_state, processed, total, hc->watcher_user_data);
 }
 
+static gboolean purple_http_conn_notify_progress_watcher_timeout(gpointer _hc)
+{
+	PurpleHttpConnection *hc = _hc;
+
+	purple_http_conn_notify_progress_watcher(hc);
+
+	return FALSE;
+}
+
 /*** Cookie jar API ***********************************************************/
 
 static PurpleHttpCookie * purple_http_cookie_new(const gchar *value);



More information about the Commits mailing list