summaryrefslogtreecommitdiff
path: root/src/lib.c
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2014-07-17 14:25:09 (GMT)
committerNirbheek Chauhan <nirbheek@centricular.com>2014-07-17 14:25:09 (GMT)
commit79ccdc559490bcdab6529dc74bba5d694e8d5913 (patch)
tree2d644e9063fa11f62cb3419037b3ca6727fc8f97 /src/lib.c
parent0a8517326c0bfb3416997aa24c525e9ce92fdd84 (diff)
downloadsoup-transcoding-proxy-79ccdc559490bcdab6529dc74bba5d694e8d5913.zip
soup-transcoding-proxy-79ccdc559490bcdab6529dc74bba5d694e8d5913.tar.gz
server: Fix another potential crash
Diffstat (limited to 'src/lib.c')
-rw-r--r--src/lib.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lib.c b/src/lib.c
index 062a8be..a986f30 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -31,6 +31,13 @@ invoke_g_hash_table_remove (TranscodeServerCtx *ctx)
return FALSE;
}
+static gboolean
+invoke_g_free_client_context (TranscodeClientCtx *ctx)
+{
+ g_free (ctx);
+ return FALSE;
+}
+
gboolean
stp_on_gst_bus_message (GstBus *bus,
GstMessage *msg,
@@ -132,6 +139,7 @@ stp_cleanup_transcode_client_ctx (TranscodeClientCtx *ctx)
stp_print_status (">>> Doing client cleanup.");
g_source_remove (ctx->timeout_handler_id);
+ ctx->timeout_handler_id = 0;
server_ctx->clients = g_list_remove (server_ctx->clients, ctx);
@@ -160,9 +168,16 @@ stp_disconnect_cleanup_client (TranscodeClientCtx *ctx)
soup_message_body_complete (ctx->msg->response_body);
g_source_remove (ctx->timeout_handler_id);
+ ctx->timeout_handler_id = 0;
/* Don't call the "finished" handler and do a double-free */
g_signal_handler_disconnect (ctx->msg, ctx->finished_handler_id);
- g_free (ctx);
+
+ /* There might still be functions which use the ctx waiting
+ * to be invoked on the next main context dispatch, so we
+ * free this at the end of all those dispatches. */
+ g_main_context_invoke_full (NULL, G_PRIORITY_LOW,
+ (GSourceFunc)invoke_g_free_client_context,
+ ctx, NULL);
}
/* Returns a copy of the streamheader GstBuffer */