From 71bb51c3fd32a3b6ed4accd1a17a5bacc7d82e3b Mon Sep 17 00:00:00 2001 From: zqmfb <267821100+angularbanjo@users.noreply.github.com> Date: Wed, 25 Mar 2026 18:30:12 -0400 Subject: [PATCH] Clarify systemd socket selection logic --- src/command_network.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/command_network.cc b/src/command_network.cc index f20888f6..71854b63 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -163,9 +163,12 @@ apply_scgi_systemd() { int selected_fd = -1; for (int i = 0; i < n; i++) { int fd = SD_LISTEN_FDS_START + i; - if (selected_fd == -1 && sd_is_socket(fd, AF_UNSPEC, SOCK_STREAM, 1) > 0) + + if (selected_fd != -1) // We've already selected an fd + ::close(fd); + else if (sd_is_socket(fd, AF_UNSPEC, SOCK_STREAM, 1) > 0) // Found an appropriate fd selected_fd = fd; - else + else // It's some other type of fd, close it. ::close(fd); }