From a9d5d2c3eb9d29d54509936b9e45f8eb034c033f Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 7 Apr 2018 20:17:23 +0200 Subject: Add network timeouts and retries All network operations can time out now. API requests are retried up to three times (default). Replaces setting max_player_errors with max_retries, which is used for player and API. Adds timeout setting. Partially reverts 436a1d4012553a2f33d0e3a5180b3b5ae0378bdd and fixes (at least) issue #657. Thanks to @exarkun for testing. --- src/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 4f4214a..a75388e 100644 --- a/src/main.c +++ b/src/main.c @@ -248,9 +248,9 @@ static void BarMainStartPlayback(BarApp_t *app) PIANO_RET_OK); if (!BarPlayer2Play(app->player)) - ++app->playerErrors; + ++app->retries; else - app->playerErrors = 0; + app->retries = 0; } } @@ -265,11 +265,11 @@ static void BarMainPlayerCleanup(BarApp_t *app) BarConsoleSetTitle(TITLE); - if (app->playerErrors >= app->settings.maxPlayerErrors) + if (app->retries >= app->settings.maxRetry) { /* don't continue playback if thread reports too many error */ app->nextStation = NULL; - app->playerErrors = 0; + app->retries = 0; } } @@ -411,7 +411,8 @@ int main(int argc, char **argv) app.settings.keys[BAR_KS_HELP]); } - HttpInit(&app.http2, app.settings.rpcHost, app.settings.rpcTlsPort); + HttpInit(&app.http2, app.settings.rpcHost, app.settings.rpcTlsPort, + app.settings.timeout); if (app.settings.controlProxy) HttpSetProxy(app.http2, app.settings.controlProxy); -- cgit v1.2.3