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

Function next_dev_disconnect

common/dev_disconnect.c:19–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

dev_disconnectFunction · 0.85

Calls 2

errFunction · 0.85
errxFunction · 0.85

Tested by

no test coverage detected