mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
connectd: Ignore sodium fd for Mac tests
On Mac most tests report BROKEN because sodium creating an untracked fd pointing to /dev/random. dev_report_fd’s finds it at tear down and reports a BROKEN message. We allow a single “char special” fd without reporting it as broken improving QOL for Mac developers. While we’re here we added the fd mode to the log to help with future rogue fd issues. ChangeLog-None
This commit is contained in:
parent
87f4907bb4
commit
e1ac2410b0
1 changed files with 35 additions and 1 deletions
|
@ -45,6 +45,7 @@
|
|||
#include <netinet/in.h>
|
||||
#include <signal.h>
|
||||
#include <sodium.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
@ -1957,12 +1958,36 @@ static const char *try_tal_name(const tal_t *ctx, const void *p)
|
|||
return tal_fmt(ctx, "%p", p);
|
||||
}
|
||||
|
||||
static char *fd_mode_str(int fd)
|
||||
{
|
||||
struct stat finfo;
|
||||
if (0 != fstat(fd, &finfo))
|
||||
return "invalid fd";
|
||||
if (S_ISBLK(finfo.st_mode))
|
||||
return "block special";
|
||||
if (S_ISCHR(finfo.st_mode))
|
||||
return "char special";
|
||||
if (S_ISDIR(finfo.st_mode))
|
||||
return "directory";
|
||||
if (S_ISFIFO(finfo.st_mode))
|
||||
return "fifo or socket";
|
||||
if (S_ISREG(finfo.st_mode))
|
||||
return "regular file";
|
||||
if (S_ISLNK(finfo.st_mode))
|
||||
return "symbolic link";
|
||||
if (S_ISSOCK(finfo.st_mode))
|
||||
return "socket";
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static void dev_report_fds(struct daemon *daemon, const u8 *msg)
|
||||
{
|
||||
bool found_chr_fd = false;
|
||||
for (int fd = 3; fd < 4096; fd++) {
|
||||
bool listener;
|
||||
const struct io_conn *c;
|
||||
const struct io_listener *l;
|
||||
struct stat finfo;
|
||||
if (!isatty(fd) && errno == EBADF)
|
||||
continue;
|
||||
if (fd == HSM_FD) {
|
||||
|
@ -1983,7 +2008,16 @@ static void dev_report_fds(struct daemon *daemon, const u8 *msg)
|
|||
}
|
||||
c = io_have_fd(fd, &listener);
|
||||
if (!c) {
|
||||
status_broken("dev_report_fds: %i open but unowned?", fd);
|
||||
/* We consider a single CHR as expected */
|
||||
if (!found_chr_fd && !fstat(fd, &finfo)
|
||||
&& S_ISCHR(finfo.st_mode)) {
|
||||
found_chr_fd = true;
|
||||
status_info("dev_report_fds: %i -> char fd", fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
status_broken("dev_report_fds: %i open but unowned? fd"
|
||||
" mode: %s", fd, fd_mode_str(fd));
|
||||
continue;
|
||||
} else if (listener) {
|
||||
l = (void *)c;
|
||||
|
|
Loading…
Add table
Reference in a new issue