From 8db5c13fe1895625a80d66ce2aef376cae6e9f8f Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 28 Sep 2010 18:41:58 -0400 Subject: [PATCH 2/2] Add assertions to ensure async resources are freed Add assertions to make sure async resources GCancellable and GSimpleAsyncResult are freed before a new async calls are attempted. --- wocky/wocky-openssl.c | 1 + wocky/wocky-porter.c | 4 ++++ wocky/wocky-tls-connector.c | 1 + wocky/wocky-tls.c | 1 + 4 files changed, 7 insertions(+), 0 deletions(-) diff --git a/wocky/wocky-openssl.c b/wocky/wocky-openssl.c index 7e045d9..ba618c0 100644 --- a/wocky/wocky-openssl.c +++ b/wocky/wocky-openssl.c @@ -626,6 +626,7 @@ wocky_tls_job_start (WockyTLSJob *job, gpointer source_tag) { g_assert (job->active == FALSE); + g_assert (job->cancellable == NULL); /* this is always a circular reference, so it will keep the * session alive for as long as the job is running. diff --git a/wocky/wocky-porter.c b/wocky/wocky-porter.c index f7a2b05..d83c035 100644 --- a/wocky/wocky-porter.c +++ b/wocky/wocky-porter.c @@ -1418,6 +1418,8 @@ wocky_porter_close_async (WockyPorter *self, priv->close_result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, wocky_porter_close_async); + g_assert (priv->close_cancellable == NULL); + if (cancellable != NULL) priv->close_cancellable = g_object_ref (cancellable); @@ -1835,6 +1837,8 @@ wocky_porter_force_close_async (WockyPorter *self, priv->force_close_result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, wocky_porter_force_close_async); + g_assert (priv->force_close_cancellable == NULL); + if (cancellable != NULL) priv->force_close_cancellable = g_object_ref (cancellable); diff --git a/wocky/wocky-tls-connector.c b/wocky/wocky-tls-connector.c index 9d89406..f2876a5 100644 --- a/wocky/wocky-tls-connector.c +++ b/wocky/wocky-tls-connector.c @@ -460,6 +460,7 @@ wocky_tls_connector_secure_async (WockyTLSConnector *self, GSimpleAsyncResult *async_result; g_assert (self->priv->secure_result == NULL); + g_assert (self->priv->cancellable == NULL); async_result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, wocky_tls_connector_secure_async); diff --git a/wocky/wocky-tls.c b/wocky/wocky-tls.c index ca77e5c..714eaa8 100644 --- a/wocky/wocky-tls.c +++ b/wocky/wocky-tls.c @@ -460,6 +460,7 @@ wocky_tls_job_start (WockyTLSJob *job, gpointer source_tag) { g_assert (job->active == FALSE); + g_assert (job->cancellable == NULL); /* this is always a circular reference, so it will keep the * session alive for as long as the job is running. -- 1.7.3.3