After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 702775 - Use libsoup directly for HTTP GET requests
Use libsoup directly for HTTP GET requests
Status: RESOLVED FIXED
Product: geocode-glib
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: geocode-glib maintainer(s)
geocode-glib maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-06-20 20:26 UTC by Zeeshan Ali
Modified: 2013-07-26 00:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
lib: Make use of g_clear_pointer() (945 bytes, patch)
2013-06-20 20:26 UTC, Zeeshan Ali
committed Details | Review
lib: Use libsoup directly for HTTP GET requests (15.04 KB, patch)
2013-06-20 20:26 UTC, Zeeshan Ali
needs-work Details | Review
lib: Use libsoup directly for HTTP GET requests (15.30 KB, patch)
2013-06-23 16:40 UTC, Zeeshan Ali
needs-work Details | Review
lib: Use libsoup directly for HTTP GET requests (15.25 KB, patch)
2013-06-24 20:20 UTC, Zeeshan Ali
accepted-commit_now Details | Review
lib: Use libsoup directly for HTTP GET requests (16.09 KB, patch)
2013-07-23 19:44 UTC, Zeeshan Ali
committed Details | Review

Description Zeeshan Ali 2013-06-20 20:26:06 UTC
See patches
Comment 1 Zeeshan Ali 2013-06-20 20:26:09 UTC
Created attachment 247383 [details] [review]
lib: Make use of g_clear_pointer()

We are doing that already in geocode-forward to free the hashtable.
Comment 2 Zeeshan Ali 2013-06-20 20:26:15 UTC
Created attachment 247384 [details] [review]
lib: Use libsoup directly for HTTP GET requests

We should be doing this anyways, libsoup being our direct dependency but
this patch also avoids the issue of reverse geocoding testcase hanging
becuase of some gvfs bug.
Comment 3 Bastien Nocera 2013-06-21 08:22:00 UTC
Review of attachment 247383 [details] [review]:

++
Comment 4 Bastien Nocera 2013-06-21 08:25:34 UTC
Review of attachment 247384 [details] [review]:

::: geocode-glib/geocode-forward.c
@@ +79,3 @@
 	forward->priv->ht = g_hash_table_new_full (g_str_hash, g_str_equal,
 						   g_free, g_free);
+        forward->priv->soup_session = soup_session_async_new ();

"soup_session_async_new is deprecated and should not be used in newly-written code. SoupSessionAsync is deprecated; use a plain SoupSession, created with soup_session_new(). See the porting guide."

@@ +80,3 @@
 						   g_free, g_free);
+        forward->priv->soup_session = soup_session_async_new ();
+        soup_session_add_feature_by_type (forward->priv->soup_session, SOUP_TYPE_PROXY_RESOLVER_DEFAULT);

That's not needed:
"Note that a SoupProxyResolverDefault and a SoupContentDecoder are added to the session by default (unless you are using one of the deprecated session subclasses)."

@@ +332,3 @@
 		g_object_set_data (G_OBJECT (query), "is-search",
 				   g_object_get_data (G_OBJECT (cache), "is-search"));
+                g_object_ref (query); // soup_session_queue_message steals ref

No C++ style comments.

::: geocode-glib/geocode-reverse.c
@@ +75,3 @@
 	object->priv->ht = g_hash_table_new_full (g_str_hash, g_str_equal,
 						  g_free, g_free);
+        object->priv->soup_session = soup_session_async_new ();

Ditto.

@@ +76,3 @@
 						  g_free, g_free);
+        object->priv->soup_session = soup_session_async_new ();
+        soup_session_add_feature_by_type (object->priv->soup_session, SOUP_TYPE_PROXY_RESOLVER_DEFAULT);

Ditto.
Comment 5 Zeeshan Ali 2013-06-23 16:16:04 UTC
In my defence, I just followed Alex' similar comment from Boxes repo. :)
Comment 6 Zeeshan Ali 2013-06-23 16:16:18 UTC
(In reply to comment #5)
> In my defence, I just followed Alex' similar comment from Boxes repo. :)

comment -> commit
Comment 7 Zeeshan Ali 2013-06-23 16:40:27 UTC
Created attachment 247568 [details] [review]
lib: Use libsoup directly for HTTP GET requests

We should be doing this anyways, libsoup being our direct dependency but
this patch also avoids the issue of reverse geocoding testcase hanging
becuase of some gvfs bug.

At the same time, this change reveals that our reverse geocoding API is
not working anymore since the Yahoo web API we rely on does not seem to
be available anymore.
Comment 8 Bastien Nocera 2013-06-24 08:31:37 UTC
Review of attachment 247568 [details] [review]:

::: geocode-glib/geocode-forward.c
@@ +333,3 @@
 		g_object_set_data (G_OBJECT (query), "is-search",
 				   g_object_get_data (G_OBJECT (cache), "is-search"));
+                g_object_ref (query); /* soup_session_queue_message steals ref */

And why do you need it around? The query will drop its last reference at the end of the callback function.

::: geocode-glib/geocode-glib-private.h
@@ +54,3 @@
+gboolean _geocode_glib_cache_load (SoupMessage *query,
+                                   char       **contents);
+GHashTable *_geocode_glib_dup_hash_table (GHashTable *ht);

This isn't in this patch.

::: geocode-glib/geocode-reverse.c
@@ +361,2 @@
 		query = g_object_get_data (G_OBJECT (cache), "query");
+                g_object_ref (query); /* soup_session_queue_message steals ref */

Same comment as earlier.
Comment 9 Bastien Nocera 2013-06-24 08:34:00 UTC
Comment on attachment 247383 [details] [review]
lib: Make use of g_clear_pointer()

Attachment 247383 [details] pushed as 201c251 - lib: Make use of g_clear_pointer()
Comment 10 Zeeshan Ali 2013-06-24 20:15:18 UTC
Review of attachment 247568 [details] [review]:

::: geocode-glib/geocode-forward.c
@@ +333,3 @@
 		g_object_set_data (G_OBJECT (query), "is-search",
 				   g_object_get_data (G_OBJECT (cache), "is-search"));
+                g_object_ref (query); /* soup_session_queue_message steals ref */

Because the cache GFile instance is going to be unrefed when this callback function returns and that will also unref the only ref we have of 'query' instance:

               g_object_set_data_full (G_OBJECT (cache), "query", query, (GDestroyNotify) g_object_unref);
                g_file_load_contents_async (cache,
                                            cancellable,
                                            on_cache_data_loaded,
                                            simple);
                g_object_unref (cache);
Comment 11 Zeeshan Ali 2013-06-24 20:20:34 UTC
Created attachment 247681 [details] [review]
lib: Use libsoup directly for HTTP GET requests

We should be doing this anyways, libsoup being our direct dependency but
this patch also avoids the issue of reverse geocoding testcase hanging
becuase of some gvfs bug.

At the same time, this change reveals that our reverse geocoding API is
not working anymore since the Yahoo web API we rely on does not seem to
be available anymore.
Comment 12 Bastien Nocera 2013-07-23 16:24:29 UTC
Review of attachment 247681 [details] [review]:

Looks fine if it's valgrind clean and passes the tests.
Comment 13 Zeeshan Ali 2013-07-23 19:44:44 UTC
Created attachment 249937 [details] [review]
lib: Use libsoup directly for HTTP GET requests

Rerunning test case pointed out to error not being set in certain cases and redundant NULL checks. Fixed those in this version. Ran the test case inside valgrind but it didn't report anything unusual and number of errors (i dont have any suppressions files for glib/gobject here) reduced actually with this patch.
Comment 14 Zeeshan Ali 2013-07-26 00:23:31 UTC
Attachment 249937 [details] pushed as d00059f - lib: Use libsoup directly for HTTP GET requests

Rebased on top of git master and pushed.