From f10f8faefb9cc19fca8a637d6744ad55eff5cc01 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 6 Sep 2011 11:07:36 +1000 Subject: [PATCH] Retry before returning a failure to get upstream work as a failure to avoid false positives for pool dead. --- main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index b79e28df..9ed80bb3 100644 --- a/main.c +++ b/main.c @@ -1986,8 +1986,9 @@ static inline struct pool *select_pool(bool lagging) static bool get_upstream_work(struct work *work, bool lagging) { struct pool *pool; - json_t *val; + json_t *val = NULL; bool rc = false; + int retries = 0; CURL *curl; curl = curl_easy_init(); @@ -2000,7 +2001,11 @@ static bool get_upstream_work(struct work *work, bool lagging) if (opt_debug) applog(LOG_DEBUG, "DBG: sending %s get RPC call: %s", pool->rpc_url, rpc_req); - val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req, + /* A single failure response here might be reported as a dead pool and + * there may be temporary denied messages etc. falsely reporting + * failure so retry a few times before giving up */ + while (!val && retries++ < 3) + val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req, false, false, &work->rolltime, pool); if (unlikely(!val)) { applog(LOG_DEBUG, "Failed json_rpc_call in get_upstream_work");