diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-15 17:50:51 (GMT) |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-15 17:50:51 (GMT) |
commit | 507f8c8a73e2f373c2b50db6490688689fc88517 (patch) | |
tree | e69cd5fa0ae4a8f094c62a97e69bd26b5b55229f /src/lib.c | |
parent | d941945543dfd412813ea68dcab70fe57b8b8273 (diff) | |
download | soup-transcoding-proxy-507f8c8a73e2f373c2b50db6490688689fc88517.zip soup-transcoding-proxy-507f8c8a73e2f373c2b50db6490688689fc88517.tar.gz |
server: Make cleanup on server exit and EOS more reliable
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); } |