From ac278d5482e166167dc09880bccca560c9a5a9b6 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 28 Sep 2010 18:41:58 -0400 Subject: [PATCH 3/3] 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. --- tests/wocky-test-sasl-auth-server.c | 3 +++ wocky/wocky-openssl.c | 1 + wocky/wocky-porter.c | 6 ++++++ wocky/wocky-tls-connector.c | 1 + wocky/wocky-tls.c | 1 + 5 files changed, 12 insertions(+), 0 deletions(-) diff --git a/tests/wocky-test-sasl-auth-server.c b/tests/wocky-test-sasl-auth-server.c index 64d2c22..59b746c 100644 --- a/tests/wocky-test-sasl-auth-server.c +++ b/tests/wocky-test-sasl-auth-server.c @@ -1004,6 +1004,9 @@ test_sasl_auth_server_auth_async (GObject *obj, TestSaslAuthServer *self = TEST_SASL_AUTH_SERVER (obj); TestSaslAuthServerPrivate *priv = self->priv; + g_assert (priv->result == NULL); + g_assert (priv->cancellable == NULL); + /* we would normally expect this to be NULL in a take-over situation, but just in case: */ if (priv->conn != NULL) diff --git a/wocky/wocky-openssl.c b/wocky/wocky-openssl.c index 9e95872..86641f9 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 9874085..4ee1e0f 100644 --- a/wocky/wocky-porter.c +++ b/wocky/wocky-porter.c @@ -1418,6 +1418,9 @@ wocky_porter_close_async (WockyPorter *self, priv->close_result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, wocky_porter_close_async); + /* The cancellable must be NULL, otherwise it will be leaked */ + g_assert (priv->close_cancellable == NULL); + if (cancellable != NULL) priv->close_cancellable = g_object_ref (cancellable); @@ -1836,6 +1839,9 @@ 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); + /* The cancellable must be NULL, otherwise it will leak */ + 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 2d97f7f..ff6d367 100644 --- a/wocky/wocky-tls-connector.c +++ b/wocky/wocky-tls-connector.c @@ -452,6 +452,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 96d5dab..f9b4c2d 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.2.3