mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-05 17:52:29 +00:00
Further clarify systemd socket selection
This commit is contained in:
+18
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user