diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-14 09:49:44 (GMT) |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-14 09:49:44 (GMT) |
commit | b4121d824b8f8453db88d4e9a05e141ee7c6acb9 (patch) | |
tree | aecc12ce20b5147adc55d7ba51ae8c4257d3ab05 /src/lib.c | |
parent | abcaa6d33f1a993b3e07b66889d86b44700b7c14 (diff) | |
download | soup-transcoding-proxy-b4121d824b8f8453db88d4e9a05e141ee7c6acb9.zip soup-transcoding-proxy-b4121d824b8f8453db88d4e9a05e141ee7c6acb9.tar.gz |
server: Fix cleanup of clients
On forced server abort, as well as normal exit
Diffstat (limited to 'src/lib.c')
-rw-r--r-- | src/lib.c | 35 |
1 files changed, 16 insertions, 19 deletions
@@ -22,8 +22,7 @@ #include "lib.h" -static void -stp_shutdown_client (TranscodeClientCtx *ctx); +static void stp_disconnect_cleanup_client (TranscodeClientCtx *ctx); gboolean stp_on_gst_bus_message (GstBus *bus, @@ -67,13 +66,13 @@ stp_cleanup_transcode_server_ctx (TranscodeServerCtx *ctx) { g_print (">>> Doing server cleanup\n"); - g_list_foreach (ctx->clients, (GFunc)stp_shutdown_client, NULL); + /* Disconnect and free the context for each client */ + g_list_foreach (ctx->clients, (GFunc)stp_disconnect_cleanup_client, NULL); g_list_free (ctx->clients); /* Cleanup gstreamer pipeline */ gst_element_set_state (ctx->pipeline, GST_STATE_NULL); gst_object_unref (ctx->pipeline); - g_free (ctx->path); g_free (ctx); } @@ -92,16 +91,15 @@ pad_blocked_cleanup_cb (GstPad *srcpad, tee = gst_pad_get_parent_element (srcpad); gst_pad_unlink (srcpad, ctx->ghostsinkpad); - gst_element_remove_pad (tee, srcpad); + gst_element_release_request_pad (tee, srcpad); gst_object_unref (srcpad); gst_object_unref (tee); gst_element_set_state (sinkbin, GST_STATE_NULL); gst_bin_remove (GST_BIN (ctx->server_ctx->pipeline), sinkbin); gst_object_unref (sinkbin); - gst_object_unref (ctx->appsink); - g_free (ctx); + g_mutex_clear (&ctx->can_write_chunk); g_print (" Client cleanup done!\n"); return GST_PAD_PROBE_OK; } @@ -128,27 +126,26 @@ stp_cleanup_transcode_client_ctx (TranscodeClientCtx *ctx) gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_BLOCK, (GstPadProbeCallback) pad_blocked_cleanup_cb, - ctx, NULL); + ctx, (GDestroyNotify)g_free); gst_object_unref (sinkbin); g_print ("."); } -/* When shutting down a client due to a server shutdown, we - * don't need to bother with removing the appsink branch of - * the pipeline, and the response is set by the "eos" callback - * on the appsink, so we just free the context */ +/* When shutting down a client due to a server shutdown, + * we just need to remove the client timeout handler and + * free the context. The rest is owned by the pipeline. */ static void -stp_shutdown_client (TranscodeClientCtx *ctx) +stp_disconnect_cleanup_client (TranscodeClientCtx *ctx) { - TranscodeServerCtx *server_ctx = ctx->server_ctx; + g_print (">>> Disconnecting client on server shutdown\n"); - g_print (">>> Doing client cleanup on server shutdown\n"); + /* FIXME: This isn't actually setting the status for client + * connections, and clients are just left hanging */ + soup_message_set_status (ctx->msg, SOUP_STATUS_GONE); + soup_message_body_complete (ctx->msg->response_body); g_source_remove (ctx->timeout_handler_id); - - server_ctx->clients = g_list_remove (server_ctx->clients, ctx); - - gst_object_unref (ctx->appsink); + g_mutex_clear (&ctx->can_write_chunk); g_free (ctx); } |