summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2014-07-11 13:15:19 (GMT)
committerNirbheek Chauhan <nirbheek@centricular.com>2014-07-11 13:15:21 (GMT)
commitabcaa6d33f1a993b3e07b66889d86b44700b7c14 (patch)
tree3b13d1290a85c6ca10354e781012ac91929f25b4 /src/main.c
parent5d0bcfb66025c10864bbe5ea5e64afe5cbc148fd (diff)
downloadsoup-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/main.c')
-rw-r--r--src/main.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index e291b2c..10aa6d9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);