diff options
Diffstat (limited to 'src/lib.c')
-rw-r--r-- | src/lib.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -24,6 +24,13 @@ static void stp_disconnect_cleanup_client (TranscodeClientCtx *ctx); +static gboolean +invoke_g_hash_table_remove (TranscodeServerCtx *ctx) +{ + g_hash_table_remove (ctx->parent_ctx_table, ctx->path); + return FALSE; +} + gboolean stp_on_gst_bus_message (GstBus *bus, GstMessage *msg, @@ -44,12 +51,19 @@ stp_on_gst_bus_message (GstBus *bus, * hasn't already finished, so we check that */ if (!ctx->stream_finished) soup_message_set_status (ctx->msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); - /* FIXME: hash tables are not threadsafe */ - g_hash_table_remove (ctx->parent_ctx_table, ctx->path); + /* Cleanup in the default main context, + * because GHashTable is not thread-safe */ + g_main_context_invoke_full (NULL, G_PRIORITY_HIGH, + (GSourceFunc)invoke_g_hash_table_remove, + ctx, NULL); break; case GST_MESSAGE_EOS: g_debug ("End of file"); - g_hash_table_remove (ctx->parent_ctx_table, ctx->path); + /* Cleanup in the default main context, + * because GHashTable is not thread-safe */ + g_main_context_invoke_full (NULL, G_PRIORITY_HIGH, + (GSourceFunc)invoke_g_hash_table_remove, + ctx, NULL); break; default: //stp_print_status ("%s\n", gst_message_type_get_name (msg->type)); @@ -146,6 +160,8 @@ stp_disconnect_cleanup_client (TranscodeClientCtx *ctx) soup_message_body_complete (ctx->msg->response_body); g_source_remove (ctx->timeout_handler_id); + /* Don't call the "finished" handler and do a double-free */ + g_signal_handler_disconnect (ctx->msg, ctx->finished_handler_id); g_free (ctx); } |