/soc/2015/jgeboski/facebook: 1cbcea2165c1: facebook: ignore canc...

James Geboski jgeboski at gmail.com
Thu Aug 20 16:20:30 EDT 2015


Changeset: 1cbcea2165c172d578747555bb1b3c71b1f244c6
Author:	 James Geboski <jgeboski at gmail.com>
Date:	 2015-08-20 16:19 -0400
Branch:	 facebook
URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/1cbcea2165c1

Description:

facebook: ignore canceling HTTP requests

diffstat:

 libpurple/http.c                    |   7 +++++++
 libpurple/http.h                    |  10 ++++++++++
 libpurple/protocols/facebook/api.c  |   5 +++++
 libpurple/protocols/facebook/data.c |   5 +++++
 4 files changed, 27 insertions(+), 0 deletions(-)

diffs (67 lines):

diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -1755,6 +1755,13 @@ void purple_http_conn_cancel_all(PurpleC
 			"related to gc=%p (it shouldn't happen)\n", gc);
 }
 
+gboolean purple_http_conn_is_cancelling(PurpleHttpConnection *http_conn)
+{
+	if (http_conn == NULL)
+		return FALSE;
+	return http_conn->is_cancelling;
+}
+
 gboolean purple_http_conn_is_running(PurpleHttpConnection *http_conn)
 {
 	if (http_conn == NULL)
diff --git a/libpurple/http.h b/libpurple/http.h
--- a/libpurple/http.h
+++ b/libpurple/http.h
@@ -222,6 +222,16 @@ void purple_http_conn_cancel(PurpleHttpC
 void purple_http_conn_cancel_all(PurpleConnection *gc);
 
 /**
+ * purple_http_conn_is_cancelling:
+ * @http_conn: The HTTP connection (may be invalid pointer).
+ *
+ * Checks, if provided HTTP request is cancelling.
+ *
+ * Returns:          TRUE, if provided connection is currently cancelling.
+ */
+gboolean purple_http_conn_is_cancelling(PurpleHttpConnection *http_conn);
+
+/**
  * purple_http_conn_is_running:
  * @http_conn: The HTTP connection (may be invalid pointer).
  *
diff --git a/libpurple/protocols/facebook/api.c b/libpurple/protocols/facebook/api.c
--- a/libpurple/protocols/facebook/api.c
+++ b/libpurple/protocols/facebook/api.c
@@ -592,6 +592,11 @@ fb_api_http_chk(FbApi *api, PurpleHttpCo
 	gint code;
 	gsize size;
 
+	if (G_UNLIKELY(purple_http_conn_is_cancelling(con))) {
+		/* Ignore canceling HTTP requests */
+		return FALSE;
+	}
+
 	msg = purple_http_response_get_error(res);
 	code = purple_http_response_get_code(res);
 	data = purple_http_response_get_data(res, &size);
diff --git a/libpurple/protocols/facebook/data.c b/libpurple/protocols/facebook/data.c
--- a/libpurple/protocols/facebook/data.c
+++ b/libpurple/protocols/facebook/data.c
@@ -530,6 +530,11 @@ fb_data_image_cb(PurpleHttpConnection *c
 	FbDataImagePrivate *priv = img->priv;
 	GError *err = NULL;
 
+	if (G_UNLIKELY(purple_http_conn_is_cancelling(con))) {
+		/* Ignore canceling HTTP requests */
+		return;
+	}
+
 	fb_http_error_chk(res, &err);
 	priv->image = (guint8*) purple_http_response_get_data(res, &priv->size);
 	priv->func(img, err);



More information about the Commits mailing list