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

Function oom_dump

cli/lightning-cli.c:392–406  ·  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

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