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

Function oom_dump

cli/lightning-cli.c:400–414  ·  view source on GitHub ↗

We rely on the fact that lightningd terminates all JSON RPC responses with * "\n\n", so we can stream even if we can't parse. */

Source from the content-addressed store, hash-verified

398/* We rely on the fact that lightningd terminates all JSON RPC responses with
399 * "\n\n", so we can stream even if we can't parse. */
400static void oom_dump(int fd, char *resp, size_t off)
401{
402 warnx("Out of memory: sending raw output");
403
404 /* Note: resp does not already end in '\n\n', and resp_len is > 0 */
405 do {
406 /* Keep last char, to avoid splitting \n\n */
407 write_all(STDOUT_FILENO, resp, off-1);
408 resp[0] = resp[off-1];
409 off = 1 + read_nofail(fd, resp + 1, tal_bytelen(resp) - 1);
410 } while (resp[off-2] != '\n' || resp[off-1] != '\n');
411 write_all(STDOUT_FILENO, resp, off-1);
412 /* We assume giant answer means "success" */
413 exit(0);
414}
415
416/* We want to return failure if tal_resize fails */
417static void tal_error(const char *msg)

Callers 1

mainFunction · 0.85

Calls 4

warnxFunction · 0.85
read_nofailFunction · 0.85
tal_bytelenFunction · 0.85
write_allFunction · 0.50

Tested by

no test coverage detected