chiark / gitweb /
service: rework PID parsing logic everywhere
[elogind.git] / src / socket.c
index 71f1672027d6905557f48f5f6b97da483a91dd98..874cc9169714e0f08451402494221424f145e29b 100644 (file)
@@ -36,7 +36,6 @@
 #include "strv.h"
 #include "unit-name.h"
 #include "dbus-socket.h"
-#include "tcpwrap.h"
 
 static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
         [SOCKET_DEAD] = UNIT_INACTIVE,
@@ -108,9 +107,6 @@ static void socket_done(Unit *u) {
         free(s->bind_to_device);
         s->bind_to_device = NULL;
 
-        free(s->tcpwrap_name);
-        s->tcpwrap_name = NULL;
-
         unit_unwatch_timer(u, &s->timer_watch);
 }
 
@@ -309,11 +305,6 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
                         "%sBindToDevice: %s\n",
                         prefix, s->bind_to_device);
 
-        if (s->tcpwrap_name)
-                fprintf(f,
-                        "%sTCPWrapName: %s\n",
-                        prefix, s->tcpwrap_name);
-
         if (s->accept)
                 fprintf(f,
                         "%sAccepted: %u\n",
@@ -1056,7 +1047,7 @@ static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
         unit_serialize_item_format(u, f, "n-accepted", "%u", s->n_accepted);
 
         if (s->control_pid > 0)
-                unit_serialize_item_format(u, f, "control-pid", "%u", (unsigned) s->control_pid);
+                unit_serialize_item_format(u, f, "control-pid", "%lu", (unsigned long) s->control_pid);
 
         if (s->control_command_id >= 0)
                 unit_serialize_item(u, f, "control-command", socket_exec_command_to_string(s->control_command_id));
@@ -1119,12 +1110,12 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
                 else
                         s->n_accepted += k;
         } else if (streq(key, "control-pid")) {
-                unsigned pid;
+                pid_t pid;
 
-                if ((r = safe_atou(value, &pid)) < 0 || pid <= 0)
+                if ((r = parse_pid(value, &pid)) < 0)
                         log_debug("Failed to parse control-pid value %s", value);
                 else
-                        s->control_pid = (pid_t) pid;
+                        s->control_pid = pid;
         } else if (streq(key, "control-command")) {
                 SocketExecCommand id;
 
@@ -1221,12 +1212,6 @@ static void socket_fd_event(Unit *u, int fd, uint32_t events, Watch *w) {
 
                         break;
                 }
-
-                if (s->tcpwrap_name)
-                        if (!socket_tcpwrap(cfd, s->tcpwrap_name)) {
-                                close_nointr_nofail(cfd);
-                                return;
-                        }
         }
 
         socket_enter_running(s, cfd);