Skip to content

Commit

Permalink
intro handling update. reset timer for a lagging listener
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
karlheyes committed Mar 7, 2018
1 parent ac8994a commit 9de12d6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/format.c
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/logging.c
Expand Up @@ -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);
}


Expand Down
11 changes: 7 additions & 4 deletions src/source.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 9de12d6

Please sign in to comment.