chiark / gitweb /
machine: make sure unpriviliged "machinectl status" can show the machine's OS version
[elogind.git] / src / core / socket.c
index 94eb2e7a5d2bc1e1f6526374c3d8382dc377add7..646887d803702fac8c495a27fc233ca44a5e7767 100644 (file)
@@ -180,9 +180,8 @@ static int socket_arm_timer(Socket *s) {
                         socket_dispatch_timer, s);
 }
 
-static int socket_instantiate_service(Socket *s) {
-        _cleanup_free_ char *prefix = NULL;
-        _cleanup_free_ char *name = NULL;
+int socket_instantiate_service(Socket *s) {
+        _cleanup_free_ char *prefix = NULL, *name = NULL;
         int r;
         Unit *u;
 
@@ -193,11 +192,9 @@ static int socket_instantiate_service(Socket *s) {
          * here. For Accept=no this is mostly a NOP since the service
          * is figured out at load time anyway. */
 
-        if (UNIT_DEREF(s->service))
+        if (UNIT_DEREF(s->service) || !s->accept)
                 return 0;
 
-        assert(s->accept);
-
         prefix = unit_name_to_prefix(UNIT(s)->id);
         if (!prefix)
                 return -ENOMEM;
@@ -1343,6 +1340,8 @@ static int socket_spawn(Socket *s, ExecCommand *c, pid_t *_pid) {
                        NULL,
                        s->exec_runtime,
                        &pid);
+        if (r < 0)
+                goto fail;
 
         r = unit_watch_pid(UNIT(s), pid);
         if (r < 0)