From 9de12d66ab1102c3dc796854e3a285ee805eb3c4 Mon Sep 17 00:00:00 2001 From: Karl Heyes Date: Wed, 7 Mar 2018 22:02:07 +0000 Subject: [PATCH] intro handling update. reset timer for a lagging listener if a listener is kicked back to intro with a partial block then reset timer so the drop case is handled better. Increase the low threshold for such cases to half bitrate. Also do not trigger a intro log entry for that case. --- src/format.c | 4 +++- src/logging.c | 6 +++--- src/source.c | 11 +++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/format.c b/src/format.c index 9504b7b3..3ffd693a 100644 --- a/src/format.c +++ b/src/format.c @@ -239,8 +239,10 @@ int format_file_read (client_t *client, format_plugin_t *plugin, icefile_handle bytes = pread (f, refbuf->data, len, client->intro_offset); if (bytes <= 0) + { + client->flags &= ~CLIENT_HAS_INTRO_CONTENT; return bytes < 0 ? -2 : -1; - + } refbuf->len = bytes; client->pos = 0; if (plugin && plugin->align_buffer) diff --git a/src/logging.c b/src/logging.c index 724bfdb3..6dbfc5cf 100644 --- a/src/logging.c +++ b/src/logging.c @@ -155,9 +155,9 @@ void logging_preroll (int log_id, const char *intro_name, client_t *client) util_get_clf_time (datebuf, sizeof(datebuf), client->worker->current_time.tv_sec); - log_write_direct (log_id, "%s|%s|%ld|%ld|%s", - datebuf, client->mount, - client->connection.id, client->intro_offset, intro_name); + log_write_direct (log_id, "%s|%s|%ld|%s|%ld|%s", + datebuf, client->mount, client->connection.id, + &client->connection.ip[0], client->intro_offset, intro_name); } diff --git a/src/source.c b/src/source.c index 070e6eb0..30c8efe7 100644 --- a/src/source.c +++ b/src/source.c @@ -860,6 +860,7 @@ static int source_queue_advance (client_t *client) client->refbuf = NULL; client->pos = 0; } + client->timer_start = 0; client->check_buffer = http_source_introfile; // do not be too eager to refill socket buffer client->schedule_ms += source->incoming_rate < 16000 ? source->incoming_rate/16 : 800; @@ -958,6 +959,8 @@ static int locate_start_on_queue (source_t *source, client_t *client) static void source_preroll_logging (source_t *source, client_t *client) { + if (client->intro_offset < 0 || (client->flags & CLIENT_HAS_INTRO_CONTENT)) + return; // content provided separately, auth or queue block copy if (source->preroll_log_id < 0) { ice_config_t *config = config_get_config(); @@ -1006,9 +1009,9 @@ static int http_source_introfile (client_t *client) if (client->connection.sent_bytes < source->default_burst_size) to_send = source->default_burst_size - client->connection.sent_bytes; duration = (long)((float)to_send / rate); - client->aux_data = duration + 16; + client->aux_data = duration + 8; client->timer_start = client->worker->current_time.tv_sec - client->aux_data; - client->counter = 16 * rate; + client->counter = 8 * rate; } incoming_rate = rate; duration = (client->worker->current_time.tv_sec - client->timer_start); @@ -1028,9 +1031,9 @@ static int http_source_introfile (client_t *client) } if (source->format->sent_bytes > (incoming_rate << 5) && // allow at least 30+ seconds on the stream (duration - client->aux_data) > 15 && - rate < (incoming_rate/4)) + rate < (incoming_rate>>1)) { - INFO2 ("Dropped listener %s, running too slow on %s", &client->connection.ip[0], source->mount); + INFO3 ("Dropped listener %s (%ld), running too slow on %s", &client->connection.ip[0], client->connection.id, source->mount); source_preroll_logging (source, client); client->connection.error = 1; client_set_queue (client, NULL);