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

Function next_dev_disconnect

common/dev_disconnect.c:15–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13static int dev_disconnect_count, dev_disconnect_len;
14
15static void next_dev_disconnect(void)
16{
17 int r;
18 char *asterisk;
19
20 r = read(dev_disconnect_fd,
21 dev_disconnect_line, sizeof(dev_disconnect_line)-1);
22 if (r < 0)
23 err(1, "Reading dev_disconnect file");
24 if (lseek(dev_disconnect_fd, -r, SEEK_CUR) < 0) {
25 err(1, "lseek failure");
26 }
27
28 /* Get first line */
29 dev_disconnect_line[r] = '\n';
30 dev_disconnect_len = strcspn(dev_disconnect_line, "\n");
31 dev_disconnect_line[dev_disconnect_len] = '\0';
32
33 asterisk = strchr(dev_disconnect_line, '*');
34 if (asterisk) {
35 dev_disconnect_count = atoi(asterisk+1);
36 if (dev_disconnect_count < 1)
37 errx(1, "dev_disconnect invalid count: %s",
38 dev_disconnect_line);
39 *asterisk = '\0';
40 } else
41 dev_disconnect_count = 1;
42}
43
44void dev_disconnect_init(int fd)
45{

Callers 2

dev_disconnect_outFunction · 0.85
dev_disconnect_inFunction · 0.85

Calls 2

errFunction · 0.85
errxFunction · 0.85

Tested by

no test coverage detected