From: <svn...@op...> - 2009-10-05 12:03:25
|
Author: bellmich Date: Mon Oct 5 14:03:10 2009 New Revision: 1311 URL: http://libsyncml.opensync.org/changeset/1311 Log: fixed cleanup code free transport implementation if the transport was never initialized Modified: trunk/libsyncml/sml_transport.c Modified: trunk/libsyncml/sml_transport.c ============================================================================== --- trunk/libsyncml/sml_transport.c Fri Oct 2 17:07:09 2009 (r1310) +++ trunk/libsyncml/sml_transport.c Mon Oct 5 14:03:10 2009 (r1311) @@ -883,15 +883,27 @@ if (tsp->command_queue) smlQueueFree(tsp->command_queue); - //GError *error = NULL; - //if (tsp->transport_data && - // !tsp->functions.finalize(tsp->transport_data, &error)) - //{ - // g_warning("The library libsyncml cannot free the transport. %s", - // error->message); - // g_error_free(error); - // error = NULL; - //} + /* If transport_data is present + * then the transport implementation was not finalized. + * This means that the transport was never initialized. + * If the transport was never initialized + * then the transport implementation was never run + * by a special thread. + */ + + GError *error = NULL; + if (tsp->transport_data) + { + /* Check the correct state - never initialized. */ + smlAssert(!tsp->thread); + if (!tsp->functions.finalize(tsp->transport_data, &error)) + { + g_warning("The library libsyncml cannot finalize the transport implementation. %s", + error->message); + g_error_free(error); + error = NULL; + } + } if (tsp->context) g_main_context_unref(tsp->context); |