From: <svn...@op...> - 2009-03-25 14:03:42
|
Author: bellmich Date: Wed Mar 25 15:03:27 2009 New Revision: 1018 URL: http://libsyncml.opensync.org/changeset/1018 Log: libsoup HTTP servers must be shut down by the correct thread too. So the finalize function of HTTP transport implementations will use the transport thread for all connection related stuff. Modified: trunk/libsyncml/sml_transport.c trunk/libsyncml/transports/http_server.c Modified: trunk/libsyncml/sml_transport.c ============================================================================== --- trunk/libsyncml/sml_transport.c Wed Mar 25 11:57:13 2009 (r1017) +++ trunk/libsyncml/sml_transport.c Wed Mar 25 15:03:27 2009 (r1018) @@ -1088,7 +1088,10 @@ } /* FIXME: Is there a situation where no thread is present? */ - if (tsp->type != SML_TRANSPORT_HTTP_CLIENT && tsp->thread) + + /* OBEX */ + if (tsp->type != SML_TRANSPORT_HTTP_CLIENT && + tsp->type != SML_TRANSPORT_HTTP_SERVER && tsp->thread) _smlTransportStop(tsp); /* give all jobs a chance to finish cleanly */ @@ -1097,7 +1100,7 @@ unsigned int queueLength = smlQueueLength(tsp->command_queue); for (; i < queueLength; i++) { if (tsp->thread) { - /* HTTP client only */ + /* HTTP */ if (!smlThreadCallFunction( tsp->thread, smlTransportDispatchQueueCallback, @@ -1105,6 +1108,7 @@ error)) goto error; } else { + /* OBEX */ smlQueueDispatch(tsp->command_queue); } } @@ -1112,7 +1116,7 @@ if (!tsp->functions.finalize(tsp->transport_data, error)) goto error; - /* HTTP client only */ + /* HTTP */ if (tsp->thread) _smlTransportStop(tsp); Modified: trunk/libsyncml/transports/http_server.c ============================================================================== --- trunk/libsyncml/transports/http_server.c Wed Mar 25 11:57:13 2009 (r1017) +++ trunk/libsyncml/transports/http_server.c Wed Mar 25 15:03:27 2009 (r1018) @@ -457,9 +457,20 @@ /* save link for disconnect event */ link = linkenv->link; + /* signal disconnect to socket and potential client */ + if (linkenv->msg) + { + soup_message_set_status (linkenv->msg, SOUP_STATUS_SERVICE_UNAVAILABLE); +#ifdef HAVE_LIBSOUP22 + soup_message_io_unpause(linkenv->msg); +#else + soup_server_unpause_message(linkenv->env->server, linkenv->msg); +#endif + linkenv->msg = NULL; + } + /* cleanup */ smlTrace(TRACE_INTERNAL, "%s: free memory", __func__); - linkenv->msg = NULL; /* FIXME: ignored */ linkenv->env = NULL; link->link_data = NULL; smlSafeFree((gpointer *)&linkenv); @@ -511,6 +522,23 @@ return TRUE; } +static SmlBool smlTransportHttpServerCleanupSocket( + gpointer data, + SmlError **error) +{ + smlTrace(TRACE_ENTRY, "%s", __func__); + CHECK_ERROR_REF + smlAssert(data); + + SoupServer *server = data; + + soup_server_quit(server); + g_object_unref(server); + + smlTrace(TRACE_EXIT, "%s", __func__); + return TRUE; +} + static SmlBool smlTransportHttpServerFinalize(void *data, SmlError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, error); @@ -525,8 +553,13 @@ * then there is no server. * (e.g. failure after smlTransportHttpServerNew) */ - soup_server_quit(env->server); - g_object_unref(env->server); + if (!smlThreadCallFunction( + env->tsp->thread, + smlTransportHttpServerCleanupSocket, + env->server, + error)) + goto error; + env->server = NULL; } if (env->url) |