MCPcopy Create free account
hub / github.com/ElementsProject/lightning / bcli_finished

Function bcli_finished

plugins/bcli.c:241–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241static void bcli_finished(struct io_conn *conn UNUSED, struct bitcoin_cli *bcli)
242{
243 int ret, status;
244 struct command_result *res;
245 enum bitcoind_prio prio = bcli->prio;
246 u64 msec = time_to_msec(time_between(time_now(), bcli->start));
247
248 /* If it took over 10 seconds, that's rather strange. */
249 if (msec > 10000)
250 plugin_log(bcli->cmd->plugin, LOG_UNUSUAL,
251 "bitcoin-cli: finished %s (%"PRIu64" ms)",
252 bcli_args(bcli), msec);
253
254 assert(bitcoind->num_requests[prio] > 0);
255
256 /* FIXME: If we waited for SIGCHILD, this could never hang! */
257 while ((ret = waitpid(bcli->pid, &status, 0)) < 0 && errno == EINTR);
258 if (ret != bcli->pid)
259 plugin_err(bcli->cmd->plugin, "%s %s", bcli_args(bcli),
260 ret == 0 ? "not exited?" : strerror(errno));
261
262 if (!WIFEXITED(status))
263 plugin_err(bcli->cmd->plugin, "%s died with signal %i",
264 bcli_args(bcli),
265 WTERMSIG(status));
266
267 /* Implicit nonzero_exit_ok == false */
268 if (!bcli->exitstatus) {
269 if (WEXITSTATUS(status) != 0) {
270 bcli_failure(bcli, WEXITSTATUS(status));
271 bitcoind->num_requests[prio]--;
272 goto done;
273 }
274 } else
275 *bcli->exitstatus = WEXITSTATUS(status);
276
277 if (WEXITSTATUS(status) == 0)
278 bitcoind->error_count = 0;
279
280 bitcoind->num_requests[bcli->prio]--;
281
282 res = bcli->process(bcli);
283 if (!res)
284 bcli_failure(bcli, WEXITSTATUS(status));
285 else
286 tal_free(bcli);
287
288done:
289 next_bcli(prio);
290}
291
292static void next_bcli(enum bitcoind_prio prio)
293{

Callers

nothing calls this directly

Calls 9

time_to_msecFunction · 0.85
time_betweenFunction · 0.85
time_nowFunction · 0.85
bcli_argsFunction · 0.85
bcli_failureFunction · 0.85
tal_freeFunction · 0.85
next_bcliFunction · 0.85
plugin_logFunction · 0.70
plugin_errFunction · 0.70

Tested by

no test coverage detected