From: <svn...@op...> - 2009-03-25 08:54:08
|
Author: bellmich Date: Wed Mar 25 09:54:02 2009 New Revision: 1014 URL: http://libsyncml.opensync.org/changeset/1014 Log: smlTransportFinalize calls the finalize function of the transport implementations directly. The http implementations depend on the correct thread because libsoup is single-threaded (at minimum in case of the http client). This means that the worker thread must be available until all connections are closed (disconnected or finalized). Therefore the finalize function of a transport implementation must be called within the worker thread and the thread must be shut down after the finalize function was called. Modified: trunk/libsyncml/sml_transport.c Modified: trunk/libsyncml/sml_transport.c ============================================================================== --- trunk/libsyncml/sml_transport.c Tue Mar 24 18:58:49 2009 (r1013) +++ trunk/libsyncml/sml_transport.c Wed Mar 25 09:54:02 2009 (r1014) @@ -1044,6 +1044,18 @@ } } +static SmlBool smlTransportDispatchQueueCallback( + gpointer data, + SmlError **error) +{ + smlTrace(TRACE_ENTRY, "%s", __func__); + CHECK_ERROR_REF + smlAssert(data); + SmlQueue *queue = data; + smlQueueDispatch(queue); + smlTrace(TRACE_EXIT, "%s", __func__); + return TRUE; +} /** @brief Finalizes the transport * @@ -1075,20 +1087,21 @@ goto error; } - if (tsp->thread) { - _smlTransportStop(tsp); - } - - smlQueueDetach(tsp->command_queue); - /* give all jobs a chance to finish cleanly */ + smlQueueDetach(tsp->command_queue); int i = 0; unsigned int queueLength = smlQueueLength(tsp->command_queue); - for (; i < queueLength; i++) - smlQueueDispatch(tsp->command_queue); + for (; i < queueLength; i++) { + if (!smlThreadCallFunction(tsp->thread, smlTransportDispatchQueueCallback, tsp->command_queue, error)) + goto error; + } if (!tsp->functions.finalize(tsp->transport_data, error)) goto error; + + if (tsp->thread) + _smlTransportStop(tsp); + tsp->transport_data = NULL; tsp->state = SML_TRANSPORT_UNINITIALIZED; |