Retry before returning a failure to get upstream work as a failure to avoid false positives for pool dead.
diff --git a/main.c b/main.c
index b79e28d..9ed80bb 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");