From 43b2249d919d3638632c4141e93d5465ec528651 Mon Sep 17 00:00:00 2001 From: x3 Date: Tue, 8 Aug 2023 11:32:39 +0200 Subject: [PATCH] Sleep for 30 minutes if api servers are out of service --- src/api.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/api.c b/src/api.c index 0f4fd00..1532c29 100644 --- a/src/api.c +++ b/src/api.c @@ -719,10 +719,16 @@ static enum error api_cmd_base_pref(char buffer[API_BUFSIZE], int send_len, if (err == ERR_API_OOS || err == ERR_API_SRV_BUSY || err == ERR_API_TIMEOUT) { struct timespec ts; + time_t wait_ms = API_TRYAGAIN_TIME; - MS_TO_TIMESPEC_L(ts, API_TRYAGAIN_TIME); + if (err == ERR_API_OOS) { + /* In this case, we should wait 30 minutes as per the wiki */ + wait_ms = 30 * 60 * 1000; + } + + MS_TO_TIMESPEC_L(ts, wait_ms); retry_count++; - uio_debug("Retry after %ld ms (%d/%d)", API_TRYAGAIN_TIME, + uio_debug("Retry after %ld ms (%d/%d)", wait_ms, retry_count, API_MAX_TRYAGAIN); if (nanosleep(&ts, NULL) == -1) { if (errno == EINTR && should_exit) {