Skip to content

Commit 4f307a7

Browse files
plugin-bcli: addresses comments
Changelog-None Signed-off-by: Nishant Bansal <[email protected]>
1 parent a9d4945 commit 4f307a7

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

plugins/bcli.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,12 +1042,16 @@ static void log_warm_up(struct plugin *p)
10421042

10431043
static void wait_and_check_bitcoind(struct plugin *p)
10441044
{
1045-
int in, from, status, ret;
1045+
int in, from, status;
10461046
pid_t child;
10471047
const char **cmd =
10481048
gather_args(bitcoind, "-rpcwait", "getnetworkinfo", NULL);
10491049
char *output = NULL;
10501050

1051+
struct timers *timer = tal(cmd, struct timers);
1052+
timers_init(timer, time_mono());
1053+
new_reltimer(timer, timer, time_from_sec(30), log_warm_up, p);
1054+
10511055
child = pipecmdarr(&in, &from, &from, cast_const2(char **, cmd));
10521056

10531057
if (bitcoind->rpcpass)
@@ -1066,32 +1070,18 @@ static void wait_and_check_bitcoind(struct plugin *p)
10661070

10671071
output = grab_fd(cmd, from);
10681072

1069-
while ((ret = waitpid(child, &status, 0)) < 0 && errno == EINTR)
1070-
;
1071-
if (ret != child)
1072-
bitcoind_failure(p, tal_fmt(bitcoind, "Waiting for %s: %s",
1073-
cmd[0], strerror(errno)));
1073+
waitpid(child, &status, 0);
1074+
10741075
if (!WIFEXITED(status))
10751076
bitcoind_failure(p, tal_fmt(bitcoind, "Death of %s: signal %i",
10761077
cmd[0], WTERMSIG(status)));
10771078

1078-
/* bitcoin/src/rpc/protocol.h:
1079-
* RPC_IN_WARMUP = -28, //!< Client still warming up
1080-
*/
1081-
if (WEXITSTATUS(status) != 0 && WEXITSTATUS(status) != 28) {
1082-
if (WEXITSTATUS(status) == 1)
1083-
bitcoind_failure(p,
1084-
"Could not connect to bitcoind using"
1085-
" bitcoin-cli. Is bitcoind running?");
1079+
if (WEXITSTATUS(status) != 0) {
10861080
bitcoind_failure(p,
10871081
tal_fmt(bitcoind, "%s exited with code %i: %s",
10881082
cmd[0], WEXITSTATUS(status), output));
10891083
}
10901084

1091-
struct timers *timer = tal(cmd, struct timers);
1092-
timers_init(timer, time_mono());
1093-
new_reltimer(timer, timer, time_from_sec(30), log_warm_up, p);
1094-
10951085
parse_getnetworkinfo_result(p, output);
10961086

10971087
tal_free(cmd);

0 commit comments

Comments
 (0)