core: merge service_connection_unref() into service_close_socket_fd()
We always call one after the other anyway, and this way service_set_socket_fd() and service_close_socket_fd() nicely match each other as one undoes the effect of the other.
This commit is contained in:
parent
b75102e5bf
commit
5cc3985ed1
|
@ -183,17 +183,14 @@ static int service_set_main_pid(Service *s, pid_t pid) {
|
||||||
void service_close_socket_fd(Service *s) {
|
void service_close_socket_fd(Service *s) {
|
||||||
assert(s);
|
assert(s);
|
||||||
|
|
||||||
|
/* Undo the effect of service_set_socket_fd(). */
|
||||||
|
|
||||||
s->socket_fd = asynchronous_close(s->socket_fd);
|
s->socket_fd = asynchronous_close(s->socket_fd);
|
||||||
}
|
|
||||||
|
|
||||||
static void service_connection_unref(Service *s) {
|
if (UNIT_ISSET(s->accept_socket)) {
|
||||||
assert(s);
|
socket_connection_unref(SOCKET(UNIT_DEREF(s->accept_socket)));
|
||||||
|
unit_ref_unset(&s->accept_socket);
|
||||||
if (!UNIT_ISSET(s->accept_socket))
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
socket_connection_unref(SOCKET(UNIT_DEREF(s->accept_socket)));
|
|
||||||
unit_ref_unset(&s->accept_socket);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void service_stop_watchdog(Service *s) {
|
static void service_stop_watchdog(Service *s) {
|
||||||
|
@ -321,7 +318,6 @@ static void service_done(Unit *u) {
|
||||||
s->bus_name_owner = mfree(s->bus_name_owner);
|
s->bus_name_owner = mfree(s->bus_name_owner);
|
||||||
|
|
||||||
service_close_socket_fd(s);
|
service_close_socket_fd(s);
|
||||||
service_connection_unref(s);
|
|
||||||
|
|
||||||
unit_ref_unset(&s->accept_socket);
|
unit_ref_unset(&s->accept_socket);
|
||||||
|
|
||||||
|
@ -910,10 +906,8 @@ static void service_set_state(Service *s, ServiceState state) {
|
||||||
SERVICE_RUNNING, SERVICE_RELOAD,
|
SERVICE_RUNNING, SERVICE_RELOAD,
|
||||||
SERVICE_STOP, SERVICE_STOP_SIGABRT, SERVICE_STOP_SIGTERM, SERVICE_STOP_SIGKILL, SERVICE_STOP_POST,
|
SERVICE_STOP, SERVICE_STOP_SIGABRT, SERVICE_STOP_SIGTERM, SERVICE_STOP_SIGKILL, SERVICE_STOP_POST,
|
||||||
SERVICE_FINAL_SIGTERM, SERVICE_FINAL_SIGKILL) &&
|
SERVICE_FINAL_SIGTERM, SERVICE_FINAL_SIGKILL) &&
|
||||||
!(state == SERVICE_DEAD && UNIT(s)->job)) {
|
!(state == SERVICE_DEAD && UNIT(s)->job))
|
||||||
service_close_socket_fd(s);
|
service_close_socket_fd(s);
|
||||||
service_connection_unref(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IN_SET(state, SERVICE_START_POST, SERVICE_RUNNING, SERVICE_RELOAD))
|
if (!IN_SET(state, SERVICE_START_POST, SERVICE_RUNNING, SERVICE_RELOAD))
|
||||||
service_stop_watchdog(s);
|
service_stop_watchdog(s);
|
||||||
|
|
Loading…
Reference in a new issue