Commit 3b35bd71 authored by Debarshi Ray's avatar Debarshi Ray

ewsclient: httpclient: Don't crash or deadlock during clean up

Clean up the SoupSession and associated data from the correct thread
and GMainContext, and do so before completing the operation.

Fixes: https://bugzilla.gnome.org/743044
parent cc65f145
......@@ -91,6 +91,8 @@ ews_client_autodiscover_data_free (gpointer user_data)
{
AutodiscoverData *data = user_data;
g_simple_async_result_complete_in_idle (data->res);
if (data->cancellable_id > 0)
{
g_cancellable_disconnect (data->cancellable, data->cancellable_id);
......@@ -338,9 +340,19 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
data->pending--;
if (data->pending == 0)
{
GMainContext *context;
GSource *source;
g_simple_async_result_set_op_res_gboolean (data->res, op_res);
g_simple_async_result_complete_in_idle (data->res);
g_idle_add (ews_client_autodiscover_data_free, data);
source = g_idle_source_new ();
g_source_set_priority (source, G_PRIORITY_DEFAULT_IDLE);
g_source_set_callback (source, ews_client_autodiscover_data_free, data, NULL);
g_source_set_name (source, "[goa] ews_client_autodiscover_data_free");
context = g_main_context_get_thread_default ();
g_source_attach (source, context);
g_source_unref (source);
}
}
......
......@@ -82,6 +82,8 @@ http_client_check_data_free (gpointer user_data)
{
CheckData *data = user_data;
g_simple_async_result_complete_in_idle (data->res);
if (data->cancellable_id > 0)
{
g_cancellable_disconnect (data->cancellable, data->cancellable_id);
......@@ -152,6 +154,8 @@ http_client_check_response_cb (SoupSession *session, SoupMessage *msg, gpointer
{
GError *error;
CheckData *data = user_data;
GMainContext *context;
GSource *source;
gboolean op_res;
error = NULL;
......@@ -182,8 +186,14 @@ http_client_check_response_cb (SoupSession *session, SoupMessage *msg, gpointer
if (error != NULL)
g_simple_async_result_take_error (data->res, error);
g_simple_async_result_complete_in_idle (data->res);
g_idle_add (http_client_check_data_free, data);
source = g_idle_source_new ();
g_source_set_priority (source, G_PRIORITY_DEFAULT_IDLE);
g_source_set_callback (source, http_client_check_data_free, data, NULL);
g_source_set_name (source, "[goa] http_client_check_data_free");
context = g_main_context_get_thread_default ();
g_source_attach (source, context);
g_source_unref (source);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment