socket.c revision 3cd761e4df278cdef6fda9d7f50be512d3c1d7ae
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny This file is part of systemd.
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny Copyright 2010 Lennart Poettering
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny systemd is free software; you can redistribute it and/or modify it
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny under the terms of the GNU Lesser General Public License as published by
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny the Free Software Foundation; either version 2.1 of the License, or
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny (at your option) any later version.
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny systemd is distributed in the hope that it will be useful, but
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny WITHOUT ANY WARRANTY; without even the implied warranty of
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny Lesser General Public License for more details.
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny You should have received a copy of the GNU Lesser General Public License
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny along with systemd; If not, see <http://www.gnu.org/licenses/>.
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozekstatic const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zelenystatic int socket_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozekstatic int socket_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata);
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny s->timeout_usec = u->manager->default_timeout_start_usec;
b668c77874c6fed325471bdcf5954979a0d734e2Stef Walter s->exec_context.std_output = u->manager->default_std_output;
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny s->exec_context.std_error = u->manager->default_std_error;
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny s->control_command_id = _SOCKET_EXEC_COMMAND_INVALID;
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zelenystatic void socket_unwatch_control_pid(Socket *s) {
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny while ((p = s->ports)) {
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek s->exec_runtime = exec_runtime_unref(s->exec_runtime);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek exec_command_free_array(s->exec_command, _SOCKET_EXEC_COMMAND_MAX);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek s->timer_event_source = sd_event_source_unref(s->timer_event_source);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek if (s->timeout_usec <= 0) {
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek s->timer_event_source = sd_event_source_unref(s->timer_event_source);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek r = sd_event_source_set_time(s->timer_event_source, now(CLOCK_MONOTONIC) + s->timeout_usec);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek _cleanup_free_ char *prefix = NULL, *name = NULL;
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek /* This fills in s->service if it isn't filled in yet. For
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek * Accept=yes sockets we create the next connection service
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek * here. For Accept=no this is mostly a NOP since the service
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek * is figured out at load time anyway. */
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek if (asprintf(&name, "%s@%u.service", prefix, s->n_accepted) < 0)
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek r = manager_load_unit(UNIT(s)->manager, name, NULL, NULL, &u);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek return unit_add_two_dependencies(UNIT(s), UNIT_BEFORE, UNIT_TRIGGERS, u, false);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek return true;
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek return true;
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny return true;
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek return false;
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozek else if (p->type == SOCKET_FIFO || p->type == SOCKET_SPECIAL)
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny if (!s->bind_to_device || streq(s->bind_to_device, "lo"))
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny t = strappenda("/sys/subsystem/net/devices/", s->bind_to_device);
8ba8222afca3026fd67af08e224b1d9e848aceaaJakub Hrozekstatic int socket_add_default_dependencies(Socket *s) {
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny r = unit_add_dependency_by_name(UNIT(s), UNIT_BEFORE, SPECIAL_SOCKETS_TARGET, NULL, true);
65393a294e635822c1d7a15fe5853dc457ad8a2aSimo Sorce if (UNIT(s)->manager->running_as == SYSTEMD_SYSTEM) {
aac3ca699a09090072ae4d68bdda8dec990ae393Sumit Bose r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true);
aac3ca699a09090072ae4d68bdda8dec990ae393Sumit Bose return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov for (i = 0; i < _SOCKET_EXEC_COMMAND_MAX; i++)
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce return true;
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny return false;
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny r = unit_add_two_dependencies(u, UNIT_BEFORE, UNIT_TRIGGERS, UNIT_DEREF(s->service), true);
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny r = unit_add_exec_dependencies(u, &s->exec_context);
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny r = unit_add_default_slice(u, &s->cgroup_context);
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorcestatic const char *socket_find_symlink_target(Socket *s) {
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny const char *f = NULL;
c0f9698cd951b7223f251ff2511c4b22a6e4ba60Jan Zeleny switch (p->type) {
909a86af4eb99f5d311d7136cab78dca535ae304Sumit Bose log_error_unit(UNIT(s)->id, "%s lacks Listen setting. Refusing.", UNIT(s)->id);
909a86af4eb99f5d311d7136cab78dca535ae304Sumit Bose log_error_unit(UNIT(s)->id, "%s configured for accepting sockets, but sockets are non-accepting. Refusing.",
909a86af4eb99f5d311d7136cab78dca535ae304Sumit Bose log_error_unit(UNIT(s)->id, "%s's MaxConnection setting too small. Refusing.", UNIT(s)->id);
909a86af4eb99f5d311d7136cab78dca535ae304Sumit Bose log_error_unit(UNIT(s)->id, "Explicit service configuration for accepting sockets not supported on %s. Refusing.", UNIT(s)->id);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek log_error_unit(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek if (!strv_isempty(s->symlinks) && !socket_find_symlink_target(s)) {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek log_error_unit(UNIT(s)->id, "%s has symlinks set but none or more than one node in the file system. Refusing.", UNIT(s)->id);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek /* This is a new unit? Then let's add in some extras */
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek_const_ static const char* listen_lookup(int family, int type) {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return "ListenNetlink";
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return "ListenStream";
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return "ListenDatagram";
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return "ListenSequentialPacket";
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekstatic void socket_dump(Unit *u, FILE *f, const char *prefix) {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sSocket State: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sResult: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sBindIPv6Only: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sBacklog: %u\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sSocketMode: %04o\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sDirectoryMode: %04o\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sKeepAlive: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sNoDelay: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sFreeBind: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sTransparent: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sBroadcast: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sPassCredentials: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sPassSecurity: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sTCPCongestion: %s\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sRemoveOnStop: %s\n",
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek prefix, socket_address_bind_ipv6_only_to_string(s->bind_ipv6_only),
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sBindToDevice: %s\n",
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sAccepted: %u\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sNConnections: %u\n"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sMaxConnections: %u\n",
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sPriority: %i\n",
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek "%sReceiveBuffer: %zu\n",
if (s->send_buffer > 0)
fprintf(f,
if (s->ip_tos >= 0)
fprintf(f,
if (s->ip_ttl >= 0)
fprintf(f,
if (s->pipe_size > 0)
fprintf(f,
if (s->mark >= 0)
fprintf(f,
if (s->mq_maxmsg > 0)
fprintf(f,
if (s->mq_msgsize > 0)
fprintf(f,
if (s->reuse_port)
fprintf(f,
if (s->smack)
fprintf(f,
if (s->smack_ip_in)
fprintf(f,
if (s->smack_ip_out)
fprintf(f,
fprintf(f,
if (s->keep_alive_time > 0)
fprintf(f,
if (s->keep_alive_interval)
fprintf(f,
if (s->keep_alive_cnt)
fprintf(f,
if (s->defer_accept)
fprintf(f,
char *k = NULL;
t = strerror(-r);
fprintf(f, "%s%s: %s\n", prefix, listen_lookup(socket_address_family(&p->address), p->address.type), t);
free(k);
for (c = 0; c < _SOCKET_EXEC_COMMAND_MAX; c++) {
if (!s->exec_command[c])
socklen_t l;
l = sizeof(local);
return -errno;
l = sizeof(remote);
return -errno;
case AF_INET: {
if (asprintf(&r,
nr,
return -ENOMEM;
case AF_INET6: {
static const unsigned char ipv4_prefix[] = {
const uint8_t
if (asprintf(&r,
nr,
return -ENOMEM;
if (asprintf(&r,
nr,
return -ENOMEM;
case AF_UNIX: {
if (asprintf(&r,
return -ENOMEM;
} else if (k == -ENODATA) {
if (asprintf(&r,
nr) < 0)
return -ENOMEM;
*instance = r;
SocketPort *p;
assert(s);
if (p->fd < 0)
if (s->remove_on_stop) {
switch (p->type) {
case SOCKET_FIFO:
case SOCKET_MQUEUE:
case SOCKET_SOCKET:
if (s->remove_on_stop)
unlink(*i);
assert(s);
if (s->keep_alive) {
int b = s->keep_alive;
if (s->keep_alive_time) {
if (s->keep_alive_interval) {
if (s->keep_alive_cnt) {
if (s->defer_accept) {
if (s->no_delay) {
int b = s->no_delay;
if (s->broadcast) {
if (s->pass_cred) {
if (s->pass_sec) {
if (s->priority >= 0)
if (s->receive_buffer > 0) {
if (s->send_buffer > 0) {
if (s->mark >= 0)
if (s->ip_tos >= 0)
if (s->ip_ttl >= 0) {
if (socket_ipv6_is_supported())
"IP_TTL/IPV6_UNICAST_HOPS failed: %m");
if (s->tcp_congestion)
if (s->reuse_port) {
int b = s->reuse_port;
if (s->smack_ip_in)
if (s->smack_ip_out)
assert(s);
if (s->pipe_size > 0)
if (s->smack)
static int fifo_address_create(
const char *path,
int *_fd) {
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -EEXIST;
goto fail;
fail:
static int special_address_create(
const char *path,
int *_fd) {
if (fd < 0) {
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -EEXIST;
goto fail;
fail:
static int mq_address_create(
const char *path,
long maxmsg,
long msgsize,
int *_fd) {
if (fd < 0) {
r = -errno;
goto fail;
r = -errno;
goto fail;
r = -EEXIST;
goto fail;
fail:
assert(s);
p = socket_find_symlink_target(s);
symlink(p, *i);
SocketPort *p;
bool know_label = false;
assert(s);
if (p->fd >= 0)
if (!know_label) {
r = socket_instantiate_service(s);
r = label_get_create_label_from_exe(SERVICE(UNIT_DEREF(s->service))->exec_command[SERVICE_EXEC_START]->path, &label);
if (r < 0 && r != -EPERM)
know_label = true;
&p->address,
s->backlog,
s->bind_ipv6_only,
s->bind_to_device,
s->free_bind,
s->transparent,
s->directory_mode,
s->socket_mode,
label);
goto rollback;
p->fd = r;
socket_symlink(s);
p->path,
&p->fd);
goto rollback;
r = fifo_address_create(
p->path,
s->directory_mode,
s->socket_mode,
&p->fd);
goto rollback;
socket_symlink(s);
r = mq_address_create(
p->path,
s->socket_mode,
s->mq_maxmsg,
s->mq_msgsize,
&p->fd);
goto rollback;
socket_close_fds(s);
SocketPort *p;
assert(s);
if (p->fd < 0)
if (!p->event_source)
SocketPort *p;
assert(s);
if (p->fd < 0)
if (p->event_source)
r = sd_event_add_io(UNIT(s)->manager->event, &p->event_source, p->fd, EPOLLIN, socket_dispatch_io, p);
goto fail;
fail:
assert(s);
socket_close_fds(s);
assert(s);
if (s->control_pid <= 0)
return -EBADMSG;
r = socket_arm_timer(s);
r = socket_open_fds(s);
r = socket_watch_fds(s);
assert(s);
assert(c);
goto fail;
r = socket_arm_timer(s);
goto fail;
goto fail;
r = exec_spawn(c,
argv,
&s->exec_context,
NULL, 0,
NULL,
s->exec_runtime,
&pid);
goto fail;
goto fail;
fail:
r = socket_arm_timer(s);
goto fail;
if (pid < 0)
return -errno;
if (pid == 0) {
SocketPort *p;
int ret;
goto fail_child;
goto fail_child;
if (!path)
r = -errno;
goto fail_child;
_exit(0);
log_open();
log_error("Failed to chown socket at step %s: %s", exit_status_to_string(ret, EXIT_STATUS_SYSTEMD), strerror(-r));
goto fail;
fail:
assert(s);
if (f != SOCKET_SUCCESS)
s->result = f;
exec_context_destroy_runtime_directory(&s->exec_context, manager_get_runtime_prefix(UNIT(s)->manager));
assert(s);
if (f != SOCKET_SUCCESS)
s->result = f;
if (s->control_command) {
goto fail;
fail:
assert(s);
if (f != SOCKET_SUCCESS)
s->result = f;
r = unit_kill_context(
UNIT(s),
&s->kill_context,
s->control_pid,
goto fail;
r = socket_arm_timer(s);
goto fail;
fail:
assert(s);
if (f != SOCKET_SUCCESS)
s->result = f;
if (s->control_command) {
goto fail;
fail:
assert(s);
r = socket_watch_fds(s);
goto fail;
fail:
assert(s);
if (s->control_command) {
goto fail;
fail:
assert(s);
r = socket_open_fds(s);
goto fail;
log_warning_unit(UNIT(s)->id, "%s failed to fork 'start-chown' task: %s", UNIT(s)->id, strerror(-r));
goto fail;
fail:
assert(s);
if (s->control_command) {
goto fail;
fail:
assert(s);
log_debug_unit(UNIT(s)->id, "Suppressing connection request on %s since unit stop is scheduled.", UNIT(s)->id);
if (cfd >= 0)
socket_close_fds(s);
r = socket_open_fds(s);
r = socket_watch_fds(s);
if (cfd < 0) {
Iterator i;
bool pending = false;
pending = true;
if (!pending) {
r = -ENOENT;
goto fail;
r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, true, &error, NULL);
goto fail;
log_warning_unit(UNIT(s)->id, "%s: Too many incoming connections (%u)", UNIT(s)->id, s->n_connections);
r = socket_instantiate_service(s);
goto fail;
if (r != -ENOTCONN)
goto fail;
if (!prefix) {
r = -ENOMEM;
goto fail;
if (!name) {
r = -ENOMEM;
goto fail;
goto fail;
s->n_accepted ++;
goto fail;
s->n_connections ++;
goto fail;
fail:
log_warning_unit(UNIT(s)->id, "%s failed to queue service startup job (Maybe the service file is missing or not a %s unit?): %s",
assert(s);
goto fail;
fail:
assert(s);
return -EAGAIN;
return -ENOENT;
return -EBUSY;
assert(s);
return -EAGAIN;
SocketPort *p;
assert(u);
assert(f);
if (s->control_pid > 0)
if (s->control_command_id >= 0)
int copy;
if (p->fd < 0)
if (copy < 0)
return copy;
assert(u);
if (state < 0)
SocketResult f;
else if (f != SOCKET_SUCCESS)
s->result = f;
s->n_accepted += k;
if (id < 0)
SocketPort *p;
SocketPort *p;
SocketPort *p;
SocketPort *p;
if (sscanf(value, "%i %i %n", &fd, &type, &skip) < 2 || fd < 0 || type < 0 || !fdset_contains(fds, fd))
SocketPort *p;
SocketPort *p;
assert(u);
Iterator i;
int fd;
if (p->fd >= 0)
assert(u);
assert(u);
assert(p);
switch (p->type) {
case SOCKET_SOCKET:
case SOCK_STREAM:
case SOCK_DGRAM:
case SOCK_SEQPACKET:
case SOCK_RAW:
return NULL;
case SOCKET_SPECIAL:
case SOCKET_MQUEUE:
case SOCKET_FIFO:
return NULL;
assert(u);
return s->n_connections > 0;
assert(p);
log_error_unit(UNIT(p->socket)->id, "%s: Got POLLHUP on a listening socket. The service probably invoked shutdown() on it, and should better not do that.",
goto fail;
if (cfd < 0) {
goto fail;
fail:
SocketResult f;
assert(s);
s->control_pid = 0;
f = SOCKET_SUCCESS;
if (s->control_command) {
f = SOCKET_SUCCESS;
u->id,
if (f != SOCKET_SUCCESS)
s->result = f;
if (s->control_command &&
f == SOCKET_SUCCESS) {
socket_run_next(s);
switch (s->state) {
case SOCKET_START_PRE:
if (f == SOCKET_SUCCESS)
case SOCKET_START_CHOWN:
if (f == SOCKET_SUCCESS)
socket_enter_stop_pre(s, f);
case SOCKET_START_POST:
if (f == SOCKET_SUCCESS)
socket_enter_stop_pre(s, f);
case SOCKET_STOP_PRE:
case SOCKET_STOP_PRE_SIGTERM:
case SOCKET_STOP_PRE_SIGKILL:
socket_enter_stop_post(s, f);
case SOCKET_STOP_POST:
case SOCKET_FINAL_SIGTERM:
case SOCKET_FINAL_SIGKILL:
socket_enter_dead(s, f);
assert(s);
switch (s->state) {
case SOCKET_START_PRE:
case SOCKET_START_CHOWN:
case SOCKET_START_POST:
case SOCKET_STOP_PRE:
case SOCKET_STOP_PRE_SIGTERM:
case SOCKET_STOP_PRE_SIGKILL:
case SOCKET_STOP_POST:
case SOCKET_FINAL_SIGTERM:
log_warning_unit(UNIT(s)->id, "%s stopping timed out (2). Skipping SIGKILL. Ignoring.", UNIT(s)->id);
case SOCKET_FINAL_SIGKILL:
log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL (2). Entering failed mode.", UNIT(s)->id);
int *rfds;
unsigned rn_fds, k;
SocketPort *p;
assert(s);
rn_fds = 0;
if (p->fd >= 0)
rn_fds++;
if (rn_fds <= 0) {
*n_fds = 0;
return -ENOMEM;
if (p->fd >= 0)
assert(s);
assert(s);
log_debug_unit(UNIT(s)->id, "%s got notified about service death (failed permanently: %s)", UNIT(s)->id, yes_no(failed_permanent));
if (failed_permanent)
assert(s);
s->n_connections--;
assert(u);
s->accept)
socket_notify_service_dead(s, false);
if (!s->timer_event_source)
.sections =
.finished_start_job = {
.finished_stop_job = {