From 81a1d6d6790ad6ae8ff63147dfab68e6835178c3 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 4 Apr 2023 15:51:07 +0200
Subject: [PATCH] =?UTF-8?q?service:=20rename=20service=5Fclose=5Fsocket=5F?=
 =?UTF-8?q?fd()=20=E2=86=92=20service=5Frelease=5Fsocket=5Ffd()?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Just to match service_release_stdio_fd() and service_release_fd_store()
in the name, since they do similar things.

This follows the concept that we "release" resources, and this is all
generically wrapped in "service_release_resources()".

Conflict:Context Adaptation.
Reference:https://github.com/systemd/systemd/commit/81a1d6d6790ad6ae8ff63147dfab68e6835178c3

---
 src/core/service.c | 9 ++++-----
 src/core/service.h | 2 +-
 src/core/socket.c  | 2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/core/service.c b/src/core/service.c
index 9bd82fc..a7d5f3f 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -188,7 +188,7 @@ static int service_set_main_pid(Service *s, pid_t pid) {
         return 0;
 }
 
-void service_close_socket_fd(Service *s) {
+void service_release_socket_fd(Service *s) {
         assert(s);
 
         if (s->socket_fd < 0 && !UNIT_ISSET(s->accept_socket) && !s->socket_peer)
@@ -399,8 +399,6 @@ static void service_done(Unit *u) {
         s->usb_function_descriptors = mfree(s->usb_function_descriptors);
         s->usb_function_strings = mfree(s->usb_function_strings);
 
-        service_close_socket_fd(s);
-
         service_stop_watchdog(s);
 
         s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source);
@@ -408,8 +406,9 @@ static void service_done(Unit *u) {
 
         s->bus_name_pid_lookup_slot = sd_bus_slot_unref(s->bus_name_pid_lookup_slot);
 
-        service_release_fd_store(s);
+        service_release_socket_fd(s);
         service_release_stdio_fd(s);
+        service_release_fd_store(s);
 }
 
 static int on_fd_store_io(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
@@ -4616,7 +4615,7 @@ static void service_release_resources(Unit *u) {
 
         log_unit_debug(u, "Releasing resources...");
 
-        service_close_socket_fd(s);
+        service_release_socket_fd(s);
         service_release_stdio_fd(s);
 
         if (s->fd_store_preserve_mode != EXEC_PRESERVE_YES)
diff --git a/src/core/service.h b/src/core/service.h
index 78a0f97..4a4ab8a 100644
--- a/src/core/service.h
+++ b/src/core/service.h
@@ -221,7 +221,7 @@ static inline usec_t service_get_watchdog_usec(Service *s) {
 extern const UnitVTable service_vtable;
 
 int service_set_socket_fd(Service *s, int fd, struct Socket *socket, struct SocketPeer *peer, bool selinux_context_net);
-void service_close_socket_fd(Service *s);
+void service_release_socket_fd(Service *s);
 
 const char* service_restart_to_string(ServiceRestart i) _const_;
 ServiceRestart service_restart_from_string(const char *s) _pure_;
diff --git a/src/core/socket.c b/src/core/socket.c
index b1c534b..f61c302 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -2426,7 +2426,7 @@ static void socket_enter_running(Socket *s, int cfd_in) {
                 if (r < 0) {
                         /* We failed to activate the new service, but it still exists. Let's make sure the
                          * service closes and forgets the connection fd again, immediately. */
-                        service_close_socket_fd(SERVICE(service));
+                        service_release_socket_fd(SERVICE(service));
                         goto fail;
                 }
 
-- 
2.33.0

