chiark / gitweb /
core: do not use quotes around virt and arch
[elogind.git] / src / core / socket.c
index 828ed31077c322b22881bb9fd2dee4e0e117d0f5..f67370b4cb921d0d041b7d5e7b4ed991af6a2db9 100644 (file)
@@ -19,7 +19,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
 #include <arpa/inet.h>
 #include <netinet/tcp.h>
 #include <mqueue.h>
-#include <sys/xattr.h>
 
 #include "sd-event.h"
 #include "log.h"
-#include "load-dropin.h"
-#include "load-fragment.h"
 #include "strv.h"
 #include "mkdir.h"
 #include "path-util.h"
@@ -48,6 +44,7 @@
 #include "smack-util.h"
 #include "bus-util.h"
 #include "bus-error.h"
+#include "selinux-util.h"
 #include "dbus-socket.h"
 #include "unit.h"
 #include "socket.h"
@@ -265,7 +262,7 @@ static int socket_add_device_link(Socket *s) {
         if (!s->bind_to_device || streq(s->bind_to_device, "lo"))
                 return 0;
 
-        t = strappenda("/sys/subsystem/net/devices/", s->bind_to_device);
+        t = strjoina("/sys/subsystem/net/devices/", s->bind_to_device);
         return unit_add_node_link(UNIT(s), t, false);
 }
 
@@ -472,7 +469,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
         assert(f);
 
         prefix = strempty(prefix);
-        prefix2 = strappenda(prefix, "\t");
+        prefix2 = strjoina(prefix, "\t");
 
         fprintf(f,
                 "%sSocket State: %s\n"
@@ -1325,7 +1322,7 @@ static void socket_set_state(Socket *s, SocketState state) {
         unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], true);
 }
 
-static int socket_coldplug(Unit *u) {
+static int socket_coldplug(Unit *u, Hashmap *deferred_work) {
         Socket *s = SOCKET(u);
         int r;
 
@@ -1395,7 +1392,11 @@ static int socket_spawn(Socket *s, ExecCommand *c, pid_t *_pid) {
         assert(c);
         assert(_pid);
 
-        unit_realize_cgroup(UNIT(s));
+        (void) unit_realize_cgroup(UNIT(s));
+        if (s->reset_cpu_usage) {
+                (void) unit_reset_cpu_usage(UNIT(s));
+                s->reset_cpu_usage = false;
+        }
 
         r = unit_setup_exec_runtime(UNIT(s));
         if (r < 0)
@@ -1456,8 +1457,8 @@ static int socket_chown(Socket *s, pid_t *_pid) {
 
         if (pid == 0) {
                 SocketPort *p;
-                uid_t uid = (uid_t) -1;
-                gid_t gid = (gid_t) -1;
+                uid_t uid = UID_INVALID;
+                gid_t gid = GID_INVALID;
                 int ret;
 
                 default_signals(SIGNALS_CRASH_HANDLER, SIGNALS_IGNORE, -1);
@@ -1951,9 +1952,11 @@ static int socket_start(Unit *u) {
         assert(s->state == SOCKET_DEAD || s->state == SOCKET_FAILED);
 
         s->result = SOCKET_SUCCESS;
+        s->reset_cpu_usage = true;
+
         socket_enter_start_pre(s);
 
-        return 0;
+        return 1;
 }
 
 static int socket_stop(Unit *u) {
@@ -1984,7 +1987,7 @@ static int socket_stop(Unit *u) {
         assert(s->state == SOCKET_LISTENING || s->state == SOCKET_RUNNING);
 
         socket_enter_stop_pre(s, SOCKET_SUCCESS);
-        return 0;
+        return 1;
 }
 
 static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
@@ -2099,7 +2102,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
 
                         LIST_FOREACH(port, p, s->ports)
                                 if (p->type == SOCKET_FIFO &&
-                                    streq_ptr(p->path, value+skip))
+                                    path_equal_or_files_same(p->path, value+skip))
                                         break;
 
                         if (p) {
@@ -2118,7 +2121,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
 
                         LIST_FOREACH(port, p, s->ports)
                                 if (p->type == SOCKET_SPECIAL &&
-                                    streq_ptr(p->path, value+skip))
+                                    path_equal_or_files_same(p->path, value+skip))
                                         break;
 
                         if (p) {
@@ -2137,7 +2140,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
 
                         LIST_FOREACH(port, p, s->ports)
                                 if (p->type == SOCKET_MQUEUE &&
-                                    streq_ptr(p->path, value+skip))
+                                    streq(p->path, value+skip))
                                         break;
 
                         if (p) {
@@ -2602,10 +2605,6 @@ static void socket_trigger_notify(Unit *u, Unit *other) {
                 socket_notify_service_dead(s, se->result == SERVICE_FAILURE_START_LIMIT);
 
         if (se->state == SERVICE_DEAD ||
-            se->state == SERVICE_STOP ||
-            se->state == SERVICE_STOP_SIGTERM ||
-            se->state == SERVICE_STOP_SIGKILL ||
-            se->state == SERVICE_STOP_POST ||
             se->state == SERVICE_FINAL_SIGTERM ||
             se->state == SERVICE_FINAL_SIGKILL ||
             se->state == SERVICE_AUTO_RESTART)