diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-04-27 05:21:39 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-04-27 05:26:34 +0800 |
commit | 1b2104e0b4cb400f0ed46df8ded421ac339e7981 (patch) | |
tree | c093edb4d14e7e578bdd0bed84725e1f01d23895 /modules | |
parent | 09e483b450ae62d344936f54ee666d461166be21 (diff) | |
download | gsoc2013-evolution-1b2104e0b4cb400f0ed46df8ded421ac339e7981.tar gsoc2013-evolution-1b2104e0b4cb400f0ed46df8ded421ac339e7981.tar.gz gsoc2013-evolution-1b2104e0b4cb400f0ed46df8ded421ac339e7981.tar.bz2 gsoc2013-evolution-1b2104e0b4cb400f0ed46df8ded421ac339e7981.tar.lz gsoc2013-evolution-1b2104e0b4cb400f0ed46df8ded421ac339e7981.tar.xz gsoc2013-evolution-1b2104e0b4cb400f0ed46df8ded421ac339e7981.tar.zst gsoc2013-evolution-1b2104e0b4cb400f0ed46df8ded421ac339e7981.zip |
EGravatarPhotoSource: Work around libsoup deadlocks.
The SoupRequest API seems to have some concurrency issues to work out,
so for the time being create a unique SoupSession for each SoupRequest.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gravatar/e-gravatar-photo-source.c | 43 |
1 files changed, 7 insertions, 36 deletions
diff --git a/modules/gravatar/e-gravatar-photo-source.c b/modules/gravatar/e-gravatar-photo-source.c index eb6e653130..655046cd14 100644 --- a/modules/gravatar/e-gravatar-photo-source.c +++ b/modules/gravatar/e-gravatar-photo-source.c @@ -30,10 +30,6 @@ typedef struct _AsyncContext AsyncContext; -struct _EGravatarPhotoSourcePrivate { - SoupSession *soup_session; -}; - struct _AsyncContext { gchar *email_address; GInputStream *stream; @@ -66,16 +62,15 @@ gravatar_photo_source_get_photo_thread (GSimpleAsyncResult *simple, GObject *source_object, GCancellable *cancellable) { - EGravatarPhotoSourcePrivate *priv; AsyncContext *async_context; SoupRequester *requester; SoupRequest *request; + SoupSession *session; GInputStream *stream = NULL; gchar *hash; gchar *uri; GError *local_error = NULL; - priv = E_GRAVATAR_PHOTO_SOURCE_GET_PRIVATE (source_object); async_context = g_simple_async_result_get_op_res_gpointer (simple); hash = e_gravatar_get_hash (async_context->email_address); @@ -84,8 +79,10 @@ gravatar_photo_source_get_photo_thread (GSimpleAsyncResult *simple, g_debug ("Requesting avatar for %s", async_context->email_address); g_debug ("%s", uri); - requester = (SoupRequester *) soup_session_get_feature ( - priv->soup_session, SOUP_TYPE_REQUESTER); + session = soup_session_sync_new (); + + requester = soup_requester_new (); + soup_session_add_feature (session, SOUP_SESSION_FEATURE (requester)); /* We control the URI so there should be no error. */ request = soup_requester_request (requester, uri, NULL); @@ -131,27 +128,15 @@ gravatar_photo_source_get_photo_thread (GSimpleAsyncResult *simple, g_debug ("Request complete"); + g_clear_object (&requester); g_clear_object (&request); + g_clear_object (&session); g_free (hash); g_free (uri); } static void -gravatar_photo_source_dispose (GObject *object) -{ - EGravatarPhotoSourcePrivate *priv; - - priv = E_GRAVATAR_PHOTO_SOURCE_GET_PRIVATE (object); - - g_clear_object (&priv->soup_session); - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (e_gravatar_photo_source_parent_class)-> - dispose (object); -} - -static void gravatar_photo_source_get_photo (EPhotoSource *photo_source, const gchar *email_address, GCancellable *cancellable, @@ -215,12 +200,6 @@ gravatar_photo_source_get_photo_finish (EPhotoSource *photo_source, static void e_gravatar_photo_source_class_init (EGravatarPhotoSourceClass *class) { - GObjectClass *object_class; - - g_type_class_add_private (class, sizeof (EGravatarPhotoSourcePrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->dispose = gravatar_photo_source_dispose; } static void @@ -238,14 +217,6 @@ e_gravatar_photo_source_interface_init (EPhotoSourceInterface *interface) static void e_gravatar_photo_source_init (EGravatarPhotoSource *photo_source) { - photo_source->priv = - E_GRAVATAR_PHOTO_SOURCE_GET_PRIVATE (photo_source); - - photo_source->priv->soup_session = soup_session_sync_new (); - - soup_session_add_feature_by_type ( - photo_source->priv->soup_session, - SOUP_TYPE_REQUESTER); } void |