dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
84b277
From e1c7d367b8523ec8c9ef3deb81a1cfd879944171 Mon Sep 17 00:00:00 2001
84b277
From: Lennart Poettering <lennart@poettering.net>
84b277
Date: Thu, 22 May 2014 16:56:21 +0900
84b277
Subject: [PATCH] socket: properly handle if our service vanished during
84b277
 runtime
84b277
84b277
(cherry-picked from 640ace4a8de907994a1b95f6d368c3e6a8fcf60f)
84b277
84b277
Resolves: #1147524
84b277
---
84b277
 src/core/socket.c | 6 ++++++
84b277
 1 file changed, 6 insertions(+)
84b277
84b277
diff --git a/src/core/socket.c b/src/core/socket.c
84b277
index 35fc204..958d063 100644
84b277
--- a/src/core/socket.c
84b277
+++ b/src/core/socket.c
84b277
@@ -1610,6 +1610,12 @@ static void socket_enter_running(Socket *s, int cfd) {
84b277
                         }
84b277
 
84b277
                 if (!pending) {
84b277
+                        if (!UNIT_ISSET(s->service)) {
84b277
+                                log_error_unit(UNIT(s)->id, "%s: service to activate vanished, refusing activation.", UNIT(s)->id);
84b277
+                                r = -ENOENT;
84b277
+                                goto fail;
84b277
+                        }
84b277
+
84b277
                         r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, true, &error, NULL);
84b277
                         if (r < 0)
84b277
                                 goto fail;