Further clarify systemd socket selection

This commit is contained in:
zqmfb
2026-03-26 18:37:24 -04:00
committed by Jari Sundell
parent 2711e4c044
commit ad3c31862e
+18 -4
View File
@@ -164,12 +164,26 @@ apply_scgi_systemd() {
for (int i = 0; i < n; i++) {
int fd = SD_LISTEN_FDS_START + i;
if (selected_fd != -1) // We've already selected an fd
if (selected_fd != -1) {
::close(fd);
else if (sd_is_socket(fd, AF_UNSPEC, SOCK_STREAM, 1) > 0) // Found an appropriate fd
selected_fd = fd;
else // It's some other type of fd, close it.
continue;
}
auto err = sd_is_socket(fd, AF_UNSPEC, SOCK_STREAM, 1);
if (err < 0) {
// Safe to ignore errors here - we just skip it and move on.
::close(fd);
continue;
}
if (err == 0) {
// Not the socket we're looking for.
::close(fd);
continue;
}
selected_fd = fd;
}
if (selected_fd == -1)