diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-08-15 16:22:14 (GMT) |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-08-15 16:22:14 (GMT) |
commit | 281222987d800e76049d4667a7bdd6b4a8f20660 (patch) | |
tree | de7f2003caee7f6f08a240cb37ba25b8bd8e0b4f /src | |
parent | 93e0724fffcd3d13134b0cd8f97d624e654b286b (diff) | |
download | soup-transcoding-proxy-281222987d800e76049d4667a7bdd6b4a8f20660.zip soup-transcoding-proxy-281222987d800e76049d4667a7bdd6b4a8f20660.tar.gz |
server: Add the ability to treat conflicting connections as restarts
Also make stream timeouts configurable
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -48,13 +48,16 @@ static int port = 8000; static int client_timeout = 10; static int server_timeout = 5; static char *token_server_addrmask = NULL; +static gboolean conflict_is_restart = FALSE; static GInetAddressMask *stp_inet_addrmask = NULL; static GOptionEntry entries[] = { { "port", 'p', 0, G_OPTION_ARG_INT, &port, "Port to listen on (default: 8000)", "PORT" }, - { "timeout", 't', 0, G_OPTION_ARG_INT, &client_timeout, "Client connection timeout (default: 10s)", "SECONDS" }, + { "client-timeout", 0, 0, G_OPTION_ARG_INT, &client_timeout, "Outgoing client connection timeout (default: 10s)", "SECONDS" }, + { "stream-timeout", 0, 0, G_OPTION_ARG_INT, &server_timeout, "Incoming stream connection timeout (default: 5s)", "SECONDS" }, { "token-server", 's', 0, G_OPTION_ARG_STRING, &token_server_addrmask, "Subnet (or IP addr) for the token server (default: disabled)", "ADDR/PREFIX" }, + { "conflict-is-restart", 0, 0, G_OPTION_ARG_NONE, &conflict_is_restart, "If a new PUT stream is received at the same path as an existing one, treat it as a restart instead of reporting a 409/CONFLICT (default: no)", NULL }, { NULL } }; @@ -700,7 +703,14 @@ PUT: { * and just pass the data to the pipeline. */ if (connection_exists && !content_range) { /* A connection already exists, and this one isn't a continuation - * of the previous one, so it's a conflict */ + * of the previous one, so it's a conflict... unless the + * '--conflict-is-restart' option has been specified. */ + if (conflict_is_restart) { + ctx = get_server_ctx_from_msg (msg, tables->ctxs); + stream_finished_cb (ctx->msg, ctx); + invoke_g_hash_table_remove (ctx); + goto new_conn; + } g_critical ("Recv Content-Length PUT on '%s' without Content-Range", path); soup_message_set_status (msg, SOUP_STATUS_CONFLICT); goto PUT_out; @@ -744,6 +754,7 @@ PUT: { goto PUT_out; } +new_conn: /* This is a new connection; treat it as such */ ctx = g_new0 (STPServerCtx, 1); ctx->stream_type = token->stream_type; |