diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-11 13:15:19 (GMT) |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-11 13:15:21 (GMT) |
commit | abcaa6d33f1a993b3e07b66889d86b44700b7c14 (patch) | |
tree | 3b13d1290a85c6ca10354e781012ac91929f25b4 /src | |
parent | 5d0bcfb66025c10864bbe5ea5e64afe5cbc148fd (diff) | |
download | soup-transcoding-proxy-abcaa6d33f1a993b3e07b66889d86b44700b7c14.zip soup-transcoding-proxy-abcaa6d33f1a993b3e07b66889d86b44700b7c14.tar.gz |
server: Add support for aborting running streams
This is useful to cancel streams that are taking too long to encode, etc
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 26 |
1 files changed, 23 insertions, 3 deletions
@@ -584,21 +584,41 @@ PUT: { if (encoding == SOUP_ENCODING_CONTENT_LENGTH) g_timeout_add_seconds (2, (GSourceFunc)increment_read_timer, ctx); goto out; - } + } GET: { - if (!g_hash_table_contains (ctx_table, soup_uri_get_path (uri))) { + const char *query; + TranscodeServerCtx *server_ctx; + + if (!g_hash_table_contains (ctx_table, + soup_uri_get_path (uri))) { g_print ("No stream on URI: %s\n", soup_uri_get_path (uri)); soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND); goto out; } + query = soup_uri_get_query (uri); + if (query && g_strcmp0 (query, "abort") == 0) { + /* We just use the "uri" field for this, so this is OK */ + server_ctx = get_server_ctx_from_msg (msg, ctx_table); + /* Abort all processing for this stream */ + if (!server_ctx->stream_finished) { + /* Close the PUT stream if necessary */ + server_ctx->stream_finished = TRUE; + soup_message_set_status (server_ctx->msg, SOUP_STATUS_OK); + } + /* Disconnect all clients, and shut down the stream */ + stp_cleanup_transcode_server_ctx (server_ctx); + soup_message_set_status (msg, SOUP_STATUS_OK); + goto out; + } + /* Our response will be chunked, and not with a fixed Content-Length */ soup_message_headers_set_encoding (msg->response_headers, SOUP_ENCODING_CHUNKED); /* The request body isn't fixed length, so tell libsoup to * not collect chunks for forming a complete request body */ soup_message_body_set_accumulate (msg->response_body, FALSE); - } + } out: soup_uri_free (uri); |