From 221825782b3666288f0959a7ba73324f99cc946d Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 12 Jun 2014 21:54:44 +1000 Subject: [PATCH] Check for a dead main process in the generator loop --- src/generator.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/generator.c b/src/generator.c index c32cc5ca..aa1ef93a 100644 --- a/src/generator.c +++ b/src/generator.c @@ -111,6 +111,9 @@ static server_instance_t *live_server(ckpool_t *ckp) LOGDEBUG("Attempting to connect to bitcoind"); retry: + if (!ping_main(ckp)) + goto out; + for (i = 0; i < ckp->btcds; i++) { server_instance_t *si; char *userpass = NULL; @@ -162,11 +165,14 @@ retry: } cs = &alive->cs; LOGINFO("Connected to live server %s:%s", cs->url, cs->port); +out: return alive; } static void kill_server(server_instance_t *si) { + if (!si) + return; close(si->cs.fd); si->cs.fd = -1; } @@ -186,6 +192,9 @@ reconnect: if (si) kill_server(si); si = live_server(ckp); + if (!si) + goto out; + gbt = si->data; cs = &si->cs;